blob_id stringlengths 40 40 | directory_id stringlengths 40 40 | path stringlengths 7 139 | content_id stringlengths 40 40 | detected_licenses listlengths 0 16 | license_type stringclasses 2
values | repo_name stringlengths 7 55 | snapshot_id stringlengths 40 40 | revision_id stringlengths 40 40 | branch_name stringclasses 6
values | visit_date int64 1,471B 1,694B | revision_date int64 1,378B 1,694B | committer_date int64 1,378B 1,694B | github_id float64 1.33M 604M ⌀ | star_events_count int64 0 43.5k | fork_events_count int64 0 1.5k | gha_license_id stringclasses 6
values | gha_event_created_at int64 1,402B 1,695B ⌀ | gha_created_at int64 1,359B 1,637B ⌀ | gha_language stringclasses 19
values | src_encoding stringclasses 2
values | language stringclasses 1
value | is_vendor bool 1
class | is_generated bool 1
class | length_bytes int64 3 6.4M | extension stringclasses 4
values | content stringlengths 3 6.12M |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
770ee667c91771e08038162accfe2938c9ad0aa7 | cf39355caa609c0f33405126beee2739aa3cb77e | /tests/lean/run/vars_anywhere.lean | e3529b2599f147d2d7dcb730cb479720cfc0b431 | [
"Apache-2.0"
] | permissive | leanprover-community/lean | 12b87f69d92e614daea8bcc9d4de9a9ace089d0e | cce7990ea86a78bdb383e38ed7f9b5ba93c60ce0 | refs/heads/master | 1,687,508,156,644 | 1,684,951,104,000 | 1,684,951,104,000 | 169,960,991 | 457 | 107 | Apache-2.0 | 1,686,744,372,000 | 1,549,790,268,000 | C++ | UTF-8 | Lean | false | false | 109 | lean | variable {A : Type}
#check @id
inductive List
| nil : List
| cons : A → List → List
#check @List.cons
|
0431059734f23ae3c6802efa596904e42f93d64f | 367134ba5a65885e863bdc4507601606690974c1 | /src/data/mv_polynomial/comm_ring.lean | 6423a775ff186e5a005c6bf074c3c18c2818bd1f | [
"Apache-2.0"
] | permissive | kodyvajjha/mathlib | 9bead00e90f68269a313f45f5561766cfd8d5cad | b98af5dd79e13a38d84438b850a2e8858ec21284 | refs/heads/master | 1,624,350,366,310 | 1,615,563,062,000 | 1,615,563,062,000 | 162,666,963 | 0 | 0 | Apache-2.0 | 1,545,367,651,000 | 1,545,367,651,000 | null | UTF-8 | Lean | false | false | 5,084 | lean | /-
Copyright (c) 2017 Johannes Hölzl. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johannes Hölzl, Johan Commelin, Mario Carneiro
-/
import data.mv_polynomial.variables
/-!
# Multivariate polynomials over a ring
Many results about polynomials hold when the coefficient ring is a commutative semiring.
Some stronger results can be derived when we assume this semiring is a ring.
This file does not define any new operations, but proves some of these stronger results.
## Notation
As in other polynomial files, we typically use the notation:
+ `σ : Type*` (indexing the variables)
+ `R : Type*` `[comm_ring R]` (the coefficients)
+ `s : σ →₀ ℕ`, a function from `σ` to `ℕ` which is zero away from a finite set.
This will give rise to a monomial in `mv_polynomial σ R` which mathematicians might call `X^s`
+ `a : R`
+ `i : σ`, with corresponding monomial `X i`, often denoted `X_i` by mathematicians
+ `p : mv_polynomial σ R`
-/
noncomputable theory
open_locale classical big_operators
open set function finsupp add_monoid_algebra
open_locale big_operators
universes u v
variables {R : Type u} {S : Type v}
namespace mv_polynomial
variables {σ : Type*} {a a' a₁ a₂ : R} {e : ℕ} {n m : σ} {s : σ →₀ ℕ}
section comm_ring
variable [comm_ring R]
variables {p q : mv_polynomial σ R}
instance : comm_ring (mv_polynomial σ R) := add_monoid_algebra.comm_ring
instance C.is_ring_hom : is_ring_hom (C : R → mv_polynomial σ R) :=
by apply is_ring_hom.of_semiring
variables (σ a a')
@[simp] lemma C_sub : (C (a - a') : mv_polynomial σ R) = C a - C a' := is_ring_hom.map_sub _
@[simp] lemma C_neg : (C (-a) : mv_polynomial σ R) = -C a := is_ring_hom.map_neg _
@[simp] lemma coeff_neg (m : σ →₀ ℕ) (p : mv_polynomial σ R) :
coeff m (-p) = -coeff m p := finsupp.neg_apply _ _
@[simp] lemma coeff_sub (m : σ →₀ ℕ) (p q : mv_polynomial σ R) :
coeff m (p - q) = coeff m p - coeff m q := finsupp.sub_apply _ _ _
@[simp] lemma support_neg : (- p).support = p.support :=
finsupp.support_neg
instance coeff.is_add_group_hom (m : σ →₀ ℕ) :
is_add_group_hom (coeff m : mv_polynomial σ R → R) :=
{ map_add := coeff_add m }
variables {σ} (p)
section degrees
lemma degrees_neg (p : mv_polynomial σ R) : (- p).degrees = p.degrees :=
by rw [degrees, support_neg]; refl
lemma degrees_sub (p q : mv_polynomial σ R) :
(p - q).degrees ≤ p.degrees ⊔ q.degrees :=
by simpa only [sub_eq_add_neg] using le_trans (degrees_add p (-q)) (by rw degrees_neg)
end degrees
section vars
variables (p q)
@[simp] lemma vars_neg : (-p).vars = p.vars :=
by simp [vars, degrees_neg]
lemma vars_sub_subset : (p - q).vars ⊆ p.vars ∪ q.vars :=
by convert vars_add_subset p (-q) using 2; simp [sub_eq_add_neg]
variables {p q}
@[simp]
lemma vars_sub_of_disjoint (hpq : disjoint p.vars q.vars) : (p - q).vars = p.vars ∪ q.vars :=
begin
rw ←vars_neg q at hpq,
convert vars_add_of_disjoint hpq using 2;
simp [sub_eq_add_neg]
end
end vars
section eval₂
variables [comm_ring S]
variables (f : R →+* S) (g : σ → S)
@[simp] lemma eval₂_sub : (p - q).eval₂ f g = p.eval₂ f g - q.eval₂ f g :=
(eval₂_hom f g).map_sub _ _
@[simp] lemma eval₂_neg : (-p).eval₂ f g = -(p.eval₂ f g) := (eval₂_hom f g).map_neg _
lemma hom_C (f : mv_polynomial σ ℤ → S) [is_ring_hom f] (n : ℤ) : f (C n) = (n : S) :=
((ring_hom.of f).comp (ring_hom.of C)).eq_int_cast n
/-- A ring homomorphism f : Z[X_1, X_2, ...] → R
is determined by the evaluations f(X_1), f(X_2), ... -/
@[simp] lemma eval₂_hom_X {R : Type u} (c : ℤ →+* S)
(f : mv_polynomial R ℤ →+* S) (x : mv_polynomial R ℤ) :
eval₂ c (f ∘ X) x = f x :=
mv_polynomial.induction_on x
(λ n, by { rw [hom_C f, eval₂_C], exact (ring_hom.of c).eq_int_cast n })
(λ p q hp hq, by { rw [eval₂_add, hp, hq], exact (is_ring_hom.map_add f).symm })
(λ p n hp, by { rw [eval₂_mul, eval₂_X, hp], exact (is_ring_hom.map_mul f).symm })
/-- Ring homomorphisms out of integer polynomials on a type `σ` are the same as
functions out of the type `σ`, -/
def hom_equiv : (mv_polynomial σ ℤ →+* S) ≃ (σ → S) :=
{ to_fun := λ f, ⇑f ∘ X,
inv_fun := λ f, eval₂_hom (int.cast_ring_hom S) f,
left_inv := λ f, ring_hom.ext $ eval₂_hom_X _ _,
right_inv := λ f, funext $ λ x, by simp only [coe_eval₂_hom, function.comp_app, eval₂_X] }
end eval₂
section total_degree
@[simp] lemma total_degree_neg (a : mv_polynomial σ R) :
(-a).total_degree = a.total_degree :=
by simp only [total_degree, support_neg]
lemma total_degree_sub (a b : mv_polynomial σ R) :
(a - b).total_degree ≤ max a.total_degree b.total_degree :=
calc (a - b).total_degree = (a + -b).total_degree : by rw sub_eq_add_neg
... ≤ max a.total_degree (-b).total_degree : total_degree_add a (-b)
... = max a.total_degree b.total_degree : by rw total_degree_neg
end total_degree
end comm_ring
end mv_polynomial
|
c20b08125c872dc86bcb6aaa138808d4566eed9d | 6dc0c8ce7a76229dd81e73ed4474f15f88a9e294 | /stage0/src/Lean/Elab/Structure.lean | 4ce87616365061c0647ef0a2e596b604655ed22e | [
"Apache-2.0"
] | permissive | williamdemeo/lean4 | 72161c58fe65c3ad955d6a3050bb7d37c04c0d54 | 6d00fcf1d6d873e195f9220c668ef9c58e9c4a35 | refs/heads/master | 1,678,305,356,877 | 1,614,708,995,000 | 1,614,708,995,000 | null | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 27,866 | lean | /-
Copyright (c) 2020 Microsoft Corporation. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Leonardo de Moura
-/
import Lean.Parser.Command
import Lean.Meta.Closure
import Lean.Meta.SizeOf
import Lean.Elab.Command
import Lean.Elab.DeclModifiers
import Lean.Elab.DeclUtil
import Lean.Elab.Inductive
import Lean.Elab.DeclarationRange
namespace Lean.Elab.Command
open Meta
/- Recall that the `structure command syntax is
```
parser! (structureTk <|> classTk) >> declId >> many Term.bracketedBinder >> optional «extends» >> Term.optType >> optional (" := " >> optional structCtor >> structFields)
```
-/
structure StructCtorView where
ref : Syntax
modifiers : Modifiers
inferMod : Bool -- true if `{}` is used in the constructor declaration
name : Name
declName : Name
structure StructFieldView where
ref : Syntax
modifiers : Modifiers
binderInfo : BinderInfo
inferMod : Bool
declName : Name
name : Name
binders : Syntax
type? : Option Syntax
value? : Option Syntax
structure StructView where
ref : Syntax
modifiers : Modifiers
scopeLevelNames : List Name -- All `universe` declarations in the current scope
allUserLevelNames : List Name -- `scopeLevelNames` ++ explicit universe parameters provided in the `structure` command
isClass : Bool
declName : Name
scopeVars : Array Expr -- All `variable` declaration in the current scope
params : Array Expr -- Explicit parameters provided in the `structure` command
parents : Array Syntax
type : Syntax
ctor : StructCtorView
fields : Array StructFieldView
inductive StructFieldKind where
| newField | fromParent | subobject
deriving Inhabited
structure StructFieldInfo where
name : Name
declName : Name -- Remark: this field value doesn't matter for fromParent fields.
fvar : Expr
kind : StructFieldKind
inferMod : Bool := false
value? : Option Expr := none
deriving Inhabited
def StructFieldInfo.isFromParent (info : StructFieldInfo) : Bool :=
match info.kind with
| StructFieldKind.fromParent => true
| _ => false
def StructFieldInfo.isSubobject (info : StructFieldInfo) : Bool :=
match info.kind with
| StructFieldKind.subobject => true
| _ => false
/- Auxiliary declaration for `mkProjections` -/
structure ProjectionInfo where
declName : Name
inferMod : Bool
structure ElabStructResult where
decl : Declaration
projInfos : List ProjectionInfo
projInstances : List Name -- projections (to parent classes) that must be marked as instances.
mctx : MetavarContext
lctx : LocalContext
localInsts : LocalInstances
defaultAuxDecls : Array (Name × Expr × Expr)
private def defaultCtorName := `mk
/-
The structure constructor syntax is
```
parser! try (declModifiers >> ident >> optional inferMod >> " :: ")
```
-/
private def expandCtor (structStx : Syntax) (structModifiers : Modifiers) (structDeclName : Name) : TermElabM StructCtorView := do
let useDefault := do
let declName := structDeclName ++ defaultCtorName
addAuxDeclarationRanges declName structStx[2] structStx[2]
pure { ref := structStx, modifiers := {}, inferMod := false, name := defaultCtorName, declName := declName }
if structStx[5].isNone then
useDefault
else
let optCtor := structStx[5][1]
if optCtor.isNone then
useDefault
else
let ctor := optCtor[0]
withRef ctor do
let ctorModifiers ← elabModifiers ctor[0]
checkValidCtorModifier ctorModifiers
if ctorModifiers.isPrivate && structModifiers.isPrivate then
throwError "invalid 'private' constructor in a 'private' structure"
if ctorModifiers.isProtected && structModifiers.isPrivate then
throwError "invalid 'protected' constructor in a 'private' structure"
let inferMod := !ctor[2].isNone
let name := ctor[1].getId
let declName := structDeclName ++ name
let declName ← applyVisibility ctorModifiers.visibility declName
addDocString' declName ctorModifiers.docString?
addAuxDeclarationRanges declName ctor[1] ctor[1]
pure { ref := ctor, name := name, modifiers := ctorModifiers, inferMod := inferMod, declName := declName }
def checkValidFieldModifier (modifiers : Modifiers) : TermElabM Unit := do
if modifiers.isNoncomputable then
throwError "invalid use of 'noncomputable' in field declaration"
if modifiers.isPartial then
throwError "invalid use of 'partial' in field declaration"
if modifiers.isUnsafe then
throwError "invalid use of 'unsafe' in field declaration"
if modifiers.attrs.size != 0 then
throwError "invalid use of attributes in field declaration"
if modifiers.isPrivate then
throwError "private fields are not supported yet"
/-
```
def structExplicitBinder := parser! atomic (declModifiers true >> "(") >> many1 ident >> optional inferMod >> optDeclSig >> optional Term.binderDefault >> ")"
def structImplicitBinder := parser! atomic (declModifiers true >> "{") >> many1 ident >> optional inferMod >> declSig >> "}"
def structInstBinder := parser! atomic (declModifiers true >> "[") >> many1 ident >> optional inferMod >> declSig >> "]"
def structSimpleBinder := parser! atomic (declModifiers true >> ident) >> optional inferMod >> optDeclSig >> optional Term.binderDefault
def structFields := parser! many (structExplicitBinder <|> structImplicitBinder <|> structInstBinder)
```
-/
private def expandFields (structStx : Syntax) (structModifiers : Modifiers) (structDeclName : Name) : TermElabM (Array StructFieldView) :=
let fieldBinders := if structStx[5].isNone then #[] else structStx[5][2][0].getArgs
fieldBinders.foldlM (init := #[]) fun (views : Array StructFieldView) fieldBinder => withRef fieldBinder do
let mut fieldBinder := fieldBinder
if fieldBinder.getKind == ``Parser.Command.structSimpleBinder then
fieldBinder := Syntax.node ``Parser.Command.structExplicitBinder
#[ fieldBinder[0], mkAtomFrom fieldBinder "(", mkNullNode #[ fieldBinder[1] ], fieldBinder[2], fieldBinder[3], fieldBinder[4], mkAtomFrom fieldBinder ")" ]
let k := fieldBinder.getKind
let binfo ←
if k == ``Parser.Command.structExplicitBinder then pure BinderInfo.default
else if k == ``Parser.Command.structImplicitBinder then pure BinderInfo.implicit
else if k == ``Parser.Command.structInstBinder then pure BinderInfo.instImplicit
else throwError "unexpected kind of structure field"
let fieldModifiers ← elabModifiers fieldBinder[0]
checkValidFieldModifier fieldModifiers
if fieldModifiers.isPrivate && structModifiers.isPrivate then
throwError "invalid 'private' field in a 'private' structure"
if fieldModifiers.isProtected && structModifiers.isPrivate then
throwError "invalid 'protected' field in a 'private' structure"
let inferMod := !fieldBinder[3].isNone
let (binders, type?) :=
if binfo == BinderInfo.default then
expandOptDeclSig fieldBinder[4]
else
let (binders, type) := expandDeclSig fieldBinder[4]
(binders, some type)
let value? :=
if binfo != BinderInfo.default then none
else
let optBinderDefault := fieldBinder[5]
if optBinderDefault.isNone then none
else
-- binderDefault := parser! " := " >> termParser
some optBinderDefault[0][1]
let idents := fieldBinder[2].getArgs
idents.foldlM (init := views) fun (views : Array StructFieldView) ident => withRef ident do
let name := ident.getId
if isInternalSubobjectFieldName name then
throwError! "invalid field name '{name}', identifiers starting with '_' are reserved to the system"
let declName := structDeclName ++ name
let declName ← applyVisibility fieldModifiers.visibility declName
addDocString' declName fieldModifiers.docString?
return views.push {
ref := ident,
modifiers := fieldModifiers,
binderInfo := binfo,
inferMod := inferMod,
declName := declName,
name := name,
binders := binders,
type? := type?,
value? := value?
}
private def validStructType (type : Expr) : Bool :=
match type with
| Expr.sort .. => true
| _ => false
private def checkParentIsStructure (parent : Expr) : TermElabM Name :=
match parent.getAppFn with
| Expr.const c _ _ => do
unless isStructure (← getEnv) c do
throwError! "'{c}' is not a structure"
pure c
| _ => throwError "expected structure"
private def findFieldInfo? (infos : Array StructFieldInfo) (fieldName : Name) : Option StructFieldInfo :=
infos.find? fun info => info.name == fieldName
private def containsFieldName (infos : Array StructFieldInfo) (fieldName : Name) : Bool :=
(findFieldInfo? infos fieldName).isSome
private partial def processSubfields (structDeclName : Name) (parentFVar : Expr) (parentStructName : Name) (subfieldNames : Array Name)
(infos : Array StructFieldInfo) (k : Array StructFieldInfo → TermElabM α) : TermElabM α :=
let rec loop (i : Nat) (infos : Array StructFieldInfo) := do
if h : i < subfieldNames.size then
let subfieldName := subfieldNames.get ⟨i, h⟩
if containsFieldName infos subfieldName then
throwError! "field '{subfieldName}' from '{parentStructName}' has already been declared"
let val ← mkProjection parentFVar subfieldName
let type ← inferType val
withLetDecl subfieldName type val fun subfieldFVar =>
/- The following `declName` is only used for creating the `_default` auxiliary declaration name when
its default value is overwritten in the structure. -/
let declName := structDeclName ++ subfieldName
let infos := infos.push { name := subfieldName, declName := declName, fvar := subfieldFVar, kind := StructFieldKind.fromParent }
loop (i+1) infos
else
k infos
loop 0 infos
private partial def withParents (view : StructView) (i : Nat) (infos : Array StructFieldInfo) (k : Array StructFieldInfo → TermElabM α) : TermElabM α := do
if h : i < view.parents.size then
let parentStx := view.parents.get ⟨i, h⟩
withRef parentStx do
let parent ← Term.elabType parentStx
let parentName ← checkParentIsStructure parent
let toParentName := Name.mkSimple $ "to" ++ parentName.eraseMacroScopes.getString! -- erase macro scopes?
if containsFieldName infos toParentName then
throwErrorAt! parentStx "field '{toParentName}' has already been declared"
let env ← getEnv
let binfo := if view.isClass && isClass env parentName then BinderInfo.instImplicit else BinderInfo.default
withLocalDecl toParentName binfo parent fun parentFVar =>
let infos := infos.push { name := toParentName, declName := view.declName ++ toParentName, fvar := parentFVar, kind := StructFieldKind.subobject }
let subfieldNames := getStructureFieldsFlattened env parentName
processSubfields view.declName parentFVar parentName subfieldNames infos fun infos => withParents view (i+1) infos k
else
k infos
private def elabFieldTypeValue (view : StructFieldView) : TermElabM (Option Expr × Option Expr) := do
Term.withAutoBoundImplicitLocal <| Term.elabBinders (catchAutoBoundImplicit := true) view.binders.getArgs fun params => do
match view.type? with
| none =>
match view.value? with
| none => return (none, none)
| some valStx =>
let params ← Term.addAutoBoundImplicits params
let value ← Term.elabTerm valStx none
let value ← mkLambdaFVars params value
return (none, value)
| some typeStx =>
Term.elabTypeWithAutoBoundImplicit typeStx fun type => do
let params ← Term.addAutoBoundImplicits params
match view.value? with
| none =>
let type ← mkForallFVars params type
return (type, none)
| some valStx =>
let value ← Term.elabTermEnsuringType valStx type
let type ← mkForallFVars params type
let value ← mkLambdaFVars params value
return (type, value)
private partial def withFields
(views : Array StructFieldView) (i : Nat) (infos : Array StructFieldInfo) (k : Array StructFieldInfo → TermElabM α) : TermElabM α := do
if h : i < views.size then
let view := views.get ⟨i, h⟩
withRef view.ref $
match findFieldInfo? infos view.name with
| none => do
let (type?, value?) ← elabFieldTypeValue view
match type?, value? with
| none, none => throwError "invalid field, type expected"
| some type, _ =>
withLocalDecl view.name view.binderInfo type fun fieldFVar =>
let infos := infos.push { name := view.name, declName := view.declName, fvar := fieldFVar, value? := value?,
kind := StructFieldKind.newField, inferMod := view.inferMod }
withFields views (i+1) infos k
| none, some value =>
let type ← inferType value
withLocalDecl view.name view.binderInfo type fun fieldFVar =>
let infos := infos.push { name := view.name, declName := view.declName, fvar := fieldFVar, value? := value,
kind := StructFieldKind.newField, inferMod := view.inferMod }
withFields views (i+1) infos k
| some info =>
match info.kind with
| StructFieldKind.newField => throwError! "field '{view.name}' has already been declared"
| StructFieldKind.fromParent =>
match view.value? with
| none => throwError! "field '{view.name}' has been declared in parent structure"
| some valStx => do
if let some type := view.type? then
throwErrorAt! type "omit field '{view.name}' type to set default value"
else
let mut valStx := valStx
if view.binders.getArgs.size > 0 then
valStx ← `(fun $(view.binders.getArgs)* => $valStx:term)
let fvarType ← inferType info.fvar
let value ← Term.elabTermEnsuringType valStx fvarType
let infos := infos.push { info with value? := value }
withFields views (i+1) infos k
| StructFieldKind.subobject => unreachable!
else
k infos
private def getResultUniverse (type : Expr) : TermElabM Level := do
let type ← whnf type
match type with
| Expr.sort u _ => pure u
| _ => throwError "unexpected structure resulting type"
private def collectUsed (params : Array Expr) (fieldInfos : Array StructFieldInfo) : StateRefT CollectFVars.State TermElabM Unit := do
params.forM fun p => do
let type ← inferType p
Term.collectUsedFVars type
fieldInfos.forM fun info => do
let fvarType ← inferType info.fvar
Term.collectUsedFVars fvarType
match info.value? with
| none => pure ()
| some value => Term.collectUsedFVars value
private def removeUnused (scopeVars : Array Expr) (params : Array Expr) (fieldInfos : Array StructFieldInfo)
: TermElabM (LocalContext × LocalInstances × Array Expr) := do
let (_, used) ← (collectUsed params fieldInfos).run {}
Term.removeUnused scopeVars used
private def withUsed {α} (scopeVars : Array Expr) (params : Array Expr) (fieldInfos : Array StructFieldInfo) (k : Array Expr → TermElabM α)
: TermElabM α := do
let (lctx, localInsts, vars) ← removeUnused scopeVars params fieldInfos
withLCtx lctx localInsts $ k vars
private def levelMVarToParamFVar (fvar : Expr) : StateRefT Nat TermElabM Unit := do
let type ← inferType fvar
discard <| Term.levelMVarToParam' type
private def levelMVarToParamFVars (fvars : Array Expr) : StateRefT Nat TermElabM Unit :=
fvars.forM levelMVarToParamFVar
private def levelMVarToParamAux (scopeVars : Array Expr) (params : Array Expr) (fieldInfos : Array StructFieldInfo)
: StateRefT Nat TermElabM (Array StructFieldInfo) := do
levelMVarToParamFVars scopeVars
levelMVarToParamFVars params
fieldInfos.mapM fun info => do
levelMVarToParamFVar info.fvar
match info.value? with
| none => pure info
| some value =>
let value ← Term.levelMVarToParam' value
pure { info with value? := value }
private def levelMVarToParam (scopeVars : Array Expr) (params : Array Expr) (fieldInfos : Array StructFieldInfo) : TermElabM (Array StructFieldInfo) :=
(levelMVarToParamAux scopeVars params fieldInfos).run' 1
private partial def collectUniversesFromFields (r : Level) (rOffset : Nat) (fieldInfos : Array StructFieldInfo) : TermElabM (Array Level) := do
fieldInfos.foldlM (init := #[]) fun (us : Array Level) (info : StructFieldInfo) => do
let type ← inferType info.fvar
let u ← getLevel type
let u ← instantiateLevelMVars u
accLevelAtCtor u r rOffset us
private def updateResultingUniverse (fieldInfos : Array StructFieldInfo) (type : Expr) : TermElabM Expr := do
let r ← getResultUniverse type
let rOffset : Nat := r.getOffset
let r : Level := r.getLevelOffset
match r with
| Level.mvar mvarId _ =>
let us ← collectUniversesFromFields r rOffset fieldInfos
let rNew := mkResultUniverse us rOffset
assignLevelMVar mvarId rNew
instantiateMVars type
| _ => throwError "failed to compute resulting universe level of structure, provide universe explicitly"
private def collectLevelParamsInFVar (s : CollectLevelParams.State) (fvar : Expr) : TermElabM CollectLevelParams.State := do
let type ← inferType fvar
let type ← instantiateMVars type
pure $ collectLevelParams s type
private def collectLevelParamsInFVars (fvars : Array Expr) (s : CollectLevelParams.State) : TermElabM CollectLevelParams.State :=
fvars.foldlM collectLevelParamsInFVar s
private def collectLevelParamsInStructure (structType : Expr) (scopeVars : Array Expr) (params : Array Expr) (fieldInfos : Array StructFieldInfo)
: TermElabM (Array Name) := do
let s := collectLevelParams {} structType
let s ← collectLevelParamsInFVars scopeVars s
let s ← collectLevelParamsInFVars params s
let s ← fieldInfos.foldlM (fun (s : CollectLevelParams.State) info => collectLevelParamsInFVar s info.fvar) s
pure s.params
private def addCtorFields (fieldInfos : Array StructFieldInfo) : Nat → Expr → TermElabM Expr
| 0, type => pure type
| i+1, type => do
let info := fieldInfos[i]
let decl ← Term.getFVarLocalDecl! info.fvar
let type ← instantiateMVars type
let type := type.abstract #[info.fvar]
match info.kind with
| StructFieldKind.fromParent =>
let val := decl.value
addCtorFields fieldInfos i (type.instantiate1 val)
| StructFieldKind.subobject =>
let n := mkInternalSubobjectFieldName $ decl.userName
addCtorFields fieldInfos i (mkForall n decl.binderInfo decl.type type)
| StructFieldKind.newField =>
addCtorFields fieldInfos i (mkForall decl.userName decl.binderInfo decl.type type)
private def mkCtor (view : StructView) (levelParams : List Name) (params : Array Expr) (fieldInfos : Array StructFieldInfo) : TermElabM Constructor :=
withRef view.ref do
let type := mkAppN (mkConst view.declName (levelParams.map mkLevelParam)) params
let type ← addCtorFields fieldInfos fieldInfos.size type
let type ← mkForallFVars params type
let type ← instantiateMVars type
trace[Meta.debug]! "ctor type: {type}"
let type := type.inferImplicit params.size !view.ctor.inferMod
pure { name := view.ctor.declName, type := type }
@[extern "lean_mk_projections"]
private constant mkProjections (env : Environment) (structName : Name) (projs : List ProjectionInfo) (isClass : Bool) : Except KernelException Environment
private def addProjections (structName : Name) (projs : List ProjectionInfo) (isClass : Bool) : TermElabM Unit := do
let env ← getEnv
match mkProjections env structName projs isClass with
| Except.ok env => setEnv env
| Except.error ex => throwKernelException ex
private def mkAuxConstructions (declName : Name) : TermElabM Unit := do
let env ← getEnv
let hasUnit := env.contains `PUnit
let hasEq := env.contains `Eq
let hasHEq := env.contains `HEq
mkRecOn declName
if hasUnit then mkCasesOn declName
if hasUnit && hasEq && hasHEq then mkNoConfusion declName
private def addDefaults (lctx : LocalContext) (defaultAuxDecls : Array (Name × Expr × Expr)) : TermElabM Unit := do
let localInsts ← getLocalInstances
withLCtx lctx localInsts do
defaultAuxDecls.forM fun (declName, type, value) => do
let value ← instantiateMVars value
if value.hasExprMVar then
throwError! "invalid default value for field, it contains metavariables{indentExpr value}"
/- The identity function is used as "marker". -/
let value ← mkId value
discard <| mkAuxDefinition declName type value (zeta := true)
setReducibleAttribute declName
private def elabStructureView (view : StructView) : TermElabM Unit := do
view.fields.forM fun field => do
if field.declName == view.ctor.declName then
throwErrorAt! field.ref "invalid field name '{field.name}', it is equal to structure constructor name"
addAuxDeclarationRanges field.declName field.ref field.ref
let numExplicitParams := view.params.size
let type ← Term.elabType view.type
unless validStructType type do throwErrorAt view.type "expected Type"
withRef view.ref do
withParents view 0 #[] fun fieldInfos =>
withFields view.fields 0 fieldInfos fun fieldInfos => do
Term.synthesizeSyntheticMVarsNoPostponing
let u ← getResultUniverse type
let inferLevel ← shouldInferResultUniverse u
withUsed view.scopeVars view.params fieldInfos $ fun scopeVars => do
let numParams := scopeVars.size + numExplicitParams
let fieldInfos ← levelMVarToParam scopeVars view.params fieldInfos
let type ← withRef view.ref do
if inferLevel then
updateResultingUniverse fieldInfos type
else
checkResultingUniverse (← getResultUniverse type)
pure type
trace[Elab.structure]! "type: {type}"
let usedLevelNames ← collectLevelParamsInStructure type scopeVars view.params fieldInfos
match sortDeclLevelParams view.scopeLevelNames view.allUserLevelNames usedLevelNames with
| Except.error msg => withRef view.ref <| throwError msg
| Except.ok levelParams =>
let params := scopeVars ++ view.params
let ctor ← mkCtor view levelParams params fieldInfos
let type ← mkForallFVars params type
let type ← instantiateMVars type
trace[Meta.debug]! "type: {type}"
let indType := { name := view.declName, type := type, ctors := [ctor] : InductiveType }
let decl := Declaration.inductDecl levelParams params.size [indType] view.modifiers.isUnsafe
Term.ensureNoUnassignedMVars decl
addDecl decl
let projInfos := (fieldInfos.filter fun (info : StructFieldInfo) => !info.isFromParent).toList.map fun (info : StructFieldInfo) =>
{ declName := info.declName, inferMod := info.inferMod : ProjectionInfo }
addProjections view.declName projInfos view.isClass
mkAuxConstructions view.declName
let instParents ← fieldInfos.filterM fun info => do
let decl ← Term.getFVarLocalDecl! info.fvar
pure (info.isSubobject && decl.binderInfo.isInstImplicit)
let projInstances := instParents.toList.map fun info => info.declName
Term.applyAttributesAt view.declName view.modifiers.attrs AttributeApplicationTime.afterTypeChecking
projInstances.forM fun declName => addInstance declName AttributeKind.global (evalPrio! default)
let lctx ← getLCtx
let fieldsWithDefault := fieldInfos.filter fun info => info.value?.isSome
let defaultAuxDecls ← fieldsWithDefault.mapM fun info => do
let type ← inferType info.fvar
pure (info.declName ++ `_default, type, info.value?.get!)
/- The `lctx` and `defaultAuxDecls` are used to create the auxiliary `_default` declarations
The parameters `params` for these definitions must be marked as implicit, and all others as explicit. -/
let lctx :=
params.foldl (init := lctx) fun (lctx : LocalContext) (p : Expr) =>
lctx.setBinderInfo p.fvarId! BinderInfo.implicit
let lctx :=
fieldInfos.foldl (init := lctx) fun (lctx : LocalContext) (info : StructFieldInfo) =>
if info.isFromParent then lctx -- `fromParent` fields are elaborated as let-decls, and are zeta-expanded when creating `_default`.
else lctx.setBinderInfo info.fvar.fvarId! BinderInfo.default
addDefaults lctx defaultAuxDecls
/-
parser! (structureTk <|> classTk) >> declId >> many Term.bracketedBinder >> optional «extends» >> Term.optType >> " := " >> optional structCtor >> structFields >> optDeriving
where
def «extends» := parser! " extends " >> sepBy1 termParser ", "
def typeSpec := parser! " : " >> termParser
def optType : Parser := optional typeSpec
def structFields := parser! many (structExplicitBinder <|> structImplicitBinder <|> structInstBinder)
def structCtor := parser! try (declModifiers >> ident >> optional inferMod >> " :: ")
-/
def elabStructure (modifiers : Modifiers) (stx : Syntax) : CommandElabM Unit := do
checkValidInductiveModifier modifiers
let isClass := stx[0].getKind == ``Parser.Command.classTk
let modifiers := if isClass then modifiers.addAttribute { name := `class } else modifiers
let declId := stx[1]
let params := stx[2].getArgs
let exts := stx[3]
let parents := if exts.isNone then #[] else exts[0][1].getSepArgs
let optType := stx[4]
let derivingClassViews ← getOptDerivingClasses stx[6]
let type ← if optType.isNone then `(Sort _) else pure optType[0][1]
let declName ←
runTermElabM none fun scopeVars => do
let scopeLevelNames ← Term.getLevelNames
let ⟨name, declName, allUserLevelNames⟩ ← Elab.expandDeclId (← getCurrNamespace) scopeLevelNames declId modifiers
addDeclarationRanges declName stx
Term.withDeclName declName do
let ctor ← expandCtor stx modifiers declName
let fields ← expandFields stx modifiers declName
Term.withLevelNames allUserLevelNames <| Term.withAutoBoundImplicitLocal <|
Term.elabBinders params (catchAutoBoundImplicit := true) fun params => do
let params ← Term.addAutoBoundImplicits params
let allUserLevelNames ← Term.getLevelNames
Term.withAutoBoundImplicitLocal (flag := false) do
elabStructureView {
ref := stx
modifiers := modifiers
scopeLevelNames := scopeLevelNames
allUserLevelNames := allUserLevelNames
declName := declName
isClass := isClass
scopeVars := scopeVars
params := params
parents := parents
type := type
ctor := ctor
fields := fields
}
unless isClass do
mkSizeOfInstances declName
return declName
derivingClassViews.forM fun view => view.applyHandlers #[declName]
builtin_initialize registerTraceClass `Elab.structure
end Lean.Elab.Command
|
202127822767b4a905001e3da69669460ad71cfe | 8cae430f0a71442d02dbb1cbb14073b31048e4b0 | /src/measure_theory/constructions/prod/basic.lean | 7aa1cd9ca24b2c84f57fa4e0cc4593b700d52477 | [
"Apache-2.0"
] | permissive | leanprover-community/mathlib | 56a2cadd17ac88caf4ece0a775932fa26327ba0e | 442a83d738cb208d3600056c489be16900ba701d | refs/heads/master | 1,693,584,102,358 | 1,693,471,902,000 | 1,693,471,902,000 | 97,922,418 | 1,595 | 352 | Apache-2.0 | 1,694,693,445,000 | 1,500,624,130,000 | Lean | UTF-8 | Lean | false | false | 38,154 | lean | /-
Copyright (c) 2020 Floris van Doorn. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Floris van Doorn
-/
import measure_theory.measure.giry_monad
import dynamics.ergodic.measure_preserving
import measure_theory.integral.lebesgue
import measure_theory.measure.open_pos
/-!
# The product measure
> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.
> Any changes to this file require a corresponding PR to mathlib4.
In this file we define and prove properties about the binary product measure. If `α` and `β` have
σ-finite measures `μ` resp. `ν` then `α × β` can be equipped with a σ-finite measure `μ.prod ν` that
satisfies `(μ.prod ν) s = ∫⁻ x, ν {y | (x, y) ∈ s} ∂μ`.
We also have `(μ.prod ν) (s ×ˢ t) = μ s * ν t`, i.e. the measure of a rectangle is the product of
the measures of the sides.
We also prove Tonelli's theorem.
## Main definition
* `measure_theory.measure.prod`: The product of two measures.
## Main results
* `measure_theory.measure.prod_apply` states `μ.prod ν s = ∫⁻ x, ν {y | (x, y) ∈ s} ∂μ`
for measurable `s`. `measure_theory.measure.prod_apply_symm` is the reversed version.
* `measure_theory.measure.prod_prod` states `μ.prod ν (s ×ˢ t) = μ s * ν t` for measurable sets
`s` and `t`.
* `measure_theory.lintegral_prod`: Tonelli's theorem. It states that for a measurable function
`α × β → ℝ≥0∞` we have `∫⁻ z, f z ∂(μ.prod ν) = ∫⁻ x, ∫⁻ y, f (x, y) ∂ν ∂μ`. The version
for functions `α → β → ℝ≥0∞` is reversed, and called `lintegral_lintegral`. Both versions have
a variant with `_symm` appended, where the order of integration is reversed.
The lemma `measurable.lintegral_prod_right'` states that the inner integral of the right-hand side
is measurable.
## Implementation Notes
Many results are proven twice, once for functions in curried form (`α → β → γ`) and one for
functions in uncurried form (`α × β → γ`). The former often has an assumption
`measurable (uncurry f)`, which could be inconvenient to discharge, but for the latter it is more
common that the function has to be given explicitly, since Lean cannot synthesize the function by
itself. We name the lemmas about the uncurried form with a prime.
Tonelli's theorem has a different naming scheme, since the version for the uncurried version is
reversed.
## Tags
product measure, Tonelli's theorem, Fubini-Tonelli theorem
-/
noncomputable theory
open_locale classical topology ennreal measure_theory
open set function real ennreal
open measure_theory measurable_space measure_theory.measure
open topological_space (hiding generate_from)
open filter (hiding prod_eq map)
variables {α α' β β' γ E : Type*}
/-- Rectangles formed by π-systems form a π-system. -/
lemma is_pi_system.prod {C : set (set α)} {D : set (set β)} (hC : is_pi_system C)
(hD : is_pi_system D) : is_pi_system (image2 (×ˢ) C D) :=
begin
rintro _ ⟨s₁, t₁, hs₁, ht₁, rfl⟩ _ ⟨s₂, t₂, hs₂, ht₂, rfl⟩ hst,
rw [prod_inter_prod] at hst ⊢, rw [prod_nonempty_iff] at hst,
exact mem_image2_of_mem (hC _ hs₁ _ hs₂ hst.1) (hD _ ht₁ _ ht₂ hst.2)
end
/-- Rectangles of countably spanning sets are countably spanning. -/
lemma is_countably_spanning.prod {C : set (set α)} {D : set (set β)}
(hC : is_countably_spanning C) (hD : is_countably_spanning D) :
is_countably_spanning (image2 (×ˢ) C D) :=
begin
rcases ⟨hC, hD⟩ with ⟨⟨s, h1s, h2s⟩, t, h1t, h2t⟩,
refine ⟨λ n, (s n.unpair.1) ×ˢ (t n.unpair.2), λ n, mem_image2_of_mem (h1s _) (h1t _), _⟩,
rw [Union_unpair_prod, h2s, h2t, univ_prod_univ]
end
variables [measurable_space α] [measurable_space α'] [measurable_space β] [measurable_space β']
variables [measurable_space γ]
variables {μ μ' : measure α} {ν ν' : measure β} {τ : measure γ}
variables [normed_add_comm_group E]
/-! ### Measurability
Before we define the product measure, we can talk about the measurability of operations on binary
functions. We show that if `f` is a binary measurable function, then the function that integrates
along one of the variables (using either the Lebesgue or Bochner integral) is measurable.
-/
/-- The product of generated σ-algebras is the one generated by rectangles, if both generating sets
are countably spanning. -/
lemma generate_from_prod_eq {α β} {C : set (set α)} {D : set (set β)}
(hC : is_countably_spanning C) (hD : is_countably_spanning D) :
@prod.measurable_space _ _ (generate_from C) (generate_from D) =
generate_from (image2 (×ˢ) C D) :=
begin
apply le_antisymm,
{ refine sup_le _ _; rw [comap_generate_from];
apply generate_from_le; rintro _ ⟨s, hs, rfl⟩,
{ rcases hD with ⟨t, h1t, h2t⟩,
rw [← prod_univ, ← h2t, prod_Union],
apply measurable_set.Union,
intro n, apply measurable_set_generate_from,
exact ⟨s, t n, hs, h1t n, rfl⟩ },
{ rcases hC with ⟨t, h1t, h2t⟩,
rw [← univ_prod, ← h2t, Union_prod_const],
apply measurable_set.Union,
rintro n, apply measurable_set_generate_from,
exact mem_image2_of_mem (h1t n) hs } },
{ apply generate_from_le, rintro _ ⟨s, t, hs, ht, rfl⟩, rw [prod_eq],
apply (measurable_fst _).inter (measurable_snd _),
{ exact measurable_set_generate_from hs },
{ exact measurable_set_generate_from ht } }
end
/-- If `C` and `D` generate the σ-algebras on `α` resp. `β`, then rectangles formed by `C` and `D`
generate the σ-algebra on `α × β`. -/
lemma generate_from_eq_prod {C : set (set α)} {D : set (set β)} (hC : generate_from C = ‹_›)
(hD : generate_from D = ‹_›) (h2C : is_countably_spanning C) (h2D : is_countably_spanning D) :
generate_from (image2 (×ˢ) C D) = prod.measurable_space :=
by rw [← hC, ← hD, generate_from_prod_eq h2C h2D]
/-- The product σ-algebra is generated from boxes, i.e. `s ×ˢ t` for sets `s : set α` and
`t : set β`. -/
lemma generate_from_prod :
generate_from (image2 (×ˢ) {s : set α | measurable_set s} {t : set β | measurable_set t}) =
prod.measurable_space :=
generate_from_eq_prod generate_from_measurable_set generate_from_measurable_set
is_countably_spanning_measurable_set is_countably_spanning_measurable_set
/-- Rectangles form a π-system. -/
lemma is_pi_system_prod :
is_pi_system (image2 (×ˢ) {s : set α | measurable_set s} {t : set β | measurable_set t}) :=
is_pi_system_measurable_set.prod is_pi_system_measurable_set
/-- If `ν` is a finite measure, and `s ⊆ α × β` is measurable, then `x ↦ ν { y | (x, y) ∈ s }` is
a measurable function. `measurable_measure_prod_mk_left` is strictly more general. -/
lemma measurable_measure_prod_mk_left_finite [is_finite_measure ν] {s : set (α × β)}
(hs : measurable_set s) : measurable (λ x, ν (prod.mk x ⁻¹' s)) :=
begin
refine induction_on_inter generate_from_prod.symm is_pi_system_prod _ _ _ _ hs,
{ simp [measurable_zero, const_def] },
{ rintro _ ⟨s, t, hs, ht, rfl⟩, simp only [mk_preimage_prod_right_eq_if, measure_if],
exact measurable_const.indicator hs },
{ intros t ht h2t,
simp_rw [preimage_compl, measure_compl (measurable_prod_mk_left ht) (measure_ne_top ν _)],
exact h2t.const_sub _ },
{ intros f h1f h2f h3f, simp_rw [preimage_Union],
have : ∀ b, ν (⋃ i, prod.mk b ⁻¹' f i) = ∑' i, ν (prod.mk b ⁻¹' f i) :=
λ b, measure_Union (λ i j hij, disjoint.preimage _ (h1f hij))
(λ i, measurable_prod_mk_left (h2f i)),
simp_rw [this], apply measurable.ennreal_tsum h3f },
end
/-- If `ν` is a σ-finite measure, and `s ⊆ α × β` is measurable, then `x ↦ ν { y | (x, y) ∈ s }` is
a measurable function. -/
lemma measurable_measure_prod_mk_left [sigma_finite ν] {s : set (α × β)}
(hs : measurable_set s) : measurable (λ x, ν (prod.mk x ⁻¹' s)) :=
begin
have : ∀ x, measurable_set (prod.mk x ⁻¹' s) := λ x, measurable_prod_mk_left hs,
simp only [← @supr_restrict_spanning_sets _ _ ν, this],
apply measurable_supr, intro i,
haveI := fact.mk (measure_spanning_sets_lt_top ν i),
exact measurable_measure_prod_mk_left_finite hs
end
/-- If `μ` is a σ-finite measure, and `s ⊆ α × β` is measurable, then `y ↦ μ { x | (x, y) ∈ s }` is
a measurable function. -/
lemma measurable_measure_prod_mk_right {μ : measure α} [sigma_finite μ] {s : set (α × β)}
(hs : measurable_set s) : measurable (λ y, μ ((λ x, (x, y)) ⁻¹' s)) :=
measurable_measure_prod_mk_left (measurable_set_swap_iff.mpr hs)
lemma measurable.map_prod_mk_left [sigma_finite ν] : measurable (λ x : α, map (prod.mk x) ν) :=
begin
apply measurable_of_measurable_coe, intros s hs,
simp_rw [map_apply measurable_prod_mk_left hs],
exact measurable_measure_prod_mk_left hs
end
lemma measurable.map_prod_mk_right {μ : measure α} [sigma_finite μ] :
measurable (λ y : β, map (λ x : α, (x, y)) μ) :=
begin
apply measurable_of_measurable_coe, intros s hs,
simp_rw [map_apply measurable_prod_mk_right hs],
exact measurable_measure_prod_mk_right hs
end
lemma measurable_embedding.prod_mk {α β γ δ : Type*} {mα : measurable_space α}
{mβ : measurable_space β} {mγ : measurable_space γ} {mδ : measurable_space δ}
{f : α → β} {g : γ → δ} (hg : measurable_embedding g) (hf : measurable_embedding f) :
measurable_embedding (λ x : γ × α, (g x.1, f x.2)) :=
begin
have h_inj : function.injective (λ x : γ × α, (g x.fst, f x.snd)),
{ intros x y hxy,
rw [← @prod.mk.eta _ _ x, ← @prod.mk.eta _ _ y],
simp only [prod.mk.inj_iff] at hxy ⊢,
exact ⟨hg.injective hxy.1, hf.injective hxy.2⟩, },
refine ⟨h_inj, _, _⟩,
{ exact (hg.measurable.comp measurable_fst).prod_mk (hf.measurable.comp measurable_snd), },
{ -- Induction using the π-system of rectangles
refine λ s hs, @measurable_space.induction_on_inter _
(λ s, measurable_set ((λ (x : γ × α), (g x.fst, f x.snd)) '' s)) _ _ generate_from_prod.symm
is_pi_system_prod _ _ _ _ _ hs,
{ simp only [set.image_empty, measurable_set.empty], },
{ rintros t ⟨t₁, t₂, ht₁, ht₂, rfl⟩,
rw ← set.prod_image_image_eq,
exact (hg.measurable_set_image.mpr ht₁).prod (hf.measurable_set_image.mpr ht₂), },
{ intros t ht ht_m,
rw [← set.range_diff_image h_inj, ← set.prod_range_range_eq],
exact measurable_set.diff
(measurable_set.prod hg.measurable_set_range hf.measurable_set_range) ht_m, },
{ intros g hg_disj hg_meas hg,
simp_rw set.image_Union,
exact measurable_set.Union hg, }, },
end
/-- The Lebesgue integral is measurable. This shows that the integrand of (the right-hand-side of)
Tonelli's theorem is measurable. -/
lemma measurable.lintegral_prod_right' [sigma_finite ν] :
∀ {f : α × β → ℝ≥0∞} (hf : measurable f), measurable (λ x, ∫⁻ y, f (x, y) ∂ν) :=
begin
have m := @measurable_prod_mk_left,
refine measurable.ennreal_induction _ _ _,
{ intros c s hs, simp only [← indicator_comp_right],
suffices : measurable (λ x, c * ν (prod.mk x ⁻¹' s)),
{ simpa [lintegral_indicator _ (m hs)] },
exact (measurable_measure_prod_mk_left hs).const_mul _ },
{ rintro f g - hf hg h2f h2g, simp_rw [pi.add_apply, lintegral_add_left (hf.comp m)],
exact h2f.add h2g },
{ intros f hf h2f h3f,
have := measurable_supr h3f,
have : ∀ x, monotone (λ n y, f n (x, y)) := λ x i j hij y, h2f hij (x, y),
simpa [lintegral_supr (λ n, (hf n).comp m), this] }
end
/-- The Lebesgue integral is measurable. This shows that the integrand of (the right-hand-side of)
Tonelli's theorem is measurable.
This version has the argument `f` in curried form. -/
lemma measurable.lintegral_prod_right [sigma_finite ν] {f : α → β → ℝ≥0∞}
(hf : measurable (uncurry f)) : measurable (λ x, ∫⁻ y, f x y ∂ν) :=
hf.lintegral_prod_right'
/-- The Lebesgue integral is measurable. This shows that the integrand of (the right-hand-side of)
the symmetric version of Tonelli's theorem is measurable. -/
lemma measurable.lintegral_prod_left' [sigma_finite μ] {f : α × β → ℝ≥0∞}
(hf : measurable f) : measurable (λ y, ∫⁻ x, f (x, y) ∂μ) :=
(measurable_swap_iff.mpr hf).lintegral_prod_right'
/-- The Lebesgue integral is measurable. This shows that the integrand of (the right-hand-side of)
the symmetric version of Tonelli's theorem is measurable.
This version has the argument `f` in curried form. -/
lemma measurable.lintegral_prod_left [sigma_finite μ] {f : α → β → ℝ≥0∞}
(hf : measurable (uncurry f)) : measurable (λ y, ∫⁻ x, f x y ∂μ) :=
hf.lintegral_prod_left'
/-! ### The product measure -/
namespace measure_theory
namespace measure
/-- The binary product of measures. They are defined for arbitrary measures, but we basically
prove all properties under the assumption that at least one of them is σ-finite. -/
@[irreducible] protected def prod (μ : measure α) (ν : measure β) : measure (α × β) :=
bind μ $ λ x : α, map (prod.mk x) ν
instance prod.measure_space {α β} [measure_space α] [measure_space β] : measure_space (α × β) :=
{ volume := volume.prod volume }
variables [sigma_finite ν]
lemma volume_eq_prod (α β) [measure_space α] [measure_space β] :
(volume : measure (α × β)) = (volume : measure α).prod (volume : measure β) :=
rfl
lemma prod_apply {s : set (α × β)} (hs : measurable_set s) :
μ.prod ν s = ∫⁻ x, ν (prod.mk x ⁻¹' s) ∂μ :=
by simp_rw [measure.prod, bind_apply hs measurable.map_prod_mk_left,
map_apply measurable_prod_mk_left hs]
/-- The product measure of the product of two sets is the product of their measures. Note that we
do not need the sets to be measurable. -/
@[simp] lemma prod_prod (s : set α) (t : set β) : μ.prod ν (s ×ˢ t) = μ s * ν t :=
begin
apply le_antisymm,
{ set ST := (to_measurable μ s) ×ˢ (to_measurable ν t),
have hSTm : measurable_set ST :=
(measurable_set_to_measurable _ _).prod (measurable_set_to_measurable _ _),
calc μ.prod ν (s ×ˢ t) ≤ μ.prod ν ST :
measure_mono $ set.prod_mono (subset_to_measurable _ _) (subset_to_measurable _ _)
... = μ (to_measurable μ s) * ν (to_measurable ν t) :
by simp_rw [prod_apply hSTm, mk_preimage_prod_right_eq_if, measure_if,
lintegral_indicator _ (measurable_set_to_measurable _ _), lintegral_const,
restrict_apply_univ, mul_comm]
... = μ s * ν t : by rw [measure_to_measurable, measure_to_measurable] },
{ /- Formalization is based on https://mathoverflow.net/a/254134/136589 -/
set ST := to_measurable (μ.prod ν) (s ×ˢ t),
have hSTm : measurable_set ST := measurable_set_to_measurable _ _,
have hST : s ×ˢ t ⊆ ST := subset_to_measurable _ _,
set f : α → ℝ≥0∞ := λ x, ν (prod.mk x ⁻¹' ST),
have hfm : measurable f := measurable_measure_prod_mk_left hSTm,
set s' : set α := {x | ν t ≤ f x},
have hss' : s ⊆ s' := λ x hx, measure_mono (λ y hy, hST $ mk_mem_prod hx hy),
calc μ s * ν t ≤ μ s' * ν t : mul_le_mul_right' (measure_mono hss') _
... = ∫⁻ x in s', ν t ∂μ : by rw [set_lintegral_const, mul_comm]
... ≤ ∫⁻ x in s', f x ∂μ : set_lintegral_mono measurable_const hfm (λ x, id)
... ≤ ∫⁻ x, f x ∂μ : lintegral_mono' restrict_le_self le_rfl
... = μ.prod ν ST : (prod_apply hSTm).symm
... = μ.prod ν (s ×ˢ t) : measure_to_measurable _ }
end
instance {X Y : Type*} [topological_space X] [topological_space Y]
{m : measurable_space X} {μ : measure X} [is_open_pos_measure μ]
{m' : measurable_space Y} {ν : measure Y} [is_open_pos_measure ν] [sigma_finite ν] :
is_open_pos_measure (μ.prod ν) :=
begin
constructor,
rintros U U_open ⟨⟨x, y⟩, hxy⟩,
rcases is_open_prod_iff.1 U_open x y hxy with ⟨u, v, u_open, v_open, xu, yv, huv⟩,
refine ne_of_gt (lt_of_lt_of_le _ (measure_mono huv)),
simp only [prod_prod, canonically_ordered_comm_semiring.mul_pos],
split,
{ exact u_open.measure_pos μ ⟨x, xu⟩ },
{ exact v_open.measure_pos ν ⟨y, yv⟩ }
end
instance {α β : Type*} {mα : measurable_space α} {mβ : measurable_space β}
(μ : measure α) (ν : measure β) [is_finite_measure μ] [is_finite_measure ν] :
is_finite_measure (μ.prod ν) :=
begin
constructor,
rw [← univ_prod_univ, prod_prod],
exact mul_lt_top (measure_lt_top _ _).ne (measure_lt_top _ _).ne,
end
instance {α β : Type*} {mα : measurable_space α} {mβ : measurable_space β}
(μ : measure α) (ν : measure β) [is_probability_measure μ] [is_probability_measure ν] :
is_probability_measure (μ.prod ν) :=
⟨by rw [← univ_prod_univ, prod_prod, measure_univ, measure_univ, mul_one]⟩
instance {α β : Type*} [topological_space α] [topological_space β]
{mα : measurable_space α} {mβ : measurable_space β} (μ : measure α) (ν : measure β)
[is_finite_measure_on_compacts μ] [is_finite_measure_on_compacts ν] [sigma_finite ν] :
is_finite_measure_on_compacts (μ.prod ν) :=
begin
refine ⟨λ K hK, _⟩,
set L := (prod.fst '' K) ×ˢ (prod.snd '' K) with hL,
have : K ⊆ L,
{ rintros ⟨x, y⟩ hxy,
simp only [prod_mk_mem_set_prod_eq, mem_image, prod.exists, exists_and_distrib_right,
exists_eq_right],
exact ⟨⟨y, hxy⟩, ⟨x, hxy⟩⟩ },
apply lt_of_le_of_lt (measure_mono this),
rw [hL, prod_prod],
exact mul_lt_top ((is_compact.measure_lt_top ((hK.image continuous_fst))).ne)
((is_compact.measure_lt_top ((hK.image continuous_snd))).ne)
end
lemma ae_measure_lt_top {s : set (α × β)} (hs : measurable_set s)
(h2s : (μ.prod ν) s ≠ ∞) : ∀ᵐ x ∂μ, ν (prod.mk x ⁻¹' s) < ∞ :=
by { simp_rw [prod_apply hs] at h2s, refine ae_lt_top (measurable_measure_prod_mk_left hs) h2s }
/-- Note: the assumption `hs` cannot be dropped. For a counterexample, see
Walter Rudin *Real and Complex Analysis*, example (c) in section 8.9. -/
lemma measure_prod_null {s : set (α × β)}
(hs : measurable_set s) : μ.prod ν s = 0 ↔ (λ x, ν (prod.mk x ⁻¹' s)) =ᵐ[μ] 0 :=
by simp_rw [prod_apply hs, lintegral_eq_zero_iff (measurable_measure_prod_mk_left hs)]
/-- Note: the converse is not true without assuming that `s` is measurable. For a counterexample,
see Walter Rudin *Real and Complex Analysis*, example (c) in section 8.9. -/
lemma measure_ae_null_of_prod_null {s : set (α × β)}
(h : μ.prod ν s = 0) : (λ x, ν (prod.mk x ⁻¹' s)) =ᵐ[μ] 0 :=
begin
obtain ⟨t, hst, mt, ht⟩ := exists_measurable_superset_of_null h,
simp_rw [measure_prod_null mt] at ht,
rw [eventually_le_antisymm_iff],
exact ⟨eventually_le.trans_eq
(eventually_of_forall $ λ x, (measure_mono (preimage_mono hst) : _)) ht,
eventually_of_forall $ λ x, zero_le _⟩
end
lemma absolutely_continuous.prod [sigma_finite ν'] (h1 : μ ≪ μ') (h2 : ν ≪ ν') :
μ.prod ν ≪ μ'.prod ν' :=
begin
refine absolutely_continuous.mk (λ s hs h2s, _),
simp_rw [measure_prod_null hs] at h2s ⊢,
exact (h2s.filter_mono h1.ae_le).mono (λ _ h, h2 h)
end
/-- Note: the converse is not true. For a counterexample, see
Walter Rudin *Real and Complex Analysis*, example (c) in section 8.9. -/
lemma ae_ae_of_ae_prod {p : α × β → Prop} (h : ∀ᵐ z ∂μ.prod ν, p z) :
∀ᵐ x ∂ μ, ∀ᵐ y ∂ ν, p (x, y) :=
measure_ae_null_of_prod_null h
/-- `μ.prod ν` has finite spanning sets in rectangles of finite spanning sets. -/
noncomputable! def finite_spanning_sets_in.prod {ν : measure β} {C : set (set α)} {D : set (set β)}
(hμ : μ.finite_spanning_sets_in C) (hν : ν.finite_spanning_sets_in D) :
(μ.prod ν).finite_spanning_sets_in (image2 (×ˢ) C D) :=
begin
haveI := hν.sigma_finite,
refine ⟨λ n, hμ.set n.unpair.1 ×ˢ hν.set n.unpair.2,
λ n, mem_image2_of_mem (hμ.set_mem _) (hν.set_mem _), λ n, _, _⟩,
{ rw [prod_prod],
exact mul_lt_top (hμ.finite _).ne (hν.finite _).ne },
{ simp_rw [Union_unpair_prod, hμ.spanning, hν.spanning, univ_prod_univ] }
end
lemma quasi_measure_preserving_fst : quasi_measure_preserving prod.fst (μ.prod ν) μ :=
begin
refine ⟨measurable_fst, absolutely_continuous.mk (λ s hs h2s, _)⟩,
rw [map_apply measurable_fst hs, ← prod_univ, prod_prod, h2s, zero_mul],
end
lemma quasi_measure_preserving_snd : quasi_measure_preserving prod.snd (μ.prod ν) ν :=
begin
refine ⟨measurable_snd, absolutely_continuous.mk (λ s hs h2s, _)⟩,
rw [map_apply measurable_snd hs, ← univ_prod, prod_prod, h2s, mul_zero]
end
variables [sigma_finite μ]
instance prod.sigma_finite : sigma_finite (μ.prod ν) :=
(μ.to_finite_spanning_sets_in.prod ν.to_finite_spanning_sets_in).sigma_finite
/-- A measure on a product space equals the product measure if they are equal on rectangles
with as sides sets that generate the corresponding σ-algebras. -/
lemma prod_eq_generate_from {μ : measure α} {ν : measure β} {C : set (set α)}
{D : set (set β)} (hC : generate_from C = ‹_›)
(hD : generate_from D = ‹_›) (h2C : is_pi_system C) (h2D : is_pi_system D)
(h3C : μ.finite_spanning_sets_in C) (h3D : ν.finite_spanning_sets_in D)
{μν : measure (α × β)}
(h₁ : ∀ (s ∈ C) (t ∈ D), μν (s ×ˢ t) = μ s * ν t) : μ.prod ν = μν :=
begin
refine (h3C.prod h3D).ext
(generate_from_eq_prod hC hD h3C.is_countably_spanning h3D.is_countably_spanning).symm
(h2C.prod h2D) _,
{ rintro _ ⟨s, t, hs, ht, rfl⟩, haveI := h3D.sigma_finite,
rw [h₁ s hs t ht, prod_prod] }
end
/-- A measure on a product space equals the product measure if they are equal on rectangles. -/
lemma prod_eq {μν : measure (α × β)}
(h : ∀ s t, measurable_set s → measurable_set t → μν (s ×ˢ t) = μ s * ν t) : μ.prod ν = μν :=
prod_eq_generate_from generate_from_measurable_set generate_from_measurable_set
is_pi_system_measurable_set is_pi_system_measurable_set
μ.to_finite_spanning_sets_in ν.to_finite_spanning_sets_in (λ s hs t ht, h s t hs ht)
lemma prod_swap : map prod.swap (μ.prod ν) = ν.prod μ :=
begin
refine (prod_eq _).symm,
intros s t hs ht,
simp_rw [map_apply measurable_swap (hs.prod ht), preimage_swap_prod, prod_prod, mul_comm]
end
lemma measure_preserving_swap : measure_preserving prod.swap (μ.prod ν) (ν.prod μ) :=
⟨measurable_swap, prod_swap⟩
lemma prod_apply_symm {s : set (α × β)} (hs : measurable_set s) :
μ.prod ν s = ∫⁻ y, μ ((λ x, (x, y)) ⁻¹' s) ∂ν :=
by { rw [← prod_swap, map_apply measurable_swap hs],
simp only [prod_apply (measurable_swap hs)], refl }
lemma prod_assoc_prod [sigma_finite τ] :
map measurable_equiv.prod_assoc ((μ.prod ν).prod τ) = μ.prod (ν.prod τ) :=
begin
refine (prod_eq_generate_from generate_from_measurable_set generate_from_prod
is_pi_system_measurable_set is_pi_system_prod μ.to_finite_spanning_sets_in
(ν.to_finite_spanning_sets_in.prod τ.to_finite_spanning_sets_in) _).symm,
rintro s hs _ ⟨t, u, ht, hu, rfl⟩, rw [mem_set_of_eq] at hs ht hu,
simp_rw [map_apply (measurable_equiv.measurable _) (hs.prod (ht.prod hu)),
measurable_equiv.prod_assoc, measurable_equiv.coe_mk, equiv.prod_assoc_preimage,
prod_prod, mul_assoc]
end
/-! ### The product of specific measures -/
lemma prod_restrict (s : set α) (t : set β) :
(μ.restrict s).prod (ν.restrict t) = (μ.prod ν).restrict (s ×ˢ t) :=
begin
refine prod_eq (λ s' t' hs' ht', _),
rw [restrict_apply (hs'.prod ht'), prod_inter_prod, prod_prod, restrict_apply hs',
restrict_apply ht']
end
lemma restrict_prod_eq_prod_univ (s : set α) :
(μ.restrict s).prod ν = (μ.prod ν).restrict (s ×ˢ (univ : set β)) :=
begin
have : ν = ν.restrict set.univ := measure.restrict_univ.symm,
rwa [this, measure.prod_restrict, ← this],
end
lemma prod_dirac (y : β) : μ.prod (dirac y) = map (λ x, (x, y)) μ :=
begin
refine prod_eq (λ s t hs ht, _),
simp_rw [map_apply measurable_prod_mk_right (hs.prod ht), mk_preimage_prod_left_eq_if, measure_if,
dirac_apply' _ ht, ← indicator_mul_right _ (λ x, μ s), pi.one_apply, mul_one]
end
lemma dirac_prod (x : α) : (dirac x).prod ν = map (prod.mk x) ν :=
begin
refine prod_eq (λ s t hs ht, _),
simp_rw [map_apply measurable_prod_mk_left (hs.prod ht), mk_preimage_prod_right_eq_if, measure_if,
dirac_apply' _ hs, ← indicator_mul_left _ _ (λ x, ν t), pi.one_apply, one_mul]
end
lemma dirac_prod_dirac {x : α} {y : β} : (dirac x).prod (dirac y) = dirac (x, y) :=
by rw [prod_dirac, map_dirac measurable_prod_mk_right]
lemma prod_sum {ι : Type*} [finite ι] (ν : ι → measure β) [∀ i, sigma_finite (ν i)] :
μ.prod (sum ν) = sum (λ i, μ.prod (ν i)) :=
begin
refine prod_eq (λ s t hs ht, _),
simp_rw [sum_apply _ (hs.prod ht), sum_apply _ ht, prod_prod, ennreal.tsum_mul_left]
end
lemma sum_prod {ι : Type*} [finite ι] (μ : ι → measure α) [∀ i, sigma_finite (μ i)] :
(sum μ).prod ν = sum (λ i, (μ i).prod ν) :=
begin
refine prod_eq (λ s t hs ht, _),
simp_rw [sum_apply _ (hs.prod ht), sum_apply _ hs, prod_prod, ennreal.tsum_mul_right]
end
lemma prod_add (ν' : measure β) [sigma_finite ν'] : μ.prod (ν + ν') = μ.prod ν + μ.prod ν' :=
by { refine prod_eq (λ s t hs ht, _), simp_rw [add_apply, prod_prod, left_distrib] }
lemma add_prod (μ' : measure α) [sigma_finite μ'] : (μ + μ').prod ν = μ.prod ν + μ'.prod ν :=
by { refine prod_eq (λ s t hs ht, _), simp_rw [add_apply, prod_prod, right_distrib] }
@[simp] lemma zero_prod (ν : measure β) : (0 : measure α).prod ν = 0 :=
by { rw measure.prod, exact bind_zero_left _ }
@[simp] lemma prod_zero (μ : measure α) : μ.prod (0 : measure β) = 0 :=
by simp [measure.prod]
lemma map_prod_map {δ} [measurable_space δ] {f : α → β} {g : γ → δ}
{μa : measure α} {μc : measure γ} (hfa : sigma_finite (map f μa))
(hgc : sigma_finite (map g μc)) (hf : measurable f) (hg : measurable g) :
(map f μa).prod (map g μc) = map (prod.map f g) (μa.prod μc) :=
begin
haveI := hgc.of_map μc hg.ae_measurable,
refine prod_eq (λ s t hs ht, _),
rw [map_apply (hf.prod_map hg) (hs.prod ht), map_apply hf hs, map_apply hg ht],
exact prod_prod (f ⁻¹' s) (g ⁻¹' t)
end
end measure
open measure
namespace measure_preserving
variables {δ : Type*} [measurable_space δ] {μa : measure α} {μb : measure β}
{μc : measure γ} {μd : measure δ}
lemma skew_product [sigma_finite μb] [sigma_finite μd]
{f : α → β} (hf : measure_preserving f μa μb) {g : α → γ → δ}
(hgm : measurable (uncurry g)) (hg : ∀ᵐ x ∂μa, map (g x) μc = μd) :
measure_preserving (λ p : α × γ, (f p.1, g p.1 p.2)) (μa.prod μc) (μb.prod μd) :=
begin
classical,
have : measurable (λ p : α × γ, (f p.1, g p.1 p.2)) := (hf.1.comp measurable_fst).prod_mk hgm,
/- if `μa = 0`, then the lemma is trivial, otherwise we can use `hg`
to deduce `sigma_finite μc`. -/
rcases eq_or_ne μa 0 with (rfl|ha),
{ rw [← hf.map_eq, zero_prod, measure.map_zero, zero_prod],
exact ⟨this, by simp only [measure.map_zero]⟩ },
haveI : sigma_finite μc,
{ rcases (ae_ne_bot.2 ha).nonempty_of_mem hg with ⟨x, hx : map (g x) μc = μd⟩,
exact sigma_finite.of_map _ hgm.of_uncurry_left.ae_measurable (by rwa hx) },
-- Thus we can apply `measure.prod_eq` to prove equality of measures.
refine ⟨this, (prod_eq $ λ s t hs ht, _).symm⟩,
rw [map_apply this (hs.prod ht)],
refine (prod_apply (this $ hs.prod ht)).trans _,
have : ∀ᵐ x ∂μa, μc ((λ y, (f x, g x y)) ⁻¹' s ×ˢ t) = indicator (f ⁻¹' s) (λ y, μd t) x,
{ refine hg.mono (λ x hx, _), unfreezingI { subst hx },
simp only [mk_preimage_prod_right_fn_eq_if, indicator_apply, mem_preimage],
split_ifs,
exacts [(map_apply hgm.of_uncurry_left ht).symm, measure_empty] },
simp only [preimage_preimage],
rw [lintegral_congr_ae this, lintegral_indicator _ (hf.1 hs),
set_lintegral_const, hf.measure_preimage hs, mul_comm]
end
/-- If `f : α → β` sends the measure `μa` to `μb` and `g : γ → δ` sends the measure `μc` to `μd`,
then `prod.map f g` sends `μa.prod μc` to `μb.prod μd`. -/
protected lemma prod [sigma_finite μb] [sigma_finite μd] {f : α → β} {g : γ → δ}
(hf : measure_preserving f μa μb) (hg : measure_preserving g μc μd) :
measure_preserving (prod.map f g) (μa.prod μc) (μb.prod μd) :=
have measurable (uncurry $ λ _ : α, g), from (hg.1.comp measurable_snd),
hf.skew_product this $ filter.eventually_of_forall $ λ _, hg.map_eq
end measure_preserving
namespace quasi_measure_preserving
lemma prod_of_right {f : α × β → γ} {μ : measure α} {ν : measure β} {τ : measure γ}
(hf : measurable f) [sigma_finite ν]
(h2f : ∀ᵐ x ∂μ, quasi_measure_preserving (λ y, f (x, y)) ν τ) :
quasi_measure_preserving f (μ.prod ν) τ :=
begin
refine ⟨hf, _⟩,
refine absolutely_continuous.mk (λ s hs h2s, _),
simp_rw [map_apply hf hs, prod_apply (hf hs), preimage_preimage,
lintegral_congr_ae (h2f.mono (λ x hx, hx.preimage_null h2s)), lintegral_zero],
end
lemma prod_of_left {α β γ} [measurable_space α] [measurable_space β]
[measurable_space γ] {f : α × β → γ} {μ : measure α} {ν : measure β} {τ : measure γ}
(hf : measurable f) [sigma_finite μ] [sigma_finite ν]
(h2f : ∀ᵐ y ∂ν, quasi_measure_preserving (λ x, f (x, y)) μ τ) :
quasi_measure_preserving f (μ.prod ν) τ :=
begin
rw [← prod_swap],
convert (quasi_measure_preserving.prod_of_right (hf.comp measurable_swap) h2f).comp
((measurable_swap.measure_preserving (ν.prod μ)).symm measurable_equiv.prod_comm)
.quasi_measure_preserving,
ext ⟨x, y⟩, refl,
end
end quasi_measure_preserving
end measure_theory
open measure_theory.measure
section
lemma ae_measurable.prod_swap [sigma_finite μ] [sigma_finite ν] {f : β × α → γ}
(hf : ae_measurable f (ν.prod μ)) : ae_measurable (λ (z : α × β), f z.swap) (μ.prod ν) :=
by { rw ← prod_swap at hf, exact hf.comp_measurable measurable_swap }
lemma ae_measurable.fst [sigma_finite ν] {f : α → γ}
(hf : ae_measurable f μ) : ae_measurable (λ (z : α × β), f z.1) (μ.prod ν) :=
hf.comp_quasi_measure_preserving quasi_measure_preserving_fst
lemma ae_measurable.snd [sigma_finite ν] {f : β → γ}
(hf : ae_measurable f ν) : ae_measurable (λ (z : α × β), f z.2) (μ.prod ν) :=
hf.comp_quasi_measure_preserving quasi_measure_preserving_snd
end
namespace measure_theory
/-! ### The Lebesgue integral on a product -/
variables [sigma_finite ν]
lemma lintegral_prod_swap [sigma_finite μ] (f : α × β → ℝ≥0∞)
(hf : ae_measurable f (μ.prod ν)) : ∫⁻ z, f z.swap ∂(ν.prod μ) = ∫⁻ z, f z ∂(μ.prod ν) :=
by { rw ← prod_swap at hf, rw [← lintegral_map' hf measurable_swap.ae_measurable, prod_swap] }
/-- **Tonelli's Theorem**: For `ℝ≥0∞`-valued measurable functions on `α × β`,
the integral of `f` is equal to the iterated integral. -/
lemma lintegral_prod_of_measurable :
∀ (f : α × β → ℝ≥0∞) (hf : measurable f), ∫⁻ z, f z ∂(μ.prod ν) = ∫⁻ x, ∫⁻ y, f (x, y) ∂ν ∂μ :=
begin
have m := @measurable_prod_mk_left,
refine measurable.ennreal_induction _ _ _,
{ intros c s hs, simp only [← indicator_comp_right],
simp [lintegral_indicator, m hs, hs, lintegral_const_mul, measurable_measure_prod_mk_left hs,
prod_apply] },
{ rintro f g - hf hg h2f h2g,
simp [lintegral_add_left, measurable.lintegral_prod_right', hf.comp m, hf, h2f, h2g] },
{ intros f hf h2f h3f,
have kf : ∀ x n, measurable (λ y, f n (x, y)) := λ x n, (hf n).comp m,
have k2f : ∀ x, monotone (λ n y, f n (x, y)) := λ x i j hij y, h2f hij (x, y),
have lf : ∀ n, measurable (λ x, ∫⁻ y, f n (x, y) ∂ν) := λ n, (hf n).lintegral_prod_right',
have l2f : monotone (λ n x, ∫⁻ y, f n (x, y) ∂ν) := λ i j hij x, lintegral_mono (k2f x hij),
simp only [lintegral_supr hf h2f, lintegral_supr (kf _), k2f, lintegral_supr lf l2f, h3f] },
end
/-- **Tonelli's Theorem**: For `ℝ≥0∞`-valued almost everywhere measurable functions on `α × β`,
the integral of `f` is equal to the iterated integral. -/
lemma lintegral_prod (f : α × β → ℝ≥0∞) (hf : ae_measurable f (μ.prod ν)) :
∫⁻ z, f z ∂(μ.prod ν) = ∫⁻ x, ∫⁻ y, f (x, y) ∂ν ∂μ :=
begin
have A : ∫⁻ z, f z ∂(μ.prod ν) = ∫⁻ z, hf.mk f z ∂(μ.prod ν) :=
lintegral_congr_ae hf.ae_eq_mk,
have B : ∫⁻ x, ∫⁻ y, f (x, y) ∂ν ∂μ = ∫⁻ x, ∫⁻ y, hf.mk f (x, y) ∂ν ∂μ,
{ apply lintegral_congr_ae,
filter_upwards [ae_ae_of_ae_prod hf.ae_eq_mk] with _ ha using lintegral_congr_ae ha, },
rw [A, B, lintegral_prod_of_measurable _ hf.measurable_mk],
apply_instance
end
/-- The symmetric verion of Tonelli's Theorem: For `ℝ≥0∞`-valued almost everywhere measurable
functions on `α × β`, the integral of `f` is equal to the iterated integral, in reverse order. -/
lemma lintegral_prod_symm [sigma_finite μ] (f : α × β → ℝ≥0∞)
(hf : ae_measurable f (μ.prod ν)) : ∫⁻ z, f z ∂(μ.prod ν) = ∫⁻ y, ∫⁻ x, f (x, y) ∂μ ∂ν :=
by { simp_rw [← lintegral_prod_swap f hf], exact lintegral_prod _ hf.prod_swap }
/-- The symmetric verion of Tonelli's Theorem: For `ℝ≥0∞`-valued measurable
functions on `α × β`, the integral of `f` is equal to the iterated integral, in reverse order. -/
lemma lintegral_prod_symm' [sigma_finite μ] (f : α × β → ℝ≥0∞)
(hf : measurable f) : ∫⁻ z, f z ∂(μ.prod ν) = ∫⁻ y, ∫⁻ x, f (x, y) ∂μ ∂ν :=
lintegral_prod_symm f hf.ae_measurable
/-- The reversed version of **Tonelli's Theorem**. In this version `f` is in curried form, which
makes it easier for the elaborator to figure out `f` automatically. -/
lemma lintegral_lintegral ⦃f : α → β → ℝ≥0∞⦄
(hf : ae_measurable (uncurry f) (μ.prod ν)) :
∫⁻ x, ∫⁻ y, f x y ∂ν ∂μ = ∫⁻ z, f z.1 z.2 ∂(μ.prod ν) :=
(lintegral_prod _ hf).symm
/-- The reversed version of **Tonelli's Theorem** (symmetric version). In this version `f` is in
curried form, which makes it easier for the elaborator to figure out `f` automatically. -/
lemma lintegral_lintegral_symm [sigma_finite μ] ⦃f : α → β → ℝ≥0∞⦄
(hf : ae_measurable (uncurry f) (μ.prod ν)) :
∫⁻ x, ∫⁻ y, f x y ∂ν ∂μ = ∫⁻ z, f z.2 z.1 ∂(ν.prod μ) :=
(lintegral_prod_symm _ hf.prod_swap).symm
/-- Change the order of Lebesgue integration. -/
lemma lintegral_lintegral_swap [sigma_finite μ] ⦃f : α → β → ℝ≥0∞⦄
(hf : ae_measurable (uncurry f) (μ.prod ν)) :
∫⁻ x, ∫⁻ y, f x y ∂ν ∂μ = ∫⁻ y, ∫⁻ x, f x y ∂μ ∂ν :=
(lintegral_lintegral hf).trans (lintegral_prod_symm _ hf)
lemma lintegral_prod_mul {f : α → ℝ≥0∞} {g : β → ℝ≥0∞}
(hf : ae_measurable f μ) (hg : ae_measurable g ν) :
∫⁻ z, f z.1 * g z.2 ∂(μ.prod ν) = ∫⁻ x, f x ∂μ * ∫⁻ y, g y ∂ν :=
by simp [lintegral_prod _ (hf.fst.mul hg.snd), lintegral_lintegral_mul hf hg]
/-! ### Marginals of a measure defined on a product -/
namespace measure
variables {ρ : measure (α × β)}
/-- Marginal measure on `α` obtained from a measure `ρ` on `α × β`, defined by `ρ.map prod.fst`. -/
noncomputable
def fst (ρ : measure (α × β)) : measure α := ρ.map prod.fst
lemma fst_apply {s : set α} (hs : measurable_set s) : ρ.fst s = ρ (prod.fst ⁻¹' s) :=
by rw [fst, measure.map_apply measurable_fst hs]
lemma fst_univ : ρ.fst univ = ρ univ :=
by rw [fst_apply measurable_set.univ, preimage_univ]
instance [is_finite_measure ρ] : is_finite_measure ρ.fst := by { rw fst, apply_instance, }
instance [is_probability_measure ρ] : is_probability_measure ρ.fst :=
{ measure_univ := by { rw fst_univ, exact measure_univ, } }
lemma fst_map_prod_mk₀ {X : α → β} {Y : α → γ} {μ : measure α}
(hX : ae_measurable X μ) (hY : ae_measurable Y μ) :
(μ.map (λ a, (X a, Y a))).fst = μ.map X :=
begin
ext1 s hs,
rw [measure.fst_apply hs, measure.map_apply_of_ae_measurable (hX.prod_mk hY) (measurable_fst hs),
measure.map_apply_of_ae_measurable hX hs, ← prod_univ, mk_preimage_prod, preimage_univ,
inter_univ],
end
lemma fst_map_prod_mk {X : α → β} {Y : α → γ} {μ : measure α}
(hX : measurable X) (hY : measurable Y) :
(μ.map (λ a, (X a, Y a))).fst = μ.map X :=
fst_map_prod_mk₀ hX.ae_measurable hY.ae_measurable
/-- Marginal measure on `β` obtained from a measure on `ρ` `α × β`, defined by `ρ.map prod.snd`. -/
noncomputable
def snd (ρ : measure (α × β)) : measure β := ρ.map prod.snd
lemma snd_apply {s : set β} (hs : measurable_set s) : ρ.snd s = ρ (prod.snd ⁻¹' s) :=
by rw [snd, measure.map_apply measurable_snd hs]
lemma snd_univ : ρ.snd univ = ρ univ :=
by rw [snd_apply measurable_set.univ, preimage_univ]
instance [is_finite_measure ρ] : is_finite_measure ρ.snd := by { rw snd, apply_instance, }
instance [is_probability_measure ρ] : is_probability_measure ρ.snd :=
{ measure_univ := by { rw snd_univ, exact measure_univ, } }
lemma snd_map_prod_mk₀ {X : α → β} {Y : α → γ} {μ : measure α}
(hX : ae_measurable X μ) (hY : ae_measurable Y μ) :
(μ.map (λ a, (X a, Y a))).snd = μ.map Y :=
begin
ext1 s hs,
rw [measure.snd_apply hs, measure.map_apply_of_ae_measurable (hX.prod_mk hY) (measurable_snd hs),
measure.map_apply_of_ae_measurable hY hs, ← univ_prod, mk_preimage_prod, preimage_univ,
univ_inter],
end
lemma snd_map_prod_mk {X : α → β} {Y : α → γ} {μ : measure α}
(hX : measurable X) (hY : measurable Y) :
(μ.map (λ a, (X a, Y a))).snd = μ.map Y :=
snd_map_prod_mk₀ hX.ae_measurable hY.ae_measurable
end measure
end measure_theory
|
1d8b98a3fb84a9286c266e5dd739fa54009a5ffa | 4727251e0cd73359b15b664c3170e5d754078599 | /src/algebra/category/Group/biproducts.lean | 40e72a1a6df968de5183b80e1b0867e6ce80b13e | [
"Apache-2.0"
] | permissive | Vierkantor/mathlib | 0ea59ac32a3a43c93c44d70f441c4ee810ccceca | 83bc3b9ce9b13910b57bda6b56222495ebd31c2f | refs/heads/master | 1,658,323,012,449 | 1,652,256,003,000 | 1,652,256,003,000 | 209,296,341 | 0 | 1 | Apache-2.0 | 1,568,807,655,000 | 1,568,807,655,000 | null | UTF-8 | Lean | false | false | 4,227 | lean | /-
Copyright (c) 2020 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Scott Morrison
-/
import algebra.group.pi
import algebra.category.Group.preadditive
import category_theory.limits.shapes.biproducts
import algebra.category.Group.limits
/-!
# The category of abelian groups has finite biproducts
-/
open category_theory
open category_theory.limits
open_locale big_operators
universe u
namespace AddCommGroup
-- As `AddCommGroup` is preadditive, and has all limits, it automatically has biproducts.
instance : has_binary_biproducts AddCommGroup :=
has_binary_biproducts.of_has_binary_products
instance : has_finite_biproducts AddCommGroup :=
has_finite_biproducts.of_has_finite_products
-- We now construct explicit limit data,
-- so we can compare the biproducts to the usual unbundled constructions.
/--
Construct limit data for a binary product in `AddCommGroup`, using `AddCommGroup.of (G × H)`.
-/
@[simps cone_X is_limit_lift]
def binary_product_limit_cone (G H : AddCommGroup.{u}) : limits.limit_cone (pair G H) :=
{ cone :=
{ X := AddCommGroup.of (G × H),
π := { app := λ j, walking_pair.cases_on j (add_monoid_hom.fst G H) (add_monoid_hom.snd G H) }},
is_limit :=
{ lift := λ s, add_monoid_hom.prod (s.π.app walking_pair.left) (s.π.app walking_pair.right),
fac' := begin rintros s (⟨⟩|⟨⟩); { ext x, simp, }, end,
uniq' := λ s m w,
begin
ext; [rw ← w walking_pair.left, rw ← w walking_pair.right]; refl,
end, } }
@[simp] lemma binary_product_limit_cone_cone_π_app_left (G H : AddCommGroup.{u}) :
(binary_product_limit_cone G H).cone.π.app walking_pair.left = add_monoid_hom.fst G H := rfl
@[simp] lemma binary_product_limit_cone_cone_π_app_right (G H : AddCommGroup.{u}) :
(binary_product_limit_cone G H).cone.π.app walking_pair.right = add_monoid_hom.snd G H := rfl
/--
We verify that the biproduct in AddCommGroup is isomorphic to
the cartesian product of the underlying types:
-/
@[simps] noncomputable
def biprod_iso_prod (G H : AddCommGroup.{u}) : (G ⊞ H : AddCommGroup) ≅ AddCommGroup.of (G × H) :=
is_limit.cone_point_unique_up_to_iso
(binary_biproduct.is_limit G H)
(binary_product_limit_cone G H).is_limit
-- Furthermore, our biproduct will automatically function as a coproduct.
example (G H : AddCommGroup.{u}) : has_colimit (pair G H) := by apply_instance
variables {J : Type u} (F : (discrete J) ⥤ AddCommGroup.{u})
namespace has_limit
/--
The map from an arbitrary cone over a indexed family of abelian groups
to the cartesian product of those groups.
-/
def lift (s : cone F) :
s.X ⟶ AddCommGroup.of (Π j, F.obj j) :=
{ to_fun := λ x j, s.π.app j x,
map_zero' := by { ext, simp },
map_add' := λ x y, by { ext, simp }, }
@[simp] lemma lift_apply (s : cone F) (x : s.X) (j : J) : (lift F s) x j = s.π.app j x := rfl
/--
Construct limit data for a product in `AddCommGroup`, using `AddCommGroup.of (Π j, F.obj j)`.
-/
@[simps] def product_limit_cone : limits.limit_cone F :=
{ cone :=
{ X := AddCommGroup.of (Π j, F.obj j),
π := discrete.nat_trans (λ j, pi.eval_add_monoid_hom (λ j, F.obj j) j), },
is_limit :=
{ lift := lift F,
fac' := λ s j, by { ext, simp, },
uniq' := λ s m w,
begin
ext x j,
dsimp only [has_limit.lift],
simp only [add_monoid_hom.coe_mk],
exact congr_arg (λ f : s.X ⟶ F.obj j, (f : s.X → F.obj j) x) (w j),
end, }, }
end has_limit
open has_limit
/--
We verify that the biproduct we've just defined is isomorphic to the AddCommGroup structure
on the dependent function type
-/
@[simps hom_apply] noncomputable
def biproduct_iso_pi [decidable_eq J] [fintype J] (f : J → AddCommGroup.{u}) :
(⨁ f : AddCommGroup) ≅ AddCommGroup.of (Π j, f j) :=
is_limit.cone_point_unique_up_to_iso
(biproduct.is_limit f)
(product_limit_cone (discrete.functor f)).is_limit
@[simp, elementwise] lemma biproduct_iso_pi_inv_comp_π [decidable_eq J] [fintype J]
(f : J → AddCommGroup.{u}) (j : J) :
(biproduct_iso_pi f).inv ≫ biproduct.π f j = pi.eval_add_monoid_hom (λ j, f j) j :=
is_limit.cone_point_unique_up_to_iso_inv_comp _ _ _
end AddCommGroup
|
08650f40b6fc9b67ea001a3c90ea43d196588c21 | 9b9a16fa2cb737daee6b2785474678b6fa91d6d4 | /src/group_theory/quotient_group.lean | 515f9ef18d8b89444ab3a4a3ce8f696ab057e824 | [
"Apache-2.0"
] | permissive | johoelzl/mathlib | 253f46daa30b644d011e8e119025b01ad69735c4 | 592e3c7a2dfbd5826919b4605559d35d4d75938f | refs/heads/master | 1,625,657,216,488 | 1,551,374,946,000 | 1,551,374,946,000 | 98,915,829 | 0 | 0 | Apache-2.0 | 1,522,917,267,000 | 1,501,524,499,000 | Lean | UTF-8 | Lean | false | false | 8,626 | lean | /-
Copyright (c) 2018 Kevin Buzzard and Patrick Massot. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kevin Buzzard, Patrick Massot.
This file is to a certain extent based on `quotient_module.lean` by Johannes Hölzl.
-/
import group_theory.coset
universes u v
namespace quotient_group
variables {G : Type u} [group G] (N : set G) [normal_subgroup N] {H : Type v} [group H]
instance : group (quotient N) :=
{ one := (1 : G),
mul := λ a b, quotient.lift_on₂' a b
(λ a b, ((a * b : G) : quotient N))
(λ a₁ a₂ b₁ b₂ hab₁ hab₂,
quot.sound
((is_subgroup.mul_mem_cancel_left N (is_subgroup.inv_mem hab₂)).1
(by rw [mul_inv_rev, mul_inv_rev, ← mul_assoc (a₂⁻¹ * a₁⁻¹),
mul_assoc _ b₂, ← mul_assoc b₂, mul_inv_self, one_mul, mul_assoc (a₂⁻¹)];
exact normal_subgroup.normal _ hab₁ _))),
mul_assoc := λ a b c, quotient.induction_on₃' a b c
(λ a b c, congr_arg mk (mul_assoc a b c)),
one_mul := λ a, quotient.induction_on' a
(λ a, congr_arg mk (one_mul a)),
mul_one := λ a, quotient.induction_on' a
(λ a, congr_arg mk (mul_one a)),
inv := λ a, quotient.lift_on' a (λ a, ((a⁻¹ : G) : quotient N))
(λ a b hab, quotient.sound' begin
show a⁻¹⁻¹ * b⁻¹ ∈ N,
rw ← mul_inv_rev,
exact is_subgroup.inv_mem (is_subgroup.mem_norm_comm hab)
end),
mul_left_inv := λ a, quotient.induction_on' a
(λ a, congr_arg mk (mul_left_inv a)) }
attribute [to_additive quotient_add_group.add_group._proof_6] quotient_group.group._proof_6
attribute [to_additive quotient_add_group.add_group._proof_5] quotient_group.group._proof_5
attribute [to_additive quotient_add_group.add_group._proof_4] quotient_group.group._proof_4
attribute [to_additive quotient_add_group.add_group._proof_3] quotient_group.group._proof_3
attribute [to_additive quotient_add_group.add_group._proof_2] quotient_group.group._proof_2
attribute [to_additive quotient_add_group.add_group._proof_1] quotient_group.group._proof_1
attribute [to_additive quotient_add_group.add_group] quotient_group.group
attribute [to_additive quotient_add_group.quotient.equations._eqn_1] quotient_group.quotient.equations._eqn_1
attribute [to_additive quotient_add_group.add_group.equations._eqn_1] quotient_group.group.equations._eqn_1
instance : is_group_hom (mk : G → quotient N) := ⟨λ _ _, rfl⟩
attribute [to_additive quotient_add_group.is_add_group_hom] quotient_group.is_group_hom
attribute [to_additive quotient_add_group.is_add_group_hom.equations._eqn_1] quotient_group.is_group_hom.equations._eqn_1
instance {G : Type*} [comm_group G] (s : set G) [is_subgroup s] : comm_group (quotient s) :=
{ mul_comm := λ a b, quotient.induction_on₂' a b
(λ a b, congr_arg mk (mul_comm a b)),
..@quotient_group.group _ _ s (normal_subgroup_of_comm_group s) }
attribute [to_additive quotient_add_group.add_comm_group._proof_6] quotient_group.comm_group._proof_6
attribute [to_additive quotient_add_group.add_comm_group._proof_5] quotient_group.comm_group._proof_5
attribute [to_additive quotient_add_group.add_comm_group._proof_4] quotient_group.comm_group._proof_4
attribute [to_additive quotient_add_group.add_comm_group._proof_3] quotient_group.comm_group._proof_3
attribute [to_additive quotient_add_group.add_comm_group._proof_2] quotient_group.comm_group._proof_2
attribute [to_additive quotient_add_group.add_comm_group._proof_1] quotient_group.comm_group._proof_1
attribute [to_additive quotient_add_group.add_comm_group] quotient_group.comm_group
attribute [to_additive quotient_add_group.add_comm_group.equations._eqn_1] quotient_group.comm_group.equations._eqn_1
@[simp] lemma coe_one : ((1 : G) : quotient N) = 1 := rfl
@[simp] lemma coe_mul (a b : G) : ((a * b : G) : quotient N) = a * b := rfl
@[simp] lemma coe_inv (a : G) : ((a⁻¹ : G) : quotient N) = a⁻¹ := rfl
@[simp] lemma coe_pow (a : G) (n : ℕ) : ((a ^ n : G) : quotient N) = a ^ n :=
@is_group_hom.pow _ _ _ _ mk _ a n
attribute [to_additive quotient_add_group.coe_zero] coe_one
attribute [to_additive quotient_add_group.coe_add] coe_mul
attribute [to_additive quotient_add_group.coe_neg] coe_inv
@[simp] lemma coe_gpow (a : G) (n : ℤ) : ((a ^ n : G) : quotient N) = a ^ n :=
@is_group_hom.gpow _ _ _ _ mk _ a n
local notation ` Q ` := quotient N
def lift (φ : G → H) [is_group_hom φ] (HN : ∀x∈N, φ x = 1) (q : Q) : H :=
q.lift_on' φ $ assume a b (hab : a⁻¹ * b ∈ N),
(calc φ a = φ a * 1 : by simp
... = φ a * φ (a⁻¹ * b) : by rw HN (a⁻¹ * b) hab
... = φ (a * (a⁻¹ * b)) : by rw is_group_hom.mul φ a (a⁻¹ * b)
... = φ b : by simp)
attribute [to_additive quotient_add_group.lift._proof_1] lift._proof_1
attribute [to_additive quotient_add_group.lift] lift
attribute [to_additive quotient_add_group.lift.equations._eqn_1] lift.equations._eqn_1
@[simp] lemma lift_mk {φ : G → H} [is_group_hom φ] (HN : ∀x∈N, φ x = 1) (g : G) :
lift N φ HN (g : Q) = φ g := rfl
attribute [to_additive quotient_add_group.lift_mk] lift_mk
@[simp] lemma lift_mk' {φ : G → H} [is_group_hom φ] (HN : ∀x∈N, φ x = 1) (g : G) :
lift N φ HN (mk g : Q) = φ g := rfl
attribute [to_additive quotient_add_group.lift_mk'] lift_mk'
def map (M : set H) [normal_subgroup M] (f : G → H) [is_group_hom f] (h : N ⊆ f ⁻¹' M) :
quotient N → quotient M :=
begin
haveI : is_group_hom ((mk : H → quotient M) ∘ f) := is_group_hom.comp _ _,
refine quotient_group.lift N (mk ∘ f) _,
assume x hx,
refine quotient_group.eq.2 _,
rw [mul_one, is_subgroup.inv_mem_iff],
exact h hx,
end
attribute [to_additive quotient_add_group.map._proof_1] map._proof_1
attribute [to_additive quotient_add_group.map._proof_2] map._proof_2
attribute [to_additive quotient_add_group.map] map
variables (φ : G → H) [is_group_hom φ] (HN : ∀x∈N, φ x = 1)
instance is_group_hom_quotient_lift :
is_group_hom (lift N φ HN) :=
⟨λ q r, quotient.induction_on₂' q r $ λ a b,
show φ (a * b) = φ a * φ b, from is_group_hom.mul φ a b⟩
attribute [to_additive quotient_add_group.is_add_group_hom_quotient_lift] quotient_group.is_group_hom_quotient_lift
attribute [to_additive quotient_add_group.is_add_group_hom_quotient_lift.equations._eqn_1] quotient_group.is_group_hom_quotient_lift.equations._eqn_1
@[to_additive quotient_add_group.map_is_add_group_hom]
instance map_is_group_hom (M : set H) [normal_subgroup M]
(f : G → H) [is_group_hom f] (h : N ⊆ f ⁻¹' M) : is_group_hom (map N M f h) :=
quotient_group.is_group_hom_quotient_lift _ _ _
open function is_group_hom
@[to_additive quotient_add_group.injective_ker_lift]
lemma injective_ker_lift : injective (lift (ker φ) φ $ λ x h, (mem_ker φ).1 h) :=
assume a b, quotient.induction_on₂' a b $ assume a b (h : φ a = φ b), quotient.sound' $
show a⁻¹ * b ∈ ker φ, by rw [mem_ker φ,
is_group_hom.mul φ, ← h, is_group_hom.inv φ, inv_mul_self]
--@[to_additive quotient_add_group.quotient_ker_equiv_range]
noncomputable def quotient_ker_equiv_range : (quotient (ker φ)) ≃ set.range φ :=
@equiv.of_bijective _ (set.range φ) (λ x, ⟨lift (ker φ) φ
(by simp [mem_ker]) x, by exact quotient.induction_on' x (λ x, ⟨x, rfl⟩)⟩)
⟨λ a b h, injective_ker_lift _ (subtype.mk.inj h),
λ ⟨x, y, hy⟩, ⟨mk y, subtype.eq hy⟩⟩
noncomputable def quotient_ker_equiv_of_surjective (hφ : function.surjective φ) :
(quotient (ker φ)) ≃ H :=
calc (quotient_group.quotient (is_group_hom.ker φ)) ≃ set.range φ : quotient_ker_equiv_range _
... ≃ H : ⟨λ a, a.1, λ b, ⟨b, hφ b⟩, λ ⟨_, _⟩, rfl, λ _, rfl⟩
end quotient_group
namespace quotient_add_group
open is_add_group_hom
variables {G : Type u} [_root_.add_group G] (N : set G) [normal_add_subgroup N] {H : Type v} [_root_.add_group H]
variables (φ : G → H) [_root_.is_add_group_hom φ]
noncomputable def quotient_ker_equiv_range : (quotient (ker φ)) ≃ set.range φ :=
@quotient_group.quotient_ker_equiv_range (multiplicative G) _ (multiplicative H) _ φ _
noncomputable def quotient_ker_equiv_of_surjective (hφ : function.surjective φ) : (quotient (ker φ)) ≃ H :=
@quotient_group.quotient_ker_equiv_of_surjective (multiplicative G) _ (multiplicative H) _ φ _ hφ
attribute [to_additive quotient_add_group.quotient_ker_equiv_range] quotient_group.quotient_ker_equiv_range
attribute [to_additive quotient_add_group.quotient_ker_equiv_of_surjective] quotient_group.quotient_ker_equiv_of_surjective
end quotient_add_group
|
b6b1328111573226311c313a3b71a745285780a5 | 4d2583807a5ac6caaffd3d7a5f646d61ca85d532 | /src/data/analysis/filter.lean | c76e3f35cdfa7295c14a27e7b5ef70325f302d1d | [
"Apache-2.0"
] | permissive | AntoineChambert-Loir/mathlib | 64aabb896129885f12296a799818061bc90da1ff | 07be904260ab6e36a5769680b6012f03a4727134 | refs/heads/master | 1,693,187,631,771 | 1,636,719,886,000 | 1,636,719,886,000 | null | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 11,822 | lean | /-
Copyright (c) 2017 Mario Carneiro. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro
Computational realization of filters (experimental).
-/
import order.filter.cofinite
open set filter
/-- A `cfilter α σ` is a realization of a filter (base) on `α`,
represented by a type `σ` together with operations for the top element and
the binary inf operation. -/
structure cfilter (α σ : Type*) [partial_order α] :=
(f : σ → α)
(pt : σ)
(inf : σ → σ → σ)
(inf_le_left : ∀ a b : σ, f (inf a b) ≤ f a)
(inf_le_right : ∀ a b : σ, f (inf a b) ≤ f b)
variables {α : Type*} {β : Type*} {σ : Type*} {τ : Type*}
namespace cfilter
section
variables [partial_order α] (F : cfilter α σ)
instance : has_coe_to_fun (cfilter α σ) (λ _, σ → α) := ⟨cfilter.f⟩
@[simp] theorem coe_mk (f pt inf h₁ h₂ a) : (@cfilter.mk α σ _ f pt inf h₁ h₂) a = f a := rfl
/-- Map a cfilter to an equivalent representation type. -/
def of_equiv (E : σ ≃ τ) : cfilter α σ → cfilter α τ
| ⟨f, p, g, h₁, h₂⟩ :=
{ f := λ a, f (E.symm a),
pt := E p,
inf := λ a b, E (g (E.symm a) (E.symm b)),
inf_le_left := λ a b, by simpa using h₁ (E.symm a) (E.symm b),
inf_le_right := λ a b, by simpa using h₂ (E.symm a) (E.symm b) }
@[simp] theorem of_equiv_val (E : σ ≃ τ) (F : cfilter α σ) (a : τ) :
F.of_equiv E a = F (E.symm a) := by cases F; refl
end
/-- The filter represented by a `cfilter` is the collection of supersets of
elements of the filter base. -/
def to_filter (F : cfilter (set α) σ) : filter α :=
{ sets := {a | ∃ b, F b ⊆ a},
univ_sets := ⟨F.pt, subset_univ _⟩,
sets_of_superset := λ x y ⟨b, h⟩ s, ⟨b, subset.trans h s⟩,
inter_sets := λ x y ⟨a, h₁⟩ ⟨b, h₂⟩, ⟨F.inf a b,
subset_inter (subset.trans (F.inf_le_left _ _) h₁) (subset.trans (F.inf_le_right _ _) h₂)⟩ }
@[simp] theorem mem_to_filter_sets (F : cfilter (set α) σ) {a : set α} :
a ∈ F.to_filter ↔ ∃ b, F b ⊆ a := iff.rfl
end cfilter
/-- A realizer for filter `f` is a cfilter which generates `f`. -/
structure filter.realizer (f : filter α) :=
(σ : Type*)
(F : cfilter (set α) σ)
(eq : F.to_filter = f)
protected def cfilter.to_realizer (F : cfilter (set α) σ) : F.to_filter.realizer := ⟨σ, F, rfl⟩
namespace filter.realizer
theorem mem_sets {f : filter α} (F : f.realizer) {a : set α} : a ∈ f ↔ ∃ b, F.F b ⊆ a :=
by cases F; subst f; simp
-- Used because it has better definitional equalities than the eq.rec proof
def of_eq {f g : filter α} (e : f = g) (F : f.realizer) : g.realizer :=
⟨F.σ, F.F, F.eq.trans e⟩
/-- A filter realizes itself. -/
def of_filter (f : filter α) : f.realizer := ⟨f.sets,
{ f := subtype.val,
pt := ⟨univ, univ_mem⟩,
inf := λ ⟨x, h₁⟩ ⟨y, h₂⟩, ⟨_, inter_mem h₁ h₂⟩,
inf_le_left := λ ⟨x, h₁⟩ ⟨y, h₂⟩, inter_subset_left x y,
inf_le_right := λ ⟨x, h₁⟩ ⟨y, h₂⟩, inter_subset_right x y },
filter_eq $ set.ext $ λ x, set_coe.exists.trans exists_mem_subset_iff⟩
/-- Transfer a filter realizer to another realizer on a different base type. -/
def of_equiv {f : filter α} (F : f.realizer) (E : F.σ ≃ τ) : f.realizer :=
⟨τ, F.F.of_equiv E, by refine eq.trans _ F.eq; exact filter_eq (set.ext $ λ x,
⟨λ ⟨s, h⟩, ⟨E.symm s, by simpa using h⟩, λ ⟨t, h⟩, ⟨E t, by simp [h]⟩⟩)⟩
@[simp] theorem of_equiv_σ {f : filter α} (F : f.realizer) (E : F.σ ≃ τ) :
(F.of_equiv E).σ = τ := rfl
@[simp] theorem of_equiv_F {f : filter α} (F : f.realizer) (E : F.σ ≃ τ) (s : τ) :
(F.of_equiv E).F s = F.F (E.symm s) := by delta of_equiv; simp
/-- `unit` is a realizer for the principal filter -/
protected def principal (s : set α) : (principal s).realizer := ⟨unit,
{ f := λ _, s,
pt := (),
inf := λ _ _, (),
inf_le_left := λ _ _, le_refl _,
inf_le_right := λ _ _, le_refl _ },
filter_eq $ set.ext $ λ x,
⟨λ ⟨_, s⟩, s, λ h, ⟨(), h⟩⟩⟩
@[simp] theorem principal_σ (s : set α) : (realizer.principal s).σ = unit := rfl
@[simp] theorem principal_F (s : set α) (u : unit) : (realizer.principal s).F u = s := rfl
/-- `unit` is a realizer for the top filter -/
protected def top : (⊤ : filter α).realizer :=
(realizer.principal _).of_eq principal_univ
@[simp] theorem top_σ : (@realizer.top α).σ = unit := rfl
@[simp] theorem top_F (u : unit) : (@realizer.top α).F u = univ := rfl
/-- `unit` is a realizer for the bottom filter -/
protected def bot : (⊥ : filter α).realizer :=
(realizer.principal _).of_eq principal_empty
@[simp] theorem bot_σ : (@realizer.bot α).σ = unit := rfl
@[simp] theorem bot_F (u : unit) : (@realizer.bot α).F u = ∅ := rfl
/-- Construct a realizer for `map m f` given a realizer for `f` -/
protected def map (m : α → β) {f : filter α} (F : f.realizer) : (map m f).realizer := ⟨F.σ,
{ f := λ s, image m (F.F s),
pt := F.F.pt,
inf := F.F.inf,
inf_le_left := λ a b, image_subset _ (F.F.inf_le_left _ _),
inf_le_right := λ a b, image_subset _ (F.F.inf_le_right _ _) },
filter_eq $ set.ext $ λ x, by simp [cfilter.to_filter]; rw F.mem_sets; refl ⟩
@[simp] theorem map_σ (m : α → β) {f : filter α} (F : f.realizer) : (F.map m).σ = F.σ := rfl
@[simp] theorem map_F (m : α → β) {f : filter α} (F : f.realizer) (s) :
(F.map m).F s = image m (F.F s) := rfl
/-- Construct a realizer for `comap m f` given a realizer for `f` -/
protected def comap (m : α → β) {f : filter β} (F : f.realizer) : (comap m f).realizer := ⟨F.σ,
{ f := λ s, preimage m (F.F s),
pt := F.F.pt,
inf := F.F.inf,
inf_le_left := λ a b, preimage_mono (F.F.inf_le_left _ _),
inf_le_right := λ a b, preimage_mono (F.F.inf_le_right _ _) },
filter_eq $ set.ext $ λ x, by cases F; subst f; simp [cfilter.to_filter, mem_comap]; exact
⟨λ ⟨s, h⟩, ⟨_, ⟨s, subset.refl _⟩, h⟩,
λ ⟨y, ⟨s, h⟩, h₂⟩, ⟨s, subset.trans (preimage_mono h) h₂⟩⟩⟩
/-- Construct a realizer for the sup of two filters -/
protected def sup {f g : filter α} (F : f.realizer) (G : g.realizer) :
(f ⊔ g).realizer := ⟨F.σ × G.σ,
{ f := λ ⟨s, t⟩, F.F s ∪ G.F t,
pt := (F.F.pt, G.F.pt),
inf := λ ⟨a, a'⟩ ⟨b, b'⟩, (F.F.inf a b, G.F.inf a' b'),
inf_le_left := λ ⟨a, a'⟩ ⟨b, b'⟩, union_subset_union (F.F.inf_le_left _ _) (G.F.inf_le_left _ _),
inf_le_right := λ ⟨a, a'⟩ ⟨b, b'⟩, union_subset_union (F.F.inf_le_right _ _)
(G.F.inf_le_right _ _) },
filter_eq $ set.ext $ λ x, by cases F; cases G; substs f g; simp [cfilter.to_filter]; exact
⟨λ ⟨s, t, h⟩, ⟨⟨s, subset.trans (subset_union_left _ _) h⟩,
⟨t, subset.trans (subset_union_right _ _) h⟩⟩,
λ ⟨⟨s, h₁⟩, ⟨t, h₂⟩⟩, ⟨s, t, union_subset h₁ h₂⟩⟩⟩
/-- Construct a realizer for the inf of two filters -/
protected def inf {f g : filter α} (F : f.realizer) (G : g.realizer) :
(f ⊓ g).realizer := ⟨F.σ × G.σ,
{ f := λ ⟨s, t⟩, F.F s ∩ G.F t,
pt := (F.F.pt, G.F.pt),
inf := λ ⟨a, a'⟩ ⟨b, b'⟩, (F.F.inf a b, G.F.inf a' b'),
inf_le_left := λ ⟨a, a'⟩ ⟨b, b'⟩, inter_subset_inter (F.F.inf_le_left _ _) (G.F.inf_le_left _ _),
inf_le_right := λ ⟨a, a'⟩ ⟨b, b'⟩, inter_subset_inter (F.F.inf_le_right _ _)
(G.F.inf_le_right _ _) },
begin
ext x,
cases F; cases G; substs f g; simp [cfilter.to_filter],
split,
{ rintro ⟨s : F_σ, t : G_σ, h⟩,
apply mem_inf_of_inter _ _ h,
use s,
use t, },
{ rintros ⟨s, ⟨a, ha⟩, t, ⟨b, hb⟩, rfl⟩,
exact ⟨a, b, inter_subset_inter ha hb⟩ }
end⟩
/-- Construct a realizer for the cofinite filter -/
protected def cofinite [decidable_eq α] : (@cofinite α).realizer := ⟨finset α,
{ f := λ s, {a | a ∉ s},
pt := ∅,
inf := (∪),
inf_le_left := λ s t a, mt (finset.mem_union_left _),
inf_le_right := λ s t a, mt (finset.mem_union_right _) },
filter_eq $ set.ext $ λ x,
⟨λ ⟨s, h⟩, s.finite_to_set.subset (compl_subset_comm.1 h),
λ ⟨fs⟩, by exactI ⟨xᶜ.to_finset, λ a (h : a ∉ xᶜ.to_finset),
classical.by_contradiction $ λ h', h (mem_to_finset.2 h')⟩⟩⟩
/-- Construct a realizer for filter bind -/
protected def bind {f : filter α} {m : α → filter β} (F : f.realizer) (G : ∀ i, (m i).realizer) :
(f.bind m).realizer :=
⟨Σ s : F.σ, Π i ∈ F.F s, (G i).σ,
{ f := λ ⟨s, f⟩, ⋃ i ∈ F.F s, (G i).F (f i H),
pt := ⟨F.F.pt, λ i H, (G i).F.pt⟩,
inf := λ ⟨a, f⟩ ⟨b, f'⟩, ⟨F.F.inf a b, λ i h,
(G i).F.inf (f i (F.F.inf_le_left _ _ h)) (f' i (F.F.inf_le_right _ _ h))⟩,
inf_le_left := λ ⟨a, f⟩ ⟨b, f'⟩ x,
show (x ∈ ⋃ (i : α) (H : i ∈ F.F (F.F.inf a b)), _) →
x ∈ ⋃ i (H : i ∈ F.F a), ((G i).F) (f i H), by simp; exact
λ i h₁ h₂, ⟨i, F.F.inf_le_left _ _ h₁, (G i).F.inf_le_left _ _ h₂⟩,
inf_le_right := λ ⟨a, f⟩ ⟨b, f'⟩ x,
show (x ∈ ⋃ (i : α) (H : i ∈ F.F (F.F.inf a b)), _) →
x ∈ ⋃ i (H : i ∈ F.F b), ((G i).F) (f' i H), by simp; exact
λ i h₁ h₂, ⟨i, F.F.inf_le_right _ _ h₁, (G i).F.inf_le_right _ _ h₂⟩ },
filter_eq $ set.ext $ λ x,
by cases F with _ F _; subst f; simp [cfilter.to_filter, mem_bind]; exact
⟨λ ⟨s, f, h⟩, ⟨F s, ⟨s, subset.refl _⟩, λ i H, (G i).mem_sets.2
⟨f i H, λ a h', h ⟨_, ⟨i, rfl⟩, _, ⟨H, rfl⟩, h'⟩⟩⟩,
λ ⟨y, ⟨s, h⟩, f⟩,
let ⟨f', h'⟩ := classical.axiom_of_choice (λ i:F s, (G i).mem_sets.1 (f i (h i.2))) in
⟨s, λ i h, f' ⟨i, h⟩, λ a ⟨_, ⟨i, rfl⟩, _, ⟨H, rfl⟩, m⟩, h' ⟨_, H⟩ m⟩⟩⟩
/-- Construct a realizer for indexed supremum -/
protected def Sup {f : α → filter β} (F : ∀ i, (f i).realizer) : (⨆ i, f i).realizer :=
let F' : (⨆ i, f i).realizer :=
((realizer.bind realizer.top F).of_eq $
filter_eq $ set.ext $ by simp [filter.bind, eq_univ_iff_forall, supr_sets_eq]) in
F'.of_equiv $ show (Σ u:unit, Π (i : α), true → (F i).σ) ≃ Π i, (F i).σ, from
⟨λ⟨_,f⟩ i, f i ⟨⟩, λ f, ⟨(), λ i _, f i⟩,
λ ⟨⟨⟩, f⟩, by dsimp; congr; simp, λ f, rfl⟩
/-- Construct a realizer for the product of filters -/
protected def prod {f g : filter α} (F : f.realizer) (G : g.realizer) : (f.prod g).realizer :=
(F.comap _).inf (G.comap _)
theorem le_iff {f g : filter α} (F : f.realizer) (G : g.realizer) :
f ≤ g ↔ ∀ b : G.σ, ∃ a : F.σ, F.F a ≤ G.F b :=
⟨λ H t, F.mem_sets.1 (H (G.mem_sets.2 ⟨t, subset.refl _⟩)),
λ H x h, F.mem_sets.2 $
let ⟨s, h₁⟩ := G.mem_sets.1 h, ⟨t, h₂⟩ := H s in ⟨t, subset.trans h₂ h₁⟩⟩
theorem tendsto_iff (f : α → β) {l₁ : filter α} {l₂ : filter β} (L₁ : l₁.realizer)
(L₂ : l₂.realizer) :
tendsto f l₁ l₂ ↔ ∀ b, ∃ a, ∀ x ∈ L₁.F a, f x ∈ L₂.F b :=
(le_iff (L₁.map f) L₂).trans $ forall_congr $ λ b, exists_congr $ λ a, image_subset_iff
theorem ne_bot_iff {f : filter α} (F : f.realizer) :
f ≠ ⊥ ↔ ∀ a : F.σ, (F.F a).nonempty :=
begin
classical,
rw [not_iff_comm, ← le_bot_iff, F.le_iff realizer.bot, not_forall],
simp only [set.not_nonempty_iff_eq_empty],
exact ⟨λ ⟨x, e⟩ _, ⟨x, le_of_eq e⟩,
λ h, let ⟨x, h⟩ := h () in ⟨x, le_bot_iff.1 h⟩⟩
end
end filter.realizer
|
5c8cc0322f3b560966eb7c042c6bf14bb3e3d82f | 05f637fa14ac28031cb1ea92086a0f4eb23ff2b1 | /tests/lean/scan_test2.lean | ecbb75f5b0a804776243cf00e4dfa1bf616bbdf1 | [
"Apache-2.0"
] | permissive | codyroux/lean0.1 | 1ce92751d664aacff0529e139083304a7bbc8a71 | 0dc6fb974aa85ed6f305a2f4b10a53a44ee5f0ef | refs/heads/master | 1,610,830,535,062 | 1,402,150,480,000 | 1,402,150,480,000 | 19,588,851 | 2 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 45 | lean | (*
a = 1 *
2
print("a")
*)
prnt "fail" |
1c9dc853eb3f3fc881b44cd0a32b5f764b6f7afa | 947b78d97130d56365ae2ec264df196ce769371a | /tests/lean/run/matcherElimUniv.lean | c412ecea00c0331eb4e89a2d6ccdf8840f9d95a6 | [
"Apache-2.0"
] | permissive | shyamalschandra/lean4 | 27044812be8698f0c79147615b1d5090b9f4b037 | 6e7a883b21eaf62831e8111b251dc9b18f40e604 | refs/heads/master | 1,671,417,126,371 | 1,601,859,995,000 | 1,601,860,020,000 | null | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 176 | lean | new_frontend
universes u
def len {α : Type u} : List α → List α → Nat
| [], bs => bs.length
| a::as, bs => len as bs + 1
theorem ex1 : len [1, 2] [3, 4] = 4 :=
rfl
|
f8f49648e18e4aa1ef8a0573b860b3a6173b4de7 | 947fa6c38e48771ae886239b4edce6db6e18d0fb | /src/data/set/countable.lean | db06ee87cbebbed0bc674492ac10f20265e8994e | [
"Apache-2.0"
] | permissive | ramonfmir/mathlib | c5dc8b33155473fab97c38bd3aa6723dc289beaa | 14c52e990c17f5a00c0cc9e09847af16fabbed25 | refs/heads/master | 1,661,979,343,526 | 1,660,830,384,000 | 1,660,830,384,000 | 182,072,989 | 0 | 0 | null | 1,555,585,876,000 | 1,555,585,876,000 | null | UTF-8 | Lean | false | false | 9,889 | lean | /-
Copyright (c) 2017 Johannes Hölzl. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johannes Hölzl
-/
import data.set.finite
import data.countable.basic
import logic.equiv.list
/-!
# Countable sets
-/
noncomputable theory
open function set encodable
open classical (hiding some)
open_locale classical
universes u v w x
variables {α : Type u} {β : Type v} {γ : Type w} {ι : Sort x}
namespace set
/-- A set is countable if there exists an encoding of the set into the natural numbers.
An encoding is an injection with a partial inverse, which can be viewed as a
constructive analogue of countability. (For the most part, theorems about
`countable` will be classical and `encodable` will be constructive.)
-/
protected def countable (s : set α) : Prop := nonempty (encodable s)
@[simp] lemma countable_coe_iff {s : set α} : countable s ↔ s.countable := nonempty_encodable.symm
/-- Prove `set.countable` from a `countable` instance on the subtype. -/
lemma to_countable (s : set α) [countable s] : s.countable := countable_coe_iff.mp ‹_›
/-- Restate `set.countable` as a `countable` instance. -/
alias countable_coe_iff ↔ _root_.countable.to_set countable.to_subtype
protected lemma countable_iff_exists_injective {s : set α} :
s.countable ↔ ∃ f : s → ℕ, injective f :=
countable_coe_iff.symm.trans (countable_iff_exists_injective s)
/-- A set `s : set α` is countable if and only if there exists a function `α → ℕ` injective
on `s`. -/
lemma countable_iff_exists_inj_on {s : set α} :
s.countable ↔ ∃ f : α → ℕ, inj_on f s :=
set.countable_iff_exists_injective.trans exists_inj_on_iff_injective.symm
/-- Convert `set.countable s` to `encodable s` (noncomputable). -/
protected def countable.to_encodable {s : set α} : s.countable → encodable s :=
classical.choice
section enumerate
/-- Noncomputably enumerate elements in a set. The `default` value is used to extend the domain to
all of `ℕ`. -/
def enumerate_countable {s : set α} (h : s.countable) (default : α) : ℕ → α :=
assume n, match @encodable.decode s h.to_encodable n with
| (some y) := y
| (none) := default
end
lemma subset_range_enumerate {s : set α} (h : s.countable) (default : α) :
s ⊆ range (enumerate_countable h default) :=
assume x hx,
⟨@encodable.encode s h.to_encodable ⟨x, hx⟩,
by simp [enumerate_countable, encodable.encodek]⟩
end enumerate
lemma countable.mono {s₁ s₂ : set α} (h : s₁ ⊆ s₂) : s₂.countable → s₁.countable
| ⟨H⟩ := ⟨@of_inj _ _ H _ (embedding_of_subset _ _ h).2⟩
lemma countable_range [countable ι] (f : ι → β) : (range f).countable :=
surjective_onto_range.countable.to_set
lemma countable_iff_exists_subset_range [nonempty α] {s : set α} :
s.countable ↔ ∃ f : ℕ → α, s ⊆ range f :=
⟨λ h, by { inhabit α, exact ⟨enumerate_countable h default, subset_range_enumerate _ _⟩ },
λ ⟨f, hsf⟩, (countable_range f).mono hsf⟩
/--
A non-empty set is countable iff there exists a surjection from the
natural numbers onto the subtype induced by the set.
-/
protected lemma countable_iff_exists_surjective {s : set α} (hs : s.nonempty) :
s.countable ↔ ∃ f : ℕ → s, surjective f :=
countable_coe_iff.symm.trans $ @countable_iff_exists_surjective s hs.to_subtype
alias set.countable_iff_exists_surjective ↔ countable.exists_surjective _
lemma countable_univ [countable α] : (univ : set α).countable := to_countable univ
/-- If `s : set α` is a nonempty countable set, then there exists a map
`f : ℕ → α` such that `s = range f`. -/
lemma countable.exists_eq_range {s : set α} (hc : s.countable) (hs : s.nonempty) :
∃ f : ℕ → α, s = range f :=
begin
rcases hc.exists_surjective hs with ⟨f, hf⟩,
refine ⟨coe ∘ f, _⟩,
rw [hf.range_comp, subtype.range_coe]
end
@[simp] lemma countable_empty : (∅ : set α).countable := to_countable _
@[simp] lemma countable_singleton (a : α) : ({a} : set α).countable :=
⟨of_equiv _ (equiv.set.singleton a)⟩
lemma countable.image {s : set α} (hs : s.countable) (f : α → β) : (f '' s).countable :=
by { rw [image_eq_range], haveI := hs.to_subtype, apply countable_range }
lemma maps_to.countable_of_inj_on {s : set α} {t : set β} {f : α → β}
(hf : maps_to f s t) (hf' : inj_on f s) (ht : t.countable) :
s.countable :=
have injective (hf.restrict f s t), from (inj_on_iff_injective.1 hf').cod_restrict _,
⟨@encodable.of_inj _ _ ht.to_encodable _ this⟩
lemma countable.preimage_of_inj_on {s : set β} (hs : s.countable) {f : α → β}
(hf : inj_on f (f ⁻¹' s)) : (f ⁻¹' s).countable :=
(maps_to_preimage f s).countable_of_inj_on hf hs
protected lemma countable.preimage {s : set β} (hs : s.countable) {f : α → β} (hf : injective f) :
(f ⁻¹' s).countable :=
hs.preimage_of_inj_on (hf.inj_on _)
lemma exists_seq_supr_eq_top_iff_countable [complete_lattice α] {p : α → Prop} (h : ∃ x, p x) :
(∃ s : ℕ → α, (∀ n, p (s n)) ∧ (⨆ n, s n) = ⊤) ↔
∃ S : set α, S.countable ∧ (∀ s ∈ S, p s) ∧ Sup S = ⊤ :=
begin
split,
{ rintro ⟨s, hps, hs⟩,
refine ⟨range s, countable_range s, forall_range_iff.2 hps, _⟩, rwa Sup_range },
{ rintro ⟨S, hSc, hps, hS⟩,
rcases eq_empty_or_nonempty S with rfl|hne,
{ rw [Sup_empty] at hS, haveI := subsingleton_of_bot_eq_top hS,
rcases h with ⟨x, hx⟩, exact ⟨λ n, x, λ n, hx, subsingleton.elim _ _⟩ },
{ rcases (set.countable_iff_exists_surjective hne).1 hSc with ⟨s, hs⟩,
refine ⟨λ n, s n, λ n, hps _ (s n).coe_prop, _⟩,
rwa [hs.supr_comp, ← Sup_eq_supr'] } }
end
lemma exists_seq_cover_iff_countable {p : set α → Prop} (h : ∃ s, p s) :
(∃ s : ℕ → set α, (∀ n, p (s n)) ∧ (⋃ n, s n) = univ) ↔
∃ S : set (set α), S.countable ∧ (∀ s ∈ S, p s) ∧ ⋃₀ S = univ :=
exists_seq_supr_eq_top_iff_countable h
lemma countable_of_injective_of_countable_image {s : set α} {f : α → β}
(hf : inj_on f s) (hs : (f '' s).countable) : s.countable :=
let ⟨g, hg⟩ := countable_iff_exists_inj_on.1 hs in
countable_iff_exists_inj_on.2 ⟨g ∘ f, hg.comp hf (maps_to_image _ _)⟩
lemma countable_Union {t : ι → set α} [countable ι] (ht : ∀ i, (t i).countable) :
(⋃ i, t i).countable :=
by { haveI := λ a, (ht a).to_subtype, rw Union_eq_range_psigma, apply countable_range }
@[simp] lemma countable_Union_iff [countable ι] {t : ι → set α} :
(⋃ i, t i).countable ↔ ∀ i, (t i).countable :=
⟨λ h i, h.mono $ subset_Union _ _, countable_Union⟩
lemma countable.bUnion_iff {s : set α} {t : Π a ∈ s, set β} (hs : s.countable) :
(⋃ a ∈ s, t a ‹_›).countable ↔ ∀ a ∈ s, (t a ‹_›).countable :=
by { haveI := hs.to_subtype, rw [bUnion_eq_Union, countable_Union_iff, set_coe.forall'] }
lemma countable.sUnion_iff {s : set (set α)} (hs : s.countable) :
(⋃₀ s).countable ↔ ∀ a ∈ s, (a : _).countable :=
by rw [sUnion_eq_bUnion, hs.bUnion_iff]
alias countable.bUnion_iff ↔ _ countable.bUnion
alias countable.sUnion_iff ↔ _ countable.sUnion
@[simp] lemma countable_union {s t : set α} : (s ∪ t).countable ↔ s.countable ∧ t.countable :=
by simp [union_eq_Union, and.comm]
lemma countable.union {s t : set α} (hs : s.countable) (ht : t.countable) :
(s ∪ t).countable :=
countable_union.2 ⟨hs, ht⟩
@[simp] lemma countable_insert {s : set α} {a : α} : (insert a s).countable ↔ s.countable :=
by simp only [insert_eq, countable_union, countable_singleton, true_and]
lemma countable.insert {s : set α} (a : α) (h : s.countable) : (insert a s).countable :=
countable_insert.2 h
lemma finite.countable {s : set α} : s.finite → s.countable
| ⟨h⟩ := trunc.nonempty (by exactI fintype.trunc_encodable s)
@[nontriviality] lemma countable.of_subsingleton [subsingleton α] (s : set α) :
s.countable :=
(finite.of_subsingleton s).countable
lemma subsingleton.countable {s : set α} (hs : s.subsingleton) : s.countable :=
hs.finite.countable
lemma countable_is_top (α : Type*) [partial_order α] : {x : α | is_top x}.countable :=
(finite_is_top α).countable
lemma countable_is_bot (α : Type*) [partial_order α] : {x : α | is_bot x}.countable :=
(finite_is_bot α).countable
/-- The set of finite subsets of a countable set is countable. -/
lemma countable_set_of_finite_subset {s : set α} : s.countable →
{t | set.finite t ∧ t ⊆ s}.countable | ⟨h⟩ :=
begin
resetI,
refine countable.mono _ (countable_range
(λ t : finset s, {a | ∃ h:a ∈ s, subtype.mk a h ∈ t})),
rintro t ⟨⟨ht⟩, ts⟩, resetI,
refine ⟨finset.univ.map (embedding_of_subset _ _ ts), set.ext $ λ a, _⟩,
simpa using @ts a
end
lemma countable_univ_pi {π : α → Type*} [finite α] {s : Π a, set (π a)}
(hs : ∀ a, (s a).countable) : (pi univ s).countable :=
begin
haveI := λ a, (hs a).to_subtype,
exact (countable.of_equiv _ (equiv.set.univ_pi s).symm).to_set
end
lemma countable_pi {π : α → Type*} [finite α] {s : Πa, set (π a)} (hs : ∀a, (s a).countable) :
{f : Πa, π a | ∀a, f a ∈ s a}.countable :=
by simpa only [← mem_univ_pi] using countable_univ_pi hs
protected lemma countable.prod {s : set α} {t : set β} (hs : s.countable) (ht : t.countable) :
set.countable (s ×ˢ t) :=
begin
haveI : countable s := hs.to_subtype,
haveI : countable t := ht.to_subtype,
exact (countable.of_equiv _ $ (equiv.set.prod _ _).symm).to_set
end
lemma countable.image2 {s : set α} {t : set β} (hs : s.countable) (ht : t.countable)
(f : α → β → γ) : (image2 f s t).countable :=
by { rw ← image_prod, exact (hs.prod ht).image _ }
end set
lemma finset.countable_to_set (s : finset α) : set.countable (↑s : set α) :=
s.finite_to_set.countable
|
f5482eabbcae40a844039798a7561d3408058573 | 6dc0c8ce7a76229dd81e73ed4474f15f88a9e294 | /stage0/src/Init/Core.lean | 4a1b70c88efdbd728253c9b1da9a592370f2385b | [
"Apache-2.0"
] | permissive | williamdemeo/lean4 | 72161c58fe65c3ad955d6a3050bb7d37c04c0d54 | 6d00fcf1d6d873e195f9220c668ef9c58e9c4a35 | refs/heads/master | 1,678,305,356,877 | 1,614,708,995,000 | 1,614,708,995,000 | null | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 34,279 | lean | /-
Copyright (c) 2014 Microsoft Corporation. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Leonardo de Moura
notation, basic datatypes and type classes
-/
prelude
import Init.Prelude
import Init.SizeOf
universes u v w
def inline {α : Sort u} (a : α) : α := a
@[inline] def flip {α : Sort u} {β : Sort v} {φ : Sort w} (f : α → β → φ) : β → α → φ :=
fun b a => f a b
/- Remark: thunks have an efficient implementation in the runtime. -/
structure Thunk (α : Type u) : Type u where
fn : Unit → α
attribute [extern "lean_mk_thunk"] Thunk.mk
@[noinline, extern "lean_thunk_pure"]
protected def Thunk.pure {α : Type u} (a : α) : Thunk α :=
⟨fun _ => a⟩
@[noinline, extern "lean_thunk_get_own"]
protected def Thunk.get {α : Type u} (x : @& Thunk α) : α :=
x.fn ()
@[noinline, extern "lean_thunk_map"]
protected def Thunk.map {α : Type u} {β : Type v} (f : α → β) (x : Thunk α) : Thunk β :=
⟨fun _ => f x.get⟩
@[noinline, extern "lean_thunk_bind"]
protected def Thunk.bind {α : Type u} {β : Type v} (x : Thunk α) (f : α → Thunk β) : Thunk β :=
⟨fun _ => (f x.get).get⟩
abbrev Eq.ndrecOn.{u1, u2} {α : Sort u2} {a : α} {motive : α → Sort u1} {b : α} (h : Eq a b) (m : motive a) : motive b :=
Eq.ndrec m h
structure Iff (a b : Prop) : Prop where
intro :: (mp : a → b) (mpr : b → a)
infix:20 " <-> " => Iff
infix:20 " ↔ " => Iff
/- Eq basic support -/
inductive Sum (α : Type u) (β : Type v) where
| inl (val : α) : Sum α β
| inr (val : β) : Sum α β
inductive PSum (α : Sort u) (β : Sort v) where
| inl (val : α) : PSum α β
| inr (val : β) : PSum α β
structure Sigma {α : Type u} (β : α → Type v) where
fst : α
snd : β fst
attribute [unbox] Sigma
structure PSigma {α : Sort u} (β : α → Sort v) where
fst : α
snd : β fst
inductive Exists {α : Sort u} (p : α → Prop) : Prop where
| intro (w : α) (h : p w) : Exists p
/- Auxiliary type used to compile `for x in xs` notation. -/
inductive ForInStep (α : Type u) where
| done : α → ForInStep α
| yield : α → ForInStep α
class ForIn (m : Type u₁ → Type u₂) (ρ : Type u) (α : outParam (Type v)) where
forIn {β} [Monad m] (x : ρ) (b : β) (f : α → β → m (ForInStep β)) : m β
export ForIn (forIn)
/- Auxiliary type used to compile `do` notation. -/
inductive DoResultPRBC (α β σ : Type u) where
| «pure» : α → σ → DoResultPRBC α β σ
| «return» : β → σ → DoResultPRBC α β σ
| «break» : σ → DoResultPRBC α β σ
| «continue» : σ → DoResultPRBC α β σ
/- Auxiliary type used to compile `do` notation. -/
inductive DoResultPR (α β σ : Type u) where
| «pure» : α → σ → DoResultPR α β σ
| «return» : β → σ → DoResultPR α β σ
/- Auxiliary type used to compile `do` notation. -/
inductive DoResultBC (σ : Type u) where
| «break» : σ → DoResultBC σ
| «continue» : σ → DoResultBC σ
/- Auxiliary type used to compile `do` notation. -/
inductive DoResultSBC (α σ : Type u) where
| «pureReturn» : α → σ → DoResultSBC α σ
| «break» : σ → DoResultSBC α σ
| «continue» : σ → DoResultSBC α σ
class HasEquiv (α : Sort u) where
Equiv : α → α → Prop
infix:50 " ≈ " => HasEquiv.Equiv
class EmptyCollection (α : Type u) where
emptyCollection : α
/- Remark: tasks have an efficient implementation in the runtime. -/
structure Task (α : Type u) : Type u where
pure :: (get : α)
attribute [extern "lean_task_pure"] Task.pure
attribute [extern "lean_task_get_own"] Task.get
namespace Task
/-- Task priority. Tasks with higher priority will always be scheduled before ones with lower priority. -/
abbrev Priority := Nat
def Priority.default : Priority := 0
-- see `LEAN_MAX_PRIO`
def Priority.max : Priority := 8
/--
Any priority higher than `Task.Priority.max` will result in the task being scheduled immediately on a dedicated thread.
This is particularly useful for long-running and/or I/O-bound tasks since Lean will by default allocate no more
non-dedicated workers than the number of cores to reduce context switches. -/
def Priority.dedicated : Priority := 9
@[noinline, extern "lean_task_spawn"]
protected def spawn {α : Type u} (fn : Unit → α) (prio := Priority.default) : Task α :=
⟨fn ()⟩
@[noinline, extern "lean_task_map"]
protected def map {α : Type u} {β : Type v} (f : α → β) (x : Task α) (prio := Priority.default) : Task β :=
⟨f x.get⟩
@[noinline, extern "lean_task_bind"]
protected def bind {α : Type u} {β : Type v} (x : Task α) (f : α → Task β) (prio := Priority.default) : Task β :=
⟨(f x.get).get⟩
end Task
/- Some type that is not a scalar value in our runtime. -/
structure NonScalar where
val : Nat
/- Some type that is not a scalar value in our runtime and is universe polymorphic. -/
inductive PNonScalar : Type u where
| mk (v : Nat) : PNonScalar
theorem natAddZero (n : Nat) : n + 0 = n := rfl
theorem optParamEq (α : Sort u) (default : α) : optParam α default = α := rfl
/- Boolean operators -/
@[extern c inline "#1 || #2"] def strictOr (b₁ b₂ : Bool) := b₁ || b₂
@[extern c inline "#1 && #2"] def strictAnd (b₁ b₂ : Bool) := b₁ && b₂
@[inline] def bne {α : Type u} [BEq α] (a b : α) : Bool :=
!(a == b)
infix:50 " != " => bne
/- Logical connectives an equality -/
def implies (a b : Prop) := a → b
theorem implies.trans {p q r : Prop} (h₁ : implies p q) (h₂ : implies q r) : implies p r :=
fun hp => h₂ (h₁ hp)
def trivial : True := ⟨⟩
theorem mt {a b : Prop} (h₁ : a → b) (h₂ : ¬b) : ¬a :=
fun ha => h₂ (h₁ ha)
theorem notFalse : ¬False := id
-- proof irrelevance is built in
theorem proofIrrel {a : Prop} (h₁ h₂ : a) : h₁ = h₂ := rfl
theorem id.def {α : Sort u} (a : α) : id a = a := rfl
@[macroInline] def Eq.mp {α β : Sort u} (h : α = β) (a : α) : β :=
h ▸ a
@[macroInline] def Eq.mpr {α β : Sort u} (h : α = β) (b : β) : α :=
h ▸ b
theorem Eq.substr {α : Sort u} {p : α → Prop} {a b : α} (h₁ : b = a) (h₂ : p a) : p b :=
h₁ ▸ h₂
theorem castEq {α : Sort u} (h : α = α) (a : α) : cast h a = a :=
rfl
@[reducible] def Ne {α : Sort u} (a b : α) :=
¬(a = b)
infix:50 " ≠ " => Ne
section Ne
variable {α : Sort u}
variable {a b : α} {p : Prop}
theorem Ne.intro (h : a = b → False) : a ≠ b := h
theorem Ne.elim (h : a ≠ b) : a = b → False := h
theorem Ne.irrefl (h : a ≠ a) : False := h rfl
theorem Ne.symm (h : a ≠ b) : b ≠ a :=
fun h₁ => h (h₁.symm)
theorem falseOfNe : a ≠ a → False := Ne.irrefl
theorem neFalseOfSelf : p → p ≠ False :=
fun (hp : p) (h : p = False) => h ▸ hp
theorem neTrueOfNot : ¬p → p ≠ True :=
fun (hnp : ¬p) (h : p = True) =>
have ¬True from h ▸ hnp
this trivial
theorem trueNeFalse : ¬True = False :=
neFalseOfSelf trivial
end Ne
section
variable {α β φ : Sort u} {a a' : α} {b b' : β} {c : φ}
theorem HEq.ndrec.{u1, u2} {α : Sort u2} {a : α} {motive : {β : Sort u2} → β → Sort u1} (m : motive a) {β : Sort u2} {b : β} (h : a ≅ b) : motive b :=
@HEq.rec α a (fun b _ => motive b) m β b h
theorem HEq.ndrecOn.{u1, u2} {α : Sort u2} {a : α} {motive : {β : Sort u2} → β → Sort u1} {β : Sort u2} {b : β} (h : a ≅ b) (m : motive a) : motive b :=
@HEq.rec α a (fun b _ => motive b) m β b h
theorem HEq.elim {α : Sort u} {a : α} {p : α → Sort v} {b : α} (h₁ : a ≅ b) (h₂ : p a) : p b :=
eqOfHEq h₁ ▸ h₂
theorem HEq.subst {p : (T : Sort u) → T → Prop} (h₁ : a ≅ b) (h₂ : p α a) : p β b :=
HEq.ndrecOn h₁ h₂
theorem HEq.symm (h : a ≅ b) : b ≅ a :=
HEq.ndrecOn (motive := fun x => x ≅ a) h (HEq.refl a)
theorem heqOfEq (h : a = a') : a ≅ a' :=
Eq.subst h (HEq.refl a)
theorem HEq.trans (h₁ : a ≅ b) (h₂ : b ≅ c) : a ≅ c :=
HEq.subst h₂ h₁
theorem heqOfHEqOfEq (h₁ : a ≅ b) (h₂ : b = b') : a ≅ b' :=
HEq.trans h₁ (heqOfEq h₂)
theorem heqOfEqOfHEq (h₁ : a = a') (h₂ : a' ≅ b) : a ≅ b :=
HEq.trans (heqOfEq h₁) h₂
def typeEqOfHEq (h : a ≅ b) : α = β :=
HEq.ndrecOn (motive := @fun (x : Sort u) _ => α = x) h (Eq.refl α)
end
theorem eqRecHEq {α : Sort u} {φ : α → Sort v} : {a a' : α} → (h : a = a') → (p : φ a) → (Eq.recOn (motive := fun x _ => φ x) h p) ≅ p
| a, _, rfl, p => HEq.refl p
theorem heqOfEqRecEq {α β : Sort u} {a : α} {b : β} (h₁ : α = β) (h₂ : Eq.rec (motive := fun α _ => α) a h₁ = b) : a ≅ b := by
subst h₁
apply heqOfEq
exact h₂
done
theorem castHEq : ∀ {α β : Sort u} (h : α = β) (a : α), cast h a ≅ a
| α, _, rfl, a => HEq.refl a
variable {a b c d : Prop}
theorem iffIffImpliesAndImplies (a b : Prop) : (a ↔ b) ↔ (a → b) ∧ (b → a) :=
Iff.intro (fun h => And.intro h.mp h.mpr) (fun h => Iff.intro h.left h.right)
theorem Iff.refl (a : Prop) : a ↔ a :=
Iff.intro (fun h => h) (fun h => h)
theorem Iff.rfl {a : Prop} : a ↔ a :=
Iff.refl a
theorem Iff.trans (h₁ : a ↔ b) (h₂ : b ↔ c) : a ↔ c :=
Iff.intro
(fun ha => Iff.mp h₂ (Iff.mp h₁ ha))
(fun hc => Iff.mpr h₁ (Iff.mpr h₂ hc))
theorem Iff.symm (h : a ↔ b) : b ↔ a :=
Iff.intro (Iff.mpr h) (Iff.mp h)
theorem Iff.comm : (a ↔ b) ↔ (b ↔ a) :=
Iff.intro Iff.symm Iff.symm
/- Exists -/
theorem Exists.elim {α : Sort u} {p : α → Prop} {b : Prop}
(h₁ : Exists (fun x => p x)) (h₂ : ∀ (a : α), p a → b) : b :=
h₂ h₁.1 h₁.2
/- Decidable -/
theorem decideTrueEqTrue (h : Decidable True) : @decide True h = true :=
match h with
| isTrue h => rfl
| isFalse h => False.elim <| h ⟨⟩
theorem decideFalseEqFalse (h : Decidable False) : @decide False h = false :=
match h with
| isFalse h => rfl
| isTrue h => False.elim h
/-- Similar to `decide`, but uses an explicit instance -/
@[inline] def toBoolUsing {p : Prop} (d : Decidable p) : Bool :=
@decide p d
theorem toBoolUsingEqTrue {p : Prop} (d : Decidable p) (h : p) : toBoolUsing d = true :=
@decideEqTrue _ d h
theorem ofBoolUsingEqTrue {p : Prop} {d : Decidable p} (h : toBoolUsing d = true) : p :=
@ofDecideEqTrue _ d h
theorem ofBoolUsingEqFalse {p : Prop} {d : Decidable p} (h : toBoolUsing d = false) : ¬ p :=
@ofDecideEqFalse _ d h
instance : Decidable True :=
isTrue trivial
instance : Decidable False :=
isFalse notFalse
namespace Decidable
variable {p q : Prop}
@[macroInline] def byCases {q : Sort u} [dec : Decidable p] (h1 : p → q) (h2 : ¬p → q) : q :=
match dec with
| isTrue h => h1 h
| isFalse h => h2 h
theorem em (p : Prop) [Decidable p] : p ∨ ¬p :=
byCases Or.inl Or.inr
theorem byContradiction [dec : Decidable p] (h : ¬p → False) : p :=
byCases id (fun np => False.elim (h np))
theorem ofNotNot [Decidable p] : ¬ ¬ p → p :=
fun hnn => byContradiction (fun hn => absurd hn hnn)
theorem notAndIffOrNot (p q : Prop) [d₁ : Decidable p] [d₂ : Decidable q] : ¬ (p ∧ q) ↔ ¬ p ∨ ¬ q :=
Iff.intro
(fun h => match d₁, d₂ with
| isTrue h₁, isTrue h₂ => absurd (And.intro h₁ h₂) h
| _, isFalse h₂ => Or.inr h₂
| isFalse h₁, _ => Or.inl h₁)
(fun (h) ⟨hp, hq⟩ => match h with
| Or.inl h => h hp
| Or.inr h => h hq)
end Decidable
section
variable {p q : Prop}
@[inline] def decidableOfDecidableOfIff (hp : Decidable p) (h : p ↔ q) : Decidable q :=
if hp : p then
isTrue (Iff.mp h hp)
else
isFalse fun hq => absurd (Iff.mpr h hq) hp
@[inline] def decidableOfDecidableOfEq (hp : Decidable p) (h : p = q) : Decidable q :=
h ▸ hp
end
@[macroInline] instance {p q} [Decidable p] [Decidable q] : Decidable (p → q) :=
if hp : p then
if hq : q then isTrue (fun h => hq)
else isFalse (fun h => absurd (h hp) hq)
else isTrue (fun h => absurd h hp)
instance {p q} [Decidable p] [Decidable q] : Decidable (p ↔ q) :=
if hp : p then
if hq : q then
isTrue ⟨fun _ => hq, fun _ => hp⟩
else
isFalse fun h => hq (h.1 hp)
else
if hq : q then
isFalse fun h => hp (h.2 hq)
else
isTrue ⟨fun h => absurd h hp, fun h => absurd h hq⟩
/- if-then-else expression theorems -/
theorem ifPos {c : Prop} [h : Decidable c] (hc : c) {α : Sort u} {t e : α} : (ite c t e) = t :=
match h with
| (isTrue hc) => rfl
| (isFalse hnc) => absurd hc hnc
theorem ifNeg {c : Prop} [h : Decidable c] (hnc : ¬c) {α : Sort u} {t e : α} : (ite c t e) = e :=
match h with
| (isTrue hc) => absurd hc hnc
| (isFalse hnc) => rfl
theorem difPos {c : Prop} [h : Decidable c] (hc : c) {α : Sort u} {t : c → α} {e : ¬ c → α} : (dite c t e) = t hc :=
match h with
| (isTrue hc) => rfl
| (isFalse hnc) => absurd hc hnc
theorem difNeg {c : Prop} [h : Decidable c] (hnc : ¬c) {α : Sort u} {t : c → α} {e : ¬ c → α} : (dite c t e) = e hnc :=
match h with
| (isTrue hc) => absurd hc hnc
| (isFalse hnc) => rfl
-- Remark: dite and ite are "defally equal" when we ignore the proofs.
theorem difEqIf (c : Prop) [h : Decidable c] {α : Sort u} (t : α) (e : α) : dite c (fun h => t) (fun h => e) = ite c t e :=
match h with
| (isTrue hc) => rfl
| (isFalse hnc) => rfl
instance {c t e : Prop} [dC : Decidable c] [dT : Decidable t] [dE : Decidable e] : Decidable (if c then t else e) :=
match dC with
| (isTrue hc) => dT
| (isFalse hc) => dE
instance {c : Prop} {t : c → Prop} {e : ¬c → Prop} [dC : Decidable c] [dT : ∀ h, Decidable (t h)] [dE : ∀ h, Decidable (e h)] : Decidable (if h : c then t h else e h) :=
match dC with
| (isTrue hc) => dT hc
| (isFalse hc) => dE hc
/- Inhabited -/
instance : Inhabited Prop where
default := True
deriving instance Inhabited for Bool, NonScalar, PNonScalar, True, ForInStep
class inductive Nonempty (α : Sort u) : Prop where
| intro (val : α) : Nonempty α
protected def Nonempty.elim {α : Sort u} {p : Prop} (h₁ : Nonempty α) (h₂ : α → p) : p :=
h₂ h₁.1
instance {α : Sort u} [Inhabited α] : Nonempty α where
val := arbitrary
theorem nonemptyOfExists {α : Sort u} {p : α → Prop} : Exists (fun x => p x) → Nonempty α
| ⟨w, h⟩ => ⟨w⟩
/- Subsingleton -/
class Subsingleton (α : Sort u) : Prop where
intro ::
allEq : (a b : α) → a = b
protected def Subsingleton.elim {α : Sort u} [h : Subsingleton α] : (a b : α) → a = b :=
h.allEq
protected def Subsingleton.helim {α β : Sort u} [h₁ : Subsingleton α] (h₂ : α = β) (a : α) (b : β) : a ≅ b := by
subst h₂
apply heqOfEq
apply Subsingleton.elim
instance (p : Prop) : Subsingleton p :=
⟨fun a b => proofIrrel a b⟩
instance (p : Prop) : Subsingleton (Decidable p) :=
Subsingleton.intro fun
| (isTrue t₁) => fun
| (isTrue t₂) => proofIrrel t₁ t₂ ▸ rfl
| (isFalse f₂) => absurd t₁ f₂
| (isFalse f₁) => fun
| (isTrue t₂) => absurd t₂ f₁
| (isFalse f₂) => proofIrrel f₁ f₂ ▸ rfl
theorem recSubsingleton
{p : Prop} [h : Decidable p]
{h₁ : p → Sort u}
{h₂ : ¬p → Sort u}
[h₃ : ∀ (h : p), Subsingleton (h₁ h)]
[h₄ : ∀ (h : ¬p), Subsingleton (h₂ h)]
: Subsingleton (Decidable.casesOn (motive := fun _ => Sort u) h h₂ h₁) :=
match h with
| (isTrue h) => h₃ h
| (isFalse h) => h₄ h
structure Equivalence {α : Sort u} (r : α → α → Prop) : Prop where
refl : ∀ x, r x x
symm : ∀ {x y}, r x y → r y x
trans : ∀ {x y z}, r x y → r y z → r x z
def emptyRelation {α : Sort u} (a₁ a₂ : α) : Prop :=
False
def Subrelation {α : Sort u} (q r : α → α → Prop) :=
∀ {x y}, q x y → r x y
def InvImage {α : Sort u} {β : Sort v} (r : β → β → Prop) (f : α → β) : α → α → Prop :=
fun a₁ a₂ => r (f a₁) (f a₂)
inductive TC {α : Sort u} (r : α → α → Prop) : α → α → Prop where
| base : ∀ a b, r a b → TC r a b
| trans : ∀ a b c, TC r a b → TC r b c → TC r a c
/- Subtype -/
namespace Subtype
def existsOfSubtype {α : Type u} {p : α → Prop} : { x // p x } → Exists (fun x => p x)
| ⟨a, h⟩ => ⟨a, h⟩
variable {α : Type u} {p : α → Prop}
protected theorem eq : ∀ {a1 a2 : {x // p x}}, val a1 = val a2 → a1 = a2
| ⟨x, h1⟩, ⟨_, _⟩, rfl => rfl
theorem eta (a : {x // p x}) (h : p (val a)) : mk (val a) h = a := by
cases a
exact rfl
instance {α : Type u} {p : α → Prop} {a : α} (h : p a) : Inhabited {x // p x} where
default := ⟨a, h⟩
instance {α : Type u} {p : α → Prop} [DecidableEq α] : DecidableEq {x : α // p x} :=
fun ⟨a, h₁⟩ ⟨b, h₂⟩ =>
if h : a = b then isTrue (by subst h; exact rfl)
else isFalse (fun h' => Subtype.noConfusion h' (fun h' => absurd h' h))
end Subtype
/- Sum -/
section
variable {α : Type u} {β : Type v}
instance Sum.inhabitedLeft [h : Inhabited α] : Inhabited (Sum α β) where
default := Sum.inl arbitrary
instance Sum.inhabitedRight [h : Inhabited β] : Inhabited (Sum α β) where
default := Sum.inr arbitrary
instance {α : Type u} {β : Type v} [DecidableEq α] [DecidableEq β] : DecidableEq (Sum α β) := fun a b =>
match a, b with
| (Sum.inl a), (Sum.inl b) =>
if h : a = b then isTrue (h ▸ rfl)
else isFalse (fun h' => Sum.noConfusion h' (fun h' => absurd h' h))
| (Sum.inr a), (Sum.inr b) =>
if h : a = b then isTrue (h ▸ rfl)
else isFalse (fun h' => Sum.noConfusion h' (fun h' => absurd h' h))
| (Sum.inr a), (Sum.inl b) => isFalse (fun h => Sum.noConfusion h)
| (Sum.inl a), (Sum.inr b) => isFalse (fun h => Sum.noConfusion h)
end
/- Product -/
instance [Inhabited α] [Inhabited β] : Inhabited (α × β) where
default := (arbitrary, arbitrary)
instance [DecidableEq α] [DecidableEq β] : DecidableEq (α × β) :=
fun ⟨a, b⟩ ⟨a', b'⟩ =>
match (decEq a a') with
| (isTrue e₁) =>
match (decEq b b') with
| (isTrue e₂) => isTrue (e₁ ▸ e₂ ▸ rfl)
| (isFalse n₂) => isFalse (fun h => Prod.noConfusion h (fun e₁' e₂' => absurd e₂' n₂))
| (isFalse n₁) => isFalse (fun h => Prod.noConfusion h (fun e₁' e₂' => absurd e₁' n₁))
instance [BEq α] [BEq β] : BEq (α × β) where
beq := fun ⟨a₁, b₁⟩ ⟨a₂, b₂⟩ => a₁ == a₂ && b₁ == b₂
instance [HasLess α] [HasLess β] : HasLess (α × β) where
Less s t := s.1 < t.1 ∨ (s.1 = t.1 ∧ s.2 < t.2)
instance prodHasDecidableLt
[HasLess α] [HasLess β] [DecidableEq α] [DecidableEq β]
[(a b : α) → Decidable (a < b)] [(a b : β) → Decidable (a < b)]
: (s t : α × β) → Decidable (s < t) :=
fun t s => inferInstanceAs (Decidable (_ ∨ _))
theorem Prod.ltDef [HasLess α] [HasLess β] (s t : α × β) : (s < t) = (s.1 < t.1 ∨ (s.1 = t.1 ∧ s.2 < t.2)) :=
rfl
theorem Prod.ext (p : α × β) : (p.1, p.2) = p := by
cases p; rfl
def Prod.map {α₁ : Type u₁} {α₂ : Type u₂} {β₁ : Type v₁} {β₂ : Type v₂}
(f : α₁ → α₂) (g : β₁ → β₂) : α₁ × β₁ → α₂ × β₂
| (a, b) => (f a, g b)
/- Dependent products -/
theorem exOfPsig {α : Type u} {p : α → Prop} : (PSigma (fun x => p x)) → Exists (fun x => p x)
| ⟨x, hx⟩ => ⟨x, hx⟩
protected theorem PSigma.eta {α : Sort u} {β : α → Sort v} {a₁ a₂ : α} {b₁ : β a₁} {b₂ : β a₂}
(h₁ : a₁ = a₂) (h₂ : Eq.ndrec b₁ h₁ = b₂) : PSigma.mk a₁ b₁ = PSigma.mk a₂ b₂ := by
subst h₁
subst h₂
exact rfl
/- Universe polymorphic unit -/
theorem PUnit.subsingleton (a b : PUnit) : a = b := by
cases a; cases b; exact rfl
@[simp] theorem PUnit.eq_punit (a : PUnit) : a = () :=
PUnit.subsingleton a ()
instance : Subsingleton PUnit :=
Subsingleton.intro PUnit.subsingleton
instance : Inhabited PUnit where
default := ⟨⟩
instance : DecidableEq PUnit :=
fun a b => isTrue (PUnit.subsingleton a b)
/- Setoid -/
class Setoid (α : Sort u) where
r : α → α → Prop
iseqv {} : Equivalence r
instance {α : Sort u} [Setoid α] : HasEquiv α :=
⟨Setoid.r⟩
namespace Setoid
variable {α : Sort u} [Setoid α]
theorem refl (a : α) : a ≈ a :=
(Setoid.iseqv α).refl a
theorem symm {a b : α} (hab : a ≈ b) : b ≈ a :=
(Setoid.iseqv α).symm hab
theorem trans {a b c : α} (hab : a ≈ b) (hbc : b ≈ c) : a ≈ c :=
(Setoid.iseqv α).trans hab hbc
end Setoid
/- Propositional extensionality -/
axiom propext {a b : Prop} : (a ↔ b) → a = b
/- Quotients -/
-- Iff can now be used to do substitutions in a calculation
theorem iffSubst {a b : Prop} {p : Prop → Prop} (h₁ : a ↔ b) (h₂ : p a) : p b :=
Eq.subst (propext h₁) h₂
namespace Quot
axiom sound : ∀ {α : Sort u} {r : α → α → Prop} {a b : α}, r a b → Quot.mk r a = Quot.mk r b
protected theorem liftBeta {α : Sort u} {r : α → α → Prop} {β : Sort v}
(f : α → β)
(c : (a b : α) → r a b → f a = f b)
(a : α)
: lift f c (Quot.mk r a) = f a :=
rfl
protected theorem indBeta {α : Sort u} {r : α → α → Prop} {motive : Quot r → Prop}
(p : (a : α) → motive (Quot.mk r a))
(a : α)
: (ind p (Quot.mk r a) : motive (Quot.mk r a)) = p a :=
rfl
protected abbrev liftOn {α : Sort u} {β : Sort v} {r : α → α → Prop} (q : Quot r) (f : α → β) (c : (a b : α) → r a b → f a = f b) : β :=
lift f c q
protected theorem inductionOn {α : Sort u} {r : α → α → Prop} {motive : Quot r → Prop}
(q : Quot r)
(h : (a : α) → motive (Quot.mk r a))
: motive q :=
ind h q
theorem existsRep {α : Sort u} {r : α → α → Prop} (q : Quot r) : Exists (fun a => (Quot.mk r a) = q) :=
Quot.inductionOn (motive := fun q => Exists (fun a => (Quot.mk r a) = q)) q (fun a => ⟨a, rfl⟩)
section
variable {α : Sort u}
variable {r : α → α → Prop}
variable {motive : Quot r → Sort v}
@[reducible, macroInline]
protected def indep (f : (a : α) → motive (Quot.mk r a)) (a : α) : PSigma motive :=
⟨Quot.mk r a, f a⟩
protected theorem indepCoherent
(f : (a : α) → motive (Quot.mk r a))
(h : (a b : α) → (p : r a b) → Eq.ndrec (f a) (sound p) = f b)
: (a b : α) → r a b → Quot.indep f a = Quot.indep f b :=
fun a b e => PSigma.eta (sound e) (h a b e)
protected theorem liftIndepPr1
(f : (a : α) → motive (Quot.mk r a))
(h : ∀ (a b : α) (p : r a b), Eq.ndrec (f a) (sound p) = f b)
(q : Quot r)
: (lift (Quot.indep f) (Quot.indepCoherent f h) q).1 = q := by
induction q using Quot.ind
exact rfl
protected abbrev rec
(f : (a : α) → motive (Quot.mk r a))
(h : (a b : α) → (p : r a b) → Eq.ndrec (f a) (sound p) = f b)
(q : Quot r) : motive q :=
Eq.ndrecOn (Quot.liftIndepPr1 f h q) ((lift (Quot.indep f) (Quot.indepCoherent f h) q).2)
protected abbrev recOn
(q : Quot r)
(f : (a : α) → motive (Quot.mk r a))
(h : (a b : α) → (p : r a b) → Eq.ndrec (f a) (sound p) = f b)
: motive q :=
Quot.rec f h q
protected abbrev recOnSubsingleton
[h : (a : α) → Subsingleton (motive (Quot.mk r a))]
(q : Quot r)
(f : (a : α) → motive (Quot.mk r a))
: motive q := by
induction q using Quot.rec
apply f
apply Subsingleton.elim
protected abbrev hrecOn
(q : Quot r)
(f : (a : α) → motive (Quot.mk r a))
(c : (a b : α) → (p : r a b) → f a ≅ f b)
: motive q :=
Quot.recOn q f fun a b p => eqOfHEq <|
have p₁ : Eq.ndrec (f a) (sound p) ≅ f a := eqRecHEq (sound p) (f a)
HEq.trans p₁ (c a b p)
end
end Quot
def Quotient {α : Sort u} (s : Setoid α) :=
@Quot α Setoid.r
namespace Quotient
@[inline]
protected def mk {α : Sort u} [s : Setoid α] (a : α) : Quotient s :=
Quot.mk Setoid.r a
def sound {α : Sort u} [s : Setoid α] {a b : α} : a ≈ b → Quotient.mk a = Quotient.mk b :=
Quot.sound
protected abbrev lift {α : Sort u} {β : Sort v} [s : Setoid α] (f : α → β) : ((a b : α) → a ≈ b → f a = f b) → Quotient s → β :=
Quot.lift f
protected theorem ind {α : Sort u} [s : Setoid α] {motive : Quotient s → Prop} : ((a : α) → motive (Quotient.mk a)) → (q : Quot Setoid.r) → motive q :=
Quot.ind
protected abbrev liftOn {α : Sort u} {β : Sort v} [s : Setoid α] (q : Quotient s) (f : α → β) (c : (a b : α) → a ≈ b → f a = f b) : β :=
Quot.liftOn q f c
protected theorem inductionOn {α : Sort u} [s : Setoid α] {motive : Quotient s → Prop}
(q : Quotient s)
(h : (a : α) → motive (Quotient.mk a))
: motive q :=
Quot.inductionOn q h
theorem existsRep {α : Sort u} [s : Setoid α] (q : Quotient s) : Exists (fun (a : α) => Quotient.mk a = q) :=
Quot.existsRep q
section
variable {α : Sort u}
variable [s : Setoid α]
variable {motive : Quotient s → Sort v}
@[inline]
protected def rec
(f : (a : α) → motive (Quotient.mk a))
(h : (a b : α) → (p : a ≈ b) → Eq.ndrec (f a) (Quotient.sound p) = f b)
(q : Quotient s)
: motive q :=
Quot.rec f h q
protected abbrev recOn
(q : Quotient s)
(f : (a : α) → motive (Quotient.mk a))
(h : (a b : α) → (p : a ≈ b) → Eq.ndrec (f a) (Quotient.sound p) = f b)
: motive q :=
Quot.recOn q f h
protected abbrev recOnSubsingleton
[h : (a : α) → Subsingleton (motive (Quotient.mk a))]
(q : Quotient s)
(f : (a : α) → motive (Quotient.mk a))
: motive q :=
Quot.recOnSubsingleton (h := h) q f
protected abbrev hrecOn
(q : Quotient s)
(f : (a : α) → motive (Quotient.mk a))
(c : (a b : α) → (p : a ≈ b) → f a ≅ f b)
: motive q :=
Quot.hrecOn q f c
end
section
universes uA uB uC
variable {α : Sort uA} {β : Sort uB} {φ : Sort uC}
variable [s₁ : Setoid α] [s₂ : Setoid β]
protected abbrev lift₂
(f : α → β → φ)
(c : (a₁ : α) → (b₁ : β) → (a₂ : α) → (b₂ : β) → a₁ ≈ a₂ → b₁ ≈ b₂ → f a₁ b₁ = f a₂ b₂)
(q₁ : Quotient s₁) (q₂ : Quotient s₂)
: φ := by
apply Quotient.lift (fun (a₁ : α) => Quotient.lift (f a₁) (fun (a b : β) => c a₁ a a₁ b (Setoid.refl a₁)) q₂) _ q₁
intros
induction q₂ using Quotient.ind
apply c; assumption; apply Setoid.refl
protected abbrev liftOn₂
(q₁ : Quotient s₁)
(q₂ : Quotient s₂)
(f : α → β → φ)
(c : (a₁ : α) → (b₁ : β) → (a₂ : α) → (b₂ : β) → a₁ ≈ a₂ → b₁ ≈ b₂ → f a₁ b₁ = f a₂ b₂)
: φ :=
Quotient.lift₂ f c q₁ q₂
protected theorem ind₂
{motive : Quotient s₁ → Quotient s₂ → Prop}
(h : (a : α) → (b : β) → motive (Quotient.mk a) (Quotient.mk b))
(q₁ : Quotient s₁)
(q₂ : Quotient s₂)
: motive q₁ q₂ := by
induction q₁ using Quotient.ind
induction q₂ using Quotient.ind
apply h
protected theorem inductionOn₂
{motive : Quotient s₁ → Quotient s₂ → Prop}
(q₁ : Quotient s₁)
(q₂ : Quotient s₂)
(h : (a : α) → (b : β) → motive (Quotient.mk a) (Quotient.mk b))
: motive q₁ q₂ := by
induction q₁ using Quotient.ind
induction q₂ using Quotient.ind
apply h
protected theorem inductionOn₃
[s₃ : Setoid φ]
{motive : Quotient s₁ → Quotient s₂ → Quotient s₃ → Prop}
(q₁ : Quotient s₁)
(q₂ : Quotient s₂)
(q₃ : Quotient s₃)
(h : (a : α) → (b : β) → (c : φ) → motive (Quotient.mk a) (Quotient.mk b) (Quotient.mk c))
: motive q₁ q₂ q₃ := by
induction q₁ using Quotient.ind
induction q₂ using Quotient.ind
induction q₃ using Quotient.ind
apply h
end
section Exact
variable {α : Sort u}
private def rel [s : Setoid α] (q₁ q₂ : Quotient s) : Prop :=
Quotient.liftOn₂ q₁ q₂
(fun a₁ a₂ => a₁ ≈ a₂)
(fun a₁ a₂ b₁ b₂ a₁b₁ a₂b₂ =>
propext (Iff.intro
(fun a₁a₂ => Setoid.trans (Setoid.symm a₁b₁) (Setoid.trans a₁a₂ a₂b₂))
(fun b₁b₂ => Setoid.trans a₁b₁ (Setoid.trans b₁b₂ (Setoid.symm a₂b₂)))))
private theorem rel.refl [s : Setoid α] (q : Quotient s) : rel q q :=
Quot.inductionOn (motive := fun q => rel q q) q (fun a => Setoid.refl a)
private theorem eqImpRel [s : Setoid α] {q₁ q₂ : Quotient s} : q₁ = q₂ → rel q₁ q₂ :=
fun h => Eq.ndrecOn h (rel.refl q₁)
theorem exact [s : Setoid α] {a b : α} : Quotient.mk a = Quotient.mk b → a ≈ b :=
fun h => eqImpRel h
end Exact
section
universes uA uB uC
variable {α : Sort uA} {β : Sort uB}
variable [s₁ : Setoid α] [s₂ : Setoid β]
protected abbrev recOnSubsingleton₂
{motive : Quotient s₁ → Quotient s₂ → Sort uC}
[s : (a : α) → (b : β) → Subsingleton (motive (Quotient.mk a) (Quotient.mk b))]
(q₁ : Quotient s₁)
(q₂ : Quotient s₂)
(g : (a : α) → (b : β) → motive (Quotient.mk a) (Quotient.mk b))
: motive q₁ q₂ := by
induction q₁ using Quot.recOnSubsingleton
induction q₂ using Quot.recOnSubsingleton
intro a; apply s
induction q₂ using Quot.recOnSubsingleton
intro a; apply s
apply g
end
end Quotient
section
variable {α : Type u}
variable (r : α → α → Prop)
instance {α : Sort u} {s : Setoid α} [d : ∀ (a b : α), Decidable (a ≈ b)] : DecidableEq (Quotient s) :=
fun (q₁ q₂ : Quotient s) =>
Quotient.recOnSubsingleton₂ (motive := fun a b => Decidable (a = b)) q₁ q₂
(fun a₁ a₂ =>
match (d a₁ a₂) with
| (isTrue h₁) => isTrue (Quotient.sound h₁)
| (isFalse h₂) => isFalse (fun h => absurd (Quotient.exact h) h₂))
/- Function extensionality -/
namespace Function
variable {α : Sort u} {β : α → Sort v}
def Equiv (f₁ f₂ : ∀ (x : α), β x) : Prop := ∀ x, f₁ x = f₂ x
protected theorem Equiv.refl (f : ∀ (x : α), β x) : Equiv f f :=
fun x => rfl
protected theorem Equiv.symm {f₁ f₂ : ∀ (x : α), β x} : Equiv f₁ f₂ → Equiv f₂ f₁ :=
fun h x => Eq.symm (h x)
protected theorem Equiv.trans {f₁ f₂ f₃ : ∀ (x : α), β x} : Equiv f₁ f₂ → Equiv f₂ f₃ → Equiv f₁ f₃ :=
fun h₁ h₂ x => Eq.trans (h₁ x) (h₂ x)
protected theorem Equiv.isEquivalence (α : Sort u) (β : α → Sort v) : Equivalence (@Function.Equiv α β) := {
refl := Equiv.refl,
symm := Equiv.symm,
trans := Equiv.trans
}
end Function
section
open Quotient
variable {α : Sort u} {β : α → Sort v}
@[instance]
private def funSetoid (α : Sort u) (β : α → Sort v) : Setoid (∀ (x : α), β x) :=
Setoid.mk (@Function.Equiv α β) (Function.Equiv.isEquivalence α β)
private def extfunApp (f : Quotient <| funSetoid α β) (x : α) : β x :=
Quot.liftOn f
(fun (f : ∀ (x : α), β x) => f x)
(fun f₁ f₂ h => h x)
theorem funext {f₁ f₂ : ∀ (x : α), β x} (h : ∀ x, f₁ x = f₂ x) : f₁ = f₂ := by
show extfunApp (Quotient.mk f₁) = extfunApp (Quotient.mk f₂)
apply congrArg
apply Quotient.sound
exact h
end
instance {α : Sort u} {β : α → Sort v} [∀ a, Subsingleton (β a)] : Subsingleton (∀ a, β a) :=
⟨fun f₁ f₂ => funext (fun a => Subsingleton.elim (f₁ a) (f₂ a))⟩
/- Squash -/
def Squash (α : Type u) := Quot (fun (a b : α) => True)
def Squash.mk {α : Type u} (x : α) : Squash α := Quot.mk _ x
theorem Squash.ind {α : Type u} {motive : Squash α → Prop} (h : ∀ (a : α), motive (Squash.mk a)) : ∀ (q : Squash α), motive q :=
Quot.ind h
@[inline] def Squash.lift {α β} [Subsingleton β] (s : Squash α) (f : α → β) : β :=
Quot.lift f (fun a b _ => Subsingleton.elim _ _) s
instance {α} : Subsingleton (Squash α) := ⟨fun a b =>
Squash.ind (motive := fun a => a = b)
(fun a => Squash.ind (motive := fun b => Squash.mk a = b)
(fun b => show Quot.mk _ a = Quot.mk _ b by apply Quot.sound; exact trivial)
b)
a⟩
namespace Lean
/- Kernel reduction hints -/
/--
When the kernel tries to reduce a term `Lean.reduceBool c`, it will invoke the Lean interpreter to evaluate `c`.
The kernel will not use the interpreter if `c` is not a constant.
This feature is useful for performing proofs by reflection.
Remark: the Lean frontend allows terms of the from `Lean.reduceBool t` where `t` is a term not containing
free variables. The frontend automatically declares a fresh auxiliary constant `c` and replaces the term with
`Lean.reduceBool c`. The main motivation is that the code for `t` will be pre-compiled.
Warning: by using this feature, the Lean compiler and interpreter become part of your trusted code base.
This is extra 30k lines of code. More importantly, you will probably not be able to check your developement using
external type checkers (e.g., Trepplein) that do not implement this feature.
Keep in mind that if you are using Lean as programming language, you are already trusting the Lean compiler and interpreter.
So, you are mainly losing the capability of type checking your developement using external checkers.
Recall that the compiler trusts the correctness of all `[implementedBy ...]` and `[extern ...]` annotations.
If an extern function is executed, then the trusted code base will also include the implementation of the associated
foreign function.
-/
constant reduceBool (b : Bool) : Bool := b
/--
Similar to `Lean.reduceBool` for closed `Nat` terms.
Remark: we do not have plans for supporting a generic `reduceValue {α} (a : α) : α := a`.
The main issue is that it is non-trivial to convert an arbitrary runtime object back into a Lean expression.
We believe `Lean.reduceBool` enables most interesting applications (e.g., proof by reflection). -/
constant reduceNat (n : Nat) : Nat := n
axiom ofReduceBool (a b : Bool) (h : reduceBool a = b) : a = b
axiom ofReduceNat (a b : Nat) (h : reduceNat a = b) : a = b
end Lean
|
2cf58bd9ee902c6db2d3c76147896074b5792a64 | 592ee40978ac7604005a4e0d35bbc4b467389241 | /Library/generated/mathscheme-lean/InvolutiveSemigroup.lean | ed50de42a84f871fe03828997058be2e879de950 | [] | no_license | ysharoda/Deriving-Definitions | 3e149e6641fae440badd35ac110a0bd705a49ad2 | dfecb27572022de3d4aa702cae8db19957523a59 | refs/heads/master | 1,679,127,857,700 | 1,615,939,007,000 | 1,615,939,007,000 | 229,785,731 | 4 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 9,063 | lean | import init.data.nat.basic
import init.data.fin.basic
import data.vector
import .Prelude
open Staged
open nat
open fin
open vector
section InvolutiveSemigroup
structure InvolutiveSemigroup (A : Type) : Type :=
(op : (A → (A → A)))
(associative_op : (∀ {x y z : A} , (op (op x y) z) = (op x (op y z))))
(prim : (A → A))
(involutive_prim : (∀ {x : A} , (prim (prim x)) = x))
(antidis_prim_op : (∀ {x y : A} , (prim (op x y)) = (op (prim y) (prim x))))
open InvolutiveSemigroup
structure Sig (AS : Type) : Type :=
(opS : (AS → (AS → AS)))
(primS : (AS → AS))
structure Product (A : Type) : Type :=
(opP : ((Prod A A) → ((Prod A A) → (Prod A A))))
(primP : ((Prod A A) → (Prod A A)))
(associative_opP : (∀ {xP yP zP : (Prod A A)} , (opP (opP xP yP) zP) = (opP xP (opP yP zP))))
(involutive_primP : (∀ {xP : (Prod A A)} , (primP (primP xP)) = xP))
(antidis_prim_opP : (∀ {xP yP : (Prod A A)} , (primP (opP xP yP)) = (opP (primP yP) (primP xP))))
structure Hom {A1 : Type} {A2 : Type} (In1 : (InvolutiveSemigroup A1)) (In2 : (InvolutiveSemigroup A2)) : Type :=
(hom : (A1 → A2))
(pres_op : (∀ {x1 x2 : A1} , (hom ((op In1) x1 x2)) = ((op In2) (hom x1) (hom x2))))
(pres_prim : (∀ {x1 : A1} , (hom ((prim In1) x1)) = ((prim In2) (hom x1))))
structure RelInterp {A1 : Type} {A2 : Type} (In1 : (InvolutiveSemigroup A1)) (In2 : (InvolutiveSemigroup A2)) : Type 1 :=
(interp : (A1 → (A2 → Type)))
(interp_op : (∀ {x1 x2 : A1} {y1 y2 : A2} , ((interp x1 y1) → ((interp x2 y2) → (interp ((op In1) x1 x2) ((op In2) y1 y2))))))
(interp_prim : (∀ {x1 : A1} {y1 : A2} , ((interp x1 y1) → (interp ((prim In1) x1) ((prim In2) y1)))))
inductive InvolutiveSemigroupTerm : Type
| opL : (InvolutiveSemigroupTerm → (InvolutiveSemigroupTerm → InvolutiveSemigroupTerm))
| primL : (InvolutiveSemigroupTerm → InvolutiveSemigroupTerm)
open InvolutiveSemigroupTerm
inductive ClInvolutiveSemigroupTerm (A : Type) : Type
| sing : (A → ClInvolutiveSemigroupTerm)
| opCl : (ClInvolutiveSemigroupTerm → (ClInvolutiveSemigroupTerm → ClInvolutiveSemigroupTerm))
| primCl : (ClInvolutiveSemigroupTerm → ClInvolutiveSemigroupTerm)
open ClInvolutiveSemigroupTerm
inductive OpInvolutiveSemigroupTerm (n : ℕ) : Type
| v : ((fin n) → OpInvolutiveSemigroupTerm)
| opOL : (OpInvolutiveSemigroupTerm → (OpInvolutiveSemigroupTerm → OpInvolutiveSemigroupTerm))
| primOL : (OpInvolutiveSemigroupTerm → OpInvolutiveSemigroupTerm)
open OpInvolutiveSemigroupTerm
inductive OpInvolutiveSemigroupTerm2 (n : ℕ) (A : Type) : Type
| v2 : ((fin n) → OpInvolutiveSemigroupTerm2)
| sing2 : (A → OpInvolutiveSemigroupTerm2)
| opOL2 : (OpInvolutiveSemigroupTerm2 → (OpInvolutiveSemigroupTerm2 → OpInvolutiveSemigroupTerm2))
| primOL2 : (OpInvolutiveSemigroupTerm2 → OpInvolutiveSemigroupTerm2)
open OpInvolutiveSemigroupTerm2
def simplifyCl {A : Type} : ((ClInvolutiveSemigroupTerm A) → (ClInvolutiveSemigroupTerm A))
| (primCl (primCl x)) := x
| (opCl (primCl y) (primCl x)) := (primCl (opCl x y))
| (opCl x1 x2) := (opCl (simplifyCl x1) (simplifyCl x2))
| (primCl x1) := (primCl (simplifyCl x1))
| (sing x1) := (sing x1)
def simplifyOpB {n : ℕ} : ((OpInvolutiveSemigroupTerm n) → (OpInvolutiveSemigroupTerm n))
| (primOL (primOL x)) := x
| (opOL (primOL y) (primOL x)) := (primOL (opOL x y))
| (opOL x1 x2) := (opOL (simplifyOpB x1) (simplifyOpB x2))
| (primOL x1) := (primOL (simplifyOpB x1))
| (v x1) := (v x1)
def simplifyOp {n : ℕ} {A : Type} : ((OpInvolutiveSemigroupTerm2 n A) → (OpInvolutiveSemigroupTerm2 n A))
| (primOL2 (primOL2 x)) := x
| (opOL2 (primOL2 y) (primOL2 x)) := (primOL2 (opOL2 x y))
| (opOL2 x1 x2) := (opOL2 (simplifyOp x1) (simplifyOp x2))
| (primOL2 x1) := (primOL2 (simplifyOp x1))
| (v2 x1) := (v2 x1)
| (sing2 x1) := (sing2 x1)
def evalB {A : Type} : ((InvolutiveSemigroup A) → (InvolutiveSemigroupTerm → A))
| In (opL x1 x2) := ((op In) (evalB In x1) (evalB In x2))
| In (primL x1) := ((prim In) (evalB In x1))
def evalCl {A : Type} : ((InvolutiveSemigroup A) → ((ClInvolutiveSemigroupTerm A) → A))
| In (sing x1) := x1
| In (opCl x1 x2) := ((op In) (evalCl In x1) (evalCl In x2))
| In (primCl x1) := ((prim In) (evalCl In x1))
def evalOpB {A : Type} {n : ℕ} : ((InvolutiveSemigroup A) → ((vector A n) → ((OpInvolutiveSemigroupTerm n) → A)))
| In vars (v x1) := (nth vars x1)
| In vars (opOL x1 x2) := ((op In) (evalOpB In vars x1) (evalOpB In vars x2))
| In vars (primOL x1) := ((prim In) (evalOpB In vars x1))
def evalOp {A : Type} {n : ℕ} : ((InvolutiveSemigroup A) → ((vector A n) → ((OpInvolutiveSemigroupTerm2 n A) → A)))
| In vars (v2 x1) := (nth vars x1)
| In vars (sing2 x1) := x1
| In vars (opOL2 x1 x2) := ((op In) (evalOp In vars x1) (evalOp In vars x2))
| In vars (primOL2 x1) := ((prim In) (evalOp In vars x1))
def inductionB {P : (InvolutiveSemigroupTerm → Type)} : ((∀ (x1 x2 : InvolutiveSemigroupTerm) , ((P x1) → ((P x2) → (P (opL x1 x2))))) → ((∀ (x1 : InvolutiveSemigroupTerm) , ((P x1) → (P (primL x1)))) → (∀ (x : InvolutiveSemigroupTerm) , (P x))))
| popl ppriml (opL x1 x2) := (popl _ _ (inductionB popl ppriml x1) (inductionB popl ppriml x2))
| popl ppriml (primL x1) := (ppriml _ (inductionB popl ppriml x1))
def inductionCl {A : Type} {P : ((ClInvolutiveSemigroupTerm A) → Type)} : ((∀ (x1 : A) , (P (sing x1))) → ((∀ (x1 x2 : (ClInvolutiveSemigroupTerm A)) , ((P x1) → ((P x2) → (P (opCl x1 x2))))) → ((∀ (x1 : (ClInvolutiveSemigroupTerm A)) , ((P x1) → (P (primCl x1)))) → (∀ (x : (ClInvolutiveSemigroupTerm A)) , (P x)))))
| psing popcl pprimcl (sing x1) := (psing x1)
| psing popcl pprimcl (opCl x1 x2) := (popcl _ _ (inductionCl psing popcl pprimcl x1) (inductionCl psing popcl pprimcl x2))
| psing popcl pprimcl (primCl x1) := (pprimcl _ (inductionCl psing popcl pprimcl x1))
def inductionOpB {n : ℕ} {P : ((OpInvolutiveSemigroupTerm n) → Type)} : ((∀ (fin : (fin n)) , (P (v fin))) → ((∀ (x1 x2 : (OpInvolutiveSemigroupTerm n)) , ((P x1) → ((P x2) → (P (opOL x1 x2))))) → ((∀ (x1 : (OpInvolutiveSemigroupTerm n)) , ((P x1) → (P (primOL x1)))) → (∀ (x : (OpInvolutiveSemigroupTerm n)) , (P x)))))
| pv popol pprimol (v x1) := (pv x1)
| pv popol pprimol (opOL x1 x2) := (popol _ _ (inductionOpB pv popol pprimol x1) (inductionOpB pv popol pprimol x2))
| pv popol pprimol (primOL x1) := (pprimol _ (inductionOpB pv popol pprimol x1))
def inductionOp {n : ℕ} {A : Type} {P : ((OpInvolutiveSemigroupTerm2 n A) → Type)} : ((∀ (fin : (fin n)) , (P (v2 fin))) → ((∀ (x1 : A) , (P (sing2 x1))) → ((∀ (x1 x2 : (OpInvolutiveSemigroupTerm2 n A)) , ((P x1) → ((P x2) → (P (opOL2 x1 x2))))) → ((∀ (x1 : (OpInvolutiveSemigroupTerm2 n A)) , ((P x1) → (P (primOL2 x1)))) → (∀ (x : (OpInvolutiveSemigroupTerm2 n A)) , (P x))))))
| pv2 psing2 popol2 pprimol2 (v2 x1) := (pv2 x1)
| pv2 psing2 popol2 pprimol2 (sing2 x1) := (psing2 x1)
| pv2 psing2 popol2 pprimol2 (opOL2 x1 x2) := (popol2 _ _ (inductionOp pv2 psing2 popol2 pprimol2 x1) (inductionOp pv2 psing2 popol2 pprimol2 x2))
| pv2 psing2 popol2 pprimol2 (primOL2 x1) := (pprimol2 _ (inductionOp pv2 psing2 popol2 pprimol2 x1))
def stageB : (InvolutiveSemigroupTerm → (Staged InvolutiveSemigroupTerm))
| (opL x1 x2) := (stage2 opL (codeLift2 opL) (stageB x1) (stageB x2))
| (primL x1) := (stage1 primL (codeLift1 primL) (stageB x1))
def stageCl {A : Type} : ((ClInvolutiveSemigroupTerm A) → (Staged (ClInvolutiveSemigroupTerm A)))
| (sing x1) := (Now (sing x1))
| (opCl x1 x2) := (stage2 opCl (codeLift2 opCl) (stageCl x1) (stageCl x2))
| (primCl x1) := (stage1 primCl (codeLift1 primCl) (stageCl x1))
def stageOpB {n : ℕ} : ((OpInvolutiveSemigroupTerm n) → (Staged (OpInvolutiveSemigroupTerm n)))
| (v x1) := (const (code (v x1)))
| (opOL x1 x2) := (stage2 opOL (codeLift2 opOL) (stageOpB x1) (stageOpB x2))
| (primOL x1) := (stage1 primOL (codeLift1 primOL) (stageOpB x1))
def stageOp {n : ℕ} {A : Type} : ((OpInvolutiveSemigroupTerm2 n A) → (Staged (OpInvolutiveSemigroupTerm2 n A)))
| (sing2 x1) := (Now (sing2 x1))
| (v2 x1) := (const (code (v2 x1)))
| (opOL2 x1 x2) := (stage2 opOL2 (codeLift2 opOL2) (stageOp x1) (stageOp x2))
| (primOL2 x1) := (stage1 primOL2 (codeLift1 primOL2) (stageOp x1))
structure StagedRepr (A : Type) (Repr : (Type → Type)) : Type :=
(opT : ((Repr A) → ((Repr A) → (Repr A))))
(primT : ((Repr A) → (Repr A)))
end InvolutiveSemigroup |
e42b9bc266ef5a6973d507d03912ffe5ac6d4ade | bbecf0f1968d1fba4124103e4f6b55251d08e9c4 | /src/algebra/order/sub.lean | 43accde50e8aa495154e5526fb53937d54005cf9 | [
"Apache-2.0"
] | permissive | waynemunro/mathlib | e3fd4ff49f4cb43d4a8ded59d17be407bc5ee552 | 065a70810b5480d584033f7bbf8e0409480c2118 | refs/heads/master | 1,693,417,182,397 | 1,634,644,781,000 | 1,634,644,781,000 | null | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 28,832 | lean | /-
Copyright (c) 2021 Floris van Doorn. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Floris van Doorn
-/
import algebra.order.monoid
/-!
# Ordered Subtraction
This file proves lemmas relating (truncated) subtraction with an order. We provide a class
`has_ordered_sub` stating that `a - b ≤ c ↔ a ≤ c + b`.
The subtraction discussed here could both be normal subtraction in an additive group or truncated
subtraction on a canonically ordered monoid (`ℕ`, `multiset`, `enat`, `ennreal`, ...)
## Implementation details
`has_ordered_sub` is a mixin type-class, so that we can use the results in this file even in cases
where we don't have a `canonically_ordered_add_monoid` instance
(even though that is our main focus). Conversely, this means we can use
`canonically_ordered_add_monoid` without necessarily having to define a subtraction.
The results in this file are ordered by the type-class assumption needed to prove it.
This means that similar results might not be close to each other. Furthermore, we don't prove
implications if a bi-implication can be proven under the same assumptions.
Many results about this subtraction are primed, to not conflict with similar lemmas about ordered
groups.
We provide a second version of most results that require `[contravariant_class α α (+) (≤)]`. In the
second version we replace this type-class assumption by explicit `add_le_cancellable` assumptions.
TODO: maybe we should make a multiplicative version of this, so that we can replace some identical
lemmas about subtraction/division in `ordered_[add_]comm_group` with these.
-/
variables {α β : Type*}
/-- `has_ordered_sub α` means that `α` has a subtraction characterized by `a - b ≤ c ↔ a ≤ c + b`.
In other words, `a - b` is the least `c` such that `a ≤ b + c`.
This is satisfied both by the subtraction in additive ordered groups and by truncated subtraction
in canonically ordered monoids on many specific types.
-/
class has_ordered_sub (α : Type*) [has_le α] [has_add α] [has_sub α] :=
(sub_le_iff_right : ∀ a b c : α, a - b ≤ c ↔ a ≤ c + b)
section has_add
variables [preorder α] [has_add α] [has_sub α] [has_ordered_sub α] {a b c d : α}
@[simp] lemma sub_le_iff_right : a - b ≤ c ↔ a ≤ c + b :=
has_ordered_sub.sub_le_iff_right a b c
/-- See `add_sub_cancel_right` for the equality if `contravariant_class α α (+) (≤)`. -/
lemma add_sub_le_right : a + b - b ≤ a :=
sub_le_iff_right.mpr le_rfl
lemma le_sub_add : b ≤ (b - a) + a :=
sub_le_iff_right.mp le_rfl
lemma add_hom.le_map_sub [preorder β] [has_add β] [has_sub β] [has_ordered_sub β]
(f : add_hom α β) (hf : monotone f) (a b : α) :
f a - f b ≤ f (a - b) :=
by { rw [sub_le_iff_right, ← f.map_add], exact hf le_sub_add }
lemma le_mul_sub {R : Type*} [distrib R] [preorder R] [has_sub R] [has_ordered_sub R]
[covariant_class R R (*) (≤)] (a b c : R) :
a * b - a * c ≤ a * (b - c) :=
(add_hom.mul_left a).le_map_sub (monotone_id.const_mul' a) _ _
lemma le_sub_mul {R : Type*} [comm_semiring R] [preorder R] [has_sub R] [has_ordered_sub R]
[covariant_class R R (*) (≤)] (a b c : R) :
a * c - b * c ≤ (a - b) * c :=
by simpa only [mul_comm c] using le_mul_sub c a b
end has_add
/-- An order isomorphism between types with ordered subtraction preserves subtraction provided that
it preserves addition. -/
lemma order_iso.map_sub {M N : Type*} [preorder M] [has_add M] [has_sub M] [has_ordered_sub M]
[partial_order N] [has_add N] [has_sub N] [has_ordered_sub N] (e : M ≃o N)
(h_add : ∀ a b, e (a + b) = e a + e b) (a b : M) :
e (a - b) = e a - e b :=
begin
set e_add : M ≃+ N := { map_add' := h_add, .. e },
refine le_antisymm _ (e_add.to_add_hom.le_map_sub e.monotone a b),
suffices : e (e.symm (e a) - e.symm (e b)) ≤ e (e.symm (e a - e b)), by simpa,
exact e.monotone (e_add.symm.to_add_hom.le_map_sub e.symm.monotone _ _)
end
section ordered_add_comm_monoid
section preorder
variables [preorder α] [add_comm_monoid α] [has_sub α] [has_ordered_sub α] {a b c d : α}
lemma sub_le_iff_left : a - b ≤ c ↔ a ≤ b + c :=
by rw [sub_le_iff_right, add_comm]
lemma le_add_sub : a ≤ b + (a - b) :=
sub_le_iff_left.mp le_rfl
/-- See `add_sub_cancel_left` for the equality if `contravariant_class α α (+) (≤)`. -/
lemma add_sub_le_left : a + b - a ≤ b :=
sub_le_iff_left.mpr le_rfl
lemma sub_le_sub_right' (h : a ≤ b) (c : α) : a - c ≤ b - c :=
sub_le_iff_left.mpr $ h.trans le_add_sub
lemma sub_le_iff_sub_le : a - b ≤ c ↔ a - c ≤ b :=
by rw [sub_le_iff_left, sub_le_iff_right]
/-- See `sub_sub_cancel_of_le` for the equality. -/
lemma sub_sub_le : b - (b - a) ≤ a :=
sub_le_iff_right.mpr le_add_sub
lemma add_monoid_hom.le_map_sub [preorder β] [add_comm_monoid β] [has_sub β]
[has_ordered_sub β] (f : α →+ β) (hf : monotone f) (a b : α) :
f a - f b ≤ f (a - b) :=
f.to_add_hom.le_map_sub hf a b
end preorder
variables [partial_order α] [add_comm_monoid α] [has_sub α] [has_ordered_sub α] {a b c d : α}
lemma sub_sub' (b a c : α) : b - a - c = b - (a + c) :=
begin
apply le_antisymm,
{ rw [sub_le_iff_left, sub_le_iff_left, ← add_assoc, ← sub_le_iff_left] },
{ rw [sub_le_iff_left, add_assoc, ← sub_le_iff_left, ← sub_le_iff_left] }
end
section cov
variable [covariant_class α α (+) (≤)]
lemma sub_le_sub_left' (h : a ≤ b) (c : α) : c - b ≤ c - a :=
sub_le_iff_left.mpr $ le_add_sub.trans $ add_le_add_right h _
lemma sub_le_sub' (hab : a ≤ b) (hcd : c ≤ d) : a - d ≤ b - c :=
(sub_le_sub_right' hab _).trans $ sub_le_sub_left' hcd _
lemma sub_add_eq_sub_sub' : a - (b + c) = a - b - c :=
begin
refine le_antisymm (sub_le_iff_left.mpr _)
(sub_le_iff_left.mpr $ sub_le_iff_left.mpr _),
{ rw [add_assoc], refine le_trans le_add_sub (add_le_add_left le_add_sub _) },
{ rw [← add_assoc], apply le_add_sub }
end
lemma sub_add_eq_sub_sub_swap' : a - (b + c) = a - c - b :=
by { rw [add_comm], exact sub_add_eq_sub_sub' }
lemma add_le_add_add_sub : a + b ≤ (a + c) + (b - c) :=
by { rw [add_assoc], exact add_le_add_left le_add_sub a }
lemma sub_right_comm' : a - b - c = a - c - b :=
by simp_rw [← sub_add_eq_sub_sub', add_comm]
/-- See `add_sub_assoc_of_le` for the equality. -/
lemma add_sub_le_assoc : a + b - c ≤ a + (b - c) :=
by { rw [sub_le_iff_left, add_left_comm], exact add_le_add_left le_add_sub a }
lemma le_sub_add_add : a + b ≤ (a - c) + (b + c) :=
by { rw [add_comm a, add_comm (a - c)], exact add_le_add_add_sub }
lemma sub_le_sub_add_sub : a - c ≤ (a - b) + (b - c) :=
begin
rw [sub_le_iff_left, ← add_assoc, add_right_comm],
refine le_add_sub.trans (add_le_add_right le_add_sub _),
end
lemma sub_sub_sub_le_sub : (c - a) - (c - b) ≤ b - a :=
begin
rw [sub_le_iff_left, sub_le_iff_left, add_left_comm],
refine le_sub_add.trans (add_le_add_left le_add_sub _),
end
end cov
/-! ### Lemmas that assume that an element is `add_le_cancellable`. -/
namespace add_le_cancellable
protected lemma le_add_sub_swap (hb : add_le_cancellable b) : a ≤ b + a - b :=
hb le_add_sub
protected lemma le_add_sub (hb : add_le_cancellable b) : a ≤ a + b - b :=
by { rw [add_comm], exact hb.le_add_sub_swap }
protected lemma sub_eq_of_eq_add (hb : add_le_cancellable b) (h : a = c + b) : a - b = c :=
le_antisymm (sub_le_iff_right.mpr h.le) $
by { rw h, exact hb.le_add_sub }
protected lemma eq_sub_of_add_eq (hc : add_le_cancellable c) (h : a + c = b) : a = b - c :=
(hc.sub_eq_of_eq_add h.symm).symm
protected theorem sub_eq_of_eq_add_rev (hb : add_le_cancellable b) (h : a = b + c) : a - b = c :=
hb.sub_eq_of_eq_add $ by rw [add_comm, h]
@[simp]
protected lemma add_sub_cancel_right (hb : add_le_cancellable b) : a + b - b = a :=
hb.sub_eq_of_eq_add $ by rw [add_comm]
@[simp]
protected lemma add_sub_cancel_left (ha : add_le_cancellable a) : a + b - a = b :=
ha.sub_eq_of_eq_add $ add_comm a b
protected lemma le_sub_of_add_le_left (ha : add_le_cancellable a) (h : a + b ≤ c) : b ≤ c - a :=
ha $ h.trans le_add_sub
protected lemma le_sub_of_add_le_right (hb : add_le_cancellable b) (h : a + b ≤ c) : a ≤ c - b :=
hb.le_sub_of_add_le_left $ by rwa [add_comm]
protected lemma lt_add_of_sub_lt_left (hb : add_le_cancellable b) (h : a - b < c) : a < b + c :=
begin
rw [lt_iff_le_and_ne, ← sub_le_iff_left],
refine ⟨h.le, _⟩,
rintro rfl,
simpa [hb] using h,
end
protected lemma lt_add_of_sub_lt_right (hc : add_le_cancellable c) (h : a - c < b) : a < b + c :=
begin
rw [lt_iff_le_and_ne, ← sub_le_iff_right],
refine ⟨h.le, _⟩,
rintro rfl,
simpa [hc] using h,
end
end add_le_cancellable
/-! ### Lemmas where addition is order-reflecting. -/
section contra
variable [contravariant_class α α (+) (≤)]
lemma le_add_sub_swap : a ≤ b + a - b :=
contravariant.add_le_cancellable.le_add_sub_swap
lemma le_add_sub' : a ≤ a + b - b :=
contravariant.add_le_cancellable.le_add_sub
lemma sub_eq_of_eq_add'' (h : a = c + b) : a - b = c :=
contravariant.add_le_cancellable.sub_eq_of_eq_add h
lemma eq_sub_of_add_eq'' (h : a + c = b) : a = b - c :=
contravariant.add_le_cancellable.eq_sub_of_add_eq h
lemma sub_eq_of_eq_add_rev (h : a = b + c) : a - b = c :=
contravariant.add_le_cancellable.sub_eq_of_eq_add_rev h
@[simp]
lemma add_sub_cancel_right (a b : α) : a + b - b = a :=
contravariant.add_le_cancellable.add_sub_cancel_right
@[simp]
lemma add_sub_cancel_left (a b : α) : a + b - a = b :=
contravariant.add_le_cancellable.add_sub_cancel_left
lemma le_sub_of_add_le_left' (h : a + b ≤ c) : b ≤ c - a :=
contravariant.add_le_cancellable.le_sub_of_add_le_left h
lemma le_sub_of_add_le_right' (h : a + b ≤ c) : a ≤ c - b :=
contravariant.add_le_cancellable.le_sub_of_add_le_right h
lemma lt_add_of_sub_lt_left' (h : a - b < c) : a < b + c :=
contravariant.add_le_cancellable.lt_add_of_sub_lt_left h
lemma lt_add_of_sub_lt_right' (h : a - c < b) : a < b + c :=
contravariant.add_le_cancellable.lt_add_of_sub_lt_right h
end contra
section both
variables [covariant_class α α (+) (≤)] [contravariant_class α α (+) (≤)]
lemma add_sub_add_right_eq_sub' (a c b : α) : (a + c) - (b + c) = a - b :=
begin
apply le_antisymm,
{ rw [sub_le_iff_left, add_right_comm], exact add_le_add_right le_add_sub c },
{ rw [sub_le_iff_left, add_comm b],
apply le_of_add_le_add_right,
rw [add_assoc],
exact le_sub_add }
end
lemma add_sub_add_eq_sub_left' (a b c : α) : (a + b) - (a + c) = b - c :=
by rw [add_comm a b, add_comm a c, add_sub_add_right_eq_sub']
end both
end ordered_add_comm_monoid
/-! ### Lemmas in a linearly ordered monoid. -/
section linear_order
variables {a b c d : α} [linear_order α] [add_comm_monoid α] [has_sub α] [has_ordered_sub α]
/-- See `lt_of_sub_lt_sub_right_of_le` for a weaker statement in a partial order. -/
lemma lt_of_sub_lt_sub_right (h : a - c < b - c) : a < b :=
lt_imp_lt_of_le_imp_le (λ h, sub_le_sub_right' h c) h
/-- See `lt_sub_iff_right_of_le` for a weaker statement in a partial order. -/
lemma lt_sub_iff_right : a < b - c ↔ a + c < b :=
lt_iff_lt_of_le_iff_le sub_le_iff_right
/-- See `lt_sub_iff_left_of_le` for a weaker statement in a partial order. -/
lemma lt_sub_iff_left : a < b - c ↔ c + a < b :=
lt_iff_lt_of_le_iff_le sub_le_iff_left
lemma lt_sub_comm : a < b - c ↔ c < b - a :=
lt_sub_iff_left.trans lt_sub_iff_right.symm
section cov
variable [covariant_class α α (+) (≤)]
/-- See `lt_of_sub_lt_sub_left_of_le` for a weaker statement in a partial order. -/
lemma lt_of_sub_lt_sub_left (h : a - b < a - c) : c < b :=
lt_imp_lt_of_le_imp_le (λ h, sub_le_sub_left' h a) h
end cov
end linear_order
/-! ### Lemmas in a canonically ordered monoid. -/
section canonically_ordered_add_monoid
variables [canonically_ordered_add_monoid α] [has_sub α] [has_ordered_sub α] {a b c d : α}
lemma add_sub_cancel_of_le (h : a ≤ b) : a + (b - a) = b :=
begin
refine le_antisymm _ le_add_sub,
obtain ⟨c, rfl⟩ := le_iff_exists_add.1 h,
exact add_le_add_left add_sub_le_left a,
end
lemma sub_add_cancel_of_le (h : a ≤ b) : b - a + a = b :=
by { rw [add_comm], exact add_sub_cancel_of_le h }
lemma add_sub_cancel_iff_le : a + (b - a) = b ↔ a ≤ b :=
⟨λ h, le_iff_exists_add.mpr ⟨b - a, h.symm⟩, add_sub_cancel_of_le⟩
lemma sub_add_cancel_iff_le : b - a + a = b ↔ a ≤ b :=
by { rw [add_comm], exact add_sub_cancel_iff_le }
lemma add_le_of_le_sub_right_of_le (h : b ≤ c) (h2 : a ≤ c - b) : a + b ≤ c :=
(add_le_add_right h2 b).trans_eq $ sub_add_cancel_of_le h
lemma add_le_of_le_sub_left_of_le (h : a ≤ c) (h2 : b ≤ c - a) : a + b ≤ c :=
(add_le_add_left h2 a).trans_eq $ add_sub_cancel_of_le h
lemma sub_le_sub_iff_right' (h : c ≤ b) : a - c ≤ b - c ↔ a ≤ b :=
by rw [sub_le_iff_right, sub_add_cancel_of_le h]
lemma sub_left_inj' (h1 : c ≤ a) (h2 : c ≤ b) : a - c = b - c ↔ a = b :=
by simp_rw [le_antisymm_iff, sub_le_sub_iff_right' h1, sub_le_sub_iff_right' h2]
/-- See `lt_of_sub_lt_sub_right` for a stronger statement in a linear order. -/
lemma lt_of_sub_lt_sub_right_of_le (h : c ≤ b) (h2 : a - c < b - c) : a < b :=
by { refine ((sub_le_sub_iff_right' h).mp h2.le).lt_of_ne _, rintro rfl, exact h2.false }
lemma sub_eq_zero_iff_le : a - b = 0 ↔ a ≤ b :=
by rw [← nonpos_iff_eq_zero, sub_le_iff_left, add_zero]
@[simp] lemma sub_self' (a : α) : a - a = 0 :=
sub_eq_zero_iff_le.mpr le_rfl
@[simp] lemma sub_le_self' : a - b ≤ a :=
sub_le_iff_left.mpr $ le_add_left le_rfl
@[simp] lemma sub_zero' (a : α) : a - 0 = a :=
le_antisymm sub_le_self' $ le_add_sub.trans_eq $ zero_add _
@[simp] lemma zero_sub' (a : α) : 0 - a = 0 :=
sub_eq_zero_iff_le.mpr $ zero_le a
lemma sub_self_add (a b : α) : a - (a + b) = 0 :=
by { rw [sub_eq_zero_iff_le], apply self_le_add_right }
lemma sub_inj_left (h₁ : a ≤ b) (h₂ : a ≤ c) (h₃ : b - a = c - a) : b = c :=
by rw [← sub_add_cancel_of_le h₁, ← sub_add_cancel_of_le h₂, h₃]
lemma sub_pos_iff_not_le : 0 < a - b ↔ ¬ a ≤ b :=
by rw [pos_iff_ne_zero, ne.def, sub_eq_zero_iff_le]
lemma sub_pos_of_lt' (h : a < b) : 0 < b - a :=
sub_pos_iff_not_le.mpr h.not_le
lemma sub_add_sub_cancel'' (hab : b ≤ a) (hbc : c ≤ b) : (a - b) + (b - c) = a - c :=
begin
convert sub_add_cancel_of_le (sub_le_sub_right' hab c) using 2,
rw [sub_sub', add_sub_cancel_of_le hbc],
end
lemma sub_sub_sub_cancel_right' (h : c ≤ b) : (a - c) - (b - c) = a - b :=
by rw [sub_sub', add_sub_cancel_of_le h]
/-! ### Lemmas that assume that an element is `add_le_cancellable`. -/
namespace add_le_cancellable
protected lemma eq_sub_iff_add_eq_of_le (hc : add_le_cancellable c) (h : c ≤ b) :
a = b - c ↔ a + c = b :=
begin
split,
{ rintro rfl, exact sub_add_cancel_of_le h },
{ rintro rfl, exact (hc.add_sub_cancel_right).symm }
end
protected lemma sub_eq_iff_eq_add_of_le (hb : add_le_cancellable b) (h : b ≤ a) :
a - b = c ↔ a = c + b :=
by rw [eq_comm, hb.eq_sub_iff_add_eq_of_le h, eq_comm]
protected lemma add_sub_assoc_of_le (hc : add_le_cancellable c) (h : c ≤ b) (a : α) :
a + b - c = a + (b - c) :=
by conv_lhs { rw [← add_sub_cancel_of_le h, add_comm c, ← add_assoc,
hc.add_sub_cancel_right] }
protected lemma sub_add_eq_add_sub (hb : add_le_cancellable b) (h : b ≤ a) :
a - b + c = a + c - b :=
by rw [add_comm a, hb.add_sub_assoc_of_le h, add_comm]
protected lemma sub_sub_assoc (hbc : add_le_cancellable (b - c)) (h₁ : b ≤ a) (h₂ : c ≤ b) :
a - (b - c) = a - b + c :=
by rw [hbc.sub_eq_iff_eq_add_of_le (sub_le_self'.trans h₁), add_assoc,
add_sub_cancel_of_le h₂, sub_add_cancel_of_le h₁]
protected lemma le_sub_iff_left (ha : add_le_cancellable a) (h : a ≤ c) : b ≤ c - a ↔ a + b ≤ c :=
⟨add_le_of_le_sub_left_of_le h, ha.le_sub_of_add_le_left⟩
protected lemma le_sub_iff_right (ha : add_le_cancellable a) (h : a ≤ c) : b ≤ c - a ↔ b + a ≤ c :=
by { rw [add_comm], exact ha.le_sub_iff_left h }
protected lemma sub_lt_iff_left (hb : add_le_cancellable b) (hba : b ≤ a) :
a - b < c ↔ a < b + c :=
begin
refine ⟨hb.lt_add_of_sub_lt_left, _⟩,
intro h, refine (sub_le_iff_left.mpr h.le).lt_of_ne _,
rintro rfl, exact h.ne' (add_sub_cancel_of_le hba)
end
protected lemma sub_lt_iff_right (hb : add_le_cancellable b) (hba : b ≤ a) :
a - b < c ↔ a < c + b :=
by { rw [add_comm], exact hb.sub_lt_iff_left hba }
protected lemma lt_sub_of_add_lt_right (hc : add_le_cancellable c) (h : a + c < b) : a < b - c :=
begin
apply lt_of_le_of_ne,
{ rw [← add_sub_cancel_of_le h.le, add_right_comm, add_assoc],
rw [hc.add_sub_assoc_of_le], refine le_self_add, refine le_add_self },
{ rintro rfl, apply h.not_le, exact le_sub_add }
end
protected lemma lt_sub_of_add_lt_left (ha : add_le_cancellable a) (h : a + c < b) : c < b - a :=
by { apply ha.lt_sub_of_add_lt_right, rwa add_comm }
protected lemma sub_lt_iff_sub_lt (hb : add_le_cancellable b) (hc : add_le_cancellable c)
(h₁ : b ≤ a) (h₂ : c ≤ a) : a - b < c ↔ a - c < b :=
by rw [hb.sub_lt_iff_left h₁, hc.sub_lt_iff_right h₂]
protected lemma le_sub_iff_le_sub (ha : add_le_cancellable a) (hc : add_le_cancellable c)
(h₁ : a ≤ b) (h₂ : c ≤ b) : a ≤ b - c ↔ c ≤ b - a :=
by rw [ha.le_sub_iff_left h₁, hc.le_sub_iff_right h₂]
protected lemma lt_sub_iff_right_of_le (hc : add_le_cancellable c) (h : c ≤ b) :
a < b - c ↔ a + c < b :=
begin
refine ⟨_, hc.lt_sub_of_add_lt_right⟩,
intro h2,
refine (add_le_of_le_sub_right_of_le h h2.le).lt_of_ne _,
rintro rfl,
apply h2.not_le,
rw [hc.add_sub_cancel_right]
end
protected lemma lt_sub_iff_left_of_le (hc : add_le_cancellable c) (h : c ≤ b) :
a < b - c ↔ c + a < b :=
by { rw [add_comm], exact hc.lt_sub_iff_right_of_le h }
protected lemma lt_of_sub_lt_sub_left_of_le [contravariant_class α α (+) (<)]
(hb : add_le_cancellable b) (hca : c ≤ a) (h : a - b < a - c) : c < b :=
begin
conv_lhs at h { rw [← sub_add_cancel_of_le hca] },
exact lt_of_add_lt_add_left (hb.lt_add_of_sub_lt_right h),
end
protected lemma sub_le_sub_iff_left (ha : add_le_cancellable a) (hc : add_le_cancellable c)
(h : c ≤ a) : a - b ≤ a - c ↔ c ≤ b :=
begin
refine ⟨_, λ h, sub_le_sub_left' h a⟩,
rw [sub_le_iff_left, ← hc.add_sub_assoc_of_le h,
hc.le_sub_iff_right (h.trans le_add_self), add_comm b],
apply ha,
end
protected lemma sub_right_inj (ha : add_le_cancellable a) (hb : add_le_cancellable b)
(hc : add_le_cancellable c) (hba : b ≤ a) (hca : c ≤ a) : a - b = a - c ↔ b = c :=
by simp_rw [le_antisymm_iff, ha.sub_le_sub_iff_left hb hba, ha.sub_le_sub_iff_left hc hca, and_comm]
protected lemma sub_lt_sub_right_of_le (hc : add_le_cancellable c) (h : c ≤ a) (h2 : a < b) :
a - c < b - c :=
by { apply hc.lt_sub_of_add_lt_left, rwa [add_sub_cancel_of_le h] }
protected lemma sub_inj_right (hab : add_le_cancellable (a - b)) (h₁ : b ≤ a) (h₂ : c ≤ a)
(h₃ : a - b = a - c) : b = c :=
by { rw ← hab.inj, rw [sub_add_cancel_of_le h₁, h₃, sub_add_cancel_of_le h₂] }
protected lemma sub_lt_sub_iff_left_of_le_of_le [contravariant_class α α (+) (<)]
(hb : add_le_cancellable b) (hab : add_le_cancellable (a - b)) (h₁ : b ≤ a) (h₂ : c ≤ a) :
a - b < a - c ↔ c < b :=
begin
refine ⟨hb.lt_of_sub_lt_sub_left_of_le h₂, _⟩,
intro h, refine (sub_le_sub_left' h.le _).lt_of_ne _,
rintro h2, exact h.ne' (hab.sub_inj_right h₁ h₂ h2)
end
@[simp] protected lemma add_sub_sub_cancel (hac : add_le_cancellable (a - c)) (h : c ≤ a) :
(a + b) - (a - c) = b + c :=
(hac.sub_eq_iff_eq_add_of_le $ sub_le_self'.trans le_self_add).mpr $
by rw [add_assoc, add_sub_cancel_of_le h, add_comm]
protected lemma sub_sub_cancel_of_le (hba : add_le_cancellable (b - a)) (h : a ≤ b) :
b - (b - a) = a :=
by rw [hba.sub_eq_iff_eq_add_of_le sub_le_self', add_sub_cancel_of_le h]
end add_le_cancellable
section contra
/-! ### Lemmas where addition is order-reflecting. -/
variable [contravariant_class α α (+) (≤)]
lemma eq_sub_iff_add_eq_of_le (h : c ≤ b) : a = b - c ↔ a + c = b :=
contravariant.add_le_cancellable.eq_sub_iff_add_eq_of_le h
lemma sub_eq_iff_eq_add_of_le (h : b ≤ a) : a - b = c ↔ a = c + b :=
contravariant.add_le_cancellable.sub_eq_iff_eq_add_of_le h
/-- See `add_sub_le_assoc` for an inequality. -/
lemma add_sub_assoc_of_le (h : c ≤ b) (a : α) : a + b - c = a + (b - c) :=
contravariant.add_le_cancellable.add_sub_assoc_of_le h a
lemma sub_add_eq_add_sub' (h : b ≤ a) : a - b + c = a + c - b :=
contravariant.add_le_cancellable.sub_add_eq_add_sub h
lemma sub_sub_assoc (h₁ : b ≤ a) (h₂ : c ≤ b) : a - (b - c) = a - b + c :=
contravariant.add_le_cancellable.sub_sub_assoc h₁ h₂
lemma le_sub_iff_left (h : a ≤ c) : b ≤ c - a ↔ a + b ≤ c :=
contravariant.add_le_cancellable.le_sub_iff_left h
lemma le_sub_iff_right (h : a ≤ c) : b ≤ c - a ↔ b + a ≤ c :=
contravariant.add_le_cancellable.le_sub_iff_right h
lemma sub_lt_iff_left (hbc : b ≤ a) : a - b < c ↔ a < b + c :=
contravariant.add_le_cancellable.sub_lt_iff_left hbc
lemma sub_lt_iff_right (hbc : b ≤ a) : a - b < c ↔ a < c + b :=
contravariant.add_le_cancellable.sub_lt_iff_right hbc
/-- This lemma (and some of its corollaries also holds for `ennreal`,
but this proof doesn't work for it.
Maybe we should add this lemma as field to `has_ordered_sub`? -/
lemma lt_sub_of_add_lt_right (h : a + c < b) : a < b - c :=
contravariant.add_le_cancellable.lt_sub_of_add_lt_right h
lemma lt_sub_of_add_lt_left (h : a + c < b) : c < b - a :=
contravariant.add_le_cancellable.lt_sub_of_add_lt_left h
lemma sub_lt_iff_sub_lt (h₁ : b ≤ a) (h₂ : c ≤ a) : a - b < c ↔ a - c < b :=
contravariant.add_le_cancellable.sub_lt_iff_sub_lt contravariant.add_le_cancellable h₁ h₂
lemma le_sub_iff_le_sub (h₁ : a ≤ b) (h₂ : c ≤ b) : a ≤ b - c ↔ c ≤ b - a :=
contravariant.add_le_cancellable.le_sub_iff_le_sub contravariant.add_le_cancellable h₁ h₂
/-- See `lt_sub_iff_right` for a stronger statement in a linear order. -/
lemma lt_sub_iff_right_of_le (h : c ≤ b) : a < b - c ↔ a + c < b :=
contravariant.add_le_cancellable.lt_sub_iff_right_of_le h
/-- See `lt_sub_iff_left` for a stronger statement in a linear order. -/
lemma lt_sub_iff_left_of_le (h : c ≤ b) : a < b - c ↔ c + a < b :=
contravariant.add_le_cancellable.lt_sub_iff_left_of_le h
/-- See `lt_of_sub_lt_sub_left` for a stronger statement in a linear order. -/
lemma lt_of_sub_lt_sub_left_of_le [contravariant_class α α (+) (<)]
(hca : c ≤ a) (h : a - b < a - c) : c < b :=
contravariant.add_le_cancellable.lt_of_sub_lt_sub_left_of_le hca h
lemma sub_le_sub_iff_left' (h : c ≤ a) : a - b ≤ a - c ↔ c ≤ b :=
contravariant.add_le_cancellable.sub_le_sub_iff_left contravariant.add_le_cancellable h
lemma sub_right_inj' (hba : b ≤ a) (hca : c ≤ a) : a - b = a - c ↔ b = c :=
contravariant.add_le_cancellable.sub_right_inj contravariant.add_le_cancellable
contravariant.add_le_cancellable hba hca
lemma sub_lt_sub_right_of_le (h : c ≤ a) (h2 : a < b) : a - c < b - c :=
contravariant.add_le_cancellable.sub_lt_sub_right_of_le h h2
lemma sub_inj_right (h₁ : b ≤ a) (h₂ : c ≤ a) (h₃ : a - b = a - c) : b = c :=
contravariant.add_le_cancellable.sub_inj_right h₁ h₂ h₃
/-- See `sub_lt_sub_iff_left_of_le` for a stronger statement in a linear order. -/
lemma sub_lt_sub_iff_left_of_le_of_le [contravariant_class α α (+) (<)]
(h₁ : b ≤ a) (h₂ : c ≤ a) : a - b < a - c ↔ c < b :=
contravariant.add_le_cancellable.sub_lt_sub_iff_left_of_le_of_le
contravariant.add_le_cancellable h₁ h₂
@[simp] lemma add_sub_sub_cancel' (h : c ≤ a) : (a + b) - (a - c) = b + c :=
contravariant.add_le_cancellable.add_sub_sub_cancel h
/-- See `sub_sub_le` for an inequality. -/
lemma sub_sub_cancel_of_le (h : a ≤ b) : b - (b - a) = a :=
contravariant.add_le_cancellable.sub_sub_cancel_of_le h
end contra
end canonically_ordered_add_monoid
/-! ### Lemmas in a linearly canonically ordered monoid. -/
section canonically_linear_ordered_add_monoid
variables [canonically_linear_ordered_add_monoid α] [has_sub α] [has_ordered_sub α] {a b c d : α}
lemma sub_pos_iff_lt : 0 < a - b ↔ b < a :=
by rw [sub_pos_iff_not_le, not_le]
lemma sub_eq_sub_min (a b : α) : a - b = a - min a b :=
begin
cases le_total a b with h h,
{ rw [min_eq_left h, sub_self', sub_eq_zero_iff_le.mpr h] },
{ rw [min_eq_right h] },
end
namespace add_le_cancellable
protected lemma lt_sub_iff_right (hc : add_le_cancellable c) : a < b - c ↔ a + c < b :=
⟨lt_imp_lt_of_le_imp_le sub_le_iff_right.mpr, hc.lt_sub_of_add_lt_right⟩
protected lemma lt_sub_iff_left (hc : add_le_cancellable c) : a < b - c ↔ c + a < b :=
⟨lt_imp_lt_of_le_imp_le sub_le_iff_left.mpr, hc.lt_sub_of_add_lt_left⟩
protected lemma sub_lt_sub_iff_right (hc : add_le_cancellable c) (h : c ≤ a) :
a - c < b - c ↔ a < b :=
by rw [hc.lt_sub_iff_left, add_sub_cancel_of_le h]
protected lemma lt_sub_iff_lt_sub (ha : add_le_cancellable a) (hc : add_le_cancellable c) :
a < b - c ↔ c < b - a :=
by rw [hc.lt_sub_iff_left, ha.lt_sub_iff_right]
protected lemma sub_lt_self (ha : add_le_cancellable a) (hb : add_le_cancellable b)
(h₁ : 0 < a) (h₂ : 0 < b) : a - b < a :=
begin
refine sub_le_self'.lt_of_ne _,
intro h,
rw [← h, sub_pos_iff_lt] at h₁,
have := h.ge,
rw [hb.le_sub_iff_left h₁.le, ha.add_le_iff_nonpos_left] at this,
exact h₂.not_le this,
end
protected lemma sub_lt_self_iff (ha : add_le_cancellable a) (hb : add_le_cancellable b) :
a - b < a ↔ 0 < a ∧ 0 < b :=
begin
refine ⟨_, λ h, ha.sub_lt_self hb h.1 h.2⟩,
intro h,
refine ⟨(zero_le _).trans_lt h, (zero_le b).lt_of_ne _⟩,
rintro rfl,
rw [sub_zero'] at h,
exact h.false
end
/-- See `lt_sub_iff_left_of_le_of_le` for a weaker statement in a partial order. -/
protected lemma sub_lt_sub_iff_left_of_le (ha : add_le_cancellable a) (hb : add_le_cancellable b)
(h : b ≤ a) : a - b < a - c ↔ c < b :=
lt_iff_lt_of_le_iff_le $ ha.sub_le_sub_iff_left hb h
end add_le_cancellable
section contra
variable [contravariant_class α α (+) (≤)]
/-- This lemma also holds for `ennreal`, but we need a different proof for that. -/
lemma sub_lt_sub_iff_right' (h : c ≤ a) : a - c < b - c ↔ a < b :=
contravariant.add_le_cancellable.sub_lt_sub_iff_right h
lemma lt_sub_iff_lt_sub : a < b - c ↔ c < b - a :=
contravariant.add_le_cancellable.lt_sub_iff_lt_sub contravariant.add_le_cancellable
lemma sub_lt_self' (h₁ : 0 < a) (h₂ : 0 < b) : a - b < a :=
contravariant.add_le_cancellable.sub_lt_self contravariant.add_le_cancellable h₁ h₂
lemma sub_lt_self_iff' : a - b < a ↔ 0 < a ∧ 0 < b :=
contravariant.add_le_cancellable.sub_lt_self_iff contravariant.add_le_cancellable
/-- See `lt_sub_iff_left_of_le_of_le` for a weaker statement in a partial order. -/
lemma sub_lt_sub_iff_left_of_le (h : b ≤ a) : a - b < a - c ↔ c < b :=
contravariant.add_le_cancellable.sub_lt_sub_iff_left_of_le contravariant.add_le_cancellable h
end contra
/-! ### Lemmas about `max` and `min`. -/
lemma sub_add_eq_max : a - b + b = max a b :=
begin
cases le_total a b with h h,
{ rw [max_eq_right h, sub_eq_zero_iff_le.mpr h, zero_add] },
{ rw [max_eq_left h, sub_add_cancel_of_le h] }
end
lemma add_sub_eq_max : a + (b - a) = max a b :=
by rw [add_comm, max_comm, sub_add_eq_max]
lemma sub_min : a - min a b = a - b :=
begin
cases le_total a b with h h,
{ rw [min_eq_left h, sub_self', sub_eq_zero_iff_le.mpr h] },
{ rw [min_eq_right h] }
end
lemma sub_add_min : a - b + min a b = a :=
by { rw [← sub_min, sub_add_cancel_of_le], apply min_le_left }
end canonically_linear_ordered_add_monoid
namespace with_top
section
variables [has_sub α] [has_zero α]
/-- If `α` has subtraction and `0`, we can extend the subtraction to `with_top α`. -/
protected def sub : Π (a b : with_top α), with_top α
| _ ⊤ := 0
| ⊤ (x : α) := ⊤
| (x : α) (y : α) := (x - y : α)
instance : has_sub (with_top α) :=
⟨with_top.sub⟩
@[simp, norm_cast] lemma coe_sub {a b : α} : (↑(a - b) : with_top α) = ↑a - ↑b := rfl
@[simp] lemma top_sub_coe {a : α} : (⊤ : with_top α) - a = ⊤ := rfl
@[simp] lemma sub_top {a : with_top α} : a - ⊤ = 0 := by { cases a; refl }
end
variables [canonically_ordered_add_monoid α] [has_sub α] [has_ordered_sub α]
instance : has_ordered_sub (with_top α) :=
begin
constructor,
rintro x y z,
induction y using with_top.rec_top_coe, { simp },
induction x using with_top.rec_top_coe, { simp },
induction z using with_top.rec_top_coe, { simp },
norm_cast, exact sub_le_iff_right
end
end with_top
|
206bc8d5e7f27045f576ae9cd985015348ec8fbd | 4d2583807a5ac6caaffd3d7a5f646d61ca85d532 | /archive/100-theorems-list/16_abel_ruffini.lean | 37460d82ee589b16bca4b4e7c7b44c2e631bee91 | [
"Apache-2.0"
] | permissive | AntoineChambert-Loir/mathlib | 64aabb896129885f12296a799818061bc90da1ff | 07be904260ab6e36a5769680b6012f03a4727134 | refs/heads/master | 1,693,187,631,771 | 1,636,719,886,000 | 1,636,719,886,000 | null | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 8,265 | lean | /-
Copyright (c) 2021 Thomas Browning. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Thomas Browning
-/
import field_theory.abel_ruffini
import analysis.calculus.local_extr
/-!
Construction of an algebraic number that is not solvable by radicals.
The main ingredients are:
* `solvable_by_rad.is_solvable'` in `field_theory/abel_ruffini` :
an irreducible polynomial with an `is_solvable_by_rad` root has solvable Galois group
* `gal_action_hom_bijective_of_prime_degree'` in `field_theory/polynomial_galois_group` :
an irreducible polynomial of prime degree with 1-3 non-real roots has full Galois group
* `equiv.perm.not_solvable` in `group_theory/solvable` : the symmetric group is not solvable
Then all that remains is the construction of a specific polynomial satisfying the conditions of
`gal_action_hom_bijective_of_prime_degree'`, which is done in this file.
-/
namespace abel_ruffini
open function polynomial polynomial.gal ideal
local attribute [instance] splits_ℚ_ℂ
variables (R : Type*) [comm_ring R] (a b : ℕ)
/-- A quintic polynomial that we will show is irreducible -/
noncomputable def Φ : polynomial R := X ^ 5 - C ↑a * X + C ↑b
variables {R}
@[simp] lemma map_Phi {S : Type*} [comm_ring S] (f : R →+* S) : (Φ R a b).map f = Φ S a b :=
by simp [Φ]
@[simp] lemma coeff_zero_Phi : (Φ R a b).coeff 0 = ↑b :=
by simp [Φ, coeff_X_pow]
@[simp] lemma coeff_five_Phi : (Φ R a b).coeff 5 = 1 :=
by simp [Φ, coeff_X, coeff_C, -C_eq_nat_cast, -ring_hom.map_nat_cast]
variables [nontrivial R]
lemma degree_Phi : (Φ R a b).degree = ↑5 :=
begin
suffices : degree (X ^ 5 - C ↑a * X) = ↑5,
{ rwa [Φ, degree_add_eq_left_of_degree_lt],
convert degree_C_le.trans_lt (with_bot.coe_lt_coe.mpr (nat.zero_lt_bit1 2)) },
rw degree_sub_eq_left_of_degree_lt; rw degree_X_pow,
exact (degree_C_mul_X_le _).trans_lt (with_bot.coe_lt_coe.mpr (nat.one_lt_bit1 two_ne_zero)),
end
lemma nat_degree_Phi : (Φ R a b).nat_degree = 5 :=
nat_degree_eq_of_degree_eq_some (degree_Phi a b)
lemma leading_coeff_Phi : (Φ R a b).leading_coeff = 1 :=
by rw [polynomial.leading_coeff, nat_degree_Phi, coeff_five_Phi]
lemma monic_Phi : (Φ R a b).monic :=
leading_coeff_Phi a b
lemma irreducible_Phi (p : ℕ) (hp : p.prime) (hpa : p ∣ a) (hpb : p ∣ b) (hp2b : ¬ p ^ 2 ∣ b) :
irreducible (Φ ℚ a b) :=
begin
rw [←map_Phi a b (int.cast_ring_hom ℚ), ←is_primitive.int.irreducible_iff_irreducible_map_cast],
apply irreducible_of_eisenstein_criterion,
{ rwa [span_singleton_prime (int.coe_nat_ne_zero.mpr hp.ne_zero), int.prime_iff_nat_abs_prime] },
{ rw [leading_coeff_Phi, mem_span_singleton],
exact_mod_cast mt nat.dvd_one.mp (hp.ne_one) },
{ intros n hn,
rw mem_span_singleton,
rw [degree_Phi, with_bot.coe_lt_coe] at hn,
interval_cases n with hn;
simp only [Φ, coeff_X_pow, coeff_C, int.coe_nat_dvd.mpr, hpb, if_true, coeff_C_mul, if_false,
nat.zero_ne_bit1, eq_self_iff_true, coeff_X_zero, hpa, coeff_add, zero_add, mul_zero,
int.nat_cast_eq_coe_nat, coeff_sub, sub_self, nat.one_ne_zero, add_zero, coeff_X_one, mul_one,
zero_sub, dvd_neg, nat.one_eq_bit1, bit0_eq_zero, neg_zero, nat.bit0_ne_bit1,
dvd_mul_of_dvd_left, nat.bit1_eq_bit1, nat.one_ne_bit0, nat.bit1_ne_zero], },
{ simp only [degree_Phi, ←with_bot.coe_zero, with_bot.coe_lt_coe, nat.succ_pos'] },
{ rw [coeff_zero_Phi, span_singleton_pow, mem_span_singleton, int.nat_cast_eq_coe_nat],
exact mt int.coe_nat_dvd.mp hp2b },
all_goals { exact monic.is_primitive (monic_Phi a b) },
end
lemma real_roots_Phi_le : fintype.card ((Φ ℚ a b).root_set ℝ) ≤ 3 :=
begin
rw [←map_Phi a b (algebra_map ℤ ℚ), Φ, ←one_mul (X ^ 5), ←C_1],
refine (card_root_set_le_derivative _).trans
(nat.succ_le_succ ((card_root_set_le_derivative _).trans (nat.succ_le_succ _))),
suffices : ((C ((algebra_map ℤ ℚ) 20) * X ^ 3).root_set ℝ).subsingleton,
{ norm_num [fintype.card_le_one_iff_subsingleton, ← mul_assoc, *] at * },
rw root_set_C_mul_X_pow; norm_num,
end
lemma real_roots_Phi_ge_aux (hab : b < a) :
∃ x y : ℝ, x ≠ y ∧ aeval x (Φ ℚ a b) = 0 ∧ aeval y (Φ ℚ a b) = 0 :=
begin
let f := λ x : ℝ, aeval x (Φ ℚ a b),
have hf : f = λ x, x ^ 5 - a * x + b := by simp [f, Φ],
have hc : ∀ s : set ℝ, continuous_on f s := λ s, (Φ ℚ a b).continuous_on_aeval,
have ha : (1 : ℝ) ≤ a := nat.one_le_cast.mpr (nat.one_le_of_lt hab),
have hle : (0 : ℝ) ≤ 1 := zero_le_one,
have hf0 : 0 ≤ f 0 := by norm_num [hf],
by_cases hb : (1 : ℝ) - a + b < 0,
{ have hf1 : f 1 < 0 := by norm_num [hf, hb],
have hfa : 0 ≤ f a,
{ simp_rw [hf, ←sq],
refine add_nonneg (sub_nonneg.mpr (pow_le_pow ha _)) _; norm_num },
obtain ⟨x, ⟨-, hx1⟩, hx2⟩ := intermediate_value_Ico' hle (hc _) (set.mem_Ioc.mpr ⟨hf1, hf0⟩),
obtain ⟨y, ⟨hy1, -⟩, hy2⟩ := intermediate_value_Ioc ha (hc _) (set.mem_Ioc.mpr ⟨hf1, hfa⟩),
exact ⟨x, y, (hx1.trans hy1).ne, hx2, hy2⟩ },
{ replace hb : (b : ℝ) = a - 1 := by linarith [show (b : ℝ) + 1 ≤ a, by exact_mod_cast hab],
have hf1 : f 1 = 0 := by norm_num [hf, hb],
have hfa := calc f (-a) = a ^ 2 - a ^ 5 + b : by norm_num [hf, ← sq]
... ≤ a ^ 2 - a ^ 3 + (a - 1) : by refine add_le_add (sub_le_sub_left
(pow_le_pow ha _) _) _; linarith
... = -(a - 1) ^ 2 * (a + 1) : by ring
... ≤ 0 : by nlinarith,
have ha' := neg_nonpos.mpr (hle.trans ha),
obtain ⟨x, ⟨-, hx1⟩, hx2⟩ := intermediate_value_Icc ha' (hc _) (set.mem_Icc.mpr ⟨hfa, hf0⟩),
exact ⟨x, 1, (hx1.trans_lt zero_lt_one).ne, hx2, hf1⟩ },
end
lemma real_roots_Phi_ge (hab : b < a) : 2 ≤ fintype.card ((Φ ℚ a b).root_set ℝ) :=
begin
have q_ne_zero : Φ ℚ a b ≠ 0 := (monic_Phi a b).ne_zero,
obtain ⟨x, y, hxy, hx, hy⟩ := real_roots_Phi_ge_aux a b hab,
have key : ↑({x, y} : finset ℝ) ⊆ (Φ ℚ a b).root_set ℝ,
{ simp [set.insert_subset, mem_root_set q_ne_zero, hx, hy] },
convert fintype.card_le_of_embedding (set.embedding_of_subset _ _ key),
simp only [finset.coe_sort_coe, fintype.card_coe, finset.card_singleton,
finset.card_insert_of_not_mem (mt finset.mem_singleton.mp hxy)]
end
lemma complex_roots_Phi (h : (Φ ℚ a b).separable) : fintype.card ((Φ ℚ a b).root_set ℂ) = 5 :=
(card_root_set_eq_nat_degree h (is_alg_closed.splits_codomain _)).trans (nat_degree_Phi a b)
lemma gal_Phi (hab : b < a) (h_irred : irreducible (Φ ℚ a b)) :
bijective (gal_action_hom (Φ ℚ a b) ℂ) :=
begin
apply gal_action_hom_bijective_of_prime_degree' h_irred,
{ norm_num [nat_degree_Phi] },
{ rw [complex_roots_Phi a b h_irred.separable, nat.succ_le_succ_iff],
exact (real_roots_Phi_le a b).trans (nat.le_succ 3) },
{ simp_rw [complex_roots_Phi a b h_irred.separable, nat.succ_le_succ_iff],
exact real_roots_Phi_ge a b hab },
end
theorem not_solvable_by_rad (p : ℕ) (x : ℂ) (hx : aeval x (Φ ℚ a b) = 0) (hab : b < a)
(hp : p.prime) (hpa : p ∣ a) (hpb : p ∣ b) (hp2b : ¬ p ^ 2 ∣ b) :
¬ is_solvable_by_rad ℚ x :=
begin
have h_irred := irreducible_Phi a b p hp hpa hpb hp2b,
apply mt (solvable_by_rad.is_solvable' h_irred hx),
introI h,
refine equiv.perm.not_solvable _ (le_of_eq _)
(solvable_of_surjective (gal_Phi a b hab h_irred).2),
rw_mod_cast [cardinal.mk_fintype, complex_roots_Phi a b h_irred.separable],
end
theorem not_solvable_by_rad' (x : ℂ) (hx : aeval x (Φ ℚ 4 2) = 0) :
¬ is_solvable_by_rad ℚ x :=
by apply not_solvable_by_rad 4 2 2 x hx; norm_num
/-- **Abel-Ruffini Theorem** -/
theorem exists_not_solvable_by_rad : ∃ x : ℂ, is_algebraic ℚ x ∧ ¬ is_solvable_by_rad ℚ x :=
begin
obtain ⟨x, hx⟩ := exists_root_of_splits (algebra_map ℚ ℂ)
(is_alg_closed.splits_codomain (Φ ℚ 4 2))
(ne_of_eq_of_ne (degree_Phi 4 2) (mt with_bot.coe_eq_coe.mp (nat.bit1_ne_zero 2))),
exact ⟨x, ⟨Φ ℚ 4 2, (monic_Phi 4 2).ne_zero, hx⟩, not_solvable_by_rad' x hx⟩,
end
end abel_ruffini
|
b0a2c5b3eb4c1222d43bf2c1ffc99b52ea78d41a | fcf3ffa92a3847189ca669cb18b34ef6b2ec2859 | /src/world2/level3.lean | 07005e82a4e5e012fd9048127f66e66abf9790fc | [
"Apache-2.0"
] | permissive | nomoid/lean-proofs | 4a80a97888699dee42b092b7b959b22d9aa0c066 | b9f03a24623d1a1d111d6c2bbf53c617e2596d6a | refs/heads/master | 1,674,955,317,080 | 1,607,475,706,000 | 1,607,475,706,000 | 314,104,281 | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 334 | lean | import mynat.definition
import mynat.add
namespace mynat
lemma succ_add (a b : mynat) : succ(a) + b = succ(a + b) :=
begin [nat_num_game]
induction b with d hd,
{
rw add_zero,
rw add_zero,
refl,
},
{
rw add_succ,
rw add_succ,
rw hd,
refl,
}
end
end mynat
|
b4c8471055b199b99bf598639262035179c7af18 | 9dc8cecdf3c4634764a18254e94d43da07142918 | /src/category_theory/preadditive/additive_functor.lean | da442099950a0aa61db557a02635fd0771151b12 | [
"Apache-2.0"
] | permissive | jcommelin/mathlib | d8456447c36c176e14d96d9e76f39841f69d2d9b | ee8279351a2e434c2852345c51b728d22af5a156 | refs/heads/master | 1,664,782,136,488 | 1,663,638,983,000 | 1,663,638,983,000 | 132,563,656 | 0 | 0 | Apache-2.0 | 1,663,599,929,000 | 1,525,760,539,000 | Lean | UTF-8 | Lean | false | false | 8,594 | lean | /-
Copyright (c) 2021 Adam Topaz. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Adam Topaz, Scott Morrison
-/
import category_theory.limits.exact_functor
import category_theory.limits.preserves.finite
import category_theory.limits.preserves.shapes.biproducts
import category_theory.preadditive.functor_category
/-!
# Additive Functors
A functor between two preadditive categories is called *additive*
provided that the induced map on hom types is a morphism of abelian
groups.
An additive functor between preadditive categories creates and preserves biproducts.
Conversely, if `F : C ⥤ D` is a functor between preadditive categories, where `C` has binary
biproducts, and if `F` preserves binary biproducts, then `F` is additive.
We also define the category of bundled additive functors.
# Implementation details
`functor.additive` is a `Prop`-valued class, defined by saying that for every two objects `X` and
`Y`, the map `F.map : (X ⟶ Y) → (F.obj X ⟶ F.obj Y)` is a morphism of abelian groups.
-/
universes v₁ v₂ u₁ u₂
namespace category_theory
/-- A functor `F` is additive provided `F.map` is an additive homomorphism. -/
class functor.additive {C D : Type*} [category C] [category D]
[preadditive C] [preadditive D] (F : C ⥤ D) : Prop :=
(map_add' : Π {X Y : C} {f g : X ⟶ Y}, F.map (f + g) = F.map f + F.map g . obviously)
section preadditive
namespace functor
section
variables {C D : Type*} [category C] [category D] [preadditive C]
[preadditive D] (F : C ⥤ D) [functor.additive F]
@[simp]
lemma map_add {X Y : C} {f g : X ⟶ Y} : F.map (f + g) = F.map f + F.map g :=
functor.additive.map_add'
/-- `F.map_add_hom` is an additive homomorphism whose underlying function is `F.map`. -/
@[simps {fully_applied := ff}]
def map_add_hom {X Y : C} : (X ⟶ Y) →+ (F.obj X ⟶ F.obj Y) :=
add_monoid_hom.mk' (λ f, F.map f) (λ f g, F.map_add)
lemma coe_map_add_hom {X Y : C} : ⇑(F.map_add_hom : (X ⟶ Y) →+ _) = @map C _ D _ F X Y := rfl
@[priority 100]
instance preserves_zero_morphisms_of_additive : preserves_zero_morphisms F :=
{ map_zero' := λ X Y, F.map_add_hom.map_zero }
instance : additive (𝟭 C) :=
{}
instance {E : Type*} [category E] [preadditive E] (G : D ⥤ E) [functor.additive G] :
additive (F ⋙ G) :=
{}
@[simp]
lemma map_neg {X Y : C} {f : X ⟶ Y} : F.map (-f) = - F.map f :=
(F.map_add_hom : (X ⟶ Y) →+ (F.obj X ⟶ F.obj Y)).map_neg _
@[simp]
lemma map_sub {X Y : C} {f g : X ⟶ Y} : F.map (f - g) = F.map f - F.map g :=
(F.map_add_hom : (X ⟶ Y) →+ (F.obj X ⟶ F.obj Y)).map_sub _ _
lemma map_nsmul {X Y : C} {f : X ⟶ Y} {n : ℕ} : F.map (n • f) = n • F.map f :=
(F.map_add_hom : (X ⟶ Y) →+ (F.obj X ⟶ F.obj Y)).map_nsmul _ _
-- You can alternatively just use `functor.map_smul` here, with an explicit `(r : ℤ)` argument.
lemma map_zsmul {X Y : C} {f : X ⟶ Y} {r : ℤ} : F.map (r • f) = r • F.map f :=
(F.map_add_hom : (X ⟶ Y) →+ (F.obj X ⟶ F.obj Y)).map_zsmul _ _
open_locale big_operators
@[simp]
lemma map_sum {X Y : C} {α : Type*} (f : α → (X ⟶ Y)) (s : finset α) :
F.map (∑ a in s, f a) = ∑ a in s, F.map (f a) :=
(F.map_add_hom : (X ⟶ Y) →+ _).map_sum f s
end
section induced_category
variables {C : Type*} {D : Type*} [category D] [preadditive D] (F : C → D)
instance induced_functor_additive : functor.additive (induced_functor F) := {}
end induced_category
section
-- To talk about preservation of biproducts we need to specify universes explicitly.
noncomputable theory
variables {C : Type u₁} {D : Type u₂} [category.{v₁} C] [category.{v₂} D]
[preadditive C] [preadditive D] (F : C ⥤ D)
open category_theory.limits
open category_theory.preadditive
@[priority 100]
instance preserves_finite_biproducts_of_additive [additive F] : preserves_finite_biproducts F :=
{ preserves := λ J _,
{ preserves := λ f,
{ preserves := λ b hb, by exactI is_bilimit_of_total _
begin
simp_rw [F.map_bicone_π, F.map_bicone_ι, ← F.map_comp, ← F.map_sum],
dsimp only [map_bicone_X],
simp_rw [← F.map_id],
refine congr_arg _ (hb.is_limit.hom_ext (λ j, hb.is_colimit.hom_ext (λ j', _))),
cases j, cases j',
dsimp only [limits.bicone.to_cone_π_app],
simp [sum_comp, comp_sum, bicone.ι_π, comp_dite, dite_comp],
end } } }
lemma additive_of_preserves_binary_biproducts [has_binary_biproducts C] [preserves_zero_morphisms F]
[preserves_binary_biproducts F] : additive F :=
{ map_add' := λ X Y f g, by rw [biprod.add_eq_lift_id_desc, F.map_comp, ← biprod.lift_map_biprod,
← biprod.map_biprod_hom_desc, category.assoc, iso.inv_hom_id_assoc, F.map_id,
biprod.add_eq_lift_id_desc] }
end
end functor
namespace equivalence
variables {C D : Type*} [category C] [category D] [preadditive C] [preadditive D]
instance inverse_additive (e : C ≌ D) [e.functor.additive] : e.inverse.additive :=
{ map_add' := λ X Y f g, by { apply e.functor.map_injective, simp, }, }
end equivalence
section
variables (C D : Type*) [category C] [category D] [preadditive C] [preadditive D]
/-- Bundled additive functors. -/
@[derive category, nolint has_nonempty_instance]
def AdditiveFunctor :=
full_subcategory (λ (F : C ⥤ D), F.additive)
infixr ` ⥤+ `:26 := AdditiveFunctor
instance : preadditive (C ⥤+ D) :=
preadditive.induced_category.category _
/-- An additive functor is in particular a functor. -/
@[derive full, derive faithful]
def AdditiveFunctor.forget : (C ⥤+ D) ⥤ (C ⥤ D) :=
full_subcategory_inclusion _
variables {C D}
/-- Turn an additive functor into an object of the category `AdditiveFunctor C D`. -/
def AdditiveFunctor.of (F : C ⥤ D) [F.additive] : C ⥤+ D :=
⟨F, infer_instance⟩
@[simp]
lemma AdditiveFunctor.of_fst (F : C ⥤ D) [F.additive] : (AdditiveFunctor.of F).1 = F :=
rfl
@[simp]
lemma AdditiveFunctor.forget_obj (F : C ⥤+ D) : (AdditiveFunctor.forget C D).obj F = F.1 :=
rfl
lemma AdditiveFunctor.forget_obj_of (F : C ⥤ D) [F.additive] :
(AdditiveFunctor.forget C D).obj (AdditiveFunctor.of F) = F :=
rfl
@[simp]
lemma AdditiveFunctor.forget_map (F G : C ⥤+ D) (α : F ⟶ G) :
(AdditiveFunctor.forget C D).map α = α :=
rfl
instance : functor.additive (AdditiveFunctor.forget C D) :=
{ map_add' := λ F G α β, rfl }
instance (F : C ⥤+ D) : functor.additive F.1 :=
F.2
end
section exact
open category_theory.limits
variables (C : Type u₁) (D : Type u₂) [category.{v₁} C] [category.{v₂} D] [preadditive C]
variables [preadditive D] [has_zero_object C] [has_zero_object D] [has_binary_biproducts C]
section
local attribute [instance] preserves_binary_biproducts_of_preserves_binary_products
local attribute [instance] preserves_binary_biproducts_of_preserves_binary_coproducts
/-- Turn a left exact functor into an additive functor. -/
@[derive full, derive faithful]
def AdditiveFunctor.of_left_exact : (C ⥤ₗ D) ⥤ (C ⥤+ D) :=
full_subcategory.map (λ F h, let hF := classical.choice h in
by exactI functor.additive_of_preserves_binary_biproducts F)
/-- Turn a right exact functor into an additive functor. -/
@[derive full, derive faithful]
def AdditiveFunctor.of_right_exact : (C ⥤ᵣ D) ⥤ (C ⥤+ D) :=
full_subcategory.map (λ F h, let hF := classical.choice h in
by exactI functor.additive_of_preserves_binary_biproducts F)
/-- Turn an exact functor into an additive functor. -/
@[derive full, derive faithful]
def AdditiveFunctor.of_exact : (C ⥤ₑ D) ⥤ (C ⥤+ D) :=
full_subcategory.map (λ F h, let hF := classical.choice h.1 in
by exactI functor.additive_of_preserves_binary_biproducts F)
end
variables {C D}
@[simp] lemma AdditiveFunctor.of_left_exact_obj_fst (F : C ⥤ₗ D) :
((AdditiveFunctor.of_left_exact C D).obj F).obj = F.obj := rfl
@[simp] lemma AdditiveFunctor.of_right_exact_obj_fst (F : C ⥤ᵣ D) :
((AdditiveFunctor.of_right_exact C D).obj F).obj = F.obj := rfl
@[simp] lemma AdditiveFunctor.of_exact_obj_fst (F : C ⥤ₑ D) :
((AdditiveFunctor.of_exact C D).obj F).obj = F.obj := rfl
@[simp] lemma Additive_Functor.of_left_exact_map {F G : C ⥤ₗ D} (α : F ⟶ G) :
(AdditiveFunctor.of_left_exact C D).map α = α := rfl
@[simp] lemma Additive_Functor.of_right_exact_map {F G : C ⥤ᵣ D} (α : F ⟶ G) :
(AdditiveFunctor.of_right_exact C D).map α = α := rfl
@[simp] lemma Additive_Functor.of_exact_map {F G : C ⥤ₑ D} (α : F ⟶ G) :
(AdditiveFunctor.of_exact C D).map α = α := rfl
end exact
end preadditive
end category_theory
|
3fb985c4a84b547337eb3094b261b75a577253ce | 94e33a31faa76775069b071adea97e86e218a8ee | /src/ring_theory/localization/integral.lean | a47c23d4295b28f7e94e6762c68fac676f822e04 | [
"Apache-2.0"
] | permissive | urkud/mathlib | eab80095e1b9f1513bfb7f25b4fa82fa4fd02989 | 6379d39e6b5b279df9715f8011369a301b634e41 | refs/heads/master | 1,658,425,342,662 | 1,658,078,703,000 | 1,658,078,703,000 | 186,910,338 | 0 | 0 | Apache-2.0 | 1,568,512,083,000 | 1,557,958,709,000 | Lean | UTF-8 | Lean | false | false | 17,426 | lean | /-
Copyright (c) 2018 Kenny Lau. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kenny Lau, Mario Carneiro, Johan Commelin, Amelia Livingston, Anne Baanen
-/
import algebra.ring.equiv
import group_theory.monoid_localization
import ring_theory.algebraic
import ring_theory.ideal.local_ring
import ring_theory.ideal.quotient
import ring_theory.integral_closure
import ring_theory.localization.fraction_ring
import ring_theory.localization.integer
import ring_theory.non_zero_divisors
import group_theory.submonoid.inverses
import tactic.ring_exp
/-!
# Integral and algebraic elements of a fraction field
## Implementation notes
See `src/ring_theory/localization/basic.lean` for a design overview.
## Tags
localization, ring localization, commutative ring localization, characteristic predicate,
commutative ring, field of fractions
-/
variables {R : Type*} [comm_ring R] (M : submonoid R) {S : Type*} [comm_ring S]
variables [algebra R S] {P : Type*} [comm_ring P]
open_locale big_operators polynomial
namespace is_localization
section integer_normalization
open polynomial
variables (M) {S} [is_localization M S]
open_locale classical
/-- `coeff_integer_normalization p` gives the coefficients of the polynomial
`integer_normalization p` -/
noncomputable def coeff_integer_normalization (p : S[X]) (i : ℕ) : R :=
if hi : i ∈ p.support
then classical.some (classical.some_spec
(exist_integer_multiples_of_finset M (p.support.image p.coeff))
(p.coeff i)
(finset.mem_image.mpr ⟨i, hi, rfl⟩))
else 0
lemma coeff_integer_normalization_of_not_mem_support (p : S[X]) (i : ℕ)
(h : coeff p i = 0) : coeff_integer_normalization M p i = 0 :=
by simp only [coeff_integer_normalization, h, mem_support_iff, eq_self_iff_true, not_true,
ne.def, dif_neg, not_false_iff]
lemma coeff_integer_normalization_mem_support (p : S[X]) (i : ℕ)
(h : coeff_integer_normalization M p i ≠ 0) : i ∈ p.support :=
begin
contrapose h,
rw [ne.def, not_not, coeff_integer_normalization, dif_neg h]
end
/-- `integer_normalization g` normalizes `g` to have integer coefficients
by clearing the denominators -/
noncomputable def integer_normalization (p : S[X]) :
R[X] :=
∑ i in p.support, monomial i (coeff_integer_normalization M p i)
@[simp]
lemma integer_normalization_coeff (p : S[X]) (i : ℕ) :
(integer_normalization M p).coeff i = coeff_integer_normalization M p i :=
by simp [integer_normalization, coeff_monomial, coeff_integer_normalization_of_not_mem_support]
{contextual := tt}
lemma integer_normalization_spec (p : S[X]) :
∃ (b : M), ∀ i,
algebra_map R S ((integer_normalization M p).coeff i) = (b : R) • p.coeff i :=
begin
use classical.some (exist_integer_multiples_of_finset M (p.support.image p.coeff)),
intro i,
rw [integer_normalization_coeff, coeff_integer_normalization],
split_ifs with hi,
{ exact classical.some_spec (classical.some_spec
(exist_integer_multiples_of_finset M (p.support.image p.coeff))
(p.coeff i)
(finset.mem_image.mpr ⟨i, hi, rfl⟩)) },
{ convert (smul_zero _).symm,
{ apply ring_hom.map_zero },
{ exact not_mem_support_iff.mp hi } }
end
lemma integer_normalization_map_to_map (p : S[X]) :
∃ (b : M), (integer_normalization M p).map (algebra_map R S) = (b : R) • p :=
let ⟨b, hb⟩ := integer_normalization_spec M p in
⟨b, polynomial.ext (λ i, by { rw [coeff_map, coeff_smul], exact hb i })⟩
variables {R' : Type*} [comm_ring R']
lemma integer_normalization_eval₂_eq_zero (g : S →+* R') (p : S[X])
{x : R'} (hx : eval₂ g x p = 0) :
eval₂ (g.comp (algebra_map R S)) x (integer_normalization M p) = 0 :=
let ⟨b, hb⟩ := integer_normalization_map_to_map M p in
trans (eval₂_map (algebra_map R S) g x).symm
(by rw [hb, ← is_scalar_tower.algebra_map_smul S (b : R) p, eval₂_smul, hx, mul_zero])
lemma integer_normalization_aeval_eq_zero [algebra R R'] [algebra S R'] [is_scalar_tower R S R']
(p : S[X]) {x : R'} (hx : aeval x p = 0) :
aeval x (integer_normalization M p) = 0 :=
by rw [aeval_def, is_scalar_tower.algebra_map_eq R S R',
integer_normalization_eval₂_eq_zero _ _ _ hx]
end integer_normalization
end is_localization
namespace is_fraction_ring
open is_localization
variables {A K C : Type*} [comm_ring A] [is_domain A] [field K] [algebra A K] [is_fraction_ring A K]
variables [comm_ring C]
lemma integer_normalization_eq_zero_iff {p : K[X]} :
integer_normalization (non_zero_divisors A) p = 0 ↔ p = 0 :=
begin
refine (polynomial.ext_iff.trans (polynomial.ext_iff.trans _).symm),
obtain ⟨⟨b, nonzero⟩, hb⟩ := integer_normalization_spec _ p,
split; intros h i,
{ apply to_map_eq_zero_iff.mp,
rw [hb i, h i],
apply smul_zero,
assumption },
{ have hi := h i,
rw [polynomial.coeff_zero, ← @to_map_eq_zero_iff A _ K, hb i, algebra.smul_def] at hi,
apply or.resolve_left (eq_zero_or_eq_zero_of_mul_eq_zero hi),
intro h,
apply mem_non_zero_divisors_iff_ne_zero.mp nonzero,
exact to_map_eq_zero_iff.mp h }
end
variables (A K C)
/-- An element of a ring is algebraic over the ring `A` iff it is algebraic
over the field of fractions of `A`.
-/
lemma is_algebraic_iff [algebra A C] [algebra K C] [is_scalar_tower A K C] {x : C} :
is_algebraic A x ↔ is_algebraic K x :=
begin
split; rintros ⟨p, hp, px⟩,
{ refine ⟨p.map (algebra_map A K), λ h, hp (polynomial.ext (λ i, _)), _⟩,
{ have : algebra_map A K (p.coeff i) = 0 := trans (polynomial.coeff_map _ _).symm (by simp [h]),
exact to_map_eq_zero_iff.mp this },
{ rwa is_scalar_tower.aeval_apply _ K at px } },
{ exact ⟨integer_normalization _ p,
mt integer_normalization_eq_zero_iff.mp hp,
integer_normalization_aeval_eq_zero _ p px⟩ },
end
variables {A K C}
/-- A ring is algebraic over the ring `A` iff it is algebraic over the field of fractions of `A`.
-/
lemma comap_is_algebraic_iff [algebra A C] [algebra K C] [is_scalar_tower A K C] :
algebra.is_algebraic A C ↔ algebra.is_algebraic K C :=
⟨λ h x, (is_algebraic_iff A K C).mp (h x), λ h x, (is_algebraic_iff A K C).mpr (h x)⟩
end is_fraction_ring
open is_localization
section is_integral
variables {R S} {Rₘ Sₘ : Type*} [comm_ring Rₘ] [comm_ring Sₘ]
variables [algebra R Rₘ] [is_localization M Rₘ]
variables [algebra S Sₘ] [is_localization (algebra.algebra_map_submonoid S M) Sₘ]
variables {S M}
open polynomial
lemma ring_hom.is_integral_elem_localization_at_leading_coeff
{R S : Type*} [comm_ring R] [comm_ring S] (f : R →+* S)
(x : S) (p : R[X]) (hf : p.eval₂ f x = 0) (M : submonoid R)
(hM : p.leading_coeff ∈ M) {Rₘ Sₘ : Type*} [comm_ring Rₘ] [comm_ring Sₘ]
[algebra R Rₘ] [is_localization M Rₘ]
[algebra S Sₘ] [is_localization (M.map f : submonoid S) Sₘ] :
(map Sₘ f M.le_comap_map : Rₘ →+* _).is_integral_elem (algebra_map S Sₘ x) :=
begin
by_cases triv : (1 : Rₘ) = 0,
{ exact ⟨0, ⟨trans leading_coeff_zero triv.symm, eval₂_zero _ _⟩⟩ },
haveI : nontrivial Rₘ := nontrivial_of_ne 1 0 triv,
obtain ⟨b, hb⟩ := is_unit_iff_exists_inv.mp
(map_units Rₘ ⟨p.leading_coeff, hM⟩),
refine ⟨(p.map (algebra_map R Rₘ)) * C b, ⟨_, _⟩⟩,
{ refine monic_mul_C_of_leading_coeff_mul_eq_one _,
rwa leading_coeff_map_of_leading_coeff_ne_zero (algebra_map R Rₘ),
refine λ hfp, zero_ne_one (trans (zero_mul b).symm (hfp ▸ hb) : (0 : Rₘ) = 1) },
{ refine eval₂_mul_eq_zero_of_left _ _ _ _,
erw [eval₂_map, is_localization.map_comp, ← hom_eval₂ _ f (algebra_map S Sₘ) x],
exact trans (congr_arg (algebra_map S Sₘ) hf) (ring_hom.map_zero _) }
end
/-- Given a particular witness to an element being algebraic over an algebra `R → S`,
We can localize to a submonoid containing the leading coefficient to make it integral.
Explicitly, the map between the localizations will be an integral ring morphism -/
theorem is_integral_localization_at_leading_coeff {x : S} (p : R[X])
(hp : aeval x p = 0) (hM : p.leading_coeff ∈ M) :
(map Sₘ (algebra_map R S)
(show _ ≤ (algebra.algebra_map_submonoid S M).comap _, from M.le_comap_map)
: Rₘ →+* _).is_integral_elem (algebra_map S Sₘ x) :=
(algebra_map R S).is_integral_elem_localization_at_leading_coeff x p hp M hM
/-- If `R → S` is an integral extension, `M` is a submonoid of `R`,
`Rₘ` is the localization of `R` at `M`,
and `Sₘ` is the localization of `S` at the image of `M` under the extension map,
then the induced map `Rₘ → Sₘ` is also an integral extension -/
theorem is_integral_localization (H : algebra.is_integral R S) :
(map Sₘ (algebra_map R S)
(show _ ≤ (algebra.algebra_map_submonoid S M).comap _, from M.le_comap_map)
: Rₘ →+* _).is_integral :=
begin
intro x,
obtain ⟨⟨s, ⟨u, hu⟩⟩, hx⟩ := surj (algebra.algebra_map_submonoid S M) x,
obtain ⟨v, hv⟩ := hu,
obtain ⟨v', hv'⟩ := is_unit_iff_exists_inv'.1 (map_units Rₘ ⟨v, hv.1⟩),
refine @is_integral_of_is_integral_mul_unit Rₘ _ _ _
(localization_algebra M S) x (algebra_map S Sₘ u) v' _ _,
{ replace hv' := congr_arg (@algebra_map Rₘ Sₘ _ _ (localization_algebra M S)) hv',
rw [ring_hom.map_mul, ring_hom.map_one, ← ring_hom.comp_apply _ (algebra_map R Rₘ)] at hv',
erw is_localization.map_comp at hv',
exact hv.2 ▸ hv' },
{ obtain ⟨p, hp⟩ := H s,
exact hx.symm ▸ is_integral_localization_at_leading_coeff p hp.2 (hp.1.symm ▸ M.one_mem) }
end
lemma is_integral_localization' {R S : Type*} [comm_ring R] [comm_ring S]
{f : R →+* S} (hf : f.is_integral) (M : submonoid R) :
(map (localization (M.map (f : R →* S))) f
(M.le_comap_map : _ ≤ submonoid.comap (f : R →* S) _) : localization M →+* _).is_integral :=
@is_integral_localization R _ M S _ f.to_algebra _ _ _ _ _ _ _ _ hf
end is_integral
variables {A K : Type*} [comm_ring A] [is_domain A]
namespace is_integral_closure
variables (A) {L : Type*} [field K] [field L] [algebra A K] [algebra A L] [is_fraction_ring A K]
variables (C : Type*) [comm_ring C] [is_domain C] [algebra C L] [is_integral_closure C A L]
variables [algebra A C] [is_scalar_tower A C L]
open algebra
/-- If the field `L` is an algebraic extension of the integral domain `A`,
the integral closure `C` of `A` in `L` has fraction field `L`. -/
lemma is_fraction_ring_of_algebraic (alg : is_algebraic A L)
(inj : ∀ x, algebra_map A L x = 0 → x = 0) :
is_fraction_ring C L :=
{ map_units := λ ⟨y, hy⟩,
is_unit.mk0 _ (show algebra_map C L y ≠ 0, from λ h, mem_non_zero_divisors_iff_ne_zero.mp hy
((injective_iff_map_eq_zero (algebra_map C L)).mp (algebra_map_injective C A L) _ h)),
surj := λ z, let ⟨x, y, hy, hxy⟩ := exists_integral_multiple (alg z) inj in
⟨⟨mk' C (x : L) x.2, algebra_map _ _ y,
mem_non_zero_divisors_iff_ne_zero.mpr (λ h, hy (inj _
(by rw [is_scalar_tower.algebra_map_apply A C L, h, ring_hom.map_zero])))⟩,
by rw [set_like.coe_mk, algebra_map_mk', ← is_scalar_tower.algebra_map_apply A C L, hxy]⟩,
eq_iff_exists := λ x y, ⟨λ h, ⟨1, by simpa using algebra_map_injective C A L h⟩, λ ⟨c, hc⟩,
congr_arg (algebra_map _ L) (mul_right_cancel₀ (mem_non_zero_divisors_iff_ne_zero.mp c.2) hc)⟩ }
variables (K L)
/-- If the field `L` is a finite extension of the fraction field of the integral domain `A`,
the integral closure `C` of `A` in `L` has fraction field `L`. -/
lemma is_fraction_ring_of_finite_extension [algebra K L] [is_scalar_tower A K L]
[finite_dimensional K L] : is_fraction_ring C L :=
is_fraction_ring_of_algebraic A C
(is_fraction_ring.comap_is_algebraic_iff.mpr (is_algebraic_of_finite K L))
(λ x hx, is_fraction_ring.to_map_eq_zero_iff.mp ((algebra_map K L).map_eq_zero.mp $
(is_scalar_tower.algebra_map_apply _ _ _ _).symm.trans hx))
end is_integral_closure
namespace integral_closure
variables {L : Type*} [field K] [field L] [algebra A K] [is_fraction_ring A K]
open algebra
/-- If the field `L` is an algebraic extension of the integral domain `A`,
the integral closure of `A` in `L` has fraction field `L`. -/
lemma is_fraction_ring_of_algebraic [algebra A L] (alg : is_algebraic A L)
(inj : ∀ x, algebra_map A L x = 0 → x = 0) :
is_fraction_ring (integral_closure A L) L :=
is_integral_closure.is_fraction_ring_of_algebraic A (integral_closure A L) alg inj
variables (K L)
/-- If the field `L` is a finite extension of the fraction field of the integral domain `A`,
the integral closure of `A` in `L` has fraction field `L`. -/
lemma is_fraction_ring_of_finite_extension [algebra A L] [algebra K L]
[is_scalar_tower A K L] [finite_dimensional K L] :
is_fraction_ring (integral_closure A L) L :=
is_integral_closure.is_fraction_ring_of_finite_extension A K L (integral_closure A L)
end integral_closure
namespace is_fraction_ring
variables (R S K)
/-- `S` is algebraic over `R` iff a fraction ring of `S` is algebraic over `R` -/
lemma is_algebraic_iff' [field K] [is_domain R] [is_domain S] [algebra R K] [algebra S K]
[no_zero_smul_divisors R K] [is_fraction_ring S K] [is_scalar_tower R S K] :
algebra.is_algebraic R S ↔ algebra.is_algebraic R K :=
begin
simp only [algebra.is_algebraic],
split,
{ intros h x,
rw [is_fraction_ring.is_algebraic_iff R (fraction_ring R) K, is_algebraic_iff_is_integral],
obtain ⟨(a : S), b, ha, rfl⟩ := @div_surjective S _ _ _ _ _ _ x,
obtain ⟨f, hf₁, hf₂⟩ := h b,
rw [div_eq_mul_inv],
refine is_integral_mul _ _,
{ rw [← is_algebraic_iff_is_integral],
refine _root_.is_algebraic_of_larger_base_of_injective
(no_zero_smul_divisors.algebra_map_injective R (fraction_ring R)) _,
exact is_algebraic_algebra_map_of_is_algebraic (h a) },
{ rw [← is_algebraic_iff_is_integral],
use (f.map (algebra_map R (fraction_ring R))).reverse,
split,
{ rwa [ne.def, polynomial.reverse_eq_zero, ← polynomial.degree_eq_bot,
polynomial.degree_map_eq_of_injective
(no_zero_smul_divisors.algebra_map_injective R (fraction_ring R)),
polynomial.degree_eq_bot]},
{ haveI : invertible (algebra_map S K b),
from is_unit.invertible (is_unit_of_mem_non_zero_divisors
(mem_non_zero_divisors_iff_ne_zero.2
(λ h, non_zero_divisors.ne_zero ha
((injective_iff_map_eq_zero (algebra_map S K)).1
(no_zero_smul_divisors.algebra_map_injective _ _) b h)))),
rw [polynomial.aeval_def, ← inv_of_eq_inv, polynomial.eval₂_reverse_eq_zero_iff,
polynomial.eval₂_map, ← is_scalar_tower.algebra_map_eq, ← polynomial.aeval_def,
← is_scalar_tower.algebra_map_aeval, hf₂, ring_hom.map_zero] } } },
{ intros h x,
obtain ⟨f, hf₁, hf₂⟩ := h (algebra_map S K x),
use [f, hf₁],
rw [← is_scalar_tower.algebra_map_aeval] at hf₂,
exact (injective_iff_map_eq_zero (algebra_map S K)).1
(no_zero_smul_divisors.algebra_map_injective _ _) _ hf₂ }
end
open_locale non_zero_divisors
variables (R) {S K}
/-- If the `S`-multiples of `a` are contained in some `R`-span, then `Frac(S)`-multiples of `a`
are contained in the equivalent `Frac(R)`-span. -/
lemma ideal_span_singleton_map_subset {L : Type*}
[is_domain R] [is_domain S] [field K] [field L]
[algebra R K] [algebra R L] [algebra S L] [is_integral_closure S R L]
[is_fraction_ring S L] [algebra K L] [is_scalar_tower R S L] [is_scalar_tower R K L]
{a : S} {b : set S} (alg : algebra.is_algebraic R L) (inj : function.injective (algebra_map R L))
(h : (ideal.span ({a} : set S) : set S) ⊆ submodule.span R b) :
(ideal.span ({algebra_map S L a} : set L) : set L) ⊆ submodule.span K (algebra_map S L '' b) :=
begin
intros x hx,
obtain ⟨x', rfl⟩ := ideal.mem_span_singleton.mp hx,
obtain ⟨y', z', rfl⟩ := is_localization.mk'_surjective (S⁰) x',
obtain ⟨y, z, hz0, yz_eq⟩ := is_integral_closure.exists_smul_eq_mul alg inj y'
(non_zero_divisors.coe_ne_zero z'),
have injRS : function.injective (algebra_map R S),
{ refine function.injective.of_comp
(show function.injective (algebra_map S L ∘ algebra_map R S), from _),
rwa [← ring_hom.coe_comp, ← is_scalar_tower.algebra_map_eq] },
have hz0' : algebra_map R S z ∈ S⁰ := map_mem_non_zero_divisors (algebra_map R S) injRS
(mem_non_zero_divisors_of_ne_zero hz0),
have mk_yz_eq : is_localization.mk' L y' z' = is_localization.mk' L y ⟨_, hz0'⟩,
{ rw [algebra.smul_def, mul_comm _ y, mul_comm _ y', ← set_like.coe_mk (algebra_map R S z) hz0']
at yz_eq,
exact is_localization.mk'_eq_of_eq yz_eq.symm },
suffices hy : algebra_map S L (a * y) ∈ submodule.span K (⇑(algebra_map S L) '' b),
{ rw [mk_yz_eq, is_fraction_ring.mk'_eq_div, set_like.coe_mk,
← is_scalar_tower.algebra_map_apply, is_scalar_tower.algebra_map_apply R K L,
div_eq_mul_inv, ← mul_assoc, mul_comm, ← ring_hom.map_inv, ← algebra.smul_def,
← _root_.map_mul],
exact (submodule.span K _).smul_mem _ hy },
refine submodule.span_subset_span R K _ _,
rw submodule.span_algebra_map_image_of_tower,
exact submodule.mem_map_of_mem (h (ideal.mem_span_singleton.mpr ⟨y, rfl⟩))
end
end is_fraction_ring
|
7d03700a758b075e02882d1fb1b42e86ed41c546 | 74addaa0e41490cbaf2abd313a764c96df57b05d | /Mathlib/data/bool_auto.lean | edfb011a03902fd79e3f9053940990ac213ea4a6 | [] | no_license | AurelienSaue/Mathlib4_auto | f538cfd0980f65a6361eadea39e6fc639e9dae14 | 590df64109b08190abe22358fabc3eae000943f2 | refs/heads/master | 1,683,906,849,776 | 1,622,564,669,000 | 1,622,564,669,000 | 371,723,747 | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 6,951 | lean | /-
Copyright (c) 2014 Microsoft Corporation. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Author: Leonardo de Moura, Jeremy Avigad
-/
import Mathlib.PrePort
import Mathlib.Lean3Lib.init.default
import Mathlib.PostPort
universes u_1
namespace Mathlib
/-!
# booleans
This file proves various trivial lemmas about booleans and their
relation to decidable propositions.
## Notations
This file introduces the notation `!b` for `bnot b`, the boolean "not".
## Tags
bool, boolean, De Morgan
-/
namespace bool
prefix:90 "!" => Mathlib.bnot
@[simp] theorem coe_sort_tt : ↥tt = True := eq_true_intro rfl
@[simp] theorem coe_sort_ff : ↥false = False := eq_false_intro ff_ne_tt
@[simp] theorem to_bool_true {h : Decidable True} : to_bool True = tt := sorry
@[simp] theorem to_bool_false {h : Decidable False} : to_bool False = false := sorry
@[simp] theorem to_bool_coe (b : Bool) {h : Decidable ↥b} : to_bool ↥b = b := sorry
theorem coe_to_bool (p : Prop) [Decidable p] : ↥(to_bool p) ↔ p := to_bool_iff p
@[simp] theorem of_to_bool_iff {p : Prop} [Decidable p] : ↥(to_bool p) ↔ p :=
{ mp := of_to_bool_true, mpr := to_bool_true }
@[simp] theorem tt_eq_to_bool_iff {p : Prop} [Decidable p] : tt = to_bool p ↔ p :=
iff.trans eq_comm of_to_bool_iff
@[simp] theorem ff_eq_to_bool_iff {p : Prop} [Decidable p] : false = to_bool p ↔ ¬p :=
iff.trans eq_comm (to_bool_ff_iff p)
@[simp] theorem to_bool_not (p : Prop) [Decidable p] : to_bool (¬p) = !to_bool p := sorry
@[simp] theorem to_bool_and (p : Prop) (q : Prop) [Decidable p] [Decidable q] :
to_bool (p ∧ q) = to_bool p && to_bool q :=
sorry
@[simp] theorem to_bool_or (p : Prop) (q : Prop) [Decidable p] [Decidable q] :
to_bool (p ∨ q) = to_bool p || to_bool q :=
sorry
@[simp] theorem to_bool_eq {p : Prop} {q : Prop} [Decidable p] [Decidable q] :
to_bool p = to_bool q ↔ (p ↔ q) :=
sorry
theorem not_ff : ¬↥false := sorry
@[simp] theorem default_bool : Inhabited.default = false := rfl
theorem dichotomy (b : Bool) : b = false ∨ b = tt := sorry
@[simp] theorem forall_bool {p : Bool → Prop} : (∀ (b : Bool), p b) ↔ p false ∧ p tt := sorry
@[simp] theorem exists_bool {p : Bool → Prop} : (∃ (b : Bool), p b) ↔ p false ∨ p tt := sorry
/-- If `p b` is decidable for all `b : bool`, then `∀ b, p b` is decidable -/
protected instance decidable_forall_bool {p : Bool → Prop} [(b : Bool) → Decidable (p b)] :
Decidable (∀ (b : Bool), p b) :=
decidable_of_decidable_of_iff and.decidable sorry
/-- If `p b` is decidable for all `b : bool`, then `∃ b, p b` is decidable -/
protected instance decidable_exists_bool {p : Bool → Prop} [(b : Bool) → Decidable (p b)] :
Decidable (∃ (b : Bool), p b) :=
decidable_of_decidable_of_iff or.decidable sorry
@[simp] theorem cond_ff {α : Type u_1} (t : α) (e : α) : cond false t e = e := rfl
@[simp] theorem cond_tt {α : Type u_1} (t : α) (e : α) : cond tt t e = t := rfl
@[simp] theorem cond_to_bool {α : Type u_1} (p : Prop) [Decidable p] (t : α) (e : α) :
cond (to_bool p) t e = ite p t e :=
sorry
theorem coe_bool_iff {a : Bool} {b : Bool} : ↥a ↔ ↥b ↔ a = b := of_as_true trivial
theorem eq_tt_of_ne_ff {a : Bool} : a ≠ false → a = tt := of_as_true trivial
theorem eq_ff_of_ne_tt {a : Bool} : a ≠ tt → a = false := of_as_true trivial
theorem bor_comm (a : Bool) (b : Bool) : a || b = b || a := of_as_true trivial
@[simp] theorem bor_assoc (a : Bool) (b : Bool) (c : Bool) : a || b || c = a || (b || c) :=
of_as_true trivial
theorem bor_left_comm (a : Bool) (b : Bool) (c : Bool) : a || (b || c) = b || (a || c) :=
of_as_true trivial
theorem bor_inl {a : Bool} {b : Bool} (H : ↥a) : ↥(a || b) := sorry
theorem bor_inr {a : Bool} {b : Bool} (H : ↥b) : ↥(a || b) := sorry
theorem band_comm (a : Bool) (b : Bool) : a && b = b && a := of_as_true trivial
@[simp] theorem band_assoc (a : Bool) (b : Bool) (c : Bool) : a && b && c = a && (b && c) :=
of_as_true trivial
theorem band_left_comm (a : Bool) (b : Bool) (c : Bool) : a && (b && c) = b && (a && c) :=
of_as_true trivial
theorem band_elim_left {a : Bool} {b : Bool} : ↥(a && b) → ↥a := of_as_true trivial
theorem band_intro {a : Bool} {b : Bool} : ↥a → ↥b → ↥(a && b) := of_as_true trivial
theorem band_elim_right {a : Bool} {b : Bool} : ↥(a && b) → ↥b := of_as_true trivial
@[simp] theorem bnot_false : !false = tt := rfl
@[simp] theorem bnot_true : !tt = false := rfl
theorem eq_tt_of_bnot_eq_ff {a : Bool} : !a = false → a = tt := of_as_true trivial
theorem eq_ff_of_bnot_eq_tt {a : Bool} : !a = tt → a = false := of_as_true trivial
theorem bxor_comm (a : Bool) (b : Bool) : bxor a b = bxor b a := of_as_true trivial
@[simp] theorem bxor_assoc (a : Bool) (b : Bool) (c : Bool) :
bxor (bxor a b) c = bxor a (bxor b c) :=
of_as_true trivial
theorem bxor_left_comm (a : Bool) (b : Bool) (c : Bool) : bxor a (bxor b c) = bxor b (bxor a c) :=
of_as_true trivial
@[simp] theorem bxor_bnot_left (a : Bool) : bxor (!a) a = tt := of_as_true trivial
@[simp] theorem bxor_bnot_right (a : Bool) : bxor a (!a) = tt := of_as_true trivial
@[simp] theorem bxor_bnot_bnot (a : Bool) (b : Bool) : bxor (!a) (!b) = bxor a b :=
of_as_true trivial
@[simp] theorem bxor_ff_left (a : Bool) : bxor false a = a := of_as_true trivial
@[simp] theorem bxor_ff_right (a : Bool) : bxor a false = a := of_as_true trivial
theorem bxor_iff_ne {x : Bool} {y : Bool} : bxor x y = tt ↔ x ≠ y := of_as_true trivial
/-! ### De Morgan's laws for booleans-/
@[simp] theorem bnot_band (a : Bool) (b : Bool) : !(a && b) = !a || !b := of_as_true trivial
@[simp] theorem bnot_bor (a : Bool) (b : Bool) : !(a || b) = !a && !b := of_as_true trivial
theorem bnot_inj {a : Bool} {b : Bool} : !a = !b → a = b := of_as_true trivial
end bool
protected instance bool.linear_order : linear_order Bool :=
linear_order.mk (fun (a b : Bool) => a = false ∨ b = tt)
(partial_order.lt._default fun (a b : Bool) => a = false ∨ b = tt) sorry sorry sorry sorry
infer_instance infer_instance infer_instance
namespace bool
@[simp] theorem ff_le {x : Bool} : false ≤ x := or.intro_left (x = tt) rfl
@[simp] theorem le_tt {x : Bool} : x ≤ tt := or.intro_right (x = false) rfl
@[simp] theorem ff_lt_tt : false < tt := lt_of_le_of_ne ff_le ff_ne_tt
/-- convert a `bool` to a `ℕ`, `false -> 0`, `true -> 1` -/
def to_nat (b : Bool) : ℕ := cond b 1 0
/-- convert a `ℕ` to a `bool`, `0 -> false`, everything else -> `true` -/
def of_nat (n : ℕ) : Bool := to_bool (n ≠ 0)
theorem of_nat_le_of_nat {n : ℕ} {m : ℕ} (h : n ≤ m) : of_nat n ≤ of_nat m := sorry
theorem to_nat_le_to_nat {b₀ : Bool} {b₁ : Bool} (h : b₀ ≤ b₁) : to_nat b₀ ≤ to_nat b₁ := sorry
theorem of_nat_to_nat (b : Bool) : of_nat (to_nat b) = b := sorry
end Mathlib |
f7380016b1381c5bf7fdf667883075a7db2cc72b | 4376c25f060c13471bb89cdb12aeac1d53e53876 | /Lean Game/world4_pow.lean | d673178053bc47d2e2522aaf6058876db7871078 | [
"MIT"
] | permissive | RaitoBezarius/projet-maths-lean | 8fa7df563d64c256561ab71893c523fc1424b85c | 42356e980e021a20c3468f5ca1639fec01bb934f | refs/heads/master | 1,613,002,128,339 | 1,589,289,282,000 | 1,589,289,282,000 | 244,431,534 | 0 | 1 | MIT | 1,584,312,574,000 | 1,583,169,883,000 | TeX | UTF-8 | Lean | false | false | 142 | lean | /- to be written
(feel free to write it, anyone! Just need stuff like
(a ^ b) ^ c = a^(b*c)
a^(b+c) = a^b*a^c
and other simpler stuff.
-/ |
68f31c59304eba14b0ed926ad0c1ce4c47935af7 | 137c667471a40116a7afd7261f030b30180468c2 | /src/analysis/convex/cone.lean | 959f5c4966584f3f80faf57f8c74d1727cee594c | [
"Apache-2.0"
] | permissive | bragadeesh153/mathlib | 46bf814cfb1eecb34b5d1549b9117dc60f657792 | b577bb2cd1f96eb47031878256856020b76f73cd | refs/heads/master | 1,687,435,188,334 | 1,626,384,207,000 | 1,626,384,207,000 | null | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 24,022 | lean | /-
Copyright (c) 2020 Yury Kudryashov All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury Kudryashov, Frédéric Dupuis
-/
import linear_algebra.linear_pmap
import analysis.convex.basic
import order.zorn
import analysis.normed_space.inner_product
/-!
# Convex cones
In a vector space `E` over `ℝ`, we define a convex cone as a subset `s` such that
`a • x + b • y ∈ s` whenever `x, y ∈ s` and `a, b > 0`. We prove that convex cones form
a `complete_lattice`, and define their images (`convex_cone.map`) and preimages
(`convex_cone.comap`) under linear maps.
We define pointed, blunt, flat and salient cones, and prove the correspondence between
convex cones and ordered modules.
We also define `convex.to_cone` to be the minimal cone that includes a given convex set.
We define `set.inner_dual_cone` to be the cone consisting of all points `y` such that for
all points `x` in a given set `0 ≤ ⟪ x, y ⟫`.
## Main statements
We prove two extension theorems:
* `riesz_extension`:
[M. Riesz extension theorem](https://en.wikipedia.org/wiki/M._Riesz_extension_theorem) says that
if `s` is a convex cone in a real vector space `E`, `p` is a submodule of `E`
such that `p + s = E`, and `f` is a linear function `p → ℝ` which is
nonnegative on `p ∩ s`, then there exists a globally defined linear function
`g : E → ℝ` that agrees with `f` on `p`, and is nonnegative on `s`.
* `exists_extension_of_le_sublinear`:
Hahn-Banach theorem: if `N : E → ℝ` is a sublinear map, `f` is a linear map
defined on a subspace of `E`, and `f x ≤ N x` for all `x` in the domain of `f`,
then `f` can be extended to the whole space to a linear map `g` such that `g x ≤ N x`
for all `x`
## Implementation notes
While `convex` is a predicate on sets, `convex_cone` is a bundled convex cone.
## References
* https://en.wikipedia.org/wiki/Convex_cone
-/
universes u v
open set linear_map
open_locale classical
variables (E : Type*) [add_comm_group E] [module ℝ E]
{F : Type*} [add_comm_group F] [module ℝ F]
{G : Type*} [add_comm_group G] [module ℝ G]
/-!
### Definition of `convex_cone` and basic properties
-/
/-- A convex cone is a subset `s` of a vector space over `ℝ` such that `a • x + b • y ∈ s`
whenever `a, b > 0` and `x, y ∈ s`. -/
structure convex_cone :=
(carrier : set E)
(smul_mem' : ∀ ⦃c : ℝ⦄, 0 < c → ∀ ⦃x : E⦄, x ∈ carrier → c • x ∈ carrier)
(add_mem' : ∀ ⦃x⦄ (hx : x ∈ carrier) ⦃y⦄ (hy : y ∈ carrier), x + y ∈ carrier)
variable {E}
namespace convex_cone
variables (S T : convex_cone E)
instance : has_coe (convex_cone E) (set E) := ⟨convex_cone.carrier⟩
instance : has_mem E (convex_cone E) := ⟨λ m S, m ∈ S.carrier⟩
instance : has_le (convex_cone E) := ⟨λ S T, S.carrier ⊆ T.carrier⟩
instance : has_lt (convex_cone E) := ⟨λ S T, S.carrier ⊂ T.carrier⟩
@[simp, norm_cast] lemma mem_coe {x : E} : x ∈ (S : set E) ↔ x ∈ S := iff.rfl
@[simp] lemma mem_mk {s : set E} {h₁ h₂ x} : x ∈ mk s h₁ h₂ ↔ x ∈ s := iff.rfl
/-- Two `convex_cone`s are equal if the underlying subsets are equal. -/
theorem ext' {S T : convex_cone E} (h : (S : set E) = T) : S = T :=
by cases S; cases T; congr'
/-- Two `convex_cone`s are equal if and only if the underlying subsets are equal. -/
protected theorem ext'_iff {S T : convex_cone E} : (S : set E) = T ↔ S = T :=
⟨ext', λ h, h ▸ rfl⟩
/-- Two `convex_cone`s are equal if they have the same elements. -/
@[ext] theorem ext {S T : convex_cone E} (h : ∀ x, x ∈ S ↔ x ∈ T) : S = T := ext' $ set.ext h
lemma smul_mem {c : ℝ} {x : E} (hc : 0 < c) (hx : x ∈ S) : c • x ∈ S := S.smul_mem' hc hx
lemma add_mem ⦃x⦄ (hx : x ∈ S) ⦃y⦄ (hy : y ∈ S) : x + y ∈ S := S.add_mem' hx hy
lemma smul_mem_iff {c : ℝ} (hc : 0 < c) {x : E} :
c • x ∈ S ↔ x ∈ S :=
⟨λ h, by simpa only [smul_smul, inv_mul_cancel (ne_of_gt hc), one_smul]
using S.smul_mem (inv_pos.2 hc) h, λ h, S.smul_mem hc h⟩
lemma convex : convex (S : set E) :=
convex_iff_forall_pos.2 $ λ x y hx hy a b ha hb hab,
S.add_mem (S.smul_mem ha hx) (S.smul_mem hb hy)
instance : has_inf (convex_cone E) :=
⟨λ S T, ⟨S ∩ T, λ c hc x hx, ⟨S.smul_mem hc hx.1, T.smul_mem hc hx.2⟩,
λ x hx y hy, ⟨S.add_mem hx.1 hy.1, T.add_mem hx.2 hy.2⟩⟩⟩
lemma coe_inf : ((S ⊓ T : convex_cone E) : set E) = ↑S ∩ ↑T := rfl
lemma mem_inf {x} : x ∈ S ⊓ T ↔ x ∈ S ∧ x ∈ T := iff.rfl
instance : has_Inf (convex_cone E) :=
⟨λ S, ⟨⋂ s ∈ S, ↑s,
λ c hc x hx, mem_bInter $ λ s hs, s.smul_mem hc $ by apply mem_bInter_iff.1 hx s hs,
λ x hx y hy, mem_bInter $ λ s hs, s.add_mem (by apply mem_bInter_iff.1 hx s hs)
(by apply mem_bInter_iff.1 hy s hs)⟩⟩
lemma mem_Inf {x : E} {S : set (convex_cone E)} : x ∈ Inf S ↔ ∀ s ∈ S, x ∈ s := mem_bInter_iff
instance : has_bot (convex_cone E) := ⟨⟨∅, λ c hc x, false.elim, λ x, false.elim⟩⟩
lemma mem_bot (x : E) : x ∈ (⊥ : convex_cone E) = false := rfl
instance : has_top (convex_cone E) := ⟨⟨univ, λ c hc x hx, mem_univ _, λ x hx y hy, mem_univ _⟩⟩
lemma mem_top (x : E) : x ∈ (⊤ : convex_cone E) := mem_univ x
instance : complete_lattice (convex_cone E) :=
{ le := (≤),
lt := (<),
bot := (⊥),
bot_le := λ S x, false.elim,
top := (⊤),
le_top := λ S x hx, mem_top x,
inf := (⊓),
Inf := has_Inf.Inf,
sup := λ a b, Inf {x | a ≤ x ∧ b ≤ x},
Sup := λ s, Inf {T | ∀ S ∈ s, S ≤ T},
le_sup_left := λ a b, λ x hx, mem_Inf.2 $ λ s hs, hs.1 hx,
le_sup_right := λ a b, λ x hx, mem_Inf.2 $ λ s hs, hs.2 hx,
sup_le := λ a b c ha hb x hx, mem_Inf.1 hx c ⟨ha, hb⟩,
le_inf := λ a b c ha hb x hx, ⟨ha hx, hb hx⟩,
inf_le_left := λ a b x, and.left,
inf_le_right := λ a b x, and.right,
le_Sup := λ s p hs x hx, mem_Inf.2 $ λ t ht, ht p hs hx,
Sup_le := λ s p hs x hx, mem_Inf.1 hx p hs,
le_Inf := λ s a ha x hx, mem_Inf.2 $ λ t ht, ha t ht hx,
Inf_le := λ s a ha x hx, mem_Inf.1 hx _ ha,
.. partial_order.lift (coe : convex_cone E → set E) (λ a b, ext') }
instance : inhabited (convex_cone E) := ⟨⊥⟩
/-- The image of a convex cone under an `ℝ`-linear map is a convex cone. -/
def map (f : E →ₗ[ℝ] F) (S : convex_cone E) : convex_cone F :=
{ carrier := f '' S,
smul_mem' := λ c hc y ⟨x, hx, hy⟩, hy ▸ f.map_smul c x ▸ mem_image_of_mem f (S.smul_mem hc hx),
add_mem' := λ y₁ ⟨x₁, hx₁, hy₁⟩ y₂ ⟨x₂, hx₂, hy₂⟩, hy₁ ▸ hy₂ ▸ f.map_add x₁ x₂ ▸
mem_image_of_mem f (S.add_mem hx₁ hx₂) }
lemma map_map (g : F →ₗ[ℝ] G) (f : E →ₗ[ℝ] F) (S : convex_cone E) :
(S.map f).map g = S.map (g.comp f) :=
ext' $ image_image g f S
@[simp] lemma map_id : S.map linear_map.id = S := ext' $ image_id _
/-- The preimage of a convex cone under an `ℝ`-linear map is a convex cone. -/
def comap (f : E →ₗ[ℝ] F) (S : convex_cone F) : convex_cone E :=
{ carrier := f ⁻¹' S,
smul_mem' := λ c hc x hx, by { rw [mem_preimage, f.map_smul c], exact S.smul_mem hc hx },
add_mem' := λ x hx y hy, by { rw [mem_preimage, f.map_add], exact S.add_mem hx hy } }
@[simp] lemma comap_id : S.comap linear_map.id = S := ext' preimage_id
lemma comap_comap (g : F →ₗ[ℝ] G) (f : E →ₗ[ℝ] F) (S : convex_cone G) :
(S.comap g).comap f = S.comap (g.comp f) :=
ext' $ preimage_comp.symm
@[simp] lemma mem_comap {f : E →ₗ[ℝ] F} {S : convex_cone F} {x : E} :
x ∈ S.comap f ↔ f x ∈ S := iff.rfl
/--
Constructs an ordered module given an `ordered_add_comm_group`, a cone, and a proof that
the order relation is the one defined by the cone.
-/
lemma to_ordered_module {M : Type*} [ordered_add_comm_group M] [module ℝ M]
(S : convex_cone M) (h : ∀ x y : M, x ≤ y ↔ y - x ∈ S) : ordered_module ℝ M :=
ordered_module.mk'
begin
intros x y z xy hz,
rw [h (z • x) (z • y), ←smul_sub z y x],
exact smul_mem S hz ((h x y).mp (le_of_lt xy))
end
/-! ### Convex cones with extra properties -/
/-- A convex cone is pointed if it includes 0. -/
def pointed (S : convex_cone E) : Prop := (0 : E) ∈ S
/-- A convex cone is blunt if it doesn't include 0. -/
def blunt (S : convex_cone E) : Prop := (0 : E) ∉ S
/-- A convex cone is flat if it contains some nonzero vector `x` and its opposite `-x`. -/
def flat (S : convex_cone E) : Prop := ∃ x ∈ S, x ≠ (0 : E) ∧ -x ∈ S
/-- A convex cone is salient if it doesn't include `x` and `-x` for any nonzero `x`. -/
def salient (S : convex_cone E) : Prop := ∀ x ∈ S, x ≠ (0 : E) → -x ∉ S
lemma pointed_iff_not_blunt (S : convex_cone E) : pointed S ↔ ¬blunt S :=
⟨λ h₁ h₂, h₂ h₁, λ h, not_not.mp h⟩
lemma salient_iff_not_flat (S : convex_cone E) : salient S ↔ ¬flat S :=
begin
split,
{ rintros h₁ ⟨x, xs, H₁, H₂⟩,
exact h₁ x xs H₁ H₂ },
{ intro h,
unfold flat at h,
push_neg at h,
exact h }
end
/-- A blunt cone (one not containing 0) is always salient. -/
lemma salient_of_blunt (S : convex_cone E) : blunt S → salient S :=
begin
intro h₁,
rw [salient_iff_not_flat],
intro h₂,
obtain ⟨x, xs, H₁, H₂⟩ := h₂,
have hkey : (0 : E) ∈ S := by rw [(show 0 = x + (-x), by simp)]; exact add_mem S xs H₂,
exact h₁ hkey,
end
/-- A pointed convex cone defines a preorder. -/
def to_preorder (S : convex_cone E) (h₁ : pointed S) : preorder E :=
{ le := λ x y, y - x ∈ S,
le_refl := λ x, by change x - x ∈ S; rw [sub_self x]; exact h₁,
le_trans := λ x y z xy zy, by simp [(show z - x = z - y + (y - x), by abel), add_mem S zy xy] }
/-- A pointed and salient cone defines a partial order. -/
def to_partial_order (S : convex_cone E) (h₁ : pointed S) (h₂ : salient S) : partial_order E :=
{ le_antisymm :=
begin
intros a b ab ba,
by_contradiction h,
have h' : b - a ≠ 0 := λ h'', h (eq_of_sub_eq_zero h'').symm,
have H := h₂ (b-a) ab h',
rw [neg_sub b a] at H,
exact H ba,
end,
..to_preorder S h₁ }
/-- A pointed and salient cone defines an `ordered_add_comm_group`. -/
def to_ordered_add_comm_group (S : convex_cone E) (h₁ : pointed S) (h₂ : salient S) :
ordered_add_comm_group E :=
{ add_le_add_left :=
begin
intros a b hab c,
change c + b - (c + a) ∈ S,
rw [add_sub_add_left_eq_sub],
exact hab,
end,
..to_partial_order S h₁ h₂,
..show add_comm_group E, by apply_instance }
/-! ### Positive cone of an ordered module -/
section positive_cone
variables (M : Type*) [ordered_add_comm_group M] [module ℝ M] [ordered_module ℝ M]
/--
The positive cone is the convex cone formed by the set of nonnegative elements in an ordered
module.
-/
def positive_cone : convex_cone M :=
{ carrier := {x | 0 ≤ x},
smul_mem' :=
begin
intros c hc x hx,
have := smul_le_smul_of_nonneg (show 0 ≤ x, by exact hx) (le_of_lt hc),
have h' : c • (0 : M) = 0,
{ simp only [smul_zero] },
rwa [h'] at this
end,
add_mem' := λ x hx y hy, add_nonneg (show 0 ≤ x, by exact hx) (show 0 ≤ y, by exact hy) }
/-- The positive cone of an ordered module is always salient. -/
lemma salient_of_positive_cone : salient (positive_cone M) :=
begin
intros x xs hx hx',
have := calc
0 < x : lt_of_le_of_ne xs hx.symm
... ≤ x + (-x) : (le_add_iff_nonneg_right x).mpr hx'
... = 0 : by rw [tactic.ring.add_neg_eq_sub x x]; exact sub_self x,
exact lt_irrefl 0 this,
end
/-- The positive cone of an ordered module is always pointed. -/
lemma pointed_of_positive_cone : pointed (positive_cone M) := le_refl 0
end positive_cone
end convex_cone
/-!
### Cone over a convex set
-/
namespace convex
/-- The set of vectors proportional to those in a convex set forms a convex cone. -/
def to_cone (s : set E) (hs : convex s) : convex_cone E :=
begin
apply convex_cone.mk (⋃ c > 0, (c : ℝ) • s);
simp only [mem_Union, mem_smul_set],
{ rintros c c_pos _ ⟨c', c'_pos, x, hx, rfl⟩,
exact ⟨c * c', mul_pos c_pos c'_pos, x, hx, (smul_smul _ _ _).symm⟩ },
{ rintros _ ⟨cx, cx_pos, x, hx, rfl⟩ _ ⟨cy, cy_pos, y, hy, rfl⟩,
have : 0 < cx + cy, from add_pos cx_pos cy_pos,
refine ⟨_, this, _, convex_iff_div.1 hs hx hy (le_of_lt cx_pos) (le_of_lt cy_pos) this, _⟩,
simp only [smul_add, smul_smul, mul_div_assoc', mul_div_cancel_left _ (ne_of_gt this)] }
end
variables {s : set E} (hs : convex s) {x : E}
lemma mem_to_cone : x ∈ hs.to_cone s ↔ ∃ (c > 0) (y ∈ s), (c : ℝ) • y = x :=
by simp only [to_cone, convex_cone.mem_mk, mem_Union, mem_smul_set, eq_comm, exists_prop]
lemma mem_to_cone' : x ∈ hs.to_cone s ↔ ∃ c > 0, (c : ℝ) • x ∈ s :=
begin
refine hs.mem_to_cone.trans ⟨_, _⟩,
{ rintros ⟨c, hc, y, hy, rfl⟩,
exact ⟨c⁻¹, inv_pos.2 hc, by rwa [smul_smul, inv_mul_cancel (ne_of_gt hc), one_smul]⟩ },
{ rintros ⟨c, hc, hcx⟩,
exact ⟨c⁻¹, inv_pos.2 hc, _, hcx, by rw [smul_smul, inv_mul_cancel (ne_of_gt hc), one_smul]⟩ }
end
lemma subset_to_cone : s ⊆ hs.to_cone s :=
λ x hx, hs.mem_to_cone'.2 ⟨1, zero_lt_one, by rwa one_smul⟩
/-- `hs.to_cone s` is the least cone that includes `s`. -/
lemma to_cone_is_least : is_least { t : convex_cone E | s ⊆ t } (hs.to_cone s) :=
begin
refine ⟨hs.subset_to_cone, λ t ht x hx, _⟩,
rcases hs.mem_to_cone.1 hx with ⟨c, hc, y, hy, rfl⟩,
exact t.smul_mem hc (ht hy)
end
lemma to_cone_eq_Inf : hs.to_cone s = Inf { t : convex_cone E | s ⊆ t } :=
hs.to_cone_is_least.is_glb.Inf_eq.symm
end convex
lemma convex_hull_to_cone_is_least (s : set E) :
is_least {t : convex_cone E | s ⊆ t} ((convex_convex_hull s).to_cone _) :=
begin
convert (convex_convex_hull s).to_cone_is_least,
ext t,
exact ⟨λ h, convex_hull_min h t.convex, λ h, subset.trans (subset_convex_hull s) h⟩
end
lemma convex_hull_to_cone_eq_Inf (s : set E) :
(convex_convex_hull s).to_cone _ = Inf {t : convex_cone E | s ⊆ t} :=
(convex_hull_to_cone_is_least s).is_glb.Inf_eq.symm
/-!
### M. Riesz extension theorem
Given a convex cone `s` in a vector space `E`, a submodule `p`, and a linear `f : p → ℝ`, assume
that `f` is nonnegative on `p ∩ s` and `p + s = E`. Then there exists a globally defined linear
function `g : E → ℝ` that agrees with `f` on `p`, and is nonnegative on `s`.
We prove this theorem using Zorn's lemma. `riesz_extension.step` is the main part of the proof.
It says that if the domain `p` of `f` is not the whole space, then `f` can be extended to a larger
subspace `p ⊔ span ℝ {y}` without breaking the non-negativity condition.
In `riesz_extension.exists_top` we use Zorn's lemma to prove that we can extend `f`
to a linear map `g` on `⊤ : submodule E`. Mathematically this is the same as a linear map on `E`
but in Lean `⊤ : submodule E` is isomorphic but is not equal to `E`. In `riesz_extension`
we use this isomorphism to prove the theorem.
-/
namespace riesz_extension
open submodule
variables (s : convex_cone E) (f : linear_pmap ℝ E ℝ)
/-- Induction step in M. Riesz extension theorem. Given a convex cone `s` in a vector space `E`,
a partially defined linear map `f : f.domain → ℝ`, assume that `f` is nonnegative on `f.domain ∩ p`
and `p + s = E`. If `f` is not defined on the whole `E`, then we can extend it to a larger
submodule without breaking the non-negativity condition. -/
lemma step (nonneg : ∀ x : f.domain, (x : E) ∈ s → 0 ≤ f x)
(dense : ∀ y, ∃ x : f.domain, (x : E) + y ∈ s) (hdom : f.domain ≠ ⊤) :
∃ g, f < g ∧ ∀ x : g.domain, (x : E) ∈ s → 0 ≤ g x :=
begin
rcases set_like.exists_of_lt (lt_top_iff_ne_top.2 hdom) with ⟨y, hy', hy⟩, clear hy',
obtain ⟨c, le_c, c_le⟩ :
∃ c, (∀ x : f.domain, -(x:E) - y ∈ s → f x ≤ c) ∧ (∀ x : f.domain, (x:E) + y ∈ s → c ≤ f x),
{ set Sp := f '' {x : f.domain | (x:E) + y ∈ s},
set Sn := f '' {x : f.domain | -(x:E) - y ∈ s},
suffices : (upper_bounds Sn ∩ lower_bounds Sp).nonempty,
by simpa only [set.nonempty, upper_bounds, lower_bounds, ball_image_iff] using this,
refine exists_between_of_forall_le (nonempty.image f _) (nonempty.image f (dense y)) _,
{ rcases (dense (-y)) with ⟨x, hx⟩,
rw [← neg_neg x, coe_neg, ← sub_eq_add_neg] at hx,
exact ⟨_, hx⟩ },
rintros a ⟨xn, hxn, rfl⟩ b ⟨xp, hxp, rfl⟩,
have := s.add_mem hxp hxn,
rw [add_assoc, add_sub_cancel'_right, ← sub_eq_add_neg, ← coe_sub] at this,
replace := nonneg _ this,
rwa [f.map_sub, sub_nonneg] at this },
have hy' : y ≠ 0, from λ hy₀, hy (hy₀.symm ▸ zero_mem _),
refine ⟨f.sup_span_singleton y (-c) hy, _, _⟩,
{ refine lt_iff_le_not_le.2 ⟨f.left_le_sup _ _, λ H, _⟩,
replace H := linear_pmap.domain_mono.monotone H,
rw [linear_pmap.domain_sup_span_singleton, sup_le_iff, span_le, singleton_subset_iff] at H,
exact hy H.2 },
{ rintros ⟨z, hz⟩ hzs,
rcases mem_sup.1 hz with ⟨x, hx, y', hy', rfl⟩,
rcases mem_span_singleton.1 hy' with ⟨r, rfl⟩,
simp only [subtype.coe_mk] at hzs,
erw [linear_pmap.sup_span_singleton_apply_mk _ _ _ _ _ hx, smul_neg,
← sub_eq_add_neg, sub_nonneg],
rcases lt_trichotomy r 0 with hr|hr|hr,
{ have : -(r⁻¹ • x) - y ∈ s,
by rwa [← s.smul_mem_iff (neg_pos.2 hr), smul_sub, smul_neg, neg_smul, neg_neg, smul_smul,
mul_inv_cancel (ne_of_lt hr), one_smul, sub_eq_add_neg, neg_smul, neg_neg],
replace := le_c (r⁻¹ • ⟨x, hx⟩) this,
rwa [← mul_le_mul_left (neg_pos.2 hr), ← neg_mul_eq_neg_mul, ← neg_mul_eq_neg_mul,
neg_le_neg_iff, f.map_smul, smul_eq_mul, ← mul_assoc, mul_inv_cancel (ne_of_lt hr),
one_mul] at this },
{ subst r,
simp only [zero_smul, add_zero] at hzs ⊢,
apply nonneg,
exact hzs },
{ have : r⁻¹ • x + y ∈ s,
by rwa [← s.smul_mem_iff hr, smul_add, smul_smul, mul_inv_cancel (ne_of_gt hr), one_smul],
replace := c_le (r⁻¹ • ⟨x, hx⟩) this,
rwa [← mul_le_mul_left hr, f.map_smul, smul_eq_mul, ← mul_assoc,
mul_inv_cancel (ne_of_gt hr), one_mul] at this } }
end
theorem exists_top (p : linear_pmap ℝ E ℝ)
(hp_nonneg : ∀ x : p.domain, (x : E) ∈ s → 0 ≤ p x)
(hp_dense : ∀ y, ∃ x : p.domain, (x : E) + y ∈ s) :
∃ q ≥ p, q.domain = ⊤ ∧ ∀ x : q.domain, (x : E) ∈ s → 0 ≤ q x :=
begin
replace hp_nonneg : p ∈ { p | _ }, by { rw mem_set_of_eq, exact hp_nonneg },
obtain ⟨q, hqs, hpq, hq⟩ := zorn.zorn_nonempty_partial_order₀ _ _ _ hp_nonneg,
{ refine ⟨q, hpq, _, hqs⟩,
contrapose! hq,
rcases step s q hqs _ hq with ⟨r, hqr, hr⟩,
{ exact ⟨r, hr, le_of_lt hqr, ne_of_gt hqr⟩ },
{ exact λ y, let ⟨x, hx⟩ := hp_dense y in ⟨of_le hpq.left x, hx⟩ } },
{ intros c hcs c_chain y hy,
clear hp_nonneg hp_dense p,
have cne : c.nonempty := ⟨y, hy⟩,
refine ⟨linear_pmap.Sup c c_chain.directed_on, _, λ _, linear_pmap.le_Sup c_chain.directed_on⟩,
rintros ⟨x, hx⟩ hxs,
have hdir : directed_on (≤) (linear_pmap.domain '' c),
from directed_on_image.2 (c_chain.directed_on.mono linear_pmap.domain_mono.monotone),
rcases (mem_Sup_of_directed (cne.image _) hdir).1 hx with ⟨_, ⟨f, hfc, rfl⟩, hfx⟩,
have : f ≤ linear_pmap.Sup c c_chain.directed_on, from linear_pmap.le_Sup _ hfc,
convert ← hcs hfc ⟨x, hfx⟩ hxs,
apply this.2, refl }
end
end riesz_extension
/-- M. **Riesz extension theorem**: given a convex cone `s` in a vector space `E`, a submodule `p`,
and a linear `f : p → ℝ`, assume that `f` is nonnegative on `p ∩ s` and `p + s = E`. Then
there exists a globally defined linear function `g : E → ℝ` that agrees with `f` on `p`,
and is nonnegative on `s`. -/
theorem riesz_extension (s : convex_cone E) (f : linear_pmap ℝ E ℝ)
(nonneg : ∀ x : f.domain, (x : E) ∈ s → 0 ≤ f x) (dense : ∀ y, ∃ x : f.domain, (x : E) + y ∈ s) :
∃ g : E →ₗ[ℝ] ℝ, (∀ x : f.domain, g x = f x) ∧ (∀ x ∈ s, 0 ≤ g x) :=
begin
rcases riesz_extension.exists_top s f nonneg dense with ⟨⟨g_dom, g⟩, ⟨hpg, hfg⟩, htop, hgs⟩,
clear hpg,
refine ⟨g.comp (linear_equiv.of_top _ htop).symm, _, _⟩;
simp only [comp_apply, linear_equiv.coe_coe, linear_equiv.of_top_symm_apply],
{ exact λ x, (hfg (submodule.coe_mk _ _).symm).symm },
{ exact λ x hx, hgs ⟨x, _⟩ hx }
end
/-- **Hahn-Banach theorem**: if `N : E → ℝ` is a sublinear map, `f` is a linear map
defined on a subspace of `E`, and `f x ≤ N x` for all `x` in the domain of `f`,
then `f` can be extended to the whole space to a linear map `g` such that `g x ≤ N x`
for all `x`. -/
theorem exists_extension_of_le_sublinear (f : linear_pmap ℝ E ℝ) (N : E → ℝ)
(N_hom : ∀ (c : ℝ), 0 < c → ∀ x, N (c • x) = c * N x)
(N_add : ∀ x y, N (x + y) ≤ N x + N y)
(hf : ∀ x : f.domain, f x ≤ N x) :
∃ g : E →ₗ[ℝ] ℝ, (∀ x : f.domain, g x = f x) ∧ (∀ x, g x ≤ N x) :=
begin
let s : convex_cone (E × ℝ) :=
{ carrier := {p : E × ℝ | N p.1 ≤ p.2 },
smul_mem' := λ c hc p hp,
calc N (c • p.1) = c * N p.1 : N_hom c hc p.1
... ≤ c * p.2 : mul_le_mul_of_nonneg_left hp (le_of_lt hc),
add_mem' := λ x hx y hy, le_trans (N_add _ _) (add_le_add hx hy) },
obtain ⟨g, g_eq, g_nonneg⟩ :=
riesz_extension s ((-f).coprod (linear_map.id.to_pmap ⊤)) _ _;
try { simp only [linear_pmap.coprod_apply, to_pmap_apply, id_apply,
linear_pmap.neg_apply, ← sub_eq_neg_add, sub_nonneg, subtype.coe_mk] at * },
replace g_eq : ∀ (x : f.domain) (y : ℝ), g (x, y) = y - f x,
{ intros x y,
simpa only [subtype.coe_mk, subtype.coe_eta] using g_eq ⟨(x, y), ⟨x.2, trivial⟩⟩ },
{ refine ⟨-g.comp (inl ℝ E ℝ), _, _⟩; simp only [neg_apply, inl_apply, comp_apply],
{ intro x, simp [g_eq x 0] },
{ intro x,
have A : (x, N x) = (x, 0) + (0, N x), by simp,
have B := g_nonneg ⟨x, N x⟩ (le_refl (N x)),
rw [A, map_add, ← neg_le_iff_add_nonneg'] at B,
have C := g_eq 0 (N x),
simp only [submodule.coe_zero, f.map_zero, sub_zero] at C,
rwa ← C } },
{ exact λ x hx, le_trans (hf _) hx },
{ rintros ⟨x, y⟩,
refine ⟨⟨(0, N x - y), ⟨f.domain.zero_mem, trivial⟩⟩, _⟩,
simp only [convex_cone.mem_mk, mem_set_of_eq, subtype.coe_mk, prod.fst_add, prod.snd_add,
zero_add, sub_add_cancel] }
end
/-!
### The dual cone
-/
section dual
variables {H : Type*} [inner_product_space ℝ H] (s t : set H)
open_locale real_inner_product_space
/-- The dual cone is the cone consisting of all points `y` such that for
all points `x` in a given set `0 ≤ ⟪ x, y ⟫`. -/
noncomputable def set.inner_dual_cone (s : set H) : convex_cone H :=
{ carrier := { y | ∀ x ∈ s, 0 ≤ ⟪ x, y ⟫ },
smul_mem' := λ c hc y hy x hx,
begin
rw real_inner_smul_right,
exact mul_nonneg (le_of_lt hc) (hy x hx)
end,
add_mem' := λ u hu v hv x hx,
begin
rw inner_add_right,
exact add_nonneg (hu x hx) (hv x hx)
end }
lemma mem_inner_dual_cone (y : H) (s : set H) :
y ∈ s.inner_dual_cone ↔ ∀ x ∈ s, 0 ≤ ⟪ x, y ⟫ := by refl
@[simp] lemma inner_dual_cone_empty : (∅ : set H).inner_dual_cone = ⊤ :=
convex_cone.ext' (eq_univ_of_forall
(λ x y hy, false.elim (set.not_mem_empty _ hy)))
lemma inner_dual_cone_le_inner_dual_cone (h : t ⊆ s) :
s.inner_dual_cone ≤ t.inner_dual_cone :=
λ y hy x hx, hy x (h hx)
lemma pointed_inner_dual_cone : s.inner_dual_cone.pointed :=
λ x hx, by rw inner_zero_right
end dual
|
40bcf72603e9304b4a024b4039379eab47f7ac43 | c1cc0e0109964c513d82364865617b077fbbca41 | /src/definitions.lean | dce5d324670e5d8aac381d7693571731e00267e3 | [] | no_license | loganrjmurphy/lean-algebra | 314f12a28459d8734200207b4304ce036b0c886d | 474ac0c2714b7c0ad544a90c0d0807b92a0da227 | refs/heads/master | 1,675,055,520,716 | 1,607,564,600,000 | 1,607,564,600,000 | 316,637,587 | 1 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 5,844 | lean | import tactic
namespace Algebra
universe u
lemma pnat_wf : well_founded (preorder.to_has_lt ℕ+).1 :=
measure_wf coe
lemma Zp_well_order (A : set pnat) : A.nonempty →
∃ m ∈ A, (∀ x ∈ A, m ≤ x) :=
begin
intro H,
have := well_founded.has_min pnat_wf A H,
rcases this with ⟨m, H1,H2⟩,
use m, split,{exact H1},
intros x H3, replace H2 := H2 x H3,
exact not_lt.mp H2,
end
lemma add_int_zero : ∀ a : ℤ, a + int.zero = a :=
by tidy
lemma add_int_zero_unique : ∀ a b : ℤ, a + b = a → (0 ≤ b) → b = 0 :=
by tidy
section has_add
variables {G : Type} [has_add G]
def left_add : G → G → G := λ a b, a + b
def right_add : G → G → G := λ a b, b + a
end has_add
@[ancestor has_add] class semigroup (G : Type u) extends has_add G :=
(assoc : ∀ a b c : G, a + b + c = a + (b + c))
namespace semigroup
variables {G : Type u} [semigroup G] {a b c : G}
lemma associative : ∀ a b c : G, a + b + c = a + (b + c) :=
semigroup.assoc
instance semigroup.is_associative : is_associative G (+) := ⟨semigroup.assoc⟩
end semigroup
class commutative_semigroup (G : Type u) extends semigroup G :=
(comm : ∀ a b : G, a + b = b + a)
section commutative_semigroup
variables {G : Type u} [commutative_semigroup G]
lemma add_comm : ∀ a b : G, a + b = b + a :=
commutative_semigroup.comm
instance commutative_semigroup.is_commutative : is_commutative G (+) :=
⟨commutative_semigroup.comm⟩
end commutative_semigroup
class left_cancel_semigroup (G : Type u) extends semigroup G :=
(left_cancel : ∀ a b c : G, a + b = a + c → b = c)
section left_cancel_semigroup
variables {G : Type u} [left_cancel_semigroup G] {a b c : G}
lemma add_cancel_l : a + b = a + c → b = c :=
left_cancel_semigroup.left_cancel a b c
lemma left_cancel_iff : a + b = a + c ↔ b = c :=
⟨add_cancel_l, congr_arg _⟩
theorem add_right_injective (a : G) : function.injective ((+) a) :=
λ b c, add_cancel_l
@[simp]
theorem add_right_inj (a : G) {b c : G} : a + b = a + c ↔ b = c :=
⟨add_cancel_l, congr_arg _⟩
end left_cancel_semigroup
class right_cancel_semigroup (G : Type u) extends semigroup G :=
(right_cancel : ∀ a b c : G, a + b = c + b → a = c)
section right_cancel_semigroup
variables {G : Type u} [right_cancel_semigroup G] {a b c : G}
lemma add_cancel_r : a + b = c + b → a = c :=
right_cancel_semigroup.right_cancel a b c
lemma add_right_cancel_iff : b + a = c + a ↔ b = c :=
⟨add_cancel_r, congr_arg _⟩
theorem add_left_injective (a : G) : function.injective (λ x, x + a) :=
λ b c, add_cancel_r
@[simp]
theorem add_left_inj (a : G) {b c : G} : b + a = c + a ↔ b = c :=
⟨add_cancel_r, congr_arg _⟩
end right_cancel_semigroup
class monoid (M : Type u) extends semigroup M, has_zero M :=
(ident_l : ∀ a : M, 0 + a = a)
(ident_r : ∀ a : M, a + 0 = a)
section monoid
variables {M : Type u} [monoid M]
@[simp]
lemma zero_add : ∀ a : M, 0 + a = a :=
monoid.ident_l
@[simp]
lemma add_zero : ∀ a : M, a + 0 = a :=
monoid.ident_r
instance monoid_left_id : is_left_id M (+) 0 :=
⟨ monoid.ident_l ⟩
instance monoid_right_id : is_right_id M (+) 0 :=
⟨ monoid.ident_r ⟩
lemma left_inv_eq_right_inv {a b c : M} (hba : b + a = 0) (hac : a + c = 0) : b = c :=
by rw [← monoid.ident_l c, ← hba, semigroup.associative,hac, add_zero]
end monoid
class commutative_monoid (M : Type u) extends monoid M :=
(comm : ∀ a b : M, a + b = b + a)
section commutative_monoid
variables {M : Type u} [commutative_monoid M]
instance is_comm_semigroup : commutative_semigroup M :=
{ add := (+),
assoc := semigroup.associative,
comm := commutative_monoid.comm}
end commutative_monoid
class left_cancel_monoid (M : Type u) extends monoid M :=
(cancel_l : ∀ a b c : M, a + b = a + c → b = c)
class right_cancel_monoid (M : Type u) extends monoid M :=
(cancel_r : ∀ a b c : M, a + b = a + c → b = c)
class cancellative_monoid (M : Type u) extends monoid M:=
(cancel_l : ∀ a b c : M, a + b = a + c → b = c)
(cancel_r : ∀ a b c : M, a + b = c + b → a = c)
class group (α : Type u) extends monoid α, has_neg α :=
(inv_l : ∀ a : α, -a + a = 0)
namespace group
variables {G : Type u} [group G] {a b c : G}
@[simp]
lemma inv_left : ∀ a : G, (-a) + a = 0 :=
group.inv_l
lemma inv_self_l (a : G) : (-a) + a = 0 := group.inv_l a
lemma associative {a b c : G} : a + b + c = a + (b + c) := semigroup.associative a b c
lemma ident_l {a : G} : 0 + a = a := monoid.ident_l a
lemma ident_r {a : G} : a + 0 = a := monoid.ident_r a
@[simp]
lemma inv_cancel_left (a b : G) : (-a) + (a + b) = b :=
by {rw [← associative, inv_self_l, ident_l]}
@[simp]
lemma add_zero_imp_inv (h : a + b = 0) : (-a) = b :=
left_inv_eq_right_inv (inv_self_l a) h
@[simp]
lemma inv_idempotent (a : G) : - (-a) = a :=
add_zero_imp_inv (inv_l a)
@[simp]
lemma inv_r (a : G) : a + (-a) = 0 :=
by { have H : -(- a) + (-a) = 0 := inv_l (-a), rwa inv_idempotent at H}
lemma inv_self_r (a : G) : a + (-a) = 0 := inv_r a
@[simp]
lemma inv_cancel_right (a b : G) : a + b + (-b) = a :=
by rw [associative, inv_r, add_zero]
def abelian (G : Type u) [group G] : Prop := ∀ a b : G, a + b = b + a
def pow (g : G) : ℕ → G
| 0 := 0
| (n + 1) := g + pow n
infix `↟` : 100 := group.pow
end group
instance group.to_cancel_monoid {G : Type u} [group G] : cancellative_monoid G := {
add := has_add.add,
assoc := λ a b c, group.associative,
zero := has_zero.zero,
ident_l := λ a , group.ident_l ,
ident_r := λ a, group.ident_r,
cancel_l := λ a b c H, by
{rw [← group.inv_cancel_left a b,
H, ← group.associative, group.inv_l, group.ident_l]},
cancel_r := λ a b c H, by
{rw [← group.inv_cancel_right a b,
H, group.associative, group.inv_r, group.ident_r]},
}
end Algebra |
04ea4b7e47e6adc0f2f9afcf9b4d8a548dbaceec | abd85493667895c57a7507870867b28124b3998f | /src/data/nat/cast.lean | b3e27dd96e9a1b4217d50582411b7706ff86836b | [
"Apache-2.0"
] | permissive | pechersky/mathlib | d56eef16bddb0bfc8bc552b05b7270aff5944393 | f1df14c2214ee114c9738e733efd5de174deb95d | refs/heads/master | 1,666,714,392,571 | 1,591,747,567,000 | 1,591,747,567,000 | 270,557,274 | 0 | 0 | Apache-2.0 | 1,591,597,975,000 | 1,591,597,974,000 | null | UTF-8 | Lean | false | false | 8,790 | lean | /-
Copyright (c) 2014 Mario Carneiro. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro
Natural homomorphism from the natural numbers into a monoid with one.
-/
import algebra.ordered_field
import data.nat.basic
namespace nat
variables {α : Type*}
section
variables [has_zero α] [has_one α] [has_add α]
/-- Canonical homomorphism from `ℕ` to a type `α` with `0`, `1` and `+`. -/
protected def cast : ℕ → α
| 0 := 0
| (n+1) := cast n + 1
/--
Coercions such as `nat.cast_coe` that go from a concrete structure such as
`ℕ` to an arbitrary ring `α` should be set up as follows:
```lean
@[priority 900] instance : has_coe_t ℕ α := ⟨...⟩
```
It needs to be `has_coe_t` instead of `has_coe` because otherwise type-class
inference would loop when constructing the transitive coercion `ℕ → ℕ → ℕ → ...`.
The reduced priority is necessary so that it doesn't conflict with instances
such as `has_coe_t α (option α)`.
For this to work, we reduce the priority of the `coe_base` and `coe_trans`
instances because we want the instances for `has_coe_t` to be tried in the
following order:
1. `has_coe_t` instances declared in mathlib (such as `has_coe_t α (with_top α)`, etc.)
2. `coe_base`, which contains instances such as `has_coe (fin n) n`
3. `nat.cast_coe : has_coe_t ℕ α` etc.
4. `coe_trans`
If `coe_trans` is tried first, then `nat.cast_coe` doesn't get a chance to apply.
-/
library_note "coercion into rings"
attribute [instance, priority 950] coe_base
attribute [instance, priority 500] coe_trans
-- see note [coercion into rings]
@[priority 900] instance cast_coe : has_coe_t ℕ α := ⟨nat.cast⟩
@[simp, norm_cast] theorem cast_zero : ((0 : ℕ) : α) = 0 := rfl
theorem cast_add_one (n : ℕ) : ((n + 1 : ℕ) : α) = n + 1 := rfl
@[simp, norm_cast, priority 500]
theorem cast_succ (n : ℕ) : ((succ n : ℕ) : α) = n + 1 := rfl
@[simp, norm_cast] theorem cast_ite (P : Prop) [decidable P] (m n : ℕ) :
(((ite P m n) : ℕ) : α) = ite P (m : α) (n : α) :=
by { split_ifs; refl, }
end
@[simp, norm_cast] theorem cast_one [add_monoid α] [has_one α] : ((1 : ℕ) : α) = 1 := zero_add _
@[simp, norm_cast] theorem cast_add [add_monoid α] [has_one α] (m) : ∀ n, ((m + n : ℕ) : α) = m + n
| 0 := (add_zero _).symm
| (n+1) := show ((m + n : ℕ) : α) + 1 = m + (n + 1), by rw [cast_add n, add_assoc]
/-- `coe : ℕ → α` as an `add_monoid_hom`. -/
def cast_add_monoid_hom (α : Type*) [add_monoid α] [has_one α] : ℕ →+ α :=
{ to_fun := coe,
map_add' := cast_add,
map_zero' := cast_zero }
@[simp] lemma coe_cast_add_monoid_hom [add_monoid α] [has_one α] :
(cast_add_monoid_hom α : ℕ → α) = coe := rfl
@[simp, norm_cast] theorem cast_bit0 [add_monoid α] [has_one α] (n : ℕ) :
((bit0 n : ℕ) : α) = bit0 n := cast_add _ _
@[simp, norm_cast] theorem cast_bit1 [add_monoid α] [has_one α] (n : ℕ) :
((bit1 n : ℕ) : α) = bit1 n :=
by rw [bit1, cast_add_one, cast_bit0]; refl
lemma cast_two {α : Type*} [semiring α] : ((2 : ℕ) : α) = 2 := by simp
@[simp, norm_cast] theorem cast_pred [add_group α] [has_one α] :
∀ {n}, 0 < n → ((n - 1 : ℕ) : α) = n - 1
| (n+1) h := (add_sub_cancel (n:α) 1).symm
@[simp, norm_cast] theorem cast_sub [add_group α] [has_one α] {m n} (h : m ≤ n) :
((n - m : ℕ) : α) = n - m :=
eq_sub_of_add_eq $ by rw [← cast_add, nat.sub_add_cancel h]
@[simp, norm_cast] theorem cast_mul [semiring α] (m) : ∀ n, ((m * n : ℕ) : α) = m * n
| 0 := (mul_zero _).symm
| (n+1) := (cast_add _ _).trans $
show ((m * n : ℕ) : α) + m = m * (n + 1), by rw [cast_mul n, left_distrib, mul_one]
/-- `coe : ℕ → α` as a `ring_hom` -/
def cast_ring_hom (α : Type*) [semiring α] : ℕ →+* α :=
{ to_fun := coe,
map_one' := cast_one,
map_mul' := cast_mul,
.. cast_add_monoid_hom α }
@[simp] lemma coe_cast_ring_hom [semiring α] : (cast_ring_hom α : ℕ → α) = coe := rfl
lemma cast_commute [semiring α] (n : ℕ) (x : α) : commute ↑n x :=
nat.rec_on n (commute.zero_left x) $ λ n ihn, ihn.add_left $ commute.one_left x
lemma commute_cast [semiring α] (x : α) (n : ℕ) : commute x n :=
(n.cast_commute x).symm
@[simp] theorem cast_nonneg [linear_ordered_semiring α] : ∀ n : ℕ, 0 ≤ (n : α)
| 0 := le_refl _
| (n+1) := add_nonneg (cast_nonneg n) zero_le_one
@[simp, norm_cast] theorem cast_le [linear_ordered_semiring α] : ∀ {m n : ℕ}, (m : α) ≤ n ↔ m ≤ n
| 0 n := by simp [zero_le]
| (m+1) 0 := by simpa [not_succ_le_zero] using
lt_add_of_nonneg_of_lt (@cast_nonneg α _ m) zero_lt_one
| (m+1) (n+1) := (add_le_add_iff_right 1).trans $
(@cast_le m n).trans $ (add_le_add_iff_right 1).symm
@[simp, norm_cast] theorem cast_lt [linear_ordered_semiring α] {m n : ℕ} : (m : α) < n ↔ m < n :=
by simpa [-cast_le] using not_congr (@cast_le α _ n m)
@[simp] theorem cast_pos [linear_ordered_semiring α] {n : ℕ} : (0 : α) < n ↔ 0 < n :=
by rw [← cast_zero, cast_lt]
lemma cast_add_one_pos [linear_ordered_semiring α] (n : ℕ) : 0 < (n : α) + 1 :=
add_pos_of_nonneg_of_pos n.cast_nonneg zero_lt_one
@[simp, norm_cast] theorem cast_min [decidable_linear_ordered_semiring α] {a b : ℕ} :
(↑(min a b) : α) = min a b :=
by by_cases a ≤ b; simp [h, min]
@[simp, norm_cast] theorem cast_max [decidable_linear_ordered_semiring α] {a b : ℕ} :
(↑(max a b) : α) = max a b :=
by by_cases a ≤ b; simp [h, max]
@[simp, norm_cast] theorem abs_cast [decidable_linear_ordered_comm_ring α] (a : ℕ) :
abs (a : α) = a :=
abs_of_nonneg (cast_nonneg a)
section linear_ordered_field
variables [linear_ordered_field α]
lemma inv_pos_of_nat {n : ℕ} : 0 < ((n : α) + 1)⁻¹ :=
inv_pos.2 $ add_pos_of_nonneg_of_pos n.cast_nonneg zero_lt_one
lemma one_div_pos_of_nat {n : ℕ} : 0 < 1 / ((n : α) + 1) :=
by { rw one_div_eq_inv, exact inv_pos_of_nat }
lemma one_div_le_one_div {n m : ℕ} (h : n ≤ m) : 1 / ((m : α) + 1) ≤ 1 / ((n : α) + 1) :=
by { refine one_div_le_one_div_of_le _ _, exact nat.cast_add_one_pos _, simpa }
lemma one_div_lt_one_div {n m : ℕ} (h : n < m) : 1 / ((m : α) + 1) < 1 / ((n : α) + 1) :=
by { refine one_div_lt_one_div_of_lt _ _, exact nat.cast_add_one_pos _, simpa }
end linear_ordered_field
end nat
namespace add_monoid_hom
variables {A : Type*} [add_monoid A]
@[ext] lemma ext_nat {f g : ℕ →+ A} (h : f 1 = g 1) : f = g :=
ext $ λ n, nat.rec_on n (f.map_zero.trans g.map_zero.symm) $ λ n ihn,
by simp only [nat.succ_eq_add_one, *, map_add]
lemma eq_nat_cast {A} [add_monoid A] [has_one A] (f : ℕ →+ A) (h1 : f 1 = 1) :
∀ n : ℕ, f n = n :=
ext_iff.1 $ show f = nat.cast_add_monoid_hom A, from ext_nat (h1.trans nat.cast_one.symm)
end add_monoid_hom
namespace ring_hom
variables {R : Type*} {S : Type*} [semiring R] [semiring S]
@[simp] lemma eq_nat_cast (f : ℕ →+* R) (n : ℕ) : f n = n :=
f.to_add_monoid_hom.eq_nat_cast f.map_one n
@[simp] lemma map_nat_cast (f : R →+* S) (n : ℕ) :
f n = n :=
(f.comp (nat.cast_ring_hom R)).eq_nat_cast n
lemma ext_nat (f g : ℕ →+* R) : f = g :=
coe_add_monoid_hom_inj $ add_monoid_hom.ext_nat $ f.map_one.trans g.map_one.symm
end ring_hom
@[simp, norm_cast] theorem nat.cast_id (n : ℕ) : ↑n = n :=
((ring_hom.id ℕ).eq_nat_cast n).symm
@[simp] theorem nat.cast_with_bot : ∀ (n : ℕ),
@coe ℕ (with_bot ℕ) (@coe_to_lift _ _ nat.cast_coe) n = n
| 0 := rfl
| (n+1) := by rw [with_bot.coe_add, nat.cast_add, nat.cast_with_bot n]; refl
instance nat.subsingleton_ring_hom {R : Type*} [semiring R] : subsingleton (ℕ →+* R) :=
⟨ring_hom.ext_nat⟩
namespace with_top
variables {α : Type*} [canonically_ordered_comm_semiring α] [decidable_eq α]
@[simp] lemma coe_nat : ∀(n : nat), ((n : α) : with_top α) = n
| 0 := rfl
| (n+1) := have (((1 : nat) : α) : with_top α) = ((1 : nat) : with_top α) := rfl,
by rw [nat.cast_add, coe_add, nat.cast_add, coe_nat n, this]
@[simp] lemma nat_ne_top (n : nat) : (n : with_top α) ≠ ⊤ :=
by rw [←coe_nat n]; apply coe_ne_top
@[simp] lemma top_ne_nat (n : nat) : (⊤ : with_top α) ≠ n :=
by rw [←coe_nat n]; apply top_ne_coe
lemma add_one_le_of_lt {i n : with_top ℕ} (h : i < n) : i + 1 ≤ n :=
begin
cases n, { exact le_top },
cases i, { exact (not_le_of_lt h le_top).elim },
exact with_top.coe_le_coe.2 (with_top.coe_lt_coe.1 h)
end
@[elab_as_eliminator]
lemma nat_induction {P : with_top ℕ → Prop} (a : with_top ℕ)
(h0 : P 0) (hsuc : ∀n:ℕ, P n → P n.succ) (htop : (∀n : ℕ, P n) → P ⊤) : P a :=
begin
have A : ∀n:ℕ, P n := λ n, nat.rec_on n h0 hsuc,
cases a,
{ exact htop A },
{ exact A a }
end
end with_top
|
55c1886cc6e0f39ded09fd514a5c4564c1df490d | 74addaa0e41490cbaf2abd313a764c96df57b05d | /Mathlib/analysis/calculus/deriv_auto.lean | b1ae2d660355c93fa8d9fee0611488312106f82d | [] | no_license | AurelienSaue/Mathlib4_auto | f538cfd0980f65a6361eadea39e6fc639e9dae14 | 590df64109b08190abe22358fabc3eae000943f2 | refs/heads/master | 1,683,906,849,776 | 1,622,564,669,000 | 1,622,564,669,000 | 371,723,747 | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 111,332 | lean | /-
Copyright (c) 2019 Gabriel Ebner. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Gabriel Ebner, Sébastien Gouëzel
-/
import Mathlib.PrePort
import Mathlib.Lean3Lib.init.default
import Mathlib.analysis.calculus.fderiv
import Mathlib.data.polynomial.derivative
import Mathlib.PostPort
universes u v u_1 w
namespace Mathlib
/-!
# One-dimensional derivatives
This file defines the derivative of a function `f : 𝕜 → F` where `𝕜` is a
normed field and `F` is a normed space over this field. The derivative of
such a function `f` at a point `x` is given by an element `f' : F`.
The theory is developed analogously to the [Fréchet
derivatives](./fderiv.lean). We first introduce predicates defined in terms
of the corresponding predicates for Fréchet derivatives:
- `has_deriv_at_filter f f' x L` states that the function `f` has the
derivative `f'` at the point `x` as `x` goes along the filter `L`.
- `has_deriv_within_at f f' s x` states that the function `f` has the
derivative `f'` at the point `x` within the subset `s`.
- `has_deriv_at f f' x` states that the function `f` has the derivative `f'`
at the point `x`.
- `has_strict_deriv_at f f' x` states that the function `f` has the derivative `f'`
at the point `x` in the sense of strict differentiability, i.e.,
`f y - f z = (y - z) • f' + o (y - z)` as `y, z → x`.
For the last two notions we also define a functional version:
- `deriv_within f s x` is a derivative of `f` at `x` within `s`. If the
derivative does not exist, then `deriv_within f s x` equals zero.
- `deriv f x` is a derivative of `f` at `x`. If the derivative does not
exist, then `deriv f x` equals zero.
The theorems `fderiv_within_deriv_within` and `fderiv_deriv` show that the
one-dimensional derivatives coincide with the general Fréchet derivatives.
We also show the existence and compute the derivatives of:
- constants
- the identity function
- linear maps
- addition
- sum of finitely many functions
- negation
- subtraction
- multiplication
- inverse `x → x⁻¹`
- multiplication of two functions in `𝕜 → 𝕜`
- multiplication of a function in `𝕜 → 𝕜` and of a function in `𝕜 → E`
- composition of a function in `𝕜 → F` with a function in `𝕜 → 𝕜`
- composition of a function in `F → E` with a function in `𝕜 → F`
- inverse function (assuming that it exists; the inverse function theorem is in `inverse.lean`)
- division
- polynomials
For most binary operations we also define `const_op` and `op_const` theorems for the cases when
the first or second argument is a constant. This makes writing chains of `has_deriv_at`'s easier,
and they more frequently lead to the desired result.
We set up the simplifier so that it can compute the derivative of simple functions. For instance,
```lean
example (x : ℝ) : deriv (λ x, cos (sin x) * exp x) x = (cos(sin(x))-sin(sin(x))*cos(x))*exp(x) :=
by { simp, ring }
```
## Implementation notes
Most of the theorems are direct restatements of the corresponding theorems
for Fréchet derivatives.
The strategy to construct simp lemmas that give the simplifier the possibility to compute
derivatives is the same as the one for differentiability statements, as explained in `fderiv.lean`.
See the explanations there.
-/
/--
`f` has the derivative `f'` at the point `x` as `x` goes along the filter `L`.
That is, `f x' = f x + (x' - x) • f' + o(x' - x)` where `x'` converges along the filter `L`.
-/
def has_deriv_at_filter {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v} [normed_group F]
[normed_space 𝕜 F] (f : 𝕜 → F) (f' : F) (x : 𝕜) (L : filter 𝕜) :=
has_fderiv_at_filter f (continuous_linear_map.smul_right 1 f') x L
/--
`f` has the derivative `f'` at the point `x` within the subset `s`.
That is, `f x' = f x + (x' - x) • f' + o(x' - x)` where `x'` converges to `x` inside `s`.
-/
def has_deriv_within_at {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v} [normed_group F]
[normed_space 𝕜 F] (f : 𝕜 → F) (f' : F) (s : set 𝕜) (x : 𝕜) :=
has_deriv_at_filter f f' x (nhds_within x s)
/--
`f` has the derivative `f'` at the point `x`.
That is, `f x' = f x + (x' - x) • f' + o(x' - x)` where `x'` converges to `x`.
-/
def has_deriv_at {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v} [normed_group F]
[normed_space 𝕜 F] (f : 𝕜 → F) (f' : F) (x : 𝕜) :=
has_deriv_at_filter f f' x (nhds x)
/-- `f` has the derivative `f'` at the point `x` in the sense of strict differentiability.
That is, `f y - f z = (y - z) • f' + o(y - z)` as `y, z → x`. -/
def has_strict_deriv_at {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v} [normed_group F]
[normed_space 𝕜 F] (f : 𝕜 → F) (f' : F) (x : 𝕜) :=
has_strict_fderiv_at f (continuous_linear_map.smul_right 1 f') x
/--
Derivative of `f` at the point `x` within the set `s`, if it exists. Zero otherwise.
If the derivative exists (i.e., `∃ f', has_deriv_within_at f f' s x`), then
`f x' = f x + (x' - x) • deriv_within f s x + o(x' - x)` where `x'` converges to `x` inside `s`.
-/
def deriv_within {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v} [normed_group F]
[normed_space 𝕜 F] (f : 𝕜 → F) (s : set 𝕜) (x : 𝕜) : F :=
coe_fn (fderiv_within 𝕜 f s x) 1
/--
Derivative of `f` at the point `x`, if it exists. Zero otherwise.
If the derivative exists (i.e., `∃ f', has_deriv_at f f' x`), then
`f x' = f x + (x' - x) • deriv f x + o(x' - x)` where `x'` converges to `x`.
-/
def deriv {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v} [normed_group F] [normed_space 𝕜 F]
(f : 𝕜 → F) (x : 𝕜) : F :=
coe_fn (fderiv 𝕜 f x) 1
/-- Expressing `has_fderiv_at_filter f f' x L` in terms of `has_deriv_at_filter` -/
theorem has_fderiv_at_filter_iff_has_deriv_at_filter {𝕜 : Type u} [nondiscrete_normed_field 𝕜]
{F : Type v} [normed_group F] [normed_space 𝕜 F] {f : 𝕜 → F} {x : 𝕜} {L : filter 𝕜}
{f' : continuous_linear_map 𝕜 𝕜 F} :
has_fderiv_at_filter f f' x L ↔ has_deriv_at_filter f (coe_fn f' 1) x L :=
sorry
theorem has_fderiv_at_filter.has_deriv_at_filter {𝕜 : Type u} [nondiscrete_normed_field 𝕜]
{F : Type v} [normed_group F] [normed_space 𝕜 F] {f : 𝕜 → F} {x : 𝕜} {L : filter 𝕜}
{f' : continuous_linear_map 𝕜 𝕜 F} :
has_fderiv_at_filter f f' x L → has_deriv_at_filter f (coe_fn f' 1) x L :=
iff.mp has_fderiv_at_filter_iff_has_deriv_at_filter
/-- Expressing `has_fderiv_within_at f f' s x` in terms of `has_deriv_within_at` -/
theorem has_fderiv_within_at_iff_has_deriv_within_at {𝕜 : Type u} [nondiscrete_normed_field 𝕜]
{F : Type v} [normed_group F] [normed_space 𝕜 F] {f : 𝕜 → F} {x : 𝕜} {s : set 𝕜}
{f' : continuous_linear_map 𝕜 𝕜 F} :
has_fderiv_within_at f f' s x ↔ has_deriv_within_at f (coe_fn f' 1) s x :=
has_fderiv_at_filter_iff_has_deriv_at_filter
/-- Expressing `has_deriv_within_at f f' s x` in terms of `has_fderiv_within_at` -/
theorem has_deriv_within_at_iff_has_fderiv_within_at {𝕜 : Type u} [nondiscrete_normed_field 𝕜]
{F : Type v} [normed_group F] [normed_space 𝕜 F] {f : 𝕜 → F} {x : 𝕜} {s : set 𝕜} {f' : F} :
has_deriv_within_at f f' s x ↔
has_fderiv_within_at f (continuous_linear_map.smul_right 1 f') s x :=
iff.rfl
theorem has_fderiv_within_at.has_deriv_within_at {𝕜 : Type u} [nondiscrete_normed_field 𝕜]
{F : Type v} [normed_group F] [normed_space 𝕜 F] {f : 𝕜 → F} {x : 𝕜} {s : set 𝕜}
{f' : continuous_linear_map 𝕜 𝕜 F} :
has_fderiv_within_at f f' s x → has_deriv_within_at f (coe_fn f' 1) s x :=
iff.mp has_fderiv_within_at_iff_has_deriv_within_at
theorem has_deriv_within_at.has_fderiv_within_at {𝕜 : Type u} [nondiscrete_normed_field 𝕜]
{F : Type v} [normed_group F] [normed_space 𝕜 F] {f : 𝕜 → F} {x : 𝕜} {s : set 𝕜} {f' : F} :
has_deriv_within_at f f' s x →
has_fderiv_within_at f (continuous_linear_map.smul_right 1 f') s x :=
iff.mp has_deriv_within_at_iff_has_fderiv_within_at
/-- Expressing `has_fderiv_at f f' x` in terms of `has_deriv_at` -/
theorem has_fderiv_at_iff_has_deriv_at {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v}
[normed_group F] [normed_space 𝕜 F] {f : 𝕜 → F} {x : 𝕜} {f' : continuous_linear_map 𝕜 𝕜 F} :
has_fderiv_at f f' x ↔ has_deriv_at f (coe_fn f' 1) x :=
has_fderiv_at_filter_iff_has_deriv_at_filter
theorem has_fderiv_at.has_deriv_at {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v}
[normed_group F] [normed_space 𝕜 F] {f : 𝕜 → F} {x : 𝕜} {f' : continuous_linear_map 𝕜 𝕜 F} :
has_fderiv_at f f' x → has_deriv_at f (coe_fn f' 1) x :=
iff.mp has_fderiv_at_iff_has_deriv_at
theorem has_strict_fderiv_at_iff_has_strict_deriv_at {𝕜 : Type u} [nondiscrete_normed_field 𝕜]
{F : Type v} [normed_group F] [normed_space 𝕜 F] {f : 𝕜 → F} {x : 𝕜}
{f' : continuous_linear_map 𝕜 𝕜 F} :
has_strict_fderiv_at f f' x ↔ has_strict_deriv_at f (coe_fn f' 1) x :=
sorry
protected theorem has_strict_fderiv_at.has_strict_deriv_at {𝕜 : Type u} [nondiscrete_normed_field 𝕜]
{F : Type v} [normed_group F] [normed_space 𝕜 F] {f : 𝕜 → F} {x : 𝕜}
{f' : continuous_linear_map 𝕜 𝕜 F} :
has_strict_fderiv_at f f' x → has_strict_deriv_at f (coe_fn f' 1) x :=
iff.mp has_strict_fderiv_at_iff_has_strict_deriv_at
/-- Expressing `has_deriv_at f f' x` in terms of `has_fderiv_at` -/
theorem has_deriv_at_iff_has_fderiv_at {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v}
[normed_group F] [normed_space 𝕜 F] {f : 𝕜 → F} {x : 𝕜} {f' : F} :
has_deriv_at f f' x ↔ has_fderiv_at f (continuous_linear_map.smul_right 1 f') x :=
iff.rfl
theorem deriv_within_zero_of_not_differentiable_within_at {𝕜 : Type u} [nondiscrete_normed_field 𝕜]
{F : Type v} [normed_group F] [normed_space 𝕜 F] {f : 𝕜 → F} {x : 𝕜} {s : set 𝕜}
(h : ¬differentiable_within_at 𝕜 f s x) : deriv_within f s x = 0 :=
sorry
theorem deriv_zero_of_not_differentiable_at {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v}
[normed_group F] [normed_space 𝕜 F] {f : 𝕜 → F} {x : 𝕜} (h : ¬differentiable_at 𝕜 f x) :
deriv f x = 0 :=
sorry
theorem unique_diff_within_at.eq_deriv {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v}
[normed_group F] [normed_space 𝕜 F] {f : 𝕜 → F} {f' : F} {f₁' : F} {x : 𝕜} (s : set 𝕜)
(H : unique_diff_within_at 𝕜 s x) (h : has_deriv_within_at f f' s x)
(h₁ : has_deriv_within_at f f₁' s x) : f' = f₁' :=
iff.mp continuous_linear_map.smul_right_one_eq_iff (unique_diff_within_at.eq H h h₁)
theorem has_deriv_at_filter_iff_tendsto {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v}
[normed_group F] [normed_space 𝕜 F] {f : 𝕜 → F} {f' : F} {x : 𝕜} {L : filter 𝕜} :
has_deriv_at_filter f f' x L ↔
filter.tendsto (fun (x' : 𝕜) => norm (x' - x)⁻¹ * norm (f x' - f x - (x' - x) • f')) L
(nhds 0) :=
has_fderiv_at_filter_iff_tendsto
theorem has_deriv_within_at_iff_tendsto {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v}
[normed_group F] [normed_space 𝕜 F] {f : 𝕜 → F} {f' : F} {x : 𝕜} {s : set 𝕜} :
has_deriv_within_at f f' s x ↔
filter.tendsto (fun (x' : 𝕜) => norm (x' - x)⁻¹ * norm (f x' - f x - (x' - x) • f'))
(nhds_within x s) (nhds 0) :=
has_fderiv_at_filter_iff_tendsto
theorem has_deriv_at_iff_tendsto {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v}
[normed_group F] [normed_space 𝕜 F] {f : 𝕜 → F} {f' : F} {x : 𝕜} :
has_deriv_at f f' x ↔
filter.tendsto (fun (x' : 𝕜) => norm (x' - x)⁻¹ * norm (f x' - f x - (x' - x) • f'))
(nhds x) (nhds 0) :=
has_fderiv_at_filter_iff_tendsto
theorem has_strict_deriv_at.has_deriv_at {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v}
[normed_group F] [normed_space 𝕜 F] {f : 𝕜 → F} {f' : F} {x : 𝕜}
(h : has_strict_deriv_at f f' x) : has_deriv_at f f' x :=
has_strict_fderiv_at.has_fderiv_at h
/-- If the domain has dimension one, then Fréchet derivative is equivalent to the classical
definition with a limit. In this version we have to take the limit along the subset `-{x}`,
because for `y=x` the slope equals zero due to the convention `0⁻¹=0`. -/
theorem has_deriv_at_filter_iff_tendsto_slope {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v}
[normed_group F] [normed_space 𝕜 F] {f : 𝕜 → F} {f' : F} {x : 𝕜} {L : filter 𝕜} :
has_deriv_at_filter f f' x L ↔
filter.tendsto (fun (y : 𝕜) => y - x⁻¹ • (f y - f x)) (L ⊓ filter.principal (singleton xᶜ))
(nhds f') :=
sorry
theorem has_deriv_within_at_iff_tendsto_slope {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v}
[normed_group F] [normed_space 𝕜 F] {f : 𝕜 → F} {f' : F} {x : 𝕜} {s : set 𝕜} :
has_deriv_within_at f f' s x ↔
filter.tendsto (fun (y : 𝕜) => y - x⁻¹ • (f y - f x)) (nhds_within x (s \ singleton x))
(nhds f') :=
sorry
theorem has_deriv_within_at_iff_tendsto_slope' {𝕜 : Type u} [nondiscrete_normed_field 𝕜]
{F : Type v} [normed_group F] [normed_space 𝕜 F] {f : 𝕜 → F} {f' : F} {x : 𝕜} {s : set 𝕜}
(hs : ¬x ∈ s) :
has_deriv_within_at f f' s x ↔
filter.tendsto (fun (y : 𝕜) => y - x⁻¹ • (f y - f x)) (nhds_within x s) (nhds f') :=
sorry
theorem has_deriv_at_iff_tendsto_slope {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v}
[normed_group F] [normed_space 𝕜 F] {f : 𝕜 → F} {f' : F} {x : 𝕜} :
has_deriv_at f f' x ↔
filter.tendsto (fun (y : 𝕜) => y - x⁻¹ • (f y - f x)) (nhds_within x (singleton xᶜ))
(nhds f') :=
has_deriv_at_filter_iff_tendsto_slope
@[simp] theorem has_deriv_within_at_diff_singleton {𝕜 : Type u} [nondiscrete_normed_field 𝕜]
{F : Type v} [normed_group F] [normed_space 𝕜 F] {f : 𝕜 → F} {f' : F} {x : 𝕜} {s : set 𝕜} :
has_deriv_within_at f f' (s \ singleton x) x ↔ has_deriv_within_at f f' s x :=
sorry
@[simp] theorem has_deriv_within_at_Ioi_iff_Ici {𝕜 : Type u} [nondiscrete_normed_field 𝕜]
{F : Type v} [normed_group F] [normed_space 𝕜 F] {f : 𝕜 → F} {f' : F} {x : 𝕜}
[partial_order 𝕜] :
has_deriv_within_at f f' (set.Ioi x) x ↔ has_deriv_within_at f f' (set.Ici x) x :=
sorry
theorem has_deriv_within_at.Ioi_of_Ici {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v}
[normed_group F] [normed_space 𝕜 F] {f : 𝕜 → F} {f' : F} {x : 𝕜} [partial_order 𝕜] :
has_deriv_within_at f f' (set.Ici x) x → has_deriv_within_at f f' (set.Ioi x) x :=
iff.mpr has_deriv_within_at_Ioi_iff_Ici
@[simp] theorem has_deriv_within_at_Iio_iff_Iic {𝕜 : Type u} [nondiscrete_normed_field 𝕜]
{F : Type v} [normed_group F] [normed_space 𝕜 F] {f : 𝕜 → F} {f' : F} {x : 𝕜}
[partial_order 𝕜] :
has_deriv_within_at f f' (set.Iio x) x ↔ has_deriv_within_at f f' (set.Iic x) x :=
sorry
theorem has_deriv_within_at.Iio_of_Iic {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v}
[normed_group F] [normed_space 𝕜 F] {f : 𝕜 → F} {f' : F} {x : 𝕜} [partial_order 𝕜] :
has_deriv_within_at f f' (set.Iic x) x → has_deriv_within_at f f' (set.Iio x) x :=
iff.mpr has_deriv_within_at_Iio_iff_Iic
theorem has_deriv_at_iff_is_o_nhds_zero {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v}
[normed_group F] [normed_space 𝕜 F] {f : 𝕜 → F} {f' : F} {x : 𝕜} :
has_deriv_at f f' x ↔
asymptotics.is_o (fun (h : 𝕜) => f (x + h) - f x - h • f') (fun (h : 𝕜) => h) (nhds 0) :=
has_fderiv_at_iff_is_o_nhds_zero
theorem has_deriv_at_filter.mono {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v}
[normed_group F] [normed_space 𝕜 F] {f : 𝕜 → F} {f' : F} {x : 𝕜} {L₁ : filter 𝕜} {L₂ : filter 𝕜}
(h : has_deriv_at_filter f f' x L₂) (hst : L₁ ≤ L₂) : has_deriv_at_filter f f' x L₁ :=
has_fderiv_at_filter.mono h hst
theorem has_deriv_within_at.mono {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v}
[normed_group F] [normed_space 𝕜 F] {f : 𝕜 → F} {f' : F} {x : 𝕜} {s : set 𝕜} {t : set 𝕜}
(h : has_deriv_within_at f f' t x) (hst : s ⊆ t) : has_deriv_within_at f f' s x :=
has_fderiv_within_at.mono h hst
theorem has_deriv_at.has_deriv_at_filter {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v}
[normed_group F] [normed_space 𝕜 F] {f : 𝕜 → F} {f' : F} {x : 𝕜} {L : filter 𝕜}
(h : has_deriv_at f f' x) (hL : L ≤ nhds x) : has_deriv_at_filter f f' x L :=
has_fderiv_at.has_fderiv_at_filter h hL
theorem has_deriv_at.has_deriv_within_at {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v}
[normed_group F] [normed_space 𝕜 F] {f : 𝕜 → F} {f' : F} {x : 𝕜} {s : set 𝕜}
(h : has_deriv_at f f' x) : has_deriv_within_at f f' s x :=
has_fderiv_at.has_fderiv_within_at h
theorem has_deriv_within_at.differentiable_within_at {𝕜 : Type u} [nondiscrete_normed_field 𝕜]
{F : Type v} [normed_group F] [normed_space 𝕜 F] {f : 𝕜 → F} {f' : F} {x : 𝕜} {s : set 𝕜}
(h : has_deriv_within_at f f' s x) : differentiable_within_at 𝕜 f s x :=
has_fderiv_within_at.differentiable_within_at h
theorem has_deriv_at.differentiable_at {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v}
[normed_group F] [normed_space 𝕜 F] {f : 𝕜 → F} {f' : F} {x : 𝕜} (h : has_deriv_at f f' x) :
differentiable_at 𝕜 f x :=
has_fderiv_at.differentiable_at h
@[simp] theorem has_deriv_within_at_univ {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v}
[normed_group F] [normed_space 𝕜 F] {f : 𝕜 → F} {f' : F} {x : 𝕜} :
has_deriv_within_at f f' set.univ x ↔ has_deriv_at f f' x :=
has_fderiv_within_at_univ
theorem has_deriv_at_unique {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v} [normed_group F]
[normed_space 𝕜 F] {f : 𝕜 → F} {f₀' : F} {f₁' : F} {x : 𝕜} (h₀ : has_deriv_at f f₀' x)
(h₁ : has_deriv_at f f₁' x) : f₀' = f₁' :=
iff.mp continuous_linear_map.smul_right_one_eq_iff (has_fderiv_at_unique h₀ h₁)
theorem has_deriv_within_at_inter' {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v}
[normed_group F] [normed_space 𝕜 F] {f : 𝕜 → F} {f' : F} {x : 𝕜} {s : set 𝕜} {t : set 𝕜}
(h : t ∈ nhds_within x s) : has_deriv_within_at f f' (s ∩ t) x ↔ has_deriv_within_at f f' s x :=
has_fderiv_within_at_inter' h
theorem has_deriv_within_at_inter {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v}
[normed_group F] [normed_space 𝕜 F] {f : 𝕜 → F} {f' : F} {x : 𝕜} {s : set 𝕜} {t : set 𝕜}
(h : t ∈ nhds x) : has_deriv_within_at f f' (s ∩ t) x ↔ has_deriv_within_at f f' s x :=
has_fderiv_within_at_inter h
theorem has_deriv_within_at.union {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v}
[normed_group F] [normed_space 𝕜 F] {f : 𝕜 → F} {f' : F} {x : 𝕜} {s : set 𝕜} {t : set 𝕜}
(hs : has_deriv_within_at f f' s x) (ht : has_deriv_within_at f f' t x) :
has_deriv_within_at f f' (s ∪ t) x :=
sorry
theorem has_deriv_within_at.nhds_within {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v}
[normed_group F] [normed_space 𝕜 F] {f : 𝕜 → F} {f' : F} {x : 𝕜} {s : set 𝕜} {t : set 𝕜}
(h : has_deriv_within_at f f' s x) (ht : s ∈ nhds_within x t) : has_deriv_within_at f f' t x :=
iff.mp (has_deriv_within_at_inter' ht) (has_deriv_within_at.mono h (set.inter_subset_right t s))
theorem has_deriv_within_at.has_deriv_at {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v}
[normed_group F] [normed_space 𝕜 F] {f : 𝕜 → F} {f' : F} {x : 𝕜} {s : set 𝕜}
(h : has_deriv_within_at f f' s x) (hs : s ∈ nhds x) : has_deriv_at f f' x :=
has_fderiv_within_at.has_fderiv_at h hs
theorem differentiable_within_at.has_deriv_within_at {𝕜 : Type u} [nondiscrete_normed_field 𝕜]
{F : Type v} [normed_group F] [normed_space 𝕜 F] {f : 𝕜 → F} {x : 𝕜} {s : set 𝕜}
(h : differentiable_within_at 𝕜 f s x) : has_deriv_within_at f (deriv_within f s x) s x :=
sorry
theorem differentiable_at.has_deriv_at {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v}
[normed_group F] [normed_space 𝕜 F] {f : 𝕜 → F} {x : 𝕜} (h : differentiable_at 𝕜 f x) :
has_deriv_at f (deriv f x) x :=
sorry
theorem has_deriv_at.deriv {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v} [normed_group F]
[normed_space 𝕜 F] {f : 𝕜 → F} {f' : F} {x : 𝕜} (h : has_deriv_at f f' x) : deriv f x = f' :=
has_deriv_at_unique (differentiable_at.has_deriv_at (has_deriv_at.differentiable_at h)) h
theorem has_deriv_within_at.deriv_within {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v}
[normed_group F] [normed_space 𝕜 F] {f : 𝕜 → F} {f' : F} {x : 𝕜} {s : set 𝕜}
(h : has_deriv_within_at f f' s x) (hxs : unique_diff_within_at 𝕜 s x) :
deriv_within f s x = f' :=
unique_diff_within_at.eq_deriv s hxs
(differentiable_within_at.has_deriv_within_at (has_deriv_within_at.differentiable_within_at h))
h
theorem fderiv_within_deriv_within {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v}
[normed_group F] [normed_space 𝕜 F] {f : 𝕜 → F} {x : 𝕜} {s : set 𝕜} :
coe_fn (fderiv_within 𝕜 f s x) 1 = deriv_within f s x :=
rfl
theorem deriv_within_fderiv_within {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v}
[normed_group F] [normed_space 𝕜 F] {f : 𝕜 → F} {x : 𝕜} {s : set 𝕜} :
continuous_linear_map.smul_right 1 (deriv_within f s x) = fderiv_within 𝕜 f s x :=
sorry
theorem fderiv_deriv {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v} [normed_group F]
[normed_space 𝕜 F] {f : 𝕜 → F} {x : 𝕜} : coe_fn (fderiv 𝕜 f x) 1 = deriv f x :=
rfl
theorem deriv_fderiv {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v} [normed_group F]
[normed_space 𝕜 F] {f : 𝕜 → F} {x : 𝕜} :
continuous_linear_map.smul_right 1 (deriv f x) = fderiv 𝕜 f x :=
sorry
theorem differentiable_at.deriv_within {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v}
[normed_group F] [normed_space 𝕜 F] {f : 𝕜 → F} {x : 𝕜} {s : set 𝕜}
(h : differentiable_at 𝕜 f x) (hxs : unique_diff_within_at 𝕜 s x) :
deriv_within f s x = deriv f x :=
sorry
theorem deriv_within_subset {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v} [normed_group F]
[normed_space 𝕜 F] {f : 𝕜 → F} {x : 𝕜} {s : set 𝕜} {t : set 𝕜} (st : s ⊆ t)
(ht : unique_diff_within_at 𝕜 s x) (h : differentiable_within_at 𝕜 f t x) :
deriv_within f s x = deriv_within f t x :=
has_deriv_within_at.deriv_within
(has_deriv_within_at.mono (differentiable_within_at.has_deriv_within_at h) st) ht
@[simp] theorem deriv_within_univ {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v}
[normed_group F] [normed_space 𝕜 F] {f : 𝕜 → F} : deriv_within f set.univ = deriv f :=
sorry
theorem deriv_within_inter {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v} [normed_group F]
[normed_space 𝕜 F] {f : 𝕜 → F} {x : 𝕜} {s : set 𝕜} {t : set 𝕜} (ht : t ∈ nhds x)
(hs : unique_diff_within_at 𝕜 s x) : deriv_within f (s ∩ t) x = deriv_within f s x :=
sorry
theorem deriv_within_of_open {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v} [normed_group F]
[normed_space 𝕜 F] {f : 𝕜 → F} {x : 𝕜} {s : set 𝕜} (hs : is_open s) (hx : x ∈ s) :
deriv_within f s x = deriv f x :=
sorry
/-! ### Congruence properties of derivatives -/
theorem filter.eventually_eq.has_deriv_at_filter_iff {𝕜 : Type u} [nondiscrete_normed_field 𝕜]
{F : Type v} [normed_group F] [normed_space 𝕜 F] {f₀ : 𝕜 → F} {f₁ : 𝕜 → F} {f₀' : F} {f₁' : F}
{x : 𝕜} {L : filter 𝕜} (h₀ : filter.eventually_eq L f₀ f₁) (hx : f₀ x = f₁ x) (h₁ : f₀' = f₁') :
has_deriv_at_filter f₀ f₀' x L ↔ has_deriv_at_filter f₁ f₁' x L :=
sorry
theorem has_deriv_at_filter.congr_of_eventually_eq {𝕜 : Type u} [nondiscrete_normed_field 𝕜]
{F : Type v} [normed_group F] [normed_space 𝕜 F] {f : 𝕜 → F} {f₁ : 𝕜 → F} {f' : F} {x : 𝕜}
{L : filter 𝕜} (h : has_deriv_at_filter f f' x L) (hL : filter.eventually_eq L f₁ f)
(hx : f₁ x = f x) : has_deriv_at_filter f₁ f' x L :=
sorry
theorem has_deriv_within_at.congr_mono {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v}
[normed_group F] [normed_space 𝕜 F] {f : 𝕜 → F} {f₁ : 𝕜 → F} {f' : F} {x : 𝕜} {s : set 𝕜}
{t : set 𝕜} (h : has_deriv_within_at f f' s x) (ht : ∀ (x : 𝕜), x ∈ t → f₁ x = f x)
(hx : f₁ x = f x) (h₁ : t ⊆ s) : has_deriv_within_at f₁ f' t x :=
has_fderiv_within_at.congr_mono h ht hx h₁
theorem has_deriv_within_at.congr {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v}
[normed_group F] [normed_space 𝕜 F] {f : 𝕜 → F} {f₁ : 𝕜 → F} {f' : F} {x : 𝕜} {s : set 𝕜}
(h : has_deriv_within_at f f' s x) (hs : ∀ (x : 𝕜), x ∈ s → f₁ x = f x) (hx : f₁ x = f x) :
has_deriv_within_at f₁ f' s x :=
has_deriv_within_at.congr_mono h hs hx (set.subset.refl s)
theorem has_deriv_within_at.congr_of_eventually_eq {𝕜 : Type u} [nondiscrete_normed_field 𝕜]
{F : Type v} [normed_group F] [normed_space 𝕜 F] {f : 𝕜 → F} {f₁ : 𝕜 → F} {f' : F} {x : 𝕜}
{s : set 𝕜} (h : has_deriv_within_at f f' s x)
(h₁ : filter.eventually_eq (nhds_within x s) f₁ f) (hx : f₁ x = f x) :
has_deriv_within_at f₁ f' s x :=
has_deriv_at_filter.congr_of_eventually_eq h h₁ hx
theorem has_deriv_within_at.congr_of_eventually_eq_of_mem {𝕜 : Type u} [nondiscrete_normed_field 𝕜]
{F : Type v} [normed_group F] [normed_space 𝕜 F] {f : 𝕜 → F} {f₁ : 𝕜 → F} {f' : F} {x : 𝕜}
{s : set 𝕜} (h : has_deriv_within_at f f' s x)
(h₁ : filter.eventually_eq (nhds_within x s) f₁ f) (hx : x ∈ s) :
has_deriv_within_at f₁ f' s x :=
has_deriv_within_at.congr_of_eventually_eq h h₁ (filter.eventually_eq.eq_of_nhds_within h₁ hx)
theorem has_deriv_at.congr_of_eventually_eq {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v}
[normed_group F] [normed_space 𝕜 F] {f : 𝕜 → F} {f₁ : 𝕜 → F} {f' : F} {x : 𝕜}
(h : has_deriv_at f f' x) (h₁ : filter.eventually_eq (nhds x) f₁ f) : has_deriv_at f₁ f' x :=
has_deriv_at_filter.congr_of_eventually_eq h h₁ (mem_of_nhds h₁)
theorem filter.eventually_eq.deriv_within_eq {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v}
[normed_group F] [normed_space 𝕜 F] {f : 𝕜 → F} {f₁ : 𝕜 → F} {x : 𝕜} {s : set 𝕜}
(hs : unique_diff_within_at 𝕜 s x) (hL : filter.eventually_eq (nhds_within x s) f₁ f)
(hx : f₁ x = f x) : deriv_within f₁ s x = deriv_within f s x :=
sorry
theorem deriv_within_congr {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v} [normed_group F]
[normed_space 𝕜 F] {f : 𝕜 → F} {f₁ : 𝕜 → F} {x : 𝕜} {s : set 𝕜}
(hs : unique_diff_within_at 𝕜 s x) (hL : ∀ (y : 𝕜), y ∈ s → f₁ y = f y) (hx : f₁ x = f x) :
deriv_within f₁ s x = deriv_within f s x :=
sorry
theorem filter.eventually_eq.deriv_eq {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v}
[normed_group F] [normed_space 𝕜 F] {f : 𝕜 → F} {f₁ : 𝕜 → F} {x : 𝕜}
(hL : filter.eventually_eq (nhds x) f₁ f) : deriv f₁ x = deriv f x :=
sorry
/-! ### Derivative of the identity -/
theorem has_deriv_at_filter_id {𝕜 : Type u} [nondiscrete_normed_field 𝕜] (x : 𝕜) (L : filter 𝕜) :
has_deriv_at_filter id 1 x L :=
has_fderiv_at_filter.has_deriv_at_filter (has_fderiv_at_filter_id x L)
theorem has_deriv_within_at_id {𝕜 : Type u} [nondiscrete_normed_field 𝕜] (x : 𝕜) (s : set 𝕜) :
has_deriv_within_at id 1 s x :=
has_deriv_at_filter_id x (nhds_within x s)
theorem has_deriv_at_id {𝕜 : Type u} [nondiscrete_normed_field 𝕜] (x : 𝕜) : has_deriv_at id 1 x :=
has_deriv_at_filter_id x (nhds x)
theorem has_deriv_at_id' {𝕜 : Type u} [nondiscrete_normed_field 𝕜] (x : 𝕜) :
has_deriv_at (fun (x : 𝕜) => x) 1 x :=
has_deriv_at_filter_id x (nhds x)
theorem has_strict_deriv_at_id {𝕜 : Type u} [nondiscrete_normed_field 𝕜] (x : 𝕜) :
has_strict_deriv_at id 1 x :=
has_strict_fderiv_at.has_strict_deriv_at (has_strict_fderiv_at_id x)
theorem deriv_id {𝕜 : Type u} [nondiscrete_normed_field 𝕜] (x : 𝕜) : deriv id x = 1 :=
has_deriv_at.deriv (has_deriv_at_id x)
@[simp] theorem deriv_id' {𝕜 : Type u} [nondiscrete_normed_field 𝕜] :
deriv id = fun (_x : 𝕜) => 1 :=
funext deriv_id
@[simp] theorem deriv_id'' {𝕜 : Type u} [nondiscrete_normed_field 𝕜] (x : 𝕜) :
deriv (fun (x : 𝕜) => x) x = 1 :=
deriv_id x
theorem deriv_within_id {𝕜 : Type u} [nondiscrete_normed_field 𝕜] (x : 𝕜) (s : set 𝕜)
(hxs : unique_diff_within_at 𝕜 s x) : deriv_within id s x = 1 :=
has_deriv_within_at.deriv_within (has_deriv_within_at_id x s) hxs
/-! ### Derivative of constant functions -/
theorem has_deriv_at_filter_const {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v}
[normed_group F] [normed_space 𝕜 F] (x : 𝕜) (L : filter 𝕜) (c : F) :
has_deriv_at_filter (fun (x : 𝕜) => c) 0 x L :=
has_fderiv_at_filter.has_deriv_at_filter (has_fderiv_at_filter_const c x L)
theorem has_strict_deriv_at_const {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v}
[normed_group F] [normed_space 𝕜 F] (x : 𝕜) (c : F) :
has_strict_deriv_at (fun (x : 𝕜) => c) 0 x :=
has_strict_fderiv_at.has_strict_deriv_at (has_strict_fderiv_at_const c x)
theorem has_deriv_within_at_const {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v}
[normed_group F] [normed_space 𝕜 F] (x : 𝕜) (s : set 𝕜) (c : F) :
has_deriv_within_at (fun (x : 𝕜) => c) 0 s x :=
has_deriv_at_filter_const x (nhds_within x s) c
theorem has_deriv_at_const {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v} [normed_group F]
[normed_space 𝕜 F] (x : 𝕜) (c : F) : has_deriv_at (fun (x : 𝕜) => c) 0 x :=
has_deriv_at_filter_const x (nhds x) c
theorem deriv_const {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v} [normed_group F]
[normed_space 𝕜 F] (x : 𝕜) (c : F) : deriv (fun (x : 𝕜) => c) x = 0 :=
has_deriv_at.deriv (has_deriv_at_const x c)
@[simp] theorem deriv_const' {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v} [normed_group F]
[normed_space 𝕜 F] (c : F) : (deriv fun (x : 𝕜) => c) = fun (x : 𝕜) => 0 :=
funext fun (x : 𝕜) => deriv_const x c
theorem deriv_within_const {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v} [normed_group F]
[normed_space 𝕜 F] (x : 𝕜) (s : set 𝕜) (c : F) (hxs : unique_diff_within_at 𝕜 s x) :
deriv_within (fun (x : 𝕜) => c) s x = 0 :=
has_deriv_within_at.deriv_within (has_deriv_within_at_const x s c) hxs
/-! ### Derivative of continuous linear maps -/
theorem continuous_linear_map.has_deriv_at_filter {𝕜 : Type u} [nondiscrete_normed_field 𝕜]
{F : Type v} [normed_group F] [normed_space 𝕜 F] {x : 𝕜} {L : filter 𝕜}
(e : continuous_linear_map 𝕜 𝕜 F) : has_deriv_at_filter (⇑e) (coe_fn e 1) x L :=
has_fderiv_at_filter.has_deriv_at_filter (continuous_linear_map.has_fderiv_at_filter e)
theorem continuous_linear_map.has_strict_deriv_at {𝕜 : Type u} [nondiscrete_normed_field 𝕜]
{F : Type v} [normed_group F] [normed_space 𝕜 F] {x : 𝕜} (e : continuous_linear_map 𝕜 𝕜 F) :
has_strict_deriv_at (⇑e) (coe_fn e 1) x :=
has_strict_fderiv_at.has_strict_deriv_at (continuous_linear_map.has_strict_fderiv_at e)
theorem continuous_linear_map.has_deriv_at {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v}
[normed_group F] [normed_space 𝕜 F] {x : 𝕜} (e : continuous_linear_map 𝕜 𝕜 F) :
has_deriv_at (⇑e) (coe_fn e 1) x :=
continuous_linear_map.has_deriv_at_filter e
theorem continuous_linear_map.has_deriv_within_at {𝕜 : Type u} [nondiscrete_normed_field 𝕜]
{F : Type v} [normed_group F] [normed_space 𝕜 F] {x : 𝕜} {s : set 𝕜}
(e : continuous_linear_map 𝕜 𝕜 F) : has_deriv_within_at (⇑e) (coe_fn e 1) s x :=
continuous_linear_map.has_deriv_at_filter e
@[simp] theorem continuous_linear_map.deriv {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v}
[normed_group F] [normed_space 𝕜 F] {x : 𝕜} (e : continuous_linear_map 𝕜 𝕜 F) :
deriv (⇑e) x = coe_fn e 1 :=
has_deriv_at.deriv (continuous_linear_map.has_deriv_at e)
theorem continuous_linear_map.deriv_within {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v}
[normed_group F] [normed_space 𝕜 F] {x : 𝕜} {s : set 𝕜} (e : continuous_linear_map 𝕜 𝕜 F)
(hxs : unique_diff_within_at 𝕜 s x) : deriv_within (⇑e) s x = coe_fn e 1 :=
has_deriv_within_at.deriv_within (continuous_linear_map.has_deriv_within_at e) hxs
/-! ### Derivative of bundled linear maps -/
theorem linear_map.has_deriv_at_filter {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v}
[normed_group F] [normed_space 𝕜 F] {x : 𝕜} {L : filter 𝕜} (e : linear_map 𝕜 𝕜 F) :
has_deriv_at_filter (⇑e) (coe_fn e 1) x L :=
continuous_linear_map.has_deriv_at_filter (linear_map.to_continuous_linear_map₁ e)
theorem linear_map.has_strict_deriv_at {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v}
[normed_group F] [normed_space 𝕜 F] {x : 𝕜} (e : linear_map 𝕜 𝕜 F) :
has_strict_deriv_at (⇑e) (coe_fn e 1) x :=
continuous_linear_map.has_strict_deriv_at (linear_map.to_continuous_linear_map₁ e)
theorem linear_map.has_deriv_at {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v}
[normed_group F] [normed_space 𝕜 F] {x : 𝕜} (e : linear_map 𝕜 𝕜 F) :
has_deriv_at (⇑e) (coe_fn e 1) x :=
linear_map.has_deriv_at_filter e
theorem linear_map.has_deriv_within_at {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v}
[normed_group F] [normed_space 𝕜 F] {x : 𝕜} {s : set 𝕜} (e : linear_map 𝕜 𝕜 F) :
has_deriv_within_at (⇑e) (coe_fn e 1) s x :=
linear_map.has_deriv_at_filter e
@[simp] theorem linear_map.deriv {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v}
[normed_group F] [normed_space 𝕜 F] {x : 𝕜} (e : linear_map 𝕜 𝕜 F) :
deriv (⇑e) x = coe_fn e 1 :=
has_deriv_at.deriv (linear_map.has_deriv_at e)
theorem linear_map.deriv_within {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v}
[normed_group F] [normed_space 𝕜 F] {x : 𝕜} {s : set 𝕜} (e : linear_map 𝕜 𝕜 F)
(hxs : unique_diff_within_at 𝕜 s x) : deriv_within (⇑e) s x = coe_fn e 1 :=
has_deriv_within_at.deriv_within (linear_map.has_deriv_within_at e) hxs
theorem has_fpower_series_at.has_strict_deriv_at {𝕜 : Type u} [nondiscrete_normed_field 𝕜]
{F : Type v} [normed_group F] [normed_space 𝕜 F] {f : 𝕜 → F} {x : 𝕜}
{p : formal_multilinear_series 𝕜 𝕜 F} (h : has_fpower_series_at f p x) :
has_strict_deriv_at f (coe_fn (p 1) fun (_x : fin 1) => 1) x :=
has_strict_fderiv_at.has_strict_deriv_at (has_fpower_series_at.has_strict_fderiv_at h)
theorem has_fpower_series_at.has_deriv_at {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v}
[normed_group F] [normed_space 𝕜 F] {f : 𝕜 → F} {x : 𝕜} {p : formal_multilinear_series 𝕜 𝕜 F}
(h : has_fpower_series_at f p x) : has_deriv_at f (coe_fn (p 1) fun (_x : fin 1) => 1) x :=
has_strict_deriv_at.has_deriv_at (has_fpower_series_at.has_strict_deriv_at h)
theorem has_fpower_series_at.deriv {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v}
[normed_group F] [normed_space 𝕜 F] {f : 𝕜 → F} {x : 𝕜} {p : formal_multilinear_series 𝕜 𝕜 F}
(h : has_fpower_series_at f p x) : deriv f x = coe_fn (p 1) fun (_x : fin 1) => 1 :=
has_deriv_at.deriv (has_fpower_series_at.has_deriv_at h)
/-! ### Derivative of the sum of two functions -/
theorem has_deriv_at_filter.add {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v}
[normed_group F] [normed_space 𝕜 F] {f : 𝕜 → F} {g : 𝕜 → F} {f' : F} {g' : F} {x : 𝕜}
{L : filter 𝕜} (hf : has_deriv_at_filter f f' x L) (hg : has_deriv_at_filter g g' x L) :
has_deriv_at_filter (fun (y : 𝕜) => f y + g y) (f' + g') x L :=
sorry
theorem has_strict_deriv_at.add {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v}
[normed_group F] [normed_space 𝕜 F] {f : 𝕜 → F} {g : 𝕜 → F} {f' : F} {g' : F} {x : 𝕜}
(hf : has_strict_deriv_at f f' x) (hg : has_strict_deriv_at g g' x) :
has_strict_deriv_at (fun (y : 𝕜) => f y + g y) (f' + g') x :=
sorry
theorem has_deriv_within_at.add {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v}
[normed_group F] [normed_space 𝕜 F] {f : 𝕜 → F} {g : 𝕜 → F} {f' : F} {g' : F} {x : 𝕜}
{s : set 𝕜} (hf : has_deriv_within_at f f' s x) (hg : has_deriv_within_at g g' s x) :
has_deriv_within_at (fun (y : 𝕜) => f y + g y) (f' + g') s x :=
has_deriv_at_filter.add hf hg
theorem has_deriv_at.add {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v} [normed_group F]
[normed_space 𝕜 F] {f : 𝕜 → F} {g : 𝕜 → F} {f' : F} {g' : F} {x : 𝕜} (hf : has_deriv_at f f' x)
(hg : has_deriv_at g g' x) : has_deriv_at (fun (x : 𝕜) => f x + g x) (f' + g') x :=
has_deriv_at_filter.add hf hg
theorem deriv_within_add {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v} [normed_group F]
[normed_space 𝕜 F] {f : 𝕜 → F} {g : 𝕜 → F} {x : 𝕜} {s : set 𝕜}
(hxs : unique_diff_within_at 𝕜 s x) (hf : differentiable_within_at 𝕜 f s x)
(hg : differentiable_within_at 𝕜 g s x) :
deriv_within (fun (y : 𝕜) => f y + g y) s x = deriv_within f s x + deriv_within g s x :=
sorry
@[simp] theorem deriv_add {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v} [normed_group F]
[normed_space 𝕜 F] {f : 𝕜 → F} {g : 𝕜 → F} {x : 𝕜} (hf : differentiable_at 𝕜 f x)
(hg : differentiable_at 𝕜 g x) : deriv (fun (y : 𝕜) => f y + g y) x = deriv f x + deriv g x :=
has_deriv_at.deriv
(has_deriv_at.add (differentiable_at.has_deriv_at hf) (differentiable_at.has_deriv_at hg))
theorem has_deriv_at_filter.add_const {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v}
[normed_group F] [normed_space 𝕜 F] {f : 𝕜 → F} {f' : F} {x : 𝕜} {L : filter 𝕜}
(hf : has_deriv_at_filter f f' x L) (c : F) :
has_deriv_at_filter (fun (y : 𝕜) => f y + c) f' x L :=
add_zero f' ▸ has_deriv_at_filter.add hf (has_deriv_at_filter_const x L c)
theorem has_deriv_within_at.add_const {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v}
[normed_group F] [normed_space 𝕜 F] {f : 𝕜 → F} {f' : F} {x : 𝕜} {s : set 𝕜}
(hf : has_deriv_within_at f f' s x) (c : F) :
has_deriv_within_at (fun (y : 𝕜) => f y + c) f' s x :=
has_deriv_at_filter.add_const hf c
theorem has_deriv_at.add_const {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v}
[normed_group F] [normed_space 𝕜 F] {f : 𝕜 → F} {f' : F} {x : 𝕜} (hf : has_deriv_at f f' x)
(c : F) : has_deriv_at (fun (x : 𝕜) => f x + c) f' x :=
has_deriv_at_filter.add_const hf c
theorem deriv_within_add_const {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v}
[normed_group F] [normed_space 𝕜 F] {f : 𝕜 → F} {x : 𝕜} {s : set 𝕜}
(hxs : unique_diff_within_at 𝕜 s x) (c : F) :
deriv_within (fun (y : 𝕜) => f y + c) s x = deriv_within f s x :=
sorry
theorem deriv_add_const {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v} [normed_group F]
[normed_space 𝕜 F] {f : 𝕜 → F} {x : 𝕜} (c : F) : deriv (fun (y : 𝕜) => f y + c) x = deriv f x :=
sorry
theorem has_deriv_at_filter.const_add {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v}
[normed_group F] [normed_space 𝕜 F] {f : 𝕜 → F} {f' : F} {x : 𝕜} {L : filter 𝕜} (c : F)
(hf : has_deriv_at_filter f f' x L) : has_deriv_at_filter (fun (y : 𝕜) => c + f y) f' x L :=
zero_add f' ▸ has_deriv_at_filter.add (has_deriv_at_filter_const x L c) hf
theorem has_deriv_within_at.const_add {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v}
[normed_group F] [normed_space 𝕜 F] {f : 𝕜 → F} {f' : F} {x : 𝕜} {s : set 𝕜} (c : F)
(hf : has_deriv_within_at f f' s x) : has_deriv_within_at (fun (y : 𝕜) => c + f y) f' s x :=
has_deriv_at_filter.const_add c hf
theorem has_deriv_at.const_add {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v}
[normed_group F] [normed_space 𝕜 F] {f : 𝕜 → F} {f' : F} {x : 𝕜} (c : F)
(hf : has_deriv_at f f' x) : has_deriv_at (fun (x : 𝕜) => c + f x) f' x :=
has_deriv_at_filter.const_add c hf
theorem deriv_within_const_add {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v}
[normed_group F] [normed_space 𝕜 F] {f : 𝕜 → F} {x : 𝕜} {s : set 𝕜}
(hxs : unique_diff_within_at 𝕜 s x) (c : F) :
deriv_within (fun (y : 𝕜) => c + f y) s x = deriv_within f s x :=
sorry
theorem deriv_const_add {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v} [normed_group F]
[normed_space 𝕜 F] {f : 𝕜 → F} {x : 𝕜} (c : F) : deriv (fun (y : 𝕜) => c + f y) x = deriv f x :=
sorry
/-! ### Derivative of a finite sum of functions -/
theorem has_deriv_at_filter.sum {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v}
[normed_group F] [normed_space 𝕜 F] {x : 𝕜} {L : filter 𝕜} {ι : Type u_1} {u : finset ι}
{A : ι → 𝕜 → F} {A' : ι → F} (h : ∀ (i : ι), i ∈ u → has_deriv_at_filter (A i) (A' i) x L) :
has_deriv_at_filter (fun (y : 𝕜) => finset.sum u fun (i : ι) => A i y)
(finset.sum u fun (i : ι) => A' i) x L :=
sorry
theorem has_strict_deriv_at.sum {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v}
[normed_group F] [normed_space 𝕜 F] {x : 𝕜} {ι : Type u_1} {u : finset ι} {A : ι → 𝕜 → F}
{A' : ι → F} (h : ∀ (i : ι), i ∈ u → has_strict_deriv_at (A i) (A' i) x) :
has_strict_deriv_at (fun (y : 𝕜) => finset.sum u fun (i : ι) => A i y)
(finset.sum u fun (i : ι) => A' i) x :=
sorry
theorem has_deriv_within_at.sum {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v}
[normed_group F] [normed_space 𝕜 F] {x : 𝕜} {s : set 𝕜} {ι : Type u_1} {u : finset ι}
{A : ι → 𝕜 → F} {A' : ι → F} (h : ∀ (i : ι), i ∈ u → has_deriv_within_at (A i) (A' i) s x) :
has_deriv_within_at (fun (y : 𝕜) => finset.sum u fun (i : ι) => A i y)
(finset.sum u fun (i : ι) => A' i) s x :=
has_deriv_at_filter.sum h
theorem has_deriv_at.sum {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v} [normed_group F]
[normed_space 𝕜 F] {x : 𝕜} {ι : Type u_1} {u : finset ι} {A : ι → 𝕜 → F} {A' : ι → F}
(h : ∀ (i : ι), i ∈ u → has_deriv_at (A i) (A' i) x) :
has_deriv_at (fun (y : 𝕜) => finset.sum u fun (i : ι) => A i y)
(finset.sum u fun (i : ι) => A' i) x :=
has_deriv_at_filter.sum h
theorem deriv_within_sum {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v} [normed_group F]
[normed_space 𝕜 F] {x : 𝕜} {s : set 𝕜} {ι : Type u_1} {u : finset ι} {A : ι → 𝕜 → F}
(hxs : unique_diff_within_at 𝕜 s x)
(h : ∀ (i : ι), i ∈ u → differentiable_within_at 𝕜 (A i) s x) :
deriv_within (fun (y : 𝕜) => finset.sum u fun (i : ι) => A i y) s x =
finset.sum u fun (i : ι) => deriv_within (A i) s x :=
has_deriv_within_at.deriv_within
(has_deriv_within_at.sum
fun (i : ι) (hi : i ∈ u) => differentiable_within_at.has_deriv_within_at (h i hi))
hxs
@[simp] theorem deriv_sum {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v} [normed_group F]
[normed_space 𝕜 F] {x : 𝕜} {ι : Type u_1} {u : finset ι} {A : ι → 𝕜 → F}
(h : ∀ (i : ι), i ∈ u → differentiable_at 𝕜 (A i) x) :
deriv (fun (y : 𝕜) => finset.sum u fun (i : ι) => A i y) x =
finset.sum u fun (i : ι) => deriv (A i) x :=
has_deriv_at.deriv
(has_deriv_at.sum fun (i : ι) (hi : i ∈ u) => differentiable_at.has_deriv_at (h i hi))
/-! ### Derivative of the multiplication of a scalar function and a vector function -/
theorem has_deriv_within_at.smul {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v}
[normed_group F] [normed_space 𝕜 F] {f : 𝕜 → F} {f' : F} {x : 𝕜} {s : set 𝕜} {c : 𝕜 → 𝕜}
{c' : 𝕜} (hc : has_deriv_within_at c c' s x) (hf : has_deriv_within_at f f' s x) :
has_deriv_within_at (fun (y : 𝕜) => c y • f y) (c x • f' + c' • f x) s x :=
sorry
theorem has_deriv_at.smul {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v} [normed_group F]
[normed_space 𝕜 F] {f : 𝕜 → F} {f' : F} {x : 𝕜} {c : 𝕜 → 𝕜} {c' : 𝕜} (hc : has_deriv_at c c' x)
(hf : has_deriv_at f f' x) : has_deriv_at (fun (y : 𝕜) => c y • f y) (c x • f' + c' • f x) x :=
sorry
theorem has_strict_deriv_at.smul {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v}
[normed_group F] [normed_space 𝕜 F] {f : 𝕜 → F} {f' : F} {x : 𝕜} {c : 𝕜 → 𝕜} {c' : 𝕜}
(hc : has_strict_deriv_at c c' x) (hf : has_strict_deriv_at f f' x) :
has_strict_deriv_at (fun (y : 𝕜) => c y • f y) (c x • f' + c' • f x) x :=
sorry
theorem deriv_within_smul {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v} [normed_group F]
[normed_space 𝕜 F] {f : 𝕜 → F} {x : 𝕜} {s : set 𝕜} {c : 𝕜 → 𝕜}
(hxs : unique_diff_within_at 𝕜 s x) (hc : differentiable_within_at 𝕜 c s x)
(hf : differentiable_within_at 𝕜 f s x) :
deriv_within (fun (y : 𝕜) => c y • f y) s x =
c x • deriv_within f s x + deriv_within c s x • f x :=
sorry
theorem deriv_smul {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v} [normed_group F]
[normed_space 𝕜 F] {f : 𝕜 → F} {x : 𝕜} {c : 𝕜 → 𝕜} (hc : differentiable_at 𝕜 c x)
(hf : differentiable_at 𝕜 f x) :
deriv (fun (y : 𝕜) => c y • f y) x = c x • deriv f x + deriv c x • f x :=
has_deriv_at.deriv
(has_deriv_at.smul (differentiable_at.has_deriv_at hc) (differentiable_at.has_deriv_at hf))
theorem has_deriv_within_at.smul_const {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v}
[normed_group F] [normed_space 𝕜 F] {x : 𝕜} {s : set 𝕜} {c : 𝕜 → 𝕜} {c' : 𝕜}
(hc : has_deriv_within_at c c' s x) (f : F) :
has_deriv_within_at (fun (y : 𝕜) => c y • f) (c' • f) s x :=
sorry
theorem has_deriv_at.smul_const {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v}
[normed_group F] [normed_space 𝕜 F] {x : 𝕜} {c : 𝕜 → 𝕜} {c' : 𝕜} (hc : has_deriv_at c c' x)
(f : F) : has_deriv_at (fun (y : 𝕜) => c y • f) (c' • f) x :=
sorry
theorem deriv_within_smul_const {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v}
[normed_group F] [normed_space 𝕜 F] {x : 𝕜} {s : set 𝕜} {c : 𝕜 → 𝕜}
(hxs : unique_diff_within_at 𝕜 s x) (hc : differentiable_within_at 𝕜 c s x) (f : F) :
deriv_within (fun (y : 𝕜) => c y • f) s x = deriv_within c s x • f :=
has_deriv_within_at.deriv_within
(has_deriv_within_at.smul_const (differentiable_within_at.has_deriv_within_at hc) f) hxs
theorem deriv_smul_const {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v} [normed_group F]
[normed_space 𝕜 F] {x : 𝕜} {c : 𝕜 → 𝕜} (hc : differentiable_at 𝕜 c x) (f : F) :
deriv (fun (y : 𝕜) => c y • f) x = deriv c x • f :=
has_deriv_at.deriv (has_deriv_at.smul_const (differentiable_at.has_deriv_at hc) f)
theorem has_deriv_within_at.const_smul {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v}
[normed_group F] [normed_space 𝕜 F] {f : 𝕜 → F} {f' : F} {x : 𝕜} {s : set 𝕜} (c : 𝕜)
(hf : has_deriv_within_at f f' s x) :
has_deriv_within_at (fun (y : 𝕜) => c • f y) (c • f') s x :=
sorry
theorem has_deriv_at.const_smul {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v}
[normed_group F] [normed_space 𝕜 F] {f : 𝕜 → F} {f' : F} {x : 𝕜} (c : 𝕜)
(hf : has_deriv_at f f' x) : has_deriv_at (fun (y : 𝕜) => c • f y) (c • f') x :=
sorry
theorem deriv_within_const_smul {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v}
[normed_group F] [normed_space 𝕜 F] {f : 𝕜 → F} {x : 𝕜} {s : set 𝕜}
(hxs : unique_diff_within_at 𝕜 s x) (c : 𝕜) (hf : differentiable_within_at 𝕜 f s x) :
deriv_within (fun (y : 𝕜) => c • f y) s x = c • deriv_within f s x :=
has_deriv_within_at.deriv_within
(has_deriv_within_at.const_smul c (differentiable_within_at.has_deriv_within_at hf)) hxs
theorem deriv_const_smul {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v} [normed_group F]
[normed_space 𝕜 F] {f : 𝕜 → F} {x : 𝕜} (c : 𝕜) (hf : differentiable_at 𝕜 f x) :
deriv (fun (y : 𝕜) => c • f y) x = c • deriv f x :=
has_deriv_at.deriv (has_deriv_at.const_smul c (differentiable_at.has_deriv_at hf))
/-! ### Derivative of the negative of a function -/
theorem has_deriv_at_filter.neg {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v}
[normed_group F] [normed_space 𝕜 F] {f : 𝕜 → F} {f' : F} {x : 𝕜} {L : filter 𝕜}
(h : has_deriv_at_filter f f' x L) : has_deriv_at_filter (fun (x : 𝕜) => -f x) (-f') x L :=
sorry
theorem has_deriv_within_at.neg {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v}
[normed_group F] [normed_space 𝕜 F] {f : 𝕜 → F} {f' : F} {x : 𝕜} {s : set 𝕜}
(h : has_deriv_within_at f f' s x) : has_deriv_within_at (fun (x : 𝕜) => -f x) (-f') s x :=
has_deriv_at_filter.neg h
theorem has_deriv_at.neg {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v} [normed_group F]
[normed_space 𝕜 F] {f : 𝕜 → F} {f' : F} {x : 𝕜} (h : has_deriv_at f f' x) :
has_deriv_at (fun (x : 𝕜) => -f x) (-f') x :=
has_deriv_at_filter.neg h
theorem has_strict_deriv_at.neg {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v}
[normed_group F] [normed_space 𝕜 F] {f : 𝕜 → F} {f' : F} {x : 𝕜}
(h : has_strict_deriv_at f f' x) : has_strict_deriv_at (fun (x : 𝕜) => -f x) (-f') x :=
sorry
theorem deriv_within.neg {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v} [normed_group F]
[normed_space 𝕜 F] {f : 𝕜 → F} {x : 𝕜} {s : set 𝕜} (hxs : unique_diff_within_at 𝕜 s x) :
deriv_within (fun (y : 𝕜) => -f y) s x = -deriv_within f s x :=
sorry
theorem deriv.neg {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v} [normed_group F]
[normed_space 𝕜 F] {f : 𝕜 → F} {x : 𝕜} : deriv (fun (y : 𝕜) => -f y) x = -deriv f x :=
sorry
@[simp] theorem deriv.neg' {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v} [normed_group F]
[normed_space 𝕜 F] {f : 𝕜 → F} : (deriv fun (y : 𝕜) => -f y) = fun (x : 𝕜) => -deriv f x :=
funext fun (x : 𝕜) => deriv.neg
/-! ### Derivative of the negation function (i.e `has_neg.neg`) -/
theorem has_deriv_at_filter_neg {𝕜 : Type u} [nondiscrete_normed_field 𝕜] (x : 𝕜) (L : filter 𝕜) :
has_deriv_at_filter Neg.neg (-1) x L :=
has_deriv_at_filter.neg (has_deriv_at_filter_id x L)
theorem has_deriv_within_at_neg {𝕜 : Type u} [nondiscrete_normed_field 𝕜] (x : 𝕜) (s : set 𝕜) :
has_deriv_within_at Neg.neg (-1) s x :=
has_deriv_at_filter_neg x (nhds_within x s)
theorem has_deriv_at_neg {𝕜 : Type u} [nondiscrete_normed_field 𝕜] (x : 𝕜) :
has_deriv_at Neg.neg (-1) x :=
has_deriv_at_filter_neg x (nhds x)
theorem has_deriv_at_neg' {𝕜 : Type u} [nondiscrete_normed_field 𝕜] (x : 𝕜) :
has_deriv_at (fun (x : 𝕜) => -x) (-1) x :=
has_deriv_at_filter_neg x (nhds x)
theorem has_strict_deriv_at_neg {𝕜 : Type u} [nondiscrete_normed_field 𝕜] (x : 𝕜) :
has_strict_deriv_at Neg.neg (-1) x :=
has_strict_deriv_at.neg (has_strict_deriv_at_id x)
theorem deriv_neg {𝕜 : Type u} [nondiscrete_normed_field 𝕜] (x : 𝕜) : deriv Neg.neg x = -1 :=
has_deriv_at.deriv (has_deriv_at_neg x)
@[simp] theorem deriv_neg' {𝕜 : Type u} [nondiscrete_normed_field 𝕜] :
deriv Neg.neg = fun (_x : 𝕜) => -1 :=
funext deriv_neg
@[simp] theorem deriv_neg'' {𝕜 : Type u} [nondiscrete_normed_field 𝕜] (x : 𝕜) :
deriv (fun (x : 𝕜) => -x) x = -1 :=
deriv_neg x
theorem deriv_within_neg {𝕜 : Type u} [nondiscrete_normed_field 𝕜] (x : 𝕜) (s : set 𝕜)
(hxs : unique_diff_within_at 𝕜 s x) : deriv_within Neg.neg s x = -1 :=
has_deriv_within_at.deriv_within (has_deriv_within_at_neg x s) hxs
theorem differentiable_neg {𝕜 : Type u} [nondiscrete_normed_field 𝕜] : differentiable 𝕜 Neg.neg :=
differentiable.neg differentiable_id
theorem differentiable_on_neg {𝕜 : Type u} [nondiscrete_normed_field 𝕜] (s : set 𝕜) :
differentiable_on 𝕜 Neg.neg s :=
differentiable_on.neg differentiable_on_id
/-! ### Derivative of the difference of two functions -/
theorem has_deriv_at_filter.sub {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v}
[normed_group F] [normed_space 𝕜 F] {f : 𝕜 → F} {g : 𝕜 → F} {f' : F} {g' : F} {x : 𝕜}
{L : filter 𝕜} (hf : has_deriv_at_filter f f' x L) (hg : has_deriv_at_filter g g' x L) :
has_deriv_at_filter (fun (x : 𝕜) => f x - g x) (f' - g') x L :=
sorry
theorem has_deriv_within_at.sub {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v}
[normed_group F] [normed_space 𝕜 F] {f : 𝕜 → F} {g : 𝕜 → F} {f' : F} {g' : F} {x : 𝕜}
{s : set 𝕜} (hf : has_deriv_within_at f f' s x) (hg : has_deriv_within_at g g' s x) :
has_deriv_within_at (fun (x : 𝕜) => f x - g x) (f' - g') s x :=
has_deriv_at_filter.sub hf hg
theorem has_deriv_at.sub {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v} [normed_group F]
[normed_space 𝕜 F] {f : 𝕜 → F} {g : 𝕜 → F} {f' : F} {g' : F} {x : 𝕜} (hf : has_deriv_at f f' x)
(hg : has_deriv_at g g' x) : has_deriv_at (fun (x : 𝕜) => f x - g x) (f' - g') x :=
has_deriv_at_filter.sub hf hg
theorem has_strict_deriv_at.sub {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v}
[normed_group F] [normed_space 𝕜 F] {f : 𝕜 → F} {g : 𝕜 → F} {f' : F} {g' : F} {x : 𝕜}
(hf : has_strict_deriv_at f f' x) (hg : has_strict_deriv_at g g' x) :
has_strict_deriv_at (fun (x : 𝕜) => f x - g x) (f' - g') x :=
sorry
theorem deriv_within_sub {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v} [normed_group F]
[normed_space 𝕜 F] {f : 𝕜 → F} {g : 𝕜 → F} {x : 𝕜} {s : set 𝕜}
(hxs : unique_diff_within_at 𝕜 s x) (hf : differentiable_within_at 𝕜 f s x)
(hg : differentiable_within_at 𝕜 g s x) :
deriv_within (fun (y : 𝕜) => f y - g y) s x = deriv_within f s x - deriv_within g s x :=
sorry
@[simp] theorem deriv_sub {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v} [normed_group F]
[normed_space 𝕜 F] {f : 𝕜 → F} {g : 𝕜 → F} {x : 𝕜} (hf : differentiable_at 𝕜 f x)
(hg : differentiable_at 𝕜 g x) : deriv (fun (y : 𝕜) => f y - g y) x = deriv f x - deriv g x :=
has_deriv_at.deriv
(has_deriv_at.sub (differentiable_at.has_deriv_at hf) (differentiable_at.has_deriv_at hg))
theorem has_deriv_at_filter.is_O_sub {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v}
[normed_group F] [normed_space 𝕜 F] {f : 𝕜 → F} {f' : F} {x : 𝕜} {L : filter 𝕜}
(h : has_deriv_at_filter f f' x L) :
asymptotics.is_O (fun (x' : 𝕜) => f x' - f x) (fun (x' : 𝕜) => x' - x) L :=
has_fderiv_at_filter.is_O_sub h
theorem has_deriv_at_filter.sub_const {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v}
[normed_group F] [normed_space 𝕜 F] {f : 𝕜 → F} {f' : F} {x : 𝕜} {L : filter 𝕜}
(hf : has_deriv_at_filter f f' x L) (c : F) :
has_deriv_at_filter (fun (x : 𝕜) => f x - c) f' x L :=
sorry
theorem has_deriv_within_at.sub_const {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v}
[normed_group F] [normed_space 𝕜 F] {f : 𝕜 → F} {f' : F} {x : 𝕜} {s : set 𝕜}
(hf : has_deriv_within_at f f' s x) (c : F) :
has_deriv_within_at (fun (x : 𝕜) => f x - c) f' s x :=
has_deriv_at_filter.sub_const hf c
theorem has_deriv_at.sub_const {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v}
[normed_group F] [normed_space 𝕜 F] {f : 𝕜 → F} {f' : F} {x : 𝕜} (hf : has_deriv_at f f' x)
(c : F) : has_deriv_at (fun (x : 𝕜) => f x - c) f' x :=
has_deriv_at_filter.sub_const hf c
theorem deriv_within_sub_const {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v}
[normed_group F] [normed_space 𝕜 F] {f : 𝕜 → F} {x : 𝕜} {s : set 𝕜}
(hxs : unique_diff_within_at 𝕜 s x) (c : F) :
deriv_within (fun (y : 𝕜) => f y - c) s x = deriv_within f s x :=
sorry
theorem deriv_sub_const {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v} [normed_group F]
[normed_space 𝕜 F] {f : 𝕜 → F} {x : 𝕜} (c : F) : deriv (fun (y : 𝕜) => f y - c) x = deriv f x :=
sorry
theorem has_deriv_at_filter.const_sub {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v}
[normed_group F] [normed_space 𝕜 F] {f : 𝕜 → F} {f' : F} {x : 𝕜} {L : filter 𝕜} (c : F)
(hf : has_deriv_at_filter f f' x L) : has_deriv_at_filter (fun (x : 𝕜) => c - f x) (-f') x L :=
sorry
theorem has_deriv_within_at.const_sub {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v}
[normed_group F] [normed_space 𝕜 F] {f : 𝕜 → F} {f' : F} {x : 𝕜} {s : set 𝕜} (c : F)
(hf : has_deriv_within_at f f' s x) : has_deriv_within_at (fun (x : 𝕜) => c - f x) (-f') s x :=
has_deriv_at_filter.const_sub c hf
theorem has_deriv_at.const_sub {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v}
[normed_group F] [normed_space 𝕜 F] {f : 𝕜 → F} {f' : F} {x : 𝕜} (c : F)
(hf : has_deriv_at f f' x) : has_deriv_at (fun (x : 𝕜) => c - f x) (-f') x :=
has_deriv_at_filter.const_sub c hf
theorem deriv_within_const_sub {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v}
[normed_group F] [normed_space 𝕜 F] {f : 𝕜 → F} {x : 𝕜} {s : set 𝕜}
(hxs : unique_diff_within_at 𝕜 s x) (c : F) :
deriv_within (fun (y : 𝕜) => c - f y) s x = -deriv_within f s x :=
sorry
theorem deriv_const_sub {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v} [normed_group F]
[normed_space 𝕜 F] {f : 𝕜 → F} {x : 𝕜} (c : F) :
deriv (fun (y : 𝕜) => c - f y) x = -deriv f x :=
sorry
/-! ### Continuity of a function admitting a derivative -/
theorem has_deriv_at_filter.tendsto_nhds {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v}
[normed_group F] [normed_space 𝕜 F] {f : 𝕜 → F} {f' : F} {x : 𝕜} {L : filter 𝕜}
(hL : L ≤ nhds x) (h : has_deriv_at_filter f f' x L) : filter.tendsto f L (nhds (f x)) :=
has_fderiv_at_filter.tendsto_nhds hL h
theorem has_deriv_within_at.continuous_within_at {𝕜 : Type u} [nondiscrete_normed_field 𝕜]
{F : Type v} [normed_group F] [normed_space 𝕜 F] {f : 𝕜 → F} {f' : F} {x : 𝕜} {s : set 𝕜}
(h : has_deriv_within_at f f' s x) : continuous_within_at f s x :=
has_deriv_at_filter.tendsto_nhds inf_le_left h
theorem has_deriv_at.continuous_at {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v}
[normed_group F] [normed_space 𝕜 F] {f : 𝕜 → F} {f' : F} {x : 𝕜} (h : has_deriv_at f f' x) :
continuous_at f x :=
has_deriv_at_filter.tendsto_nhds (le_refl (nhds x)) h
/-! ### Derivative of the cartesian product of two functions -/
theorem has_deriv_at_filter.prod {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v}
[normed_group F] [normed_space 𝕜 F] {f₁ : 𝕜 → F} {f₁' : F} {x : 𝕜} {L : filter 𝕜} {G : Type w}
[normed_group G] [normed_space 𝕜 G] {f₂ : 𝕜 → G} {f₂' : G}
(hf₁ : has_deriv_at_filter f₁ f₁' x L) (hf₂ : has_deriv_at_filter f₂ f₂' x L) :
has_deriv_at_filter (fun (x : 𝕜) => (f₁ x, f₂ x)) (f₁', f₂') x L :=
sorry
theorem has_deriv_within_at.prod {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v}
[normed_group F] [normed_space 𝕜 F] {f₁ : 𝕜 → F} {f₁' : F} {x : 𝕜} {s : set 𝕜} {G : Type w}
[normed_group G] [normed_space 𝕜 G] {f₂ : 𝕜 → G} {f₂' : G}
(hf₁ : has_deriv_within_at f₁ f₁' s x) (hf₂ : has_deriv_within_at f₂ f₂' s x) :
has_deriv_within_at (fun (x : 𝕜) => (f₁ x, f₂ x)) (f₁', f₂') s x :=
has_deriv_at_filter.prod hf₁ hf₂
theorem has_deriv_at.prod {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v} [normed_group F]
[normed_space 𝕜 F] {f₁ : 𝕜 → F} {f₁' : F} {x : 𝕜} {G : Type w} [normed_group G]
[normed_space 𝕜 G] {f₂ : 𝕜 → G} {f₂' : G} (hf₁ : has_deriv_at f₁ f₁' x)
(hf₂ : has_deriv_at f₂ f₂' x) : has_deriv_at (fun (x : 𝕜) => (f₁ x, f₂ x)) (f₁', f₂') x :=
has_deriv_at_filter.prod hf₁ hf₂
/-!
### Derivative of the composition of a vector function and a scalar function
We use `scomp` in lemmas on composition of vector valued and scalar valued functions, and `comp`
in lemmas on composition of scalar valued functions, in analogy for `smul` and `mul` (and also
because the `comp` version with the shorter name will show up much more often in applications).
The formula for the derivative involves `smul` in `scomp` lemmas, which can be reduced to
usual multiplication in `comp` lemmas.
-/
/- For composition lemmas, we put x explicit to help the elaborator, as otherwise Lean tends to
get confused since there are too many possibilities for composition -/
theorem has_deriv_at_filter.scomp {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v}
[normed_group F] [normed_space 𝕜 F] {g : 𝕜 → F} {g' : F} (x : 𝕜) {L : filter 𝕜} {h : 𝕜 → 𝕜}
{h' : 𝕜} (hg : has_deriv_at_filter g g' (h x) (filter.map h L))
(hh : has_deriv_at_filter h h' x L) : has_deriv_at_filter (g ∘ h) (h' • g') x L :=
sorry
theorem has_deriv_within_at.scomp {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v}
[normed_group F] [normed_space 𝕜 F] {g : 𝕜 → F} {g' : F} (x : 𝕜) {s : set 𝕜} {h : 𝕜 → 𝕜}
{h' : 𝕜} {t : set 𝕜} (hg : has_deriv_within_at g g' t (h x)) (hh : has_deriv_within_at h h' s x)
(hst : s ⊆ h ⁻¹' t) : has_deriv_within_at (g ∘ h) (h' • g') s x :=
sorry
/-- The chain rule. -/
theorem has_deriv_at.scomp {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v} [normed_group F]
[normed_space 𝕜 F] {g : 𝕜 → F} {g' : F} (x : 𝕜) {h : 𝕜 → 𝕜} {h' : 𝕜}
(hg : has_deriv_at g g' (h x)) (hh : has_deriv_at h h' x) : has_deriv_at (g ∘ h) (h' • g') x :=
has_deriv_at_filter.scomp x (has_deriv_at_filter.mono hg (has_deriv_at.continuous_at hh)) hh
theorem has_strict_deriv_at.scomp {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v}
[normed_group F] [normed_space 𝕜 F] {g : 𝕜 → F} {g' : F} (x : 𝕜) {h : 𝕜 → 𝕜} {h' : 𝕜}
(hg : has_strict_deriv_at g g' (h x)) (hh : has_strict_deriv_at h h' x) :
has_strict_deriv_at (g ∘ h) (h' • g') x :=
sorry
theorem has_deriv_at.scomp_has_deriv_within_at {𝕜 : Type u} [nondiscrete_normed_field 𝕜]
{F : Type v} [normed_group F] [normed_space 𝕜 F] {g : 𝕜 → F} {g' : F} (x : 𝕜) {s : set 𝕜}
{h : 𝕜 → 𝕜} {h' : 𝕜} (hg : has_deriv_at g g' (h x)) (hh : has_deriv_within_at h h' s x) :
has_deriv_within_at (g ∘ h) (h' • g') s x :=
has_deriv_within_at.scomp x
(eq.mp
(Eq._oldrec (Eq.refl (has_deriv_at g g' (h x))) (Eq.symm (propext has_deriv_within_at_univ)))
hg)
hh set.subset_preimage_univ
theorem deriv_within.scomp {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v} [normed_group F]
[normed_space 𝕜 F] {g : 𝕜 → F} (x : 𝕜) {s : set 𝕜} {t : set 𝕜} {h : 𝕜 → 𝕜}
(hg : differentiable_within_at 𝕜 g t (h x)) (hh : differentiable_within_at 𝕜 h s x)
(hs : s ⊆ h ⁻¹' t) (hxs : unique_diff_within_at 𝕜 s x) :
deriv_within (g ∘ h) s x = deriv_within h s x • deriv_within g t (h x) :=
sorry
theorem deriv.scomp {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v} [normed_group F]
[normed_space 𝕜 F] {g : 𝕜 → F} (x : 𝕜) {h : 𝕜 → 𝕜} (hg : differentiable_at 𝕜 g (h x))
(hh : differentiable_at 𝕜 h x) : deriv (g ∘ h) x = deriv h x • deriv g (h x) :=
has_deriv_at.deriv
(has_deriv_at.scomp x (differentiable_at.has_deriv_at hg) (differentiable_at.has_deriv_at hh))
/-! ### Derivative of the composition of a scalar and vector functions -/
theorem has_deriv_at_filter.comp_has_fderiv_at_filter {𝕜 : Type u} [nondiscrete_normed_field 𝕜]
{E : Type w} [normed_group E] [normed_space 𝕜 E] {h₁ : 𝕜 → 𝕜} {h₁' : 𝕜} {f : E → 𝕜}
{f' : continuous_linear_map 𝕜 E 𝕜} (x : E) {L : filter E}
(hh₁ : has_deriv_at_filter h₁ h₁' (f x) (filter.map f L)) (hf : has_fderiv_at_filter f f' x L) :
has_fderiv_at_filter (h₁ ∘ f) (h₁' • f') x L :=
sorry
theorem has_deriv_at.comp_has_fderiv_at {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {E : Type w}
[normed_group E] [normed_space 𝕜 E] {h₁ : 𝕜 → 𝕜} {h₁' : 𝕜} {f : E → 𝕜}
{f' : continuous_linear_map 𝕜 E 𝕜} (x : E) (hh₁ : has_deriv_at h₁ h₁' (f x))
(hf : has_fderiv_at f f' x) : has_fderiv_at (h₁ ∘ f) (h₁' • f') x :=
has_deriv_at_filter.comp_has_fderiv_at_filter x
(has_deriv_at_filter.mono hh₁ (has_fderiv_at.continuous_at hf)) hf
theorem has_deriv_at.comp_has_fderiv_within_at {𝕜 : Type u} [nondiscrete_normed_field 𝕜]
{E : Type w} [normed_group E] [normed_space 𝕜 E] {h₁ : 𝕜 → 𝕜} {h₁' : 𝕜} {f : E → 𝕜}
{f' : continuous_linear_map 𝕜 E 𝕜} {s : set E} (x : E) (hh₁ : has_deriv_at h₁ h₁' (f x))
(hf : has_fderiv_within_at f f' s x) : has_fderiv_within_at (h₁ ∘ f) (h₁' • f') s x :=
has_deriv_at_filter.comp_has_fderiv_at_filter x
(has_deriv_at_filter.mono hh₁ (has_fderiv_within_at.continuous_within_at hf)) hf
theorem has_deriv_within_at.comp_has_fderiv_within_at {𝕜 : Type u} [nondiscrete_normed_field 𝕜]
{E : Type w} [normed_group E] [normed_space 𝕜 E] {h₁ : 𝕜 → 𝕜} {h₁' : 𝕜} {f : E → 𝕜}
{f' : continuous_linear_map 𝕜 E 𝕜} {s : set E} {t : set 𝕜} (x : E)
(hh₁ : has_deriv_within_at h₁ h₁' t (f x)) (hf : has_fderiv_within_at f f' s x)
(hst : set.maps_to f s t) : has_fderiv_within_at (h₁ ∘ f) (h₁' • f') s x :=
sorry
/-! ### Derivative of the composition of two scalar functions -/
theorem has_deriv_at_filter.comp {𝕜 : Type u} [nondiscrete_normed_field 𝕜] (x : 𝕜) {L : filter 𝕜}
{h₁ : 𝕜 → 𝕜} {h₂ : 𝕜 → 𝕜} {h₁' : 𝕜} {h₂' : 𝕜}
(hh₁ : has_deriv_at_filter h₁ h₁' (h₂ x) (filter.map h₂ L))
(hh₂ : has_deriv_at_filter h₂ h₂' x L) : has_deriv_at_filter (h₁ ∘ h₂) (h₁' * h₂') x L :=
eq.mpr
(id (Eq._oldrec (Eq.refl (has_deriv_at_filter (h₁ ∘ h₂) (h₁' * h₂') x L)) (mul_comm h₁' h₂')))
(has_deriv_at_filter.scomp x hh₁ hh₂)
theorem has_deriv_within_at.comp {𝕜 : Type u} [nondiscrete_normed_field 𝕜] (x : 𝕜) {s : set 𝕜}
{h₁ : 𝕜 → 𝕜} {h₂ : 𝕜 → 𝕜} {h₁' : 𝕜} {h₂' : 𝕜} {t : set 𝕜}
(hh₁ : has_deriv_within_at h₁ h₁' t (h₂ x)) (hh₂ : has_deriv_within_at h₂ h₂' s x)
(hst : s ⊆ h₂ ⁻¹' t) : has_deriv_within_at (h₁ ∘ h₂) (h₁' * h₂') s x :=
eq.mpr
(id (Eq._oldrec (Eq.refl (has_deriv_within_at (h₁ ∘ h₂) (h₁' * h₂') s x)) (mul_comm h₁' h₂')))
(has_deriv_within_at.scomp x hh₁ hh₂ hst)
/-- The chain rule. -/
theorem has_deriv_at.comp {𝕜 : Type u} [nondiscrete_normed_field 𝕜] (x : 𝕜) {h₁ : 𝕜 → 𝕜}
{h₂ : 𝕜 → 𝕜} {h₁' : 𝕜} {h₂' : 𝕜} (hh₁ : has_deriv_at h₁ h₁' (h₂ x))
(hh₂ : has_deriv_at h₂ h₂' x) : has_deriv_at (h₁ ∘ h₂) (h₁' * h₂') x :=
has_deriv_at_filter.comp x (has_deriv_at_filter.mono hh₁ (has_deriv_at.continuous_at hh₂)) hh₂
theorem has_strict_deriv_at.comp {𝕜 : Type u} [nondiscrete_normed_field 𝕜] (x : 𝕜) {h₁ : 𝕜 → 𝕜}
{h₂ : 𝕜 → 𝕜} {h₁' : 𝕜} {h₂' : 𝕜} (hh₁ : has_strict_deriv_at h₁ h₁' (h₂ x))
(hh₂ : has_strict_deriv_at h₂ h₂' x) : has_strict_deriv_at (h₁ ∘ h₂) (h₁' * h₂') x :=
eq.mpr
(id (Eq._oldrec (Eq.refl (has_strict_deriv_at (h₁ ∘ h₂) (h₁' * h₂') x)) (mul_comm h₁' h₂')))
(has_strict_deriv_at.scomp x hh₁ hh₂)
theorem has_deriv_at.comp_has_deriv_within_at {𝕜 : Type u} [nondiscrete_normed_field 𝕜] (x : 𝕜)
{s : set 𝕜} {h₁ : 𝕜 → 𝕜} {h₂ : 𝕜 → 𝕜} {h₁' : 𝕜} {h₂' : 𝕜} (hh₁ : has_deriv_at h₁ h₁' (h₂ x))
(hh₂ : has_deriv_within_at h₂ h₂' s x) : has_deriv_within_at (h₁ ∘ h₂) (h₁' * h₂') s x :=
has_deriv_within_at.comp x
(eq.mp
(Eq._oldrec (Eq.refl (has_deriv_at h₁ h₁' (h₂ x)))
(Eq.symm (propext has_deriv_within_at_univ)))
hh₁)
hh₂ set.subset_preimage_univ
theorem deriv_within.comp {𝕜 : Type u} [nondiscrete_normed_field 𝕜] (x : 𝕜) {s : set 𝕜} {t : set 𝕜}
{h₁ : 𝕜 → 𝕜} {h₂ : 𝕜 → 𝕜} (hh₁ : differentiable_within_at 𝕜 h₁ t (h₂ x))
(hh₂ : differentiable_within_at 𝕜 h₂ s x) (hs : s ⊆ h₂ ⁻¹' t)
(hxs : unique_diff_within_at 𝕜 s x) :
deriv_within (h₁ ∘ h₂) s x = deriv_within h₁ t (h₂ x) * deriv_within h₂ s x :=
sorry
theorem deriv.comp {𝕜 : Type u} [nondiscrete_normed_field 𝕜] (x : 𝕜) {h₁ : 𝕜 → 𝕜} {h₂ : 𝕜 → 𝕜}
(hh₁ : differentiable_at 𝕜 h₁ (h₂ x)) (hh₂ : differentiable_at 𝕜 h₂ x) :
deriv (h₁ ∘ h₂) x = deriv h₁ (h₂ x) * deriv h₂ x :=
has_deriv_at.deriv
(has_deriv_at.comp x (differentiable_at.has_deriv_at hh₁) (differentiable_at.has_deriv_at hh₂))
protected theorem has_deriv_at_filter.iterate {𝕜 : Type u} [nondiscrete_normed_field 𝕜] (x : 𝕜)
{L : filter 𝕜} {f : 𝕜 → 𝕜} {f' : 𝕜} (hf : has_deriv_at_filter f f' x L)
(hL : filter.tendsto f L L) (hx : f x = x) (n : ℕ) :
has_deriv_at_filter (nat.iterate f n) (f' ^ n) x L :=
sorry
protected theorem has_deriv_at.iterate {𝕜 : Type u} [nondiscrete_normed_field 𝕜] (x : 𝕜) {f : 𝕜 → 𝕜}
{f' : 𝕜} (hf : has_deriv_at f f' x) (hx : f x = x) (n : ℕ) :
has_deriv_at (nat.iterate f n) (f' ^ n) x :=
sorry
protected theorem has_deriv_within_at.iterate {𝕜 : Type u} [nondiscrete_normed_field 𝕜] (x : 𝕜)
{s : set 𝕜} {f : 𝕜 → 𝕜} {f' : 𝕜} (hf : has_deriv_within_at f f' s x) (hx : f x = x)
(hs : set.maps_to f s s) (n : ℕ) : has_deriv_within_at (nat.iterate f n) (f' ^ n) s x :=
sorry
protected theorem has_strict_deriv_at.iterate {𝕜 : Type u} [nondiscrete_normed_field 𝕜] (x : 𝕜)
{f : 𝕜 → 𝕜} {f' : 𝕜} (hf : has_strict_deriv_at f f' x) (hx : f x = x) (n : ℕ) :
has_strict_deriv_at (nat.iterate f n) (f' ^ n) x :=
sorry
/-! ### Derivative of the composition of a function between vector spaces and of a function defined on `𝕜` -/
/-- The composition `l ∘ f` where `l : F → E` and `f : 𝕜 → F`, has a derivative within a set
equal to the Fréchet derivative of `l` applied to the derivative of `f`. -/
theorem has_fderiv_within_at.comp_has_deriv_within_at {𝕜 : Type u} [nondiscrete_normed_field 𝕜]
{F : Type v} [normed_group F] [normed_space 𝕜 F] {E : Type w} [normed_group E]
[normed_space 𝕜 E] {f : 𝕜 → F} {f' : F} (x : 𝕜) {s : set 𝕜} {l : F → E}
{l' : continuous_linear_map 𝕜 F E} {t : set F} (hl : has_fderiv_within_at l l' t (f x))
(hf : has_deriv_within_at f f' s x) (hst : s ⊆ f ⁻¹' t) :
has_deriv_within_at (l ∘ f) (coe_fn l' f') s x :=
sorry
/-- The composition `l ∘ f` where `l : F → E` and `f : 𝕜 → F`, has a derivative equal to the
Fréchet derivative of `l` applied to the derivative of `f`. -/
theorem has_fderiv_at.comp_has_deriv_at {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v}
[normed_group F] [normed_space 𝕜 F] {E : Type w} [normed_group E] [normed_space 𝕜 E] {f : 𝕜 → F}
{f' : F} (x : 𝕜) {l : F → E} {l' : continuous_linear_map 𝕜 F E} (hl : has_fderiv_at l l' (f x))
(hf : has_deriv_at f f' x) : has_deriv_at (l ∘ f) (coe_fn l' f') x :=
sorry
theorem has_fderiv_at.comp_has_deriv_within_at {𝕜 : Type u} [nondiscrete_normed_field 𝕜]
{F : Type v} [normed_group F] [normed_space 𝕜 F] {E : Type w} [normed_group E]
[normed_space 𝕜 E] {f : 𝕜 → F} {f' : F} (x : 𝕜) {s : set 𝕜} {l : F → E}
{l' : continuous_linear_map 𝕜 F E} (hl : has_fderiv_at l l' (f x))
(hf : has_deriv_within_at f f' s x) : has_deriv_within_at (l ∘ f) (coe_fn l' f') s x :=
has_fderiv_within_at.comp_has_deriv_within_at x
(eq.mp
(Eq._oldrec (Eq.refl (has_fderiv_at l l' (f x)))
(Eq.symm (propext has_fderiv_within_at_univ)))
hl)
hf set.subset_preimage_univ
theorem fderiv_within.comp_deriv_within {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v}
[normed_group F] [normed_space 𝕜 F] {E : Type w} [normed_group E] [normed_space 𝕜 E] {f : 𝕜 → F}
(x : 𝕜) {s : set 𝕜} {l : F → E} {t : set F} (hl : differentiable_within_at 𝕜 l t (f x))
(hf : differentiable_within_at 𝕜 f s x) (hs : s ⊆ f ⁻¹' t) (hxs : unique_diff_within_at 𝕜 s x) :
deriv_within (l ∘ f) s x = coe_fn (fderiv_within 𝕜 l t (f x)) (deriv_within f s x) :=
sorry
theorem fderiv.comp_deriv {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v} [normed_group F]
[normed_space 𝕜 F] {E : Type w} [normed_group E] [normed_space 𝕜 E] {f : 𝕜 → F} (x : 𝕜)
{l : F → E} (hl : differentiable_at 𝕜 l (f x)) (hf : differentiable_at 𝕜 f x) :
deriv (l ∘ f) x = coe_fn (fderiv 𝕜 l (f x)) (deriv f x) :=
has_deriv_at.deriv
(has_fderiv_at.comp_has_deriv_at x (differentiable_at.has_fderiv_at hl)
(differentiable_at.has_deriv_at hf))
/-! ### Derivative of the multiplication of two scalar functions -/
theorem has_deriv_within_at.mul {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {x : 𝕜} {s : set 𝕜}
{c : 𝕜 → 𝕜} {d : 𝕜 → 𝕜} {c' : 𝕜} {d' : 𝕜} (hc : has_deriv_within_at c c' s x)
(hd : has_deriv_within_at d d' s x) :
has_deriv_within_at (fun (y : 𝕜) => c y * d y) (c' * d x + c x * d') s x :=
sorry
theorem has_deriv_at.mul {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {x : 𝕜} {c : 𝕜 → 𝕜} {d : 𝕜 → 𝕜}
{c' : 𝕜} {d' : 𝕜} (hc : has_deriv_at c c' x) (hd : has_deriv_at d d' x) :
has_deriv_at (fun (y : 𝕜) => c y * d y) (c' * d x + c x * d') x :=
sorry
theorem has_strict_deriv_at.mul {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {x : 𝕜} {c : 𝕜 → 𝕜}
{d : 𝕜 → 𝕜} {c' : 𝕜} {d' : 𝕜} (hc : has_strict_deriv_at c c' x)
(hd : has_strict_deriv_at d d' x) :
has_strict_deriv_at (fun (y : 𝕜) => c y * d y) (c' * d x + c x * d') x :=
sorry
theorem deriv_within_mul {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {x : 𝕜} {s : set 𝕜} {c : 𝕜 → 𝕜}
{d : 𝕜 → 𝕜} (hxs : unique_diff_within_at 𝕜 s x) (hc : differentiable_within_at 𝕜 c s x)
(hd : differentiable_within_at 𝕜 d s x) :
deriv_within (fun (y : 𝕜) => c y * d y) s x =
deriv_within c s x * d x + c x * deriv_within d s x :=
sorry
@[simp] theorem deriv_mul {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {x : 𝕜} {c : 𝕜 → 𝕜} {d : 𝕜 → 𝕜}
(hc : differentiable_at 𝕜 c x) (hd : differentiable_at 𝕜 d x) :
deriv (fun (y : 𝕜) => c y * d y) x = deriv c x * d x + c x * deriv d x :=
has_deriv_at.deriv
(has_deriv_at.mul (differentiable_at.has_deriv_at hc) (differentiable_at.has_deriv_at hd))
theorem has_deriv_within_at.mul_const {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {x : 𝕜} {s : set 𝕜}
{c : 𝕜 → 𝕜} {c' : 𝕜} (hc : has_deriv_within_at c c' s x) (d : 𝕜) :
has_deriv_within_at (fun (y : 𝕜) => c y * d) (c' * d) s x :=
sorry
theorem has_deriv_at.mul_const {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {x : 𝕜} {c : 𝕜 → 𝕜}
{c' : 𝕜} (hc : has_deriv_at c c' x) (d : 𝕜) :
has_deriv_at (fun (y : 𝕜) => c y * d) (c' * d) x :=
sorry
theorem deriv_within_mul_const {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {x : 𝕜} {s : set 𝕜}
{c : 𝕜 → 𝕜} (hxs : unique_diff_within_at 𝕜 s x) (hc : differentiable_within_at 𝕜 c s x)
(d : 𝕜) : deriv_within (fun (y : 𝕜) => c y * d) s x = deriv_within c s x * d :=
has_deriv_within_at.deriv_within
(has_deriv_within_at.mul_const (differentiable_within_at.has_deriv_within_at hc) d) hxs
theorem deriv_mul_const {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {x : 𝕜} {c : 𝕜 → 𝕜}
(hc : differentiable_at 𝕜 c x) (d : 𝕜) : deriv (fun (y : 𝕜) => c y * d) x = deriv c x * d :=
has_deriv_at.deriv (has_deriv_at.mul_const (differentiable_at.has_deriv_at hc) d)
theorem has_deriv_within_at.const_mul {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {x : 𝕜} {s : set 𝕜}
{d : 𝕜 → 𝕜} {d' : 𝕜} (c : 𝕜) (hd : has_deriv_within_at d d' s x) :
has_deriv_within_at (fun (y : 𝕜) => c * d y) (c * d') s x :=
sorry
theorem has_deriv_at.const_mul {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {x : 𝕜} {d : 𝕜 → 𝕜}
{d' : 𝕜} (c : 𝕜) (hd : has_deriv_at d d' x) :
has_deriv_at (fun (y : 𝕜) => c * d y) (c * d') x :=
sorry
theorem deriv_within_const_mul {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {x : 𝕜} {s : set 𝕜}
{d : 𝕜 → 𝕜} (hxs : unique_diff_within_at 𝕜 s x) (c : 𝕜)
(hd : differentiable_within_at 𝕜 d s x) :
deriv_within (fun (y : 𝕜) => c * d y) s x = c * deriv_within d s x :=
has_deriv_within_at.deriv_within
(has_deriv_within_at.const_mul c (differentiable_within_at.has_deriv_within_at hd)) hxs
theorem deriv_const_mul {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {x : 𝕜} {d : 𝕜 → 𝕜} (c : 𝕜)
(hd : differentiable_at 𝕜 d x) : deriv (fun (y : 𝕜) => c * d y) x = c * deriv d x :=
has_deriv_at.deriv (has_deriv_at.const_mul c (differentiable_at.has_deriv_at hd))
/-! ### Derivative of `x ↦ x⁻¹` -/
theorem has_strict_deriv_at_inv {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {x : 𝕜} (hx : x ≠ 0) :
has_strict_deriv_at has_inv.inv (-(x ^ bit0 1⁻¹)) x :=
sorry
theorem has_deriv_at_inv {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {x : 𝕜} (x_ne_zero : x ≠ 0) :
has_deriv_at (fun (y : 𝕜) => y⁻¹) (-(x ^ bit0 1⁻¹)) x :=
has_strict_deriv_at.has_deriv_at (has_strict_deriv_at_inv x_ne_zero)
theorem has_deriv_within_at_inv {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {x : 𝕜}
(x_ne_zero : x ≠ 0) (s : set 𝕜) :
has_deriv_within_at (fun (x : 𝕜) => x⁻¹) (-(x ^ bit0 1⁻¹)) s x :=
has_deriv_at.has_deriv_within_at (has_deriv_at_inv x_ne_zero)
theorem differentiable_at_inv {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {x : 𝕜}
(x_ne_zero : x ≠ 0) : differentiable_at 𝕜 (fun (x : 𝕜) => x⁻¹) x :=
has_deriv_at.differentiable_at (has_deriv_at_inv x_ne_zero)
theorem differentiable_within_at_inv {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {x : 𝕜} {s : set 𝕜}
(x_ne_zero : x ≠ 0) : differentiable_within_at 𝕜 (fun (x : 𝕜) => x⁻¹) s x :=
differentiable_at.differentiable_within_at (differentiable_at_inv x_ne_zero)
theorem differentiable_on_inv {𝕜 : Type u} [nondiscrete_normed_field 𝕜] :
differentiable_on 𝕜 (fun (x : 𝕜) => x⁻¹) (set_of fun (x : 𝕜) => x ≠ 0) :=
fun (x : 𝕜) (hx : x ∈ set_of fun (x : 𝕜) => x ≠ 0) => differentiable_within_at_inv hx
theorem deriv_inv {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {x : 𝕜} (x_ne_zero : x ≠ 0) :
deriv (fun (x : 𝕜) => x⁻¹) x = -(x ^ bit0 1⁻¹) :=
has_deriv_at.deriv (has_deriv_at_inv x_ne_zero)
theorem deriv_within_inv {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {x : 𝕜} {s : set 𝕜}
(x_ne_zero : x ≠ 0) (hxs : unique_diff_within_at 𝕜 s x) :
deriv_within (fun (x : 𝕜) => x⁻¹) s x = -(x ^ bit0 1⁻¹) :=
sorry
theorem has_fderiv_at_inv {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {x : 𝕜} (x_ne_zero : x ≠ 0) :
has_fderiv_at (fun (x : 𝕜) => x⁻¹) (continuous_linear_map.smul_right 1 (-(x ^ bit0 1⁻¹))) x :=
has_deriv_at_inv x_ne_zero
theorem has_fderiv_within_at_inv {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {x : 𝕜} {s : set 𝕜}
(x_ne_zero : x ≠ 0) :
has_fderiv_within_at (fun (x : 𝕜) => x⁻¹) (continuous_linear_map.smul_right 1 (-(x ^ bit0 1⁻¹)))
s x :=
has_fderiv_at.has_fderiv_within_at (has_fderiv_at_inv x_ne_zero)
theorem fderiv_inv {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {x : 𝕜} (x_ne_zero : x ≠ 0) :
fderiv 𝕜 (fun (x : 𝕜) => x⁻¹) x = continuous_linear_map.smul_right 1 (-(x ^ bit0 1⁻¹)) :=
has_fderiv_at.fderiv (has_fderiv_at_inv x_ne_zero)
theorem fderiv_within_inv {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {x : 𝕜} {s : set 𝕜}
(x_ne_zero : x ≠ 0) (hxs : unique_diff_within_at 𝕜 s x) :
fderiv_within 𝕜 (fun (x : 𝕜) => x⁻¹) s x =
continuous_linear_map.smul_right 1 (-(x ^ bit0 1⁻¹)) :=
sorry
theorem has_deriv_within_at.inv {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {x : 𝕜} {s : set 𝕜}
{c : 𝕜 → 𝕜} {c' : 𝕜} (hc : has_deriv_within_at c c' s x) (hx : c x ≠ 0) :
has_deriv_within_at (fun (y : 𝕜) => c y⁻¹) (-c' / c x ^ bit0 1) s x :=
sorry
theorem has_deriv_at.inv {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {x : 𝕜} {c : 𝕜 → 𝕜} {c' : 𝕜}
(hc : has_deriv_at c c' x) (hx : c x ≠ 0) :
has_deriv_at (fun (y : 𝕜) => c y⁻¹) (-c' / c x ^ bit0 1) x :=
sorry
theorem differentiable_within_at.inv {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {x : 𝕜} {s : set 𝕜}
{c : 𝕜 → 𝕜} (hc : differentiable_within_at 𝕜 c s x) (hx : c x ≠ 0) :
differentiable_within_at 𝕜 (fun (x : 𝕜) => c x⁻¹) s x :=
has_deriv_within_at.differentiable_within_at
(has_deriv_within_at.inv (differentiable_within_at.has_deriv_within_at hc) hx)
@[simp] theorem differentiable_at.inv {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {x : 𝕜} {c : 𝕜 → 𝕜}
(hc : differentiable_at 𝕜 c x) (hx : c x ≠ 0) : differentiable_at 𝕜 (fun (x : 𝕜) => c x⁻¹) x :=
has_deriv_at.differentiable_at (has_deriv_at.inv (differentiable_at.has_deriv_at hc) hx)
theorem differentiable_on.inv {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {s : set 𝕜} {c : 𝕜 → 𝕜}
(hc : differentiable_on 𝕜 c s) (hx : ∀ (x : 𝕜), x ∈ s → c x ≠ 0) :
differentiable_on 𝕜 (fun (x : 𝕜) => c x⁻¹) s :=
fun (x : 𝕜) (h : x ∈ s) => differentiable_within_at.inv (hc x h) (hx x h)
@[simp] theorem differentiable.inv {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {c : 𝕜 → 𝕜}
(hc : differentiable 𝕜 c) (hx : ∀ (x : 𝕜), c x ≠ 0) : differentiable 𝕜 fun (x : 𝕜) => c x⁻¹ :=
fun (x : 𝕜) => differentiable_at.inv (hc x) (hx x)
theorem deriv_within_inv' {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {x : 𝕜} {s : set 𝕜} {c : 𝕜 → 𝕜}
(hc : differentiable_within_at 𝕜 c s x) (hx : c x ≠ 0) (hxs : unique_diff_within_at 𝕜 s x) :
deriv_within (fun (x : 𝕜) => c x⁻¹) s x = -deriv_within c s x / c x ^ bit0 1 :=
has_deriv_within_at.deriv_within
(has_deriv_within_at.inv (differentiable_within_at.has_deriv_within_at hc) hx) hxs
@[simp] theorem deriv_inv' {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {x : 𝕜} {c : 𝕜 → 𝕜}
(hc : differentiable_at 𝕜 c x) (hx : c x ≠ 0) :
deriv (fun (x : 𝕜) => c x⁻¹) x = -deriv c x / c x ^ bit0 1 :=
has_deriv_at.deriv (has_deriv_at.inv (differentiable_at.has_deriv_at hc) hx)
/-! ### Derivative of `x ↦ c x / d x` -/
theorem has_deriv_within_at.div {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {x : 𝕜} {s : set 𝕜}
{c : 𝕜 → 𝕜} {d : 𝕜 → 𝕜} {c' : 𝕜} {d' : 𝕜} (hc : has_deriv_within_at c c' s x)
(hd : has_deriv_within_at d d' s x) (hx : d x ≠ 0) :
has_deriv_within_at (fun (y : 𝕜) => c y / d y) ((c' * d x - c x * d') / d x ^ bit0 1) s x :=
sorry
theorem has_deriv_at.div {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {x : 𝕜} {c : 𝕜 → 𝕜} {d : 𝕜 → 𝕜}
{c' : 𝕜} {d' : 𝕜} (hc : has_deriv_at c c' x) (hd : has_deriv_at d d' x) (hx : d x ≠ 0) :
has_deriv_at (fun (y : 𝕜) => c y / d y) ((c' * d x - c x * d') / d x ^ bit0 1) x :=
sorry
theorem differentiable_within_at.div {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {x : 𝕜} {s : set 𝕜}
{c : 𝕜 → 𝕜} {d : 𝕜 → 𝕜} (hc : differentiable_within_at 𝕜 c s x)
(hd : differentiable_within_at 𝕜 d s x) (hx : d x ≠ 0) :
differentiable_within_at 𝕜 (fun (x : 𝕜) => c x / d x) s x :=
has_deriv_within_at.differentiable_within_at
(has_deriv_within_at.div (differentiable_within_at.has_deriv_within_at hc)
(differentiable_within_at.has_deriv_within_at hd) hx)
@[simp] theorem differentiable_at.div {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {x : 𝕜} {c : 𝕜 → 𝕜}
{d : 𝕜 → 𝕜} (hc : differentiable_at 𝕜 c x) (hd : differentiable_at 𝕜 d x) (hx : d x ≠ 0) :
differentiable_at 𝕜 (fun (x : 𝕜) => c x / d x) x :=
has_deriv_at.differentiable_at
(has_deriv_at.div (differentiable_at.has_deriv_at hc) (differentiable_at.has_deriv_at hd) hx)
theorem differentiable_on.div {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {s : set 𝕜} {c : 𝕜 → 𝕜}
{d : 𝕜 → 𝕜} (hc : differentiable_on 𝕜 c s) (hd : differentiable_on 𝕜 d s)
(hx : ∀ (x : 𝕜), x ∈ s → d x ≠ 0) : differentiable_on 𝕜 (fun (x : 𝕜) => c x / d x) s :=
fun (x : 𝕜) (h : x ∈ s) => differentiable_within_at.div (hc x h) (hd x h) (hx x h)
@[simp] theorem differentiable.div {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {c : 𝕜 → 𝕜} {d : 𝕜 → 𝕜}
(hc : differentiable 𝕜 c) (hd : differentiable 𝕜 d) (hx : ∀ (x : 𝕜), d x ≠ 0) :
differentiable 𝕜 fun (x : 𝕜) => c x / d x :=
fun (x : 𝕜) => differentiable_at.div (hc x) (hd x) (hx x)
theorem deriv_within_div {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {x : 𝕜} {s : set 𝕜} {c : 𝕜 → 𝕜}
{d : 𝕜 → 𝕜} (hc : differentiable_within_at 𝕜 c s x) (hd : differentiable_within_at 𝕜 d s x)
(hx : d x ≠ 0) (hxs : unique_diff_within_at 𝕜 s x) :
deriv_within (fun (x : 𝕜) => c x / d x) s x =
(deriv_within c s x * d x - c x * deriv_within d s x) / d x ^ bit0 1 :=
sorry
@[simp] theorem deriv_div {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {x : 𝕜} {c : 𝕜 → 𝕜} {d : 𝕜 → 𝕜}
(hc : differentiable_at 𝕜 c x) (hd : differentiable_at 𝕜 d x) (hx : d x ≠ 0) :
deriv (fun (x : 𝕜) => c x / d x) x = (deriv c x * d x - c x * deriv d x) / d x ^ bit0 1 :=
has_deriv_at.deriv
(has_deriv_at.div (differentiable_at.has_deriv_at hc) (differentiable_at.has_deriv_at hd) hx)
theorem differentiable_within_at.div_const {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {x : 𝕜}
{s : set 𝕜} {c : 𝕜 → 𝕜} (hc : differentiable_within_at 𝕜 c s x) {d : 𝕜} :
differentiable_within_at 𝕜 (fun (x : 𝕜) => c x / d) s x :=
sorry
@[simp] theorem differentiable_at.div_const {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {x : 𝕜}
{c : 𝕜 → 𝕜} (hc : differentiable_at 𝕜 c x) {d : 𝕜} :
differentiable_at 𝕜 (fun (x : 𝕜) => c x / d) x :=
has_deriv_at.differentiable_at (has_deriv_at.mul_const (differentiable_at.has_deriv_at hc) (d⁻¹))
theorem differentiable_on.div_const {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {s : set 𝕜}
{c : 𝕜 → 𝕜} (hc : differentiable_on 𝕜 c s) {d : 𝕜} :
differentiable_on 𝕜 (fun (x : 𝕜) => c x / d) s :=
sorry
@[simp] theorem differentiable.div_const {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {c : 𝕜 → 𝕜}
(hc : differentiable 𝕜 c) {d : 𝕜} : differentiable 𝕜 fun (x : 𝕜) => c x / d :=
sorry
theorem deriv_within_div_const {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {x : 𝕜} {s : set 𝕜}
{c : 𝕜 → 𝕜} (hc : differentiable_within_at 𝕜 c s x) {d : 𝕜}
(hxs : unique_diff_within_at 𝕜 s x) :
deriv_within (fun (x : 𝕜) => c x / d) s x = deriv_within c s x / d :=
sorry
@[simp] theorem deriv_div_const {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {x : 𝕜} {c : 𝕜 → 𝕜}
(hc : differentiable_at 𝕜 c x) {d : 𝕜} : deriv (fun (x : 𝕜) => c x / d) x = deriv c x / d :=
sorry
theorem has_strict_deriv_at.has_strict_fderiv_at_equiv {𝕜 : Type u} [nondiscrete_normed_field 𝕜]
{f : 𝕜 → 𝕜} {f' : 𝕜} {x : 𝕜} (hf : has_strict_deriv_at f f' x) (hf' : f' ≠ 0) :
has_strict_fderiv_at f
(↑(coe_fn (continuous_linear_equiv.units_equiv_aut 𝕜) (units.mk0 f' hf'))) x :=
hf
theorem has_deriv_at.has_fderiv_at_equiv {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {f : 𝕜 → 𝕜}
{f' : 𝕜} {x : 𝕜} (hf : has_deriv_at f f' x) (hf' : f' ≠ 0) :
has_fderiv_at f (↑(coe_fn (continuous_linear_equiv.units_equiv_aut 𝕜) (units.mk0 f' hf'))) x :=
hf
/-- If `f (g y) = y` for `y` in some neighborhood of `a`, `g` is continuous at `a`, and `f` has an
invertible derivative `f'` at `g a` in the strict sense, then `g` has the derivative `f'⁻¹` at `a`
in the strict sense.
This is one of the easy parts of the inverse function theorem: it assumes that we already have an
inverse function. -/
theorem has_strict_deriv_at.of_local_left_inverse {𝕜 : Type u} [nondiscrete_normed_field 𝕜]
{f : 𝕜 → 𝕜} {g : 𝕜 → 𝕜} {f' : 𝕜} {a : 𝕜} (hg : continuous_at g a)
(hf : has_strict_deriv_at f f' (g a)) (hf' : f' ≠ 0)
(hfg : filter.eventually (fun (y : 𝕜) => f (g y) = y) (nhds a)) :
has_strict_deriv_at g (f'⁻¹) a :=
has_strict_fderiv_at.of_local_left_inverse hg
(has_strict_deriv_at.has_strict_fderiv_at_equiv hf hf') hfg
/-- If `f (g y) = y` for `y` in some neighborhood of `a`, `g` is continuous at `a`, and `f` has an
invertible derivative `f'` at `g a`, then `g` has the derivative `f'⁻¹` at `a`.
This is one of the easy parts of the inverse function theorem: it assumes that we already have
an inverse function. -/
theorem has_deriv_at.of_local_left_inverse {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {f : 𝕜 → 𝕜}
{g : 𝕜 → 𝕜} {f' : 𝕜} {a : 𝕜} (hg : continuous_at g a) (hf : has_deriv_at f f' (g a))
(hf' : f' ≠ 0) (hfg : filter.eventually (fun (y : 𝕜) => f (g y) = y) (nhds a)) :
has_deriv_at g (f'⁻¹) a :=
has_fderiv_at.of_local_left_inverse hg (has_deriv_at.has_fderiv_at_equiv hf hf') hfg
/-- If `f` is a local homeomorphism defined on a neighbourhood of `f.symm a`, and `f` has an
nonzero derivative `f'` at `f.symm a`, then `f.symm` has the derivative `f'⁻¹` at `a`.
This is one of the easy parts of the inverse function theorem: it assumes that we already have
an inverse function. -/
theorem local_homeomorph.has_deriv_at_symm {𝕜 : Type u} [nondiscrete_normed_field 𝕜]
(f : local_homeomorph 𝕜 𝕜) {a : 𝕜} {f' : 𝕜}
(ha : a ∈ local_equiv.target (local_homeomorph.to_local_equiv f)) (hf' : f' ≠ 0)
(htff' : has_deriv_at (⇑f) f' (coe_fn (local_homeomorph.symm f) a)) :
has_deriv_at (⇑(local_homeomorph.symm f)) (f'⁻¹) a :=
has_deriv_at.of_local_left_inverse (local_homeomorph.continuous_at (local_homeomorph.symm f) ha)
htff' hf' (local_homeomorph.eventually_right_inverse f ha)
theorem has_deriv_at.eventually_ne {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {F : Type v}
[normed_group F] [normed_space 𝕜 F] {f : 𝕜 → F} {f' : F} {x : 𝕜} (h : has_deriv_at f f' x)
(hf' : f' ≠ 0) : filter.eventually (fun (z : 𝕜) => f z ≠ f x) (nhds_within x (singleton xᶜ)) :=
sorry
theorem not_differentiable_within_at_of_local_left_inverse_has_deriv_within_at_zero {𝕜 : Type u}
[nondiscrete_normed_field 𝕜] {f : 𝕜 → 𝕜} {g : 𝕜 → 𝕜} {a : 𝕜} {s : set 𝕜} {t : set 𝕜}
(ha : a ∈ s) (hsu : unique_diff_within_at 𝕜 s a) (hf : has_deriv_within_at f 0 t (g a))
(hst : set.maps_to g s t) (hfg : filter.eventually_eq (nhds_within a s) (f ∘ g) id) :
¬differentiable_within_at 𝕜 g s a :=
sorry
theorem not_differentiable_at_of_local_left_inverse_has_deriv_at_zero {𝕜 : Type u}
[nondiscrete_normed_field 𝕜] {f : 𝕜 → 𝕜} {g : 𝕜 → 𝕜} {a : 𝕜} (hf : has_deriv_at f 0 (g a))
(hfg : filter.eventually_eq (nhds a) (f ∘ g) id) : ¬differentiable_at 𝕜 g a :=
sorry
namespace polynomial
/-! ### Derivative of a polynomial -/
/-- The derivative (in the analysis sense) of a polynomial `p` is given by `p.derivative`. -/
protected theorem has_strict_deriv_at {𝕜 : Type u} [nondiscrete_normed_field 𝕜] (p : polynomial 𝕜)
(x : 𝕜) : has_strict_deriv_at (fun (x : 𝕜) => eval x p) (eval x (coe_fn derivative p)) x :=
sorry
/-- The derivative (in the analysis sense) of a polynomial `p` is given by `p.derivative`. -/
protected theorem has_deriv_at {𝕜 : Type u} [nondiscrete_normed_field 𝕜] (p : polynomial 𝕜)
(x : 𝕜) : has_deriv_at (fun (x : 𝕜) => eval x p) (eval x (coe_fn derivative p)) x :=
has_strict_deriv_at.has_deriv_at (polynomial.has_strict_deriv_at p x)
protected theorem has_deriv_within_at {𝕜 : Type u} [nondiscrete_normed_field 𝕜] (p : polynomial 𝕜)
(x : 𝕜) (s : set 𝕜) :
has_deriv_within_at (fun (x : 𝕜) => eval x p) (eval x (coe_fn derivative p)) s x :=
has_deriv_at.has_deriv_within_at (polynomial.has_deriv_at p x)
protected theorem differentiable_at {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {x : 𝕜}
(p : polynomial 𝕜) : differentiable_at 𝕜 (fun (x : 𝕜) => eval x p) x :=
has_deriv_at.differentiable_at (polynomial.has_deriv_at p x)
protected theorem differentiable_within_at {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {x : 𝕜}
{s : set 𝕜} (p : polynomial 𝕜) : differentiable_within_at 𝕜 (fun (x : 𝕜) => eval x p) s x :=
differentiable_at.differentiable_within_at (polynomial.differentiable_at p)
protected theorem differentiable {𝕜 : Type u} [nondiscrete_normed_field 𝕜] (p : polynomial 𝕜) :
differentiable 𝕜 fun (x : 𝕜) => eval x p :=
fun (x : 𝕜) => polynomial.differentiable_at p
protected theorem differentiable_on {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {s : set 𝕜}
(p : polynomial 𝕜) : differentiable_on 𝕜 (fun (x : 𝕜) => eval x p) s :=
differentiable.differentiable_on (polynomial.differentiable p)
@[simp] protected theorem deriv {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {x : 𝕜}
(p : polynomial 𝕜) : deriv (fun (x : 𝕜) => eval x p) x = eval x (coe_fn derivative p) :=
has_deriv_at.deriv (polynomial.has_deriv_at p x)
protected theorem deriv_within {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {x : 𝕜} {s : set 𝕜}
(p : polynomial 𝕜) (hxs : unique_diff_within_at 𝕜 s x) :
deriv_within (fun (x : 𝕜) => eval x p) s x = eval x (coe_fn derivative p) :=
sorry
protected theorem has_fderiv_at {𝕜 : Type u} [nondiscrete_normed_field 𝕜] (p : polynomial 𝕜)
(x : 𝕜) :
has_fderiv_at (fun (x : 𝕜) => eval x p)
(continuous_linear_map.smul_right 1 (eval x (coe_fn derivative p))) x :=
sorry
protected theorem has_fderiv_within_at {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {s : set 𝕜}
(p : polynomial 𝕜) (x : 𝕜) :
has_fderiv_within_at (fun (x : 𝕜) => eval x p)
(continuous_linear_map.smul_right 1 (eval x (coe_fn derivative p))) s x :=
has_fderiv_at.has_fderiv_within_at (polynomial.has_fderiv_at p x)
@[simp] protected theorem fderiv {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {x : 𝕜}
(p : polynomial 𝕜) :
fderiv 𝕜 (fun (x : 𝕜) => eval x p) x =
continuous_linear_map.smul_right 1 (eval x (coe_fn derivative p)) :=
has_fderiv_at.fderiv (polynomial.has_fderiv_at p x)
protected theorem fderiv_within {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {x : 𝕜} {s : set 𝕜}
(p : polynomial 𝕜) (hxs : unique_diff_within_at 𝕜 s x) :
fderiv_within 𝕜 (fun (x : 𝕜) => eval x p) s x =
continuous_linear_map.smul_right 1 (eval x (coe_fn derivative p)) :=
sorry
end polynomial
/-! ### Derivative of `x ↦ x^n` for `n : ℕ` -/
theorem has_strict_deriv_at_pow {𝕜 : Type u} [nondiscrete_normed_field 𝕜] (n : ℕ) (x : 𝕜) :
has_strict_deriv_at (fun (x : 𝕜) => x ^ n) (↑n * x ^ (n - 1)) x :=
sorry
theorem has_deriv_at_pow {𝕜 : Type u} [nondiscrete_normed_field 𝕜] (n : ℕ) (x : 𝕜) :
has_deriv_at (fun (x : 𝕜) => x ^ n) (↑n * x ^ (n - 1)) x :=
has_strict_deriv_at.has_deriv_at (has_strict_deriv_at_pow n x)
theorem has_deriv_within_at_pow {𝕜 : Type u} [nondiscrete_normed_field 𝕜] (n : ℕ) (x : 𝕜)
(s : set 𝕜) : has_deriv_within_at (fun (x : 𝕜) => x ^ n) (↑n * x ^ (n - 1)) s x :=
has_deriv_at.has_deriv_within_at (has_deriv_at_pow n x)
theorem differentiable_at_pow {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {x : 𝕜} {n : ℕ} :
differentiable_at 𝕜 (fun (x : 𝕜) => x ^ n) x :=
has_deriv_at.differentiable_at (has_deriv_at_pow n x)
theorem differentiable_within_at_pow {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {x : 𝕜} {s : set 𝕜}
{n : ℕ} : differentiable_within_at 𝕜 (fun (x : 𝕜) => x ^ n) s x :=
differentiable_at.differentiable_within_at differentiable_at_pow
theorem differentiable_pow {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {n : ℕ} :
differentiable 𝕜 fun (x : 𝕜) => x ^ n :=
fun (x : 𝕜) => differentiable_at_pow
theorem differentiable_on_pow {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {s : set 𝕜} {n : ℕ} :
differentiable_on 𝕜 (fun (x : 𝕜) => x ^ n) s :=
differentiable.differentiable_on differentiable_pow
theorem deriv_pow {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {x : 𝕜} {n : ℕ} :
deriv (fun (x : 𝕜) => x ^ n) x = ↑n * x ^ (n - 1) :=
has_deriv_at.deriv (has_deriv_at_pow n x)
@[simp] theorem deriv_pow' {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {n : ℕ} :
(deriv fun (x : 𝕜) => x ^ n) = fun (x : 𝕜) => ↑n * x ^ (n - 1) :=
funext fun (x : 𝕜) => deriv_pow
theorem deriv_within_pow {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {x : 𝕜} {s : set 𝕜} {n : ℕ}
(hxs : unique_diff_within_at 𝕜 s x) :
deriv_within (fun (x : 𝕜) => x ^ n) s x = ↑n * x ^ (n - 1) :=
has_deriv_within_at.deriv_within (has_deriv_within_at_pow n x s) hxs
theorem iter_deriv_pow' {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {n : ℕ} {k : ℕ} :
(nat.iterate deriv k fun (x : 𝕜) => x ^ n) =
fun (x : 𝕜) => ↑(finset.prod (finset.range k) fun (i : ℕ) => n - i) * x ^ (n - k) :=
sorry
theorem iter_deriv_pow {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {x : 𝕜} {n : ℕ} {k : ℕ} :
nat.iterate deriv k (fun (x : 𝕜) => x ^ n) x =
↑(finset.prod (finset.range k) fun (i : ℕ) => n - i) * x ^ (n - k) :=
congr_fun iter_deriv_pow' x
theorem has_deriv_within_at.pow {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {x : 𝕜} {s : set 𝕜}
{c : 𝕜 → 𝕜} {c' : 𝕜} {n : ℕ} (hc : has_deriv_within_at c c' s x) :
has_deriv_within_at (fun (y : 𝕜) => c y ^ n) (↑n * c x ^ (n - 1) * c') s x :=
has_deriv_at.comp_has_deriv_within_at x (has_deriv_at_pow n (c x)) hc
theorem has_deriv_at.pow {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {x : 𝕜} {c : 𝕜 → 𝕜} {c' : 𝕜}
{n : ℕ} (hc : has_deriv_at c c' x) :
has_deriv_at (fun (y : 𝕜) => c y ^ n) (↑n * c x ^ (n - 1) * c') x :=
sorry
theorem differentiable_within_at.pow {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {x : 𝕜} {s : set 𝕜}
{c : 𝕜 → 𝕜} {n : ℕ} (hc : differentiable_within_at 𝕜 c s x) :
differentiable_within_at 𝕜 (fun (x : 𝕜) => c x ^ n) s x :=
has_deriv_within_at.differentiable_within_at
(has_deriv_within_at.pow (differentiable_within_at.has_deriv_within_at hc))
@[simp] theorem differentiable_at.pow {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {x : 𝕜} {c : 𝕜 → 𝕜}
{n : ℕ} (hc : differentiable_at 𝕜 c x) : differentiable_at 𝕜 (fun (x : 𝕜) => c x ^ n) x :=
has_deriv_at.differentiable_at (has_deriv_at.pow (differentiable_at.has_deriv_at hc))
theorem differentiable_on.pow {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {s : set 𝕜} {c : 𝕜 → 𝕜}
{n : ℕ} (hc : differentiable_on 𝕜 c s) : differentiable_on 𝕜 (fun (x : 𝕜) => c x ^ n) s :=
fun (x : 𝕜) (h : x ∈ s) => differentiable_within_at.pow (hc x h)
@[simp] theorem differentiable.pow {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {c : 𝕜 → 𝕜} {n : ℕ}
(hc : differentiable 𝕜 c) : differentiable 𝕜 fun (x : 𝕜) => c x ^ n :=
fun (x : 𝕜) => differentiable_at.pow (hc x)
theorem deriv_within_pow' {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {x : 𝕜} {s : set 𝕜} {c : 𝕜 → 𝕜}
{n : ℕ} (hc : differentiable_within_at 𝕜 c s x) (hxs : unique_diff_within_at 𝕜 s x) :
deriv_within (fun (x : 𝕜) => c x ^ n) s x = ↑n * c x ^ (n - 1) * deriv_within c s x :=
has_deriv_within_at.deriv_within
(has_deriv_within_at.pow (differentiable_within_at.has_deriv_within_at hc)) hxs
@[simp] theorem deriv_pow'' {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {x : 𝕜} {c : 𝕜 → 𝕜} {n : ℕ}
(hc : differentiable_at 𝕜 c x) :
deriv (fun (x : 𝕜) => c x ^ n) x = ↑n * c x ^ (n - 1) * deriv c x :=
has_deriv_at.deriv (has_deriv_at.pow (differentiable_at.has_deriv_at hc))
/-! ### Derivative of `x ↦ x^m` for `m : ℤ` -/
theorem has_strict_deriv_at_fpow {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {x : 𝕜} (m : ℤ)
(hx : x ≠ 0) : has_strict_deriv_at (fun (x : 𝕜) => x ^ m) (↑m * x ^ (m - 1)) x :=
sorry
theorem has_deriv_at_fpow {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {x : 𝕜} (m : ℤ) (hx : x ≠ 0) :
has_deriv_at (fun (x : 𝕜) => x ^ m) (↑m * x ^ (m - 1)) x :=
has_strict_deriv_at.has_deriv_at (has_strict_deriv_at_fpow m hx)
theorem has_deriv_within_at_fpow {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {x : 𝕜} (m : ℤ)
(hx : x ≠ 0) (s : set 𝕜) : has_deriv_within_at (fun (x : 𝕜) => x ^ m) (↑m * x ^ (m - 1)) s x :=
has_deriv_at.has_deriv_within_at (has_deriv_at_fpow m hx)
theorem differentiable_at_fpow {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {x : 𝕜} {m : ℤ}
(hx : x ≠ 0) : differentiable_at 𝕜 (fun (x : 𝕜) => x ^ m) x :=
has_deriv_at.differentiable_at (has_deriv_at_fpow m hx)
theorem differentiable_within_at_fpow {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {x : 𝕜} {s : set 𝕜}
{m : ℤ} (hx : x ≠ 0) : differentiable_within_at 𝕜 (fun (x : 𝕜) => x ^ m) s x :=
differentiable_at.differentiable_within_at (differentiable_at_fpow hx)
theorem differentiable_on_fpow {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {s : set 𝕜} {m : ℤ}
(hs : ¬0 ∈ s) : differentiable_on 𝕜 (fun (x : 𝕜) => x ^ m) s :=
fun (x : 𝕜) (hxs : x ∈ s) => differentiable_within_at_fpow fun (hx : x = 0) => hs (hx ▸ hxs)
-- TODO : this is true at `x=0` as well
theorem deriv_fpow {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {x : 𝕜} {m : ℤ} (hx : x ≠ 0) :
deriv (fun (x : 𝕜) => x ^ m) x = ↑m * x ^ (m - 1) :=
has_deriv_at.deriv (has_deriv_at_fpow m hx)
theorem deriv_within_fpow {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {x : 𝕜} {s : set 𝕜} {m : ℤ}
(hxs : unique_diff_within_at 𝕜 s x) (hx : x ≠ 0) :
deriv_within (fun (x : 𝕜) => x ^ m) s x = ↑m * x ^ (m - 1) :=
has_deriv_within_at.deriv_within (has_deriv_within_at_fpow m hx s) hxs
theorem iter_deriv_fpow {𝕜 : Type u} [nondiscrete_normed_field 𝕜] {x : 𝕜} {m : ℤ} {k : ℕ}
(hx : x ≠ 0) :
nat.iterate deriv k (fun (x : 𝕜) => x ^ m) x =
↑(finset.prod (finset.range k) fun (i : ℕ) => m - ↑i) * x ^ (m - ↑k) :=
sorry
/-! ### Upper estimates on liminf and limsup -/
theorem has_deriv_within_at.limsup_slope_le {f : ℝ → ℝ} {f' : ℝ} {s : set ℝ} {x : ℝ} {r : ℝ}
(hf : has_deriv_within_at f f' s x) (hr : f' < r) :
filter.eventually (fun (z : ℝ) => z - x⁻¹ * (f z - f x) < r)
(nhds_within x (s \ singleton x)) :=
iff.mp has_deriv_within_at_iff_tendsto_slope hf (set.Iio r) (mem_nhds_sets is_open_Iio hr)
theorem has_deriv_within_at.limsup_slope_le' {f : ℝ → ℝ} {f' : ℝ} {s : set ℝ} {x : ℝ} {r : ℝ}
(hf : has_deriv_within_at f f' s x) (hs : ¬x ∈ s) (hr : f' < r) :
filter.eventually (fun (z : ℝ) => z - x⁻¹ * (f z - f x) < r) (nhds_within x s) :=
iff.mp (has_deriv_within_at_iff_tendsto_slope' hs) hf (set.Iio r) (mem_nhds_sets is_open_Iio hr)
theorem has_deriv_within_at.liminf_right_slope_le {f : ℝ → ℝ} {f' : ℝ} {x : ℝ} {r : ℝ}
(hf : has_deriv_within_at f f' (set.Ici x) x) (hr : f' < r) :
filter.frequently (fun (z : ℝ) => z - x⁻¹ * (f z - f x) < r) (nhds_within x (set.Ioi x)) :=
filter.eventually.frequently
(has_deriv_within_at.limsup_slope_le' (has_deriv_within_at.Ioi_of_Ici hf) (lt_irrefl x) hr)
/-- If `f` has derivative `f'` within `s` at `x`, then for any `r > ∥f'∥` the ratio
`∥f z - f x∥ / ∥z - x∥` is less than `r` in some neighborhood of `x` within `s`.
In other words, the limit superior of this ratio as `z` tends to `x` along `s`
is less than or equal to `∥f'∥`. -/
theorem has_deriv_within_at.limsup_norm_slope_le {E : Type u} [normed_group E] [normed_space ℝ E]
{f : ℝ → E} {f' : E} {s : set ℝ} {x : ℝ} {r : ℝ} (hf : has_deriv_within_at f f' s x)
(hr : norm f' < r) :
filter.eventually (fun (z : ℝ) => norm (z - x)⁻¹ * norm (f z - f x) < r) (nhds_within x s) :=
sorry
/-- If `f` has derivative `f'` within `s` at `x`, then for any `r > ∥f'∥` the ratio
`(∥f z∥ - ∥f x∥) / ∥z - x∥` is less than `r` in some neighborhood of `x` within `s`.
In other words, the limit superior of this ratio as `z` tends to `x` along `s`
is less than or equal to `∥f'∥`.
This lemma is a weaker version of `has_deriv_within_at.limsup_norm_slope_le`
where `∥f z∥ - ∥f x∥` is replaced by `∥f z - f x∥`. -/
theorem has_deriv_within_at.limsup_slope_norm_le {E : Type u} [normed_group E] [normed_space ℝ E]
{f : ℝ → E} {f' : E} {s : set ℝ} {x : ℝ} {r : ℝ} (hf : has_deriv_within_at f f' s x)
(hr : norm f' < r) :
filter.eventually (fun (z : ℝ) => norm (z - x)⁻¹ * (norm (f z) - norm (f x)) < r)
(nhds_within x s) :=
sorry
/-- If `f` has derivative `f'` within `(x, +∞)` at `x`, then for any `r > ∥f'∥` the ratio
`∥f z - f x∥ / ∥z - x∥` is frequently less than `r` as `z → x+0`.
In other words, the limit inferior of this ratio as `z` tends to `x+0`
is less than or equal to `∥f'∥`. See also `has_deriv_within_at.limsup_norm_slope_le`
for a stronger version using limit superior and any set `s`. -/
theorem has_deriv_within_at.liminf_right_norm_slope_le {E : Type u} [normed_group E]
[normed_space ℝ E] {f : ℝ → E} {f' : E} {x : ℝ} {r : ℝ}
(hf : has_deriv_within_at f f' (set.Ici x) x) (hr : norm f' < r) :
filter.frequently (fun (z : ℝ) => norm (z - x)⁻¹ * norm (f z - f x) < r)
(nhds_within x (set.Ioi x)) :=
filter.eventually.frequently
(has_deriv_within_at.limsup_norm_slope_le (has_deriv_within_at.Ioi_of_Ici hf) hr)
/-- If `f` has derivative `f'` within `(x, +∞)` at `x`, then for any `r > ∥f'∥` the ratio
`(∥f z∥ - ∥f x∥) / (z - x)` is frequently less than `r` as `z → x+0`.
In other words, the limit inferior of this ratio as `z` tends to `x+0`
is less than or equal to `∥f'∥`.
See also
* `has_deriv_within_at.limsup_norm_slope_le` for a stronger version using
limit superior and any set `s`;
* `has_deriv_within_at.liminf_right_norm_slope_le` for a stronger version using
`∥f z - f x∥` instead of `∥f z∥ - ∥f x∥`. -/
theorem has_deriv_within_at.liminf_right_slope_norm_le {E : Type u} [normed_group E]
[normed_space ℝ E] {f : ℝ → E} {f' : E} {x : ℝ} {r : ℝ}
(hf : has_deriv_within_at f f' (set.Ici x) x) (hr : norm f' < r) :
filter.frequently (fun (z : ℝ) => z - x⁻¹ * (norm (f z) - norm (f x)) < r)
(nhds_within x (set.Ioi x)) :=
sorry
end Mathlib |
1d127caf9645390c09f1a9941fc07ab58e0ab232 | 8cae430f0a71442d02dbb1cbb14073b31048e4b0 | /src/order/upper_lower/basic.lean | db5b4c91df203e75aa337707c1b018f94cbefd6c | [
"Apache-2.0"
] | permissive | leanprover-community/mathlib | 56a2cadd17ac88caf4ece0a775932fa26327ba0e | 442a83d738cb208d3600056c489be16900ba701d | refs/heads/master | 1,693,584,102,358 | 1,693,471,902,000 | 1,693,471,902,000 | 97,922,418 | 1,595 | 352 | Apache-2.0 | 1,694,693,445,000 | 1,500,624,130,000 | Lean | UTF-8 | Lean | false | false | 45,914 | lean | /-
Copyright (c) 2022 Yaël Dillies, Sara Rousta. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yaël Dillies, Sara Rousta
-/
import data.set_like.basic
import data.set.intervals.ord_connected
import data.set.intervals.order_iso
import tactic.by_contra
/-!
# Up-sets and down-sets
> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.
> Any changes to this file require a corresponding PR to mathlib4.
This file defines upper and lower sets in an order.
## Main declarations
* `is_upper_set`: Predicate for a set to be an upper set. This means every element greater than a
member of the set is in the set itself.
* `is_lower_set`: Predicate for a set to be a lower set. This means every element less than a member
of the set is in the set itself.
* `upper_set`: The type of upper sets.
* `lower_set`: The type of lower sets.
* `upper_closure`: The greatest upper set containing a set.
* `lower_closure`: The least lower set containing a set.
* `upper_set.Ici`: Principal upper set. `set.Ici` as an upper set.
* `upper_set.Ioi`: Strict principal upper set. `set.Ioi` as an upper set.
* `lower_set.Iic`: Principal lower set. `set.Iic` as an lower set.
* `lower_set.Iio`: Strict principal lower set. `set.Iio` as an lower set.
## Notation
`×ˢ` is notation for `upper_set.prod`/`lower_set.prod`.
## Notes
Upper sets are ordered by **reverse** inclusion. This convention is motivated by the fact that this
makes them order-isomorphic to lower sets and antichains, and matches the convention on `filter`.
## TODO
Lattice structure on antichains. Order equivalence between upper/lower sets and antichains.
-/
open order_dual set
variables {α β γ : Type*} {ι : Sort*} {κ : ι → Sort*}
/-! ### Unbundled upper/lower sets -/
section has_le
variables [has_le α] [has_le β] {s t : set α}
/-- An upper set in an order `α` is a set such that any element greater than one of its members is
also a member. Also called up-set, upward-closed set. -/
def is_upper_set (s : set α) : Prop := ∀ ⦃a b : α⦄, a ≤ b → a ∈ s → b ∈ s
/-- A lower set in an order `α` is a set such that any element less than one of its members is also
a member. Also called down-set, downward-closed set. -/
def is_lower_set (s : set α) : Prop := ∀ ⦃a b : α⦄, b ≤ a → a ∈ s → b ∈ s
lemma is_upper_set_empty : is_upper_set (∅ : set α) := λ _ _ _, id
lemma is_lower_set_empty : is_lower_set (∅ : set α) := λ _ _ _, id
lemma is_upper_set_univ : is_upper_set (univ : set α) := λ _ _ _, id
lemma is_lower_set_univ : is_lower_set (univ : set α) := λ _ _ _, id
lemma is_upper_set.compl (hs : is_upper_set s) : is_lower_set sᶜ := λ a b h hb ha, hb $ hs h ha
lemma is_lower_set.compl (hs : is_lower_set s) : is_upper_set sᶜ := λ a b h hb ha, hb $ hs h ha
@[simp] lemma is_upper_set_compl : is_upper_set sᶜ ↔ is_lower_set s :=
⟨λ h, by { convert h.compl, rw compl_compl }, is_lower_set.compl⟩
@[simp] lemma is_lower_set_compl : is_lower_set sᶜ ↔ is_upper_set s :=
⟨λ h, by { convert h.compl, rw compl_compl }, is_upper_set.compl⟩
lemma is_upper_set.union (hs : is_upper_set s) (ht : is_upper_set t) : is_upper_set (s ∪ t) :=
λ a b h, or.imp (hs h) (ht h)
lemma is_lower_set.union (hs : is_lower_set s) (ht : is_lower_set t) : is_lower_set (s ∪ t) :=
λ a b h, or.imp (hs h) (ht h)
lemma is_upper_set.inter (hs : is_upper_set s) (ht : is_upper_set t) : is_upper_set (s ∩ t) :=
λ a b h, and.imp (hs h) (ht h)
lemma is_lower_set.inter (hs : is_lower_set s) (ht : is_lower_set t) : is_lower_set (s ∩ t) :=
λ a b h, and.imp (hs h) (ht h)
lemma is_upper_set_Union {f : ι → set α} (hf : ∀ i, is_upper_set (f i)) : is_upper_set (⋃ i, f i) :=
λ a b h, Exists₂.imp $ forall_range_iff.2 $ λ i, hf i h
lemma is_lower_set_Union {f : ι → set α} (hf : ∀ i, is_lower_set (f i)) : is_lower_set (⋃ i, f i) :=
λ a b h, Exists₂.imp $ forall_range_iff.2 $ λ i, hf i h
lemma is_upper_set_Union₂ {f : Π i, κ i → set α} (hf : ∀ i j, is_upper_set (f i j)) :
is_upper_set (⋃ i j, f i j) :=
is_upper_set_Union $ λ i, is_upper_set_Union $ hf i
lemma is_lower_set_Union₂ {f : Π i, κ i → set α} (hf : ∀ i j, is_lower_set (f i j)) :
is_lower_set (⋃ i j, f i j) :=
is_lower_set_Union $ λ i, is_lower_set_Union $ hf i
lemma is_upper_set_sUnion {S : set (set α)} (hf : ∀ s ∈ S, is_upper_set s) : is_upper_set (⋃₀ S) :=
λ a b h, Exists₂.imp $ λ s hs, hf s hs h
lemma is_lower_set_sUnion {S : set (set α)} (hf : ∀ s ∈ S, is_lower_set s) : is_lower_set (⋃₀ S) :=
λ a b h, Exists₂.imp $ λ s hs, hf s hs h
lemma is_upper_set_Inter {f : ι → set α} (hf : ∀ i, is_upper_set (f i)) : is_upper_set (⋂ i, f i) :=
λ a b h, forall₂_imp $ forall_range_iff.2 $ λ i, hf i h
lemma is_lower_set_Inter {f : ι → set α} (hf : ∀ i, is_lower_set (f i)) : is_lower_set (⋂ i, f i) :=
λ a b h, forall₂_imp $ forall_range_iff.2 $ λ i, hf i h
lemma is_upper_set_Inter₂ {f : Π i, κ i → set α} (hf : ∀ i j, is_upper_set (f i j)) :
is_upper_set (⋂ i j, f i j) :=
is_upper_set_Inter $ λ i, is_upper_set_Inter $ hf i
lemma is_lower_set_Inter₂ {f : Π i, κ i → set α} (hf : ∀ i j, is_lower_set (f i j)) :
is_lower_set (⋂ i j, f i j) :=
is_lower_set_Inter $ λ i, is_lower_set_Inter $ hf i
lemma is_upper_set_sInter {S : set (set α)} (hf : ∀ s ∈ S, is_upper_set s) : is_upper_set (⋂₀ S) :=
λ a b h, forall₂_imp $ λ s hs, hf s hs h
lemma is_lower_set_sInter {S : set (set α)} (hf : ∀ s ∈ S, is_lower_set s) : is_lower_set (⋂₀ S) :=
λ a b h, forall₂_imp $ λ s hs, hf s hs h
@[simp] lemma is_lower_set_preimage_of_dual_iff : is_lower_set (of_dual ⁻¹' s) ↔ is_upper_set s :=
iff.rfl
@[simp] lemma is_upper_set_preimage_of_dual_iff : is_upper_set (of_dual ⁻¹' s) ↔ is_lower_set s :=
iff.rfl
@[simp] lemma is_lower_set_preimage_to_dual_iff {s : set αᵒᵈ} :
is_lower_set (to_dual ⁻¹' s) ↔ is_upper_set s := iff.rfl
@[simp] lemma is_upper_set_preimage_to_dual_iff {s : set αᵒᵈ} :
is_upper_set (to_dual ⁻¹' s) ↔ is_lower_set s := iff.rfl
alias is_lower_set_preimage_of_dual_iff ↔ _ is_upper_set.to_dual
alias is_upper_set_preimage_of_dual_iff ↔ _ is_lower_set.to_dual
alias is_lower_set_preimage_to_dual_iff ↔ _ is_upper_set.of_dual
alias is_upper_set_preimage_to_dual_iff ↔ _ is_lower_set.of_dual
end has_le
section preorder
variables [preorder α] [preorder β] {s : set α} {p : α → Prop} (a : α)
lemma is_upper_set_Ici : is_upper_set (Ici a) := λ _ _, ge_trans
lemma is_lower_set_Iic : is_lower_set (Iic a) := λ _ _, le_trans
lemma is_upper_set_Ioi : is_upper_set (Ioi a) := λ _ _, flip lt_of_lt_of_le
lemma is_lower_set_Iio : is_lower_set (Iio a) := λ _ _, lt_of_le_of_lt
lemma is_upper_set_iff_Ici_subset : is_upper_set s ↔ ∀ ⦃a⦄, a ∈ s → Ici a ⊆ s :=
by simp [is_upper_set, subset_def, @forall_swap (_ ∈ s)]
lemma is_lower_set_iff_Iic_subset : is_lower_set s ↔ ∀ ⦃a⦄, a ∈ s → Iic a ⊆ s :=
by simp [is_lower_set, subset_def, @forall_swap (_ ∈ s)]
alias is_upper_set_iff_Ici_subset ↔ is_upper_set.Ici_subset _
alias is_lower_set_iff_Iic_subset ↔ is_lower_set.Iic_subset _
lemma is_upper_set.ord_connected (h : is_upper_set s) : s.ord_connected :=
⟨λ a ha b _, Icc_subset_Ici_self.trans $ h.Ici_subset ha⟩
lemma is_lower_set.ord_connected (h : is_lower_set s) : s.ord_connected :=
⟨λ a _ b hb, Icc_subset_Iic_self.trans $ h.Iic_subset hb⟩
lemma is_upper_set.preimage (hs : is_upper_set s) {f : β → α} (hf : monotone f) :
is_upper_set (f ⁻¹' s : set β) :=
λ x y hxy, hs $ hf hxy
lemma is_lower_set.preimage (hs : is_lower_set s) {f : β → α} (hf : monotone f) :
is_lower_set (f ⁻¹' s : set β) :=
λ x y hxy, hs $ hf hxy
lemma is_upper_set.image (hs : is_upper_set s) (f : α ≃o β) : is_upper_set (f '' s : set β) :=
by { change is_upper_set ((f : α ≃ β) '' s), rw set.image_equiv_eq_preimage_symm,
exact hs.preimage f.symm.monotone }
lemma is_lower_set.image (hs : is_lower_set s) (f : α ≃o β) : is_lower_set (f '' s : set β) :=
by { change is_lower_set ((f : α ≃ β) '' s), rw set.image_equiv_eq_preimage_symm,
exact hs.preimage f.symm.monotone }
@[simp] lemma set.monotone_mem : monotone (∈ s) ↔ is_upper_set s := iff.rfl
@[simp] lemma set.antitone_mem : antitone (∈ s) ↔ is_lower_set s := forall_swap
@[simp] lemma is_upper_set_set_of : is_upper_set {a | p a} ↔ monotone p := iff.rfl
@[simp] lemma is_lower_set_set_of : is_lower_set {a | p a} ↔ antitone p := forall_swap
section order_top
variables [order_top α]
lemma is_lower_set.top_mem (hs : is_lower_set s) : ⊤ ∈ s ↔ s = univ :=
⟨λ h, eq_univ_of_forall $ λ a, hs le_top h, λ h, h.symm ▸ mem_univ _⟩
lemma is_upper_set.top_mem (hs : is_upper_set s) : ⊤ ∈ s ↔ s.nonempty :=
⟨λ h, ⟨_, h⟩, λ ⟨a, ha⟩, hs le_top ha⟩
lemma is_upper_set.not_top_mem (hs : is_upper_set s) : ⊤ ∉ s ↔ s = ∅ :=
hs.top_mem.not.trans not_nonempty_iff_eq_empty
end order_top
section order_bot
variables [order_bot α]
lemma is_upper_set.bot_mem (hs : is_upper_set s) : ⊥ ∈ s ↔ s = univ :=
⟨λ h, eq_univ_of_forall $ λ a, hs bot_le h, λ h, h.symm ▸ mem_univ _⟩
lemma is_lower_set.bot_mem (hs : is_lower_set s) : ⊥ ∈ s ↔ s.nonempty :=
⟨λ h, ⟨_, h⟩, λ ⟨a, ha⟩, hs bot_le ha⟩
lemma is_lower_set.not_bot_mem (hs : is_lower_set s) : ⊥ ∉ s ↔ s = ∅ :=
hs.bot_mem.not.trans not_nonempty_iff_eq_empty
end order_bot
section no_max_order
variables [no_max_order α] (a)
lemma is_upper_set.not_bdd_above (hs : is_upper_set s) : s.nonempty → ¬ bdd_above s :=
begin
rintro ⟨a, ha⟩ ⟨b, hb⟩,
obtain ⟨c, hc⟩ := exists_gt b,
exact hc.not_le (hb $ hs ((hb ha).trans hc.le) ha),
end
lemma not_bdd_above_Ici : ¬ bdd_above (Ici a) := (is_upper_set_Ici _).not_bdd_above nonempty_Ici
lemma not_bdd_above_Ioi : ¬ bdd_above (Ioi a) := (is_upper_set_Ioi _).not_bdd_above nonempty_Ioi
end no_max_order
section no_min_order
variables [no_min_order α] (a)
lemma is_lower_set.not_bdd_below (hs : is_lower_set s) : s.nonempty → ¬ bdd_below s :=
begin
rintro ⟨a, ha⟩ ⟨b, hb⟩,
obtain ⟨c, hc⟩ := exists_lt b,
exact hc.not_le (hb $ hs (hc.le.trans $ hb ha) ha),
end
lemma not_bdd_below_Iic : ¬ bdd_below (Iic a) := (is_lower_set_Iic _).not_bdd_below nonempty_Iic
lemma not_bdd_below_Iio : ¬ bdd_below (Iio a) := (is_lower_set_Iio _).not_bdd_below nonempty_Iio
end no_min_order
end preorder
section partial_order
variables [partial_order α] {s : set α}
lemma is_upper_set_iff_forall_lt : is_upper_set s ↔ ∀ ⦃a b : α⦄, a < b → a ∈ s → b ∈ s :=
forall_congr $ λ a, by simp [le_iff_eq_or_lt, or_imp_distrib, forall_and_distrib]
lemma is_lower_set_iff_forall_lt : is_lower_set s ↔ ∀ ⦃a b : α⦄, b < a → a ∈ s → b ∈ s :=
forall_congr $ λ a, by simp [le_iff_eq_or_lt, or_imp_distrib, forall_and_distrib]
lemma is_upper_set_iff_Ioi_subset : is_upper_set s ↔ ∀ ⦃a⦄, a ∈ s → Ioi a ⊆ s :=
by simp [is_upper_set_iff_forall_lt, subset_def, @forall_swap (_ ∈ s)]
lemma is_lower_set_iff_Iio_subset : is_lower_set s ↔ ∀ ⦃a⦄, a ∈ s → Iio a ⊆ s :=
by simp [is_lower_set_iff_forall_lt, subset_def, @forall_swap (_ ∈ s)]
alias is_upper_set_iff_Ioi_subset ↔ is_upper_set.Ioi_subset _
alias is_lower_set_iff_Iio_subset ↔ is_lower_set.Iio_subset _
end partial_order
section linear_order
variables [linear_order α] {s t : set α}
lemma is_upper_set.total (hs : is_upper_set s) (ht : is_upper_set t) : s ⊆ t ∨ t ⊆ s :=
begin
by_contra' h,
simp_rw set.not_subset at h,
obtain ⟨⟨a, has, hat⟩, b, hbt, hbs⟩ := h,
obtain hab | hba := le_total a b,
{ exact hbs (hs hab has) },
{ exact hat (ht hba hbt) }
end
lemma is_lower_set.total (hs : is_lower_set s) (ht : is_lower_set t) : s ⊆ t ∨ t ⊆ s :=
hs.to_dual.total ht.to_dual
end linear_order
/-! ### Bundled upper/lower sets -/
section has_le
variables [has_le α]
/-- The type of upper sets of an order. -/
structure upper_set (α : Type*) [has_le α] :=
(carrier : set α)
(upper' : is_upper_set carrier)
/-- The type of lower sets of an order. -/
structure lower_set (α : Type*) [has_le α] :=
(carrier : set α)
(lower' : is_lower_set carrier)
namespace upper_set
instance : set_like (upper_set α) α :=
{ coe := upper_set.carrier,
coe_injective' := λ s t h, by { cases s, cases t, congr' } }
@[ext] lemma ext {s t : upper_set α} : (s : set α) = t → s = t := set_like.ext'
@[simp] lemma carrier_eq_coe (s : upper_set α) : s.carrier = s := rfl
protected lemma upper (s : upper_set α) : is_upper_set (s : set α) := s.upper'
@[simp] lemma mem_mk (carrier : set α) (upper') {a : α} : a ∈ mk carrier upper' ↔ a ∈ carrier :=
iff.rfl
end upper_set
namespace lower_set
instance : set_like (lower_set α) α :=
{ coe := lower_set.carrier,
coe_injective' := λ s t h, by { cases s, cases t, congr' } }
@[ext] lemma ext {s t : lower_set α} : (s : set α) = t → s = t := set_like.ext'
@[simp] lemma carrier_eq_coe (s : lower_set α) : s.carrier = s := rfl
protected lemma lower (s : lower_set α) : is_lower_set (s : set α) := s.lower'
@[simp] lemma mem_mk (carrier : set α) (lower') {a : α} : a ∈ mk carrier lower' ↔ a ∈ carrier :=
iff.rfl
end lower_set
/-! #### Order -/
namespace upper_set
variables {S : set (upper_set α)} {s t : upper_set α} {a : α}
instance : has_sup (upper_set α) := ⟨λ s t, ⟨s ∩ t, s.upper.inter t.upper⟩⟩
instance : has_inf (upper_set α) := ⟨λ s t, ⟨s ∪ t, s.upper.union t.upper⟩⟩
instance : has_top (upper_set α) := ⟨⟨∅, is_upper_set_empty⟩⟩
instance : has_bot (upper_set α) := ⟨⟨univ, is_upper_set_univ⟩⟩
instance : has_Sup (upper_set α) :=
⟨λ S, ⟨⋂ s ∈ S, ↑s, is_upper_set_Inter₂ $ λ s _, s.upper⟩⟩
instance : has_Inf (upper_set α) :=
⟨λ S, ⟨⋃ s ∈ S, ↑s, is_upper_set_Union₂ $ λ s _, s.upper⟩⟩
instance : complete_distrib_lattice (upper_set α) :=
(to_dual.injective.comp $ set_like.coe_injective).complete_distrib_lattice _
(λ _ _, rfl) (λ _ _, rfl) (λ _, rfl) (λ _, rfl) rfl rfl
instance : inhabited (upper_set α) := ⟨⊥⟩
@[simp, norm_cast] lemma coe_subset_coe : (s : set α) ⊆ t ↔ t ≤ s := iff.rfl
@[simp, norm_cast] lemma coe_top : ((⊤ : upper_set α) : set α) = ∅ := rfl
@[simp, norm_cast] lemma coe_bot : ((⊥ : upper_set α) : set α) = univ := rfl
@[simp, norm_cast] lemma coe_eq_univ : (s : set α) = univ ↔ s = ⊥ := by simp [set_like.ext'_iff]
@[simp, norm_cast] lemma coe_eq_empty : (s : set α) = ∅ ↔ s = ⊤ := by simp [set_like.ext'_iff]
@[simp, norm_cast] lemma coe_sup (s t : upper_set α) : (↑(s ⊔ t) : set α) = s ∩ t := rfl
@[simp, norm_cast] lemma coe_inf (s t : upper_set α) : (↑(s ⊓ t) : set α) = s ∪ t := rfl
@[simp, norm_cast] lemma coe_Sup (S : set (upper_set α)) : (↑(Sup S) : set α) = ⋂ s ∈ S, ↑s := rfl
@[simp, norm_cast] lemma coe_Inf (S : set (upper_set α)) : (↑(Inf S) : set α) = ⋃ s ∈ S, ↑s := rfl
@[simp, norm_cast] lemma coe_supr (f : ι → upper_set α) : (↑(⨆ i, f i) : set α) = ⋂ i, f i :=
by simp [supr]
@[simp, norm_cast] lemma coe_infi (f : ι → upper_set α) : (↑(⨅ i, f i) : set α) = ⋃ i, f i :=
by simp [infi]
@[simp, norm_cast] lemma coe_supr₂ (f : Π i, κ i → upper_set α) :
(↑(⨆ i j, f i j) : set α) = ⋂ i j, f i j := by simp_rw coe_supr
@[simp, norm_cast] lemma coe_infi₂ (f : Π i, κ i → upper_set α) :
(↑(⨅ i j, f i j) : set α) = ⋃ i j, f i j := by simp_rw coe_infi
@[simp] lemma not_mem_top : a ∉ (⊤ : upper_set α) := id
@[simp] lemma mem_bot : a ∈ (⊥ : upper_set α) := trivial
@[simp] lemma mem_sup_iff : a ∈ s ⊔ t ↔ a ∈ s ∧ a ∈ t := iff.rfl
@[simp] lemma mem_inf_iff : a ∈ s ⊓ t ↔ a ∈ s ∨ a ∈ t := iff.rfl
@[simp] lemma mem_Sup_iff : a ∈ Sup S ↔ ∀ s ∈ S, a ∈ s := mem_Inter₂
@[simp] lemma mem_Inf_iff : a ∈ Inf S ↔ ∃ s ∈ S, a ∈ s := mem_Union₂
@[simp] lemma mem_supr_iff {f : ι → upper_set α} : a ∈ (⨆ i, f i) ↔ ∀ i, a ∈ f i :=
by { rw [←set_like.mem_coe, coe_supr], exact mem_Inter }
@[simp] lemma mem_infi_iff {f : ι → upper_set α} : a ∈ (⨅ i, f i) ↔ ∃ i, a ∈ f i :=
by { rw [←set_like.mem_coe, coe_infi], exact mem_Union }
@[simp] lemma mem_supr₂_iff {f : Π i, κ i → upper_set α} : a ∈ (⨆ i j, f i j) ↔ ∀ i j, a ∈ f i j :=
by simp_rw mem_supr_iff
@[simp] lemma mem_infi₂_iff {f : Π i, κ i → upper_set α} : a ∈ (⨅ i j, f i j) ↔ ∃ i j, a ∈ f i j :=
by simp_rw mem_infi_iff
@[simp, norm_cast] lemma codisjoint_coe : codisjoint (s : set α) t ↔ disjoint s t :=
by simp [disjoint_iff, codisjoint_iff, set_like.ext'_iff]
end upper_set
namespace lower_set
variables {S : set (lower_set α)} {s t : lower_set α} {a : α}
instance : has_sup (lower_set α) := ⟨λ s t, ⟨s ∪ t, λ a b h, or.imp (s.lower h) (t.lower h)⟩⟩
instance : has_inf (lower_set α) := ⟨λ s t, ⟨s ∩ t, λ a b h, and.imp (s.lower h) (t.lower h)⟩⟩
instance : has_top (lower_set α) := ⟨⟨univ, λ a b h, id⟩⟩
instance : has_bot (lower_set α) := ⟨⟨∅, λ a b h, id⟩⟩
instance : has_Sup (lower_set α) := ⟨λ S, ⟨⋃ s ∈ S, ↑s, is_lower_set_Union₂ $ λ s _, s.lower⟩⟩
instance : has_Inf (lower_set α) := ⟨λ S, ⟨⋂ s ∈ S, ↑s, is_lower_set_Inter₂ $ λ s _, s.lower⟩⟩
instance : complete_distrib_lattice (lower_set α) :=
set_like.coe_injective.complete_distrib_lattice _
(λ _ _, rfl) (λ _ _, rfl) (λ _, rfl) (λ _, rfl) rfl rfl
instance : inhabited (lower_set α) := ⟨⊥⟩
@[simp, norm_cast] lemma coe_subset_coe : (s : set α) ⊆ t ↔ s ≤ t := iff.rfl
@[simp, norm_cast] lemma coe_top : ((⊤ : lower_set α) : set α) = univ := rfl
@[simp, norm_cast] lemma coe_bot : ((⊥ : lower_set α) : set α) = ∅ := rfl
@[simp, norm_cast] lemma coe_eq_univ : (s : set α) = univ ↔ s = ⊤ := by simp [set_like.ext'_iff]
@[simp, norm_cast] lemma coe_eq_empty : (s : set α) = ∅ ↔ s = ⊥ := by simp [set_like.ext'_iff]
@[simp, norm_cast] lemma coe_sup (s t : lower_set α) : (↑(s ⊔ t) : set α) = s ∪ t := rfl
@[simp, norm_cast] lemma coe_inf (s t : lower_set α) : (↑(s ⊓ t) : set α) = s ∩ t := rfl
@[simp, norm_cast] lemma coe_Sup (S : set (lower_set α)) : (↑(Sup S) : set α) = ⋃ s ∈ S, ↑s := rfl
@[simp, norm_cast] lemma coe_Inf (S : set (lower_set α)) : (↑(Inf S) : set α) = ⋂ s ∈ S, ↑s := rfl
@[simp, norm_cast] lemma coe_supr (f : ι → lower_set α) : (↑(⨆ i, f i) : set α) = ⋃ i, f i :=
by simp_rw [supr, coe_Sup, mem_range, Union_exists, Union_Union_eq']
@[simp, norm_cast] lemma coe_infi (f : ι → lower_set α) : (↑(⨅ i, f i) : set α) = ⋂ i, f i :=
by simp_rw [infi, coe_Inf, mem_range, Inter_exists, Inter_Inter_eq']
@[simp, norm_cast] lemma coe_supr₂ (f : Π i, κ i → lower_set α) :
(↑(⨆ i j, f i j) : set α) = ⋃ i j, f i j := by simp_rw coe_supr
@[simp, norm_cast] lemma coe_infi₂ (f : Π i, κ i → lower_set α) :
(↑(⨅ i j, f i j) : set α) = ⋂ i j, f i j := by simp_rw coe_infi
@[simp] lemma mem_top : a ∈ (⊤ : lower_set α) := trivial
@[simp] lemma not_mem_bot : a ∉ (⊥ : lower_set α) := id
@[simp] lemma mem_sup_iff : a ∈ s ⊔ t ↔ a ∈ s ∨ a ∈ t := iff.rfl
@[simp] lemma mem_inf_iff : a ∈ s ⊓ t ↔ a ∈ s ∧ a ∈ t := iff.rfl
@[simp] lemma mem_Sup_iff : a ∈ Sup S ↔ ∃ s ∈ S, a ∈ s := mem_Union₂
@[simp] lemma mem_Inf_iff : a ∈ Inf S ↔ ∀ s ∈ S, a ∈ s := mem_Inter₂
@[simp] lemma mem_supr_iff {f : ι → lower_set α} : a ∈ (⨆ i, f i) ↔ ∃ i, a ∈ f i :=
by { rw [←set_like.mem_coe, coe_supr], exact mem_Union }
@[simp] lemma mem_infi_iff {f : ι → lower_set α} : a ∈ (⨅ i, f i) ↔ ∀ i, a ∈ f i :=
by { rw [←set_like.mem_coe, coe_infi], exact mem_Inter }
@[simp] lemma mem_supr₂_iff {f : Π i, κ i → lower_set α} : a ∈ (⨆ i j, f i j) ↔ ∃ i j, a ∈ f i j :=
by simp_rw mem_supr_iff
@[simp] lemma mem_infi₂_iff {f : Π i, κ i → lower_set α} : a ∈ (⨅ i j, f i j) ↔ ∀ i j, a ∈ f i j :=
by simp_rw mem_infi_iff
@[simp, norm_cast] lemma disjoint_coe : disjoint (s : set α) t ↔ disjoint s t :=
by simp [disjoint_iff, set_like.ext'_iff]
end lower_set
/-! #### Complement -/
/-- The complement of a lower set as an upper set. -/
def upper_set.compl (s : upper_set α) : lower_set α := ⟨sᶜ, s.upper.compl⟩
/-- The complement of a lower set as an upper set. -/
def lower_set.compl (s : lower_set α) : upper_set α := ⟨sᶜ, s.lower.compl⟩
namespace upper_set
variables {s t : upper_set α} {a : α}
@[simp] lemma coe_compl (s : upper_set α) : (s.compl : set α) = sᶜ := rfl
@[simp] lemma mem_compl_iff : a ∈ s.compl ↔ a ∉ s := iff.rfl
@[simp] lemma compl_compl (s : upper_set α) : s.compl.compl = s := upper_set.ext $ compl_compl _
@[simp] lemma compl_le_compl : s.compl ≤ t.compl ↔ s ≤ t := compl_subset_compl
@[simp] protected lemma compl_sup (s t : upper_set α) : (s ⊔ t).compl = s.compl ⊔ t.compl :=
lower_set.ext compl_inf
@[simp] protected lemma compl_inf (s t : upper_set α) : (s ⊓ t).compl = s.compl ⊓ t.compl :=
lower_set.ext compl_sup
@[simp] protected lemma compl_top : (⊤ : upper_set α).compl = ⊤ := lower_set.ext compl_empty
@[simp] protected lemma compl_bot : (⊥ : upper_set α).compl = ⊥ := lower_set.ext compl_univ
@[simp] protected lemma compl_Sup (S : set (upper_set α)) :
(Sup S).compl = ⨆ s ∈ S, upper_set.compl s :=
lower_set.ext $ by simp only [coe_compl, coe_Sup, compl_Inter₂, lower_set.coe_supr₂]
@[simp] protected lemma compl_Inf (S : set (upper_set α)) :
(Inf S).compl = ⨅ s ∈ S, upper_set.compl s :=
lower_set.ext $ by simp only [coe_compl, coe_Inf, compl_Union₂, lower_set.coe_infi₂]
@[simp] protected lemma compl_supr (f : ι → upper_set α) : (⨆ i, f i).compl = ⨆ i, (f i).compl :=
lower_set.ext $ by simp only [coe_compl, coe_supr, compl_Inter, lower_set.coe_supr]
@[simp] protected lemma compl_infi (f : ι → upper_set α) : (⨅ i, f i).compl = ⨅ i, (f i).compl :=
lower_set.ext $ by simp only [coe_compl, coe_infi, compl_Union, lower_set.coe_infi]
@[simp] lemma compl_supr₂ (f : Π i, κ i → upper_set α) :
(⨆ i j, f i j).compl = ⨆ i j, (f i j).compl :=
by simp_rw upper_set.compl_supr
@[simp] lemma compl_infi₂ (f : Π i, κ i → upper_set α) :
(⨅ i j, f i j).compl = ⨅ i j, (f i j).compl :=
by simp_rw upper_set.compl_infi
end upper_set
namespace lower_set
variables {s t : lower_set α} {a : α}
@[simp] lemma coe_compl (s : lower_set α) : (s.compl : set α) = sᶜ := rfl
@[simp] lemma mem_compl_iff : a ∈ s.compl ↔ a ∉ s := iff.rfl
@[simp] lemma compl_compl (s : lower_set α) : s.compl.compl = s := lower_set.ext $ compl_compl _
@[simp] lemma compl_le_compl : s.compl ≤ t.compl ↔ s ≤ t := compl_subset_compl
protected lemma compl_sup (s t : lower_set α) : (s ⊔ t).compl = s.compl ⊔ t.compl :=
upper_set.ext compl_sup
protected lemma compl_inf (s t : lower_set α) : (s ⊓ t).compl = s.compl ⊓ t.compl :=
upper_set.ext compl_inf
protected lemma compl_top : (⊤ : lower_set α).compl = ⊤ := upper_set.ext compl_univ
protected lemma compl_bot : (⊥ : lower_set α).compl = ⊥ := upper_set.ext compl_empty
protected lemma compl_Sup (S : set (lower_set α)) : (Sup S).compl = ⨆ s ∈ S, lower_set.compl s :=
upper_set.ext $ by simp only [coe_compl, coe_Sup, compl_Union₂, upper_set.coe_supr₂]
protected lemma compl_Inf (S : set (lower_set α)) : (Inf S).compl = ⨅ s ∈ S, lower_set.compl s :=
upper_set.ext $ by simp only [coe_compl, coe_Inf, compl_Inter₂, upper_set.coe_infi₂]
protected lemma compl_supr (f : ι → lower_set α) : (⨆ i, f i).compl = ⨆ i, (f i).compl :=
upper_set.ext $ by simp only [coe_compl, coe_supr, compl_Union, upper_set.coe_supr]
protected lemma compl_infi (f : ι → lower_set α) : (⨅ i, f i).compl = ⨅ i, (f i).compl :=
upper_set.ext $ by simp only [coe_compl, coe_infi, compl_Inter, upper_set.coe_infi]
@[simp] lemma compl_supr₂ (f : Π i, κ i → lower_set α) :
(⨆ i j, f i j).compl = ⨆ i j, (f i j).compl :=
by simp_rw lower_set.compl_supr
@[simp] lemma compl_infi₂ (f : Π i, κ i → lower_set α) :
(⨅ i j, f i j).compl = ⨅ i j, (f i j).compl :=
by simp_rw lower_set.compl_infi
end lower_set
/-- Upper sets are order-isomorphic to lower sets under complementation. -/
@[simps] def upper_set_iso_lower_set : upper_set α ≃o lower_set α :=
{ to_fun := upper_set.compl,
inv_fun := lower_set.compl,
left_inv := upper_set.compl_compl,
right_inv := lower_set.compl_compl,
map_rel_iff' := λ _ _, upper_set.compl_le_compl }
end has_le
section linear_order
variables [linear_order α]
instance upper_set.is_total_le : is_total (upper_set α) (≤) := ⟨λ s t, t.upper.total s.upper⟩
instance lower_set.is_total_le : is_total (lower_set α) (≤) := ⟨λ s t, s.lower.total t.lower⟩
noncomputable instance : complete_linear_order (upper_set α) :=
{ le_total := is_total.total,
decidable_le := classical.dec_rel _,
decidable_eq := classical.dec_rel _,
decidable_lt := classical.dec_rel _,
max_def := by classical; exact sup_eq_max_default,
min_def := by classical; exact inf_eq_min_default,
..upper_set.complete_distrib_lattice }
noncomputable instance : complete_linear_order (lower_set α) :=
{ le_total := is_total.total,
decidable_le := classical.dec_rel _,
decidable_eq := classical.dec_rel _,
decidable_lt := classical.dec_rel _,
max_def := by classical; exact sup_eq_max_default,
min_def := by classical; exact inf_eq_min_default,
..lower_set.complete_distrib_lattice }
end linear_order
/-! #### Map -/
section
variables [preorder α] [preorder β] [preorder γ]
namespace upper_set
variables {f : α ≃o β} {s t : upper_set α} {a : α} {b : β}
/-- An order isomorphism of preorders induces an order isomorphism of their upper sets. -/
def map (f : α ≃o β) : upper_set α ≃o upper_set β :=
{ to_fun := λ s, ⟨f '' s, s.upper.image f⟩,
inv_fun := λ t, ⟨f ⁻¹' t, t.upper.preimage f.monotone⟩,
left_inv := λ _, ext $ f.preimage_image _,
right_inv := λ _, ext $ f.image_preimage _,
map_rel_iff' := λ s t, image_subset_image_iff f.injective }
@[simp] lemma symm_map (f : α ≃o β) : (map f).symm = map f.symm :=
fun_like.ext _ _ $ λ s, ext $ set.preimage_equiv_eq_image_symm _ _
@[simp] lemma mem_map : b ∈ map f s ↔ f.symm b ∈ s :=
by { rw [←f.symm_symm, ←symm_map, f.symm_symm], refl }
@[simp] lemma map_refl : map (order_iso.refl α) = order_iso.refl _ := by { ext, simp }
@[simp] lemma map_map (g : β ≃o γ) (f : α ≃o β) : map g (map f s) = map (f.trans g) s :=
by { ext, simp }
variables (f s t)
@[simp, norm_cast] lemma coe_map : (map f s : set β) = f '' s := rfl
end upper_set
namespace lower_set
variables {f : α ≃o β} {s t : lower_set α} {a : α} {b : β}
/-- An order isomorphism of preorders induces an order isomorphism of their lower sets. -/
def map (f : α ≃o β) : lower_set α ≃o lower_set β :=
{ to_fun := λ s, ⟨f '' s, s.lower.image f⟩,
inv_fun := λ t, ⟨f ⁻¹' t, t.lower.preimage f.monotone⟩,
left_inv := λ _, set_like.coe_injective $ f.preimage_image _,
right_inv := λ _, set_like.coe_injective $ f.image_preimage _,
map_rel_iff' := λ s t, image_subset_image_iff f.injective }
@[simp] lemma symm_map (f : α ≃o β) : (map f).symm = map f.symm :=
fun_like.ext _ _ $ λ s, set_like.coe_injective $ set.preimage_equiv_eq_image_symm _ _
@[simp] lemma mem_map {f : α ≃o β} {b : β} : b ∈ map f s ↔ f.symm b ∈ s :=
by { rw [←f.symm_symm, ←symm_map, f.symm_symm], refl }
@[simp] lemma map_refl : map (order_iso.refl α) = order_iso.refl _ := by { ext, simp }
@[simp] lemma map_map (g : β ≃o γ) (f : α ≃o β) : map g (map f s) = map (f.trans g) s :=
by { ext, simp }
variables (f s t)
@[simp, norm_cast] lemma coe_map : (map f s : set β) = f '' s := rfl
end lower_set
namespace upper_set
@[simp] lemma compl_map (f : α ≃o β) (s : upper_set α) :
(map f s).compl = lower_set.map f s.compl :=
set_like.coe_injective (set.image_compl_eq f.bijective).symm
end upper_set
namespace lower_set
@[simp] lemma compl_map (f : α ≃o β) (s : lower_set α) :
(map f s).compl = upper_set.map f s.compl :=
set_like.coe_injective (set.image_compl_eq f.bijective).symm
end lower_set
end
/-! #### Principal sets -/
namespace upper_set
section preorder
variables [preorder α] [preorder β] {s : upper_set α} {a b : α}
/-- The smallest upper set containing a given element. -/
def Ici (a : α) : upper_set α := ⟨Ici a, is_upper_set_Ici a⟩
/-- The smallest upper set containing a given element. -/
def Ioi (a : α) : upper_set α := ⟨Ioi a, is_upper_set_Ioi a⟩
@[simp] lemma coe_Ici (a : α) : ↑(Ici a) = set.Ici a := rfl
@[simp] lemma coe_Ioi (a : α) : ↑(Ioi a) = set.Ioi a := rfl
@[simp] lemma mem_Ici_iff : b ∈ Ici a ↔ a ≤ b := iff.rfl
@[simp] lemma mem_Ioi_iff : b ∈ Ioi a ↔ a < b := iff.rfl
@[simp] lemma map_Ici (f : α ≃o β) (a : α) : map f (Ici a) = Ici (f a) := by { ext, simp }
@[simp] lemma map_Ioi (f : α ≃o β) (a : α) : map f (Ioi a) = Ioi (f a) := by { ext, simp }
lemma Ici_le_Ioi (a : α) : Ici a ≤ Ioi a := Ioi_subset_Ici_self
@[simp] lemma Ioi_top [order_top α] : Ioi (⊤ : α) = ⊤ := set_like.coe_injective Ioi_top
@[simp] lemma Ici_bot [order_bot α] : Ici (⊥ : α) = ⊥ := set_like.coe_injective Ici_bot
end preorder
@[simp] lemma Ici_sup [semilattice_sup α] (a b : α) : Ici (a ⊔ b) = Ici a ⊔ Ici b :=
ext Ici_inter_Ici.symm
section complete_lattice
variables [complete_lattice α]
@[simp] lemma Ici_Sup (S : set α) : Ici (Sup S) = ⨆ a ∈ S, Ici a :=
set_like.ext $ λ c, by simp only [mem_Ici_iff, mem_supr_iff, Sup_le_iff]
@[simp] lemma Ici_supr (f : ι → α) : Ici (⨆ i, f i) = ⨆ i, Ici (f i) :=
set_like.ext $ λ c, by simp only [mem_Ici_iff, mem_supr_iff, supr_le_iff]
@[simp] lemma Ici_supr₂ (f : Π i, κ i → α) : Ici (⨆ i j, f i j) = ⨆ i j, Ici (f i j) :=
by simp_rw Ici_supr
end complete_lattice
end upper_set
namespace lower_set
section preorder
variables [preorder α] [preorder β] {s : lower_set α} {a b : α}
/-- Principal lower set. `set.Iic` as a lower set. The smallest lower set containing a given
element. -/
def Iic (a : α) : lower_set α := ⟨Iic a, is_lower_set_Iic a⟩
/-- Strict principal lower set. `set.Iio` as a lower set. -/
def Iio (a : α) : lower_set α := ⟨Iio a, is_lower_set_Iio a⟩
@[simp] lemma coe_Iic (a : α) : ↑(Iic a) = set.Iic a := rfl
@[simp] lemma coe_Iio (a : α) : ↑(Iio a) = set.Iio a := rfl
@[simp] lemma mem_Iic_iff : b ∈ Iic a ↔ b ≤ a := iff.rfl
@[simp] lemma mem_Iio_iff : b ∈ Iio a ↔ b < a := iff.rfl
@[simp] lemma map_Iic (f : α ≃o β) (a : α) : map f (Iic a) = Iic (f a) := by { ext, simp }
@[simp] lemma map_Iio (f : α ≃o β) (a : α) : map f (Iio a) = Iio (f a) := by { ext, simp }
lemma Ioi_le_Ici (a : α) : Ioi a ≤ Ici a := Ioi_subset_Ici_self
@[simp] lemma Iic_top [order_top α] : Iic (⊤ : α) = ⊤ := set_like.coe_injective Iic_top
@[simp] lemma Iio_bot [order_bot α] : Iio (⊥ : α) = ⊥ := set_like.coe_injective Iio_bot
end preorder
@[simp] lemma Iic_inf [semilattice_inf α] (a b : α) : Iic (a ⊓ b) = Iic a ⊓ Iic b :=
set_like.coe_injective Iic_inter_Iic.symm
section complete_lattice
variables [complete_lattice α]
@[simp] lemma Iic_Inf (S : set α) : Iic (Inf S) = ⨅ a ∈ S, Iic a :=
set_like.ext $ λ c, by simp only [mem_Iic_iff, mem_infi₂_iff, le_Inf_iff]
@[simp] lemma Iic_infi (f : ι → α) : Iic (⨅ i, f i) = ⨅ i, Iic (f i) :=
set_like.ext $ λ c, by simp only [mem_Iic_iff, mem_infi_iff, le_infi_iff]
@[simp] lemma Iic_infi₂ (f : Π i, κ i → α) : Iic (⨅ i j, f i j) = ⨅ i j, Iic (f i j) :=
by simp_rw Iic_infi
end complete_lattice
end lower_set
section closure
variables [preorder α] [preorder β] {s t : set α} {x : α}
/-- The greatest upper set containing a given set. -/
def upper_closure (s : set α) : upper_set α :=
⟨{x | ∃ a ∈ s, a ≤ x}, λ x y h, Exists₂.imp $ λ a _, h.trans'⟩
/-- The least lower set containing a given set. -/
def lower_closure (s : set α) : lower_set α :=
⟨{x | ∃ a ∈ s, x ≤ a}, λ x y h, Exists₂.imp $ λ a _, h.trans⟩
@[simp] lemma mem_upper_closure : x ∈ upper_closure s ↔ ∃ a ∈ s, a ≤ x := iff.rfl
@[simp] lemma mem_lower_closure : x ∈ lower_closure s ↔ ∃ a ∈ s, x ≤ a := iff.rfl
-- We do not tag those two as `simp` to respect the abstraction.
@[norm_cast] lemma coe_upper_closure (s : set α) : ↑(upper_closure s) = ⋃ a ∈ s, Ici a :=
by { ext, simp }
@[norm_cast] lemma coe_lower_closure (s : set α) : ↑(lower_closure s) = ⋃ a ∈ s, Iic a :=
by { ext, simp }
lemma subset_upper_closure : s ⊆ upper_closure s := λ x hx, ⟨x, hx, le_rfl⟩
lemma subset_lower_closure : s ⊆ lower_closure s := λ x hx, ⟨x, hx, le_rfl⟩
lemma upper_closure_min (h : s ⊆ t) (ht : is_upper_set t) : ↑(upper_closure s) ⊆ t :=
λ a ⟨b, hb, hba⟩, ht hba $ h hb
lemma lower_closure_min (h : s ⊆ t) (ht : is_lower_set t) : ↑(lower_closure s) ⊆ t :=
λ a ⟨b, hb, hab⟩, ht hab $ h hb
protected lemma is_upper_set.upper_closure (hs : is_upper_set s) : ↑(upper_closure s) = s :=
(upper_closure_min subset.rfl hs).antisymm subset_upper_closure
protected lemma is_lower_set.lower_closure (hs : is_lower_set s) : ↑(lower_closure s) = s :=
(lower_closure_min subset.rfl hs).antisymm subset_lower_closure
@[simp] protected lemma upper_set.upper_closure (s : upper_set α) : upper_closure (s : set α) = s :=
set_like.coe_injective s.2.upper_closure
@[simp] protected lemma lower_set.lower_closure (s : lower_set α) : lower_closure (s : set α) = s :=
set_like.coe_injective s.2.lower_closure
@[simp] lemma upper_closure_image (f : α ≃o β) :
upper_closure (f '' s) = upper_set.map f (upper_closure s) :=
begin
rw [←f.symm_symm, ←upper_set.symm_map, f.symm_symm],
ext,
simp [-upper_set.symm_map, upper_set.map, order_iso.symm, ←f.le_symm_apply],
end
@[simp] lemma lower_closure_image (f : α ≃o β) :
lower_closure (f '' s) = lower_set.map f (lower_closure s) :=
begin
rw [←f.symm_symm, ←lower_set.symm_map, f.symm_symm],
ext,
simp [-lower_set.symm_map, lower_set.map, order_iso.symm, ←f.symm_apply_le],
end
@[simp] lemma upper_set.infi_Ici (s : set α) : (⨅ a ∈ s, upper_set.Ici a) = upper_closure s :=
by { ext, simp }
@[simp] lemma lower_set.supr_Iic (s : set α) : (⨆ a ∈ s, lower_set.Iic a) = lower_closure s :=
by { ext, simp }
lemma gc_upper_closure_coe :
galois_connection (to_dual ∘ upper_closure : set α → (upper_set α)ᵒᵈ) (coe ∘ of_dual) :=
λ s t, ⟨λ h, subset_upper_closure.trans $ upper_set.coe_subset_coe.2 h,
λ h, upper_closure_min h t.upper⟩
lemma gc_lower_closure_coe : galois_connection (lower_closure : set α → lower_set α) coe :=
λ s t, ⟨λ h, subset_lower_closure.trans $ lower_set.coe_subset_coe.2 h,
λ h, lower_closure_min h t.lower⟩
/-- `upper_closure` forms a reversed Galois insertion with the coercion from upper sets to sets. -/
def gi_upper_closure_coe :
galois_insertion (to_dual ∘ upper_closure : set α → (upper_set α)ᵒᵈ) (coe ∘ of_dual) :=
{ choice := λ s hs, to_dual (⟨s, λ a b hab ha, hs ⟨a, ha, hab⟩⟩ : upper_set α),
gc := gc_upper_closure_coe,
le_l_u := λ _, subset_upper_closure,
choice_eq := λ s hs,
of_dual.injective $ set_like.coe_injective $ subset_upper_closure.antisymm hs }
/-- `lower_closure` forms a Galois insertion with the coercion from lower sets to sets. -/
def gi_lower_closure_coe : galois_insertion (lower_closure : set α → lower_set α) coe :=
{ choice := λ s hs, ⟨s, λ a b hba ha, hs ⟨a, ha, hba⟩⟩,
gc := gc_lower_closure_coe,
le_l_u := λ _, subset_lower_closure,
choice_eq := λ s hs, set_like.coe_injective $ subset_lower_closure.antisymm hs }
lemma upper_closure_anti : antitone (upper_closure : set α → upper_set α) :=
gc_upper_closure_coe.monotone_l
lemma lower_closure_mono : monotone (lower_closure : set α → lower_set α) :=
gc_lower_closure_coe.monotone_l
@[simp] lemma upper_closure_empty : upper_closure (∅ : set α) = ⊤ := by { ext, simp }
@[simp] lemma lower_closure_empty : lower_closure (∅ : set α) = ⊥ := by { ext, simp }
@[simp] lemma upper_closure_singleton (a : α) : upper_closure ({a} : set α) = upper_set.Ici a :=
by { ext, simp }
@[simp] lemma lower_closure_singleton (a : α) : lower_closure ({a} : set α) = lower_set.Iic a :=
by { ext, simp }
@[simp] lemma upper_closure_univ : upper_closure (univ : set α) = ⊥ :=
le_bot_iff.1 subset_upper_closure
@[simp] lemma lower_closure_univ : lower_closure (univ : set α) = ⊤ :=
top_le_iff.1 subset_lower_closure
@[simp] lemma upper_closure_eq_top_iff : upper_closure s = ⊤ ↔ s = ∅ :=
⟨λ h, subset_empty_iff.1 $ subset_upper_closure.trans (congr_arg coe h).subset,
by { rintro rfl, exact upper_closure_empty }⟩
@[simp] lemma lower_closure_eq_bot_iff : lower_closure s = ⊥ ↔ s = ∅ :=
⟨λ h, subset_empty_iff.1 $ subset_lower_closure.trans (congr_arg coe h).subset,
by { rintro rfl, exact lower_closure_empty }⟩
@[simp] lemma upper_closure_union (s t : set α) :
upper_closure (s ∪ t) = upper_closure s ⊓ upper_closure t :=
by { ext, simp [or_and_distrib_right, exists_or_distrib] }
@[simp] lemma lower_closure_union (s t : set α) :
lower_closure (s ∪ t) = lower_closure s ⊔ lower_closure t :=
by { ext, simp [or_and_distrib_right, exists_or_distrib] }
@[simp] lemma upper_closure_Union (f : ι → set α) :
upper_closure (⋃ i, f i) = ⨅ i, upper_closure (f i) :=
by { ext, simp [←exists_and_distrib_right, @exists_comm α] }
@[simp] lemma lower_closure_Union (f : ι → set α) :
lower_closure (⋃ i, f i) = ⨆ i, lower_closure (f i) :=
by { ext, simp [←exists_and_distrib_right, @exists_comm α] }
@[simp] lemma upper_closure_sUnion (S : set (set α)) :
upper_closure (⋃₀ S) = ⨅ s ∈ S, upper_closure s :=
by simp_rw [sUnion_eq_bUnion, upper_closure_Union]
@[simp] lemma lower_closure_sUnion (S : set (set α)) :
lower_closure (⋃₀ S) = ⨆ s ∈ S, lower_closure s :=
by simp_rw [sUnion_eq_bUnion, lower_closure_Union]
lemma set.ord_connected.upper_closure_inter_lower_closure (h : s.ord_connected) :
↑(upper_closure s) ∩ ↑(lower_closure s) = s :=
(subset_inter subset_upper_closure subset_lower_closure).antisymm' $ λ a ⟨⟨b, hb, hba⟩, c, hc, hac⟩,
h.out hb hc ⟨hba, hac⟩
lemma ord_connected_iff_upper_closure_inter_lower_closure :
s.ord_connected ↔ ↑(upper_closure s) ∩ ↑(lower_closure s) = s :=
begin
refine ⟨set.ord_connected.upper_closure_inter_lower_closure, λ h, _⟩,
rw ←h,
exact (upper_set.upper _).ord_connected.inter (lower_set.lower _).ord_connected,
end
@[simp] lemma upper_bounds_lower_closure :
upper_bounds (lower_closure s : set α) = upper_bounds s :=
(upper_bounds_mono_set subset_lower_closure).antisymm $ λ a ha b ⟨c, hc, hcb⟩, hcb.trans $ ha hc
@[simp] lemma lower_bounds_upper_closure :
lower_bounds (upper_closure s : set α) = lower_bounds s :=
(lower_bounds_mono_set subset_upper_closure).antisymm $ λ a ha b ⟨c, hc, hcb⟩, (ha hc).trans hcb
@[simp] lemma bdd_above_lower_closure : bdd_above (lower_closure s : set α) ↔ bdd_above s :=
by simp_rw [bdd_above, upper_bounds_lower_closure]
@[simp] lemma bdd_below_upper_closure : bdd_below (upper_closure s : set α) ↔ bdd_below s :=
by simp_rw [bdd_below, lower_bounds_upper_closure]
alias bdd_above_lower_closure ↔ bdd_above.of_lower_closure bdd_above.lower_closure
alias bdd_below_upper_closure ↔ bdd_below.of_upper_closure bdd_below.upper_closure
attribute [protected] bdd_above.lower_closure bdd_below.upper_closure
end closure
/-! ### Product -/
section preorder
variables [preorder α] [preorder β]
section
variables {s : set α} {t : set β} {x : α × β}
lemma is_upper_set.prod (hs : is_upper_set s) (ht : is_upper_set t) : is_upper_set (s ×ˢ t) :=
λ a b h ha, ⟨hs h.1 ha.1, ht h.2 ha.2⟩
lemma is_lower_set.prod (hs : is_lower_set s) (ht : is_lower_set t) : is_lower_set (s ×ˢ t) :=
λ a b h ha, ⟨hs h.1 ha.1, ht h.2 ha.2⟩
end
namespace upper_set
variables (s s₁ s₂ : upper_set α) (t t₁ t₂ : upper_set β) {x : α × β}
/-- The product of two upper sets as an upper set. -/
def prod : upper_set (α × β) := ⟨s ×ˢ t, s.2.prod t.2⟩
infixr (name := upper_set.prod) ` ×ˢ `:82 := prod
@[simp, norm_cast] lemma coe_prod : (↑(s ×ˢ t) : set (α × β)) = s ×ˢ t := rfl
@[simp] lemma mem_prod {s : upper_set α} {t : upper_set β} : x ∈ s ×ˢ t ↔ x.1 ∈ s ∧ x.2 ∈ t :=
iff.rfl
lemma Ici_prod (x : α × β) : Ici x = Ici x.1 ×ˢ Ici x.2 := rfl
@[simp] lemma Ici_prod_Ici (a : α) (b : β) : Ici a ×ˢ Ici b = Ici (a, b) := rfl
@[simp] lemma prod_top : s ×ˢ (⊤ : upper_set β) = ⊤ := ext prod_empty
@[simp] lemma top_prod : (⊤ : upper_set α) ×ˢ t = ⊤ := ext empty_prod
@[simp] lemma bot_prod_bot : (⊥ : upper_set α) ×ˢ (⊥ : upper_set β) = ⊥ := ext univ_prod_univ
@[simp] lemma sup_prod : (s₁ ⊔ s₂) ×ˢ t = s₁ ×ˢ t ⊔ s₂ ×ˢ t := ext inter_prod
@[simp] lemma prod_sup : s ×ˢ (t₁ ⊔ t₂) = s ×ˢ t₁ ⊔ s ×ˢ t₂ := ext prod_inter
@[simp] lemma inf_prod : (s₁ ⊓ s₂) ×ˢ t = s₁ ×ˢ t ⊓ s₂ ×ˢ t := ext union_prod
@[simp] lemma prod_inf : s ×ˢ (t₁ ⊓ t₂) = s ×ˢ t₁ ⊓ s ×ˢ t₂ := ext prod_union
lemma prod_sup_prod : s₁ ×ˢ t₁ ⊔ s₂ ×ˢ t₂ = (s₁ ⊔ s₂) ×ˢ (t₁ ⊔ t₂) := ext prod_inter_prod
variables {s s₁ s₂ t t₁ t₂}
lemma prod_mono : s₁ ≤ s₂ → t₁ ≤ t₂ → s₁ ×ˢ t₁ ≤ s₂ ×ˢ t₂ := prod_mono
lemma prod_mono_left : s₁ ≤ s₂ → s₁ ×ˢ t ≤ s₂ ×ˢ t := prod_mono_left
lemma prod_mono_right : t₁ ≤ t₂ → s ×ˢ t₁ ≤ s ×ˢ t₂ := prod_mono_right
@[simp] lemma prod_self_le_prod_self : s₁ ×ˢ s₁ ≤ s₂ ×ˢ s₂ ↔ s₁ ≤ s₂ := prod_self_subset_prod_self
@[simp] lemma prod_self_lt_prod_self : s₁ ×ˢ s₁ < s₂ ×ˢ s₂ ↔ s₁ < s₂ := prod_self_ssubset_prod_self
lemma prod_le_prod_iff : s₁ ×ˢ t₁ ≤ s₂ ×ˢ t₂ ↔ s₁ ≤ s₂ ∧ t₁ ≤ t₂ ∨ s₂ = ⊤ ∨ t₂ = ⊤ :=
prod_subset_prod_iff.trans $ by simp
@[simp] lemma prod_eq_top : s ×ˢ t = ⊤ ↔ s = ⊤ ∨ t = ⊤ :=
by { simp_rw set_like.ext'_iff, exact prod_eq_empty_iff }
@[simp] lemma codisjoint_prod :
codisjoint (s₁ ×ˢ t₁) (s₂ ×ˢ t₂) ↔ codisjoint s₁ s₂ ∨ codisjoint t₁ t₂ :=
by simp_rw [codisjoint_iff, prod_sup_prod, prod_eq_top]
end upper_set
namespace lower_set
variables (s s₁ s₂ : lower_set α) (t t₁ t₂ : lower_set β) {x : α × β}
/-- The product of two lower sets as a lower set. -/
def prod : lower_set (α × β) := ⟨s ×ˢ t, s.2.prod t.2⟩
infixr (name := lower_set.prod) ` ×ˢ `:82 := lower_set.prod
@[simp, norm_cast] lemma coe_prod : (↑(s ×ˢ t) : set (α × β)) = s ×ˢ t := rfl
@[simp] lemma mem_prod {s : lower_set α} {t : lower_set β} : x ∈ s ×ˢ t ↔ x.1 ∈ s ∧ x.2 ∈ t :=
iff.rfl
lemma Iic_prod (x : α × β) : Iic x = Iic x.1 ×ˢ Iic x.2 := rfl
@[simp] lemma Ici_prod_Ici (a : α) (b : β) : Iic a ×ˢ Iic b = Iic (a, b) := rfl
@[simp] lemma prod_bot : s ×ˢ (⊥ : lower_set β) = ⊥ := ext prod_empty
@[simp] lemma bot_prod : (⊥ : lower_set α) ×ˢ t = ⊥ := ext empty_prod
@[simp] lemma top_prod_top : (⊤ : lower_set α) ×ˢ (⊤ : lower_set β) = ⊤ := ext univ_prod_univ
@[simp] lemma inf_prod : (s₁ ⊓ s₂) ×ˢ t = s₁ ×ˢ t ⊓ s₂ ×ˢ t := ext inter_prod
@[simp] lemma prod_inf : s ×ˢ (t₁ ⊓ t₂) = s ×ˢ t₁ ⊓ s ×ˢ t₂ := ext prod_inter
@[simp] lemma sup_prod : (s₁ ⊔ s₂) ×ˢ t = s₁ ×ˢ t ⊔ s₂ ×ˢ t := ext union_prod
@[simp] lemma prod_sup : s ×ˢ (t₁ ⊔ t₂) = s ×ˢ t₁ ⊔ s ×ˢ t₂ := ext prod_union
lemma prod_inf_prod : s₁ ×ˢ t₁ ⊓ s₂ ×ˢ t₂ = (s₁ ⊓ s₂) ×ˢ (t₁ ⊓ t₂) := ext prod_inter_prod
variables {s s₁ s₂ t t₁ t₂}
lemma prod_mono : s₁ ≤ s₂ → t₁ ≤ t₂ → s₁ ×ˢ t₁ ≤ s₂ ×ˢ t₂ := prod_mono
lemma prod_mono_left : s₁ ≤ s₂ → s₁ ×ˢ t ≤ s₂ ×ˢ t := prod_mono_left
lemma prod_mono_right : t₁ ≤ t₂ → s ×ˢ t₁ ≤ s ×ˢ t₂ := prod_mono_right
@[simp] lemma prod_self_le_prod_self : s₁ ×ˢ s₁ ≤ s₂ ×ˢ s₂ ↔ s₁ ≤ s₂ := prod_self_subset_prod_self
@[simp] lemma prod_self_lt_prod_self : s₁ ×ˢ s₁ < s₂ ×ˢ s₂ ↔ s₁ < s₂ := prod_self_ssubset_prod_self
lemma prod_le_prod_iff : s₁ ×ˢ t₁ ≤ s₂ ×ˢ t₂ ↔ s₁ ≤ s₂ ∧ t₁ ≤ t₂ ∨ s₁ = ⊥ ∨ t₁ = ⊥ :=
prod_subset_prod_iff.trans $ by simp
@[simp] lemma prod_eq_bot : s ×ˢ t = ⊥ ↔ s = ⊥ ∨ t = ⊥ :=
by { simp_rw set_like.ext'_iff, exact prod_eq_empty_iff }
@[simp] lemma disjoint_prod : disjoint (s₁ ×ˢ t₁) (s₂ ×ˢ t₂) ↔ disjoint s₁ s₂ ∨ disjoint t₁ t₂ :=
by simp_rw [disjoint_iff, prod_inf_prod, prod_eq_bot]
end lower_set
@[simp] lemma upper_closure_prod (s : set α) (t : set β) :
upper_closure (s ×ˢ t) = upper_closure s ×ˢ upper_closure t :=
by { ext, simp [prod.le_def, and_and_and_comm _ (_ ∈ t)] }
@[simp] lemma lower_closure_prod (s : set α) (t : set β) :
lower_closure (s ×ˢ t) = lower_closure s ×ˢ lower_closure t :=
by { ext, simp [prod.le_def, and_and_and_comm _ (_ ∈ t)] }
end preorder
|
e14b450e69d3866d0daeee58b47e5b4d8bd456f3 | 57c233acf9386e610d99ed20ef139c5f97504ba3 | /src/data/finset/pairwise.lean | 628786368281183cb4d63d4ac9b3850179b817ac | [
"Apache-2.0"
] | permissive | robertylewis/mathlib | 3d16e3e6daf5ddde182473e03a1b601d2810952c | 1d13f5b932f5e40a8308e3840f96fc882fae01f0 | refs/heads/master | 1,651,379,945,369 | 1,644,276,960,000 | 1,644,276,960,000 | 98,875,504 | 0 | 0 | Apache-2.0 | 1,644,253,514,000 | 1,501,495,700,000 | Lean | UTF-8 | Lean | false | false | 1,970 | lean | /-
Copyright (c) 2021 Yaël Dillies. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yaël Dillies
-/
import data.finset.lattice
/-!
# Relations holding pairwise on finite sets
In this file we prove a few results about the interaction of `set.pairwise_disjoint` and `finset`.
-/
open finset
variables {α ι ι' : Type*}
lemma finset.pairwise_disjoint_range_singleton [decidable_eq α] :
(set.range (singleton : α → finset α)).pairwise_disjoint id :=
begin
rintro _ ⟨a, rfl⟩ _ ⟨b, rfl⟩ h,
exact disjoint_singleton.2 (ne_of_apply_ne _ h),
end
namespace set
lemma pairwise_disjoint.elim_finset [decidable_eq α] {s : set ι} {f : ι → finset α}
(hs : s.pairwise_disjoint f) {i j : ι} (hi : i ∈ s) (hj : j ∈ s) (a : α) (hai : a ∈ f i)
(haj : a ∈ f j) :
i = j :=
hs.elim hi hj (finset.not_disjoint_iff.2 ⟨a, hai, haj⟩)
lemma pairwise_disjoint.image_finset_of_le [decidable_eq ι] [semilattice_inf α] [order_bot α]
{s : finset ι} {f : ι → α} (hs : (s : set ι).pairwise_disjoint f) {g : ι → ι}
(hf : ∀ a, f (g a) ≤ f a) :
(s.image g : set ι).pairwise_disjoint f :=
begin
rw coe_image,
exact hs.image_of_le hf,
end
variables [lattice α] [order_bot α]
/-- Bind operation for `set.pairwise_disjoint`. In a complete lattice, you can use
`set.pairwise_disjoint.bUnion`. -/
lemma pairwise_disjoint.bUnion_finset {s : set ι'} {g : ι' → finset ι} {f : ι → α}
(hs : s.pairwise_disjoint (λ i' : ι', (g i').sup f))
(hg : ∀ i ∈ s, (g i : set ι).pairwise_disjoint f) :
(⋃ i ∈ s, ↑(g i)).pairwise_disjoint f :=
begin
rintro a ha b hb hab,
simp_rw set.mem_Union at ha hb,
obtain ⟨c, hc, ha⟩ := ha,
obtain ⟨d, hd, hb⟩ := hb,
obtain hcd | hcd := eq_or_ne (g c) (g d),
{ exact hg d hd (by rwa hcd at ha) hb hab },
{ exact (hs hc hd (ne_of_apply_ne _ hcd)).mono (finset.le_sup ha) (finset.le_sup hb) }
end
end set
|
90726840905c463eea919953f29db0e8e0429932 | df561f413cfe0a88b1056655515399c546ff32a5 | /6-advanced-addition-world/l12.lean | af56bf828a69aef29577f1219ab7261f2cc320ca | [] | no_license | nicholaspun/natural-number-game-solutions | 31d5158415c6f582694680044c5c6469032c2a06 | 1e2aed86d2e76a3f4a275c6d99e795ad30cf6df0 | refs/heads/main | 1,675,123,625,012 | 1,607,633,548,000 | 1,607,633,548,000 | 318,933,860 | 3 | 1 | null | null | null | null | UTF-8 | Lean | false | false | 81 | lean | theorem add_one_eq_succ (d : mynat) : d + 1 = succ d :=
begin
symmetry, refl,
end |
66c1a59a65ae028a26e26c4a1cea8a382d404f75 | 9dc8cecdf3c4634764a18254e94d43da07142918 | /src/category_theory/functor/fully_faithful.lean | 91635c902256677423aafdcc9bc5b943c8a93761 | [
"Apache-2.0"
] | permissive | jcommelin/mathlib | d8456447c36c176e14d96d9e76f39841f69d2d9b | ee8279351a2e434c2852345c51b728d22af5a156 | refs/heads/master | 1,664,782,136,488 | 1,663,638,983,000 | 1,663,638,983,000 | 132,563,656 | 0 | 0 | Apache-2.0 | 1,663,599,929,000 | 1,525,760,539,000 | Lean | UTF-8 | Lean | false | false | 11,960 | lean | /-
Copyright (c) 2018 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Scott Morrison
-/
import category_theory.natural_isomorphism
import logic.equiv.basic
/-!
# Full and faithful functors
We define typeclasses `full` and `faithful`, decorating functors.
## Main definitions and results
* Use `F.map_injective` to retrieve the fact that `F.map` is injective when `[faithful F]`.
* Similarly, `F.map_surjective` states that `F.map` is surjective when `[full F]`.
* Use `F.preimage` to obtain preimages of morphisms when `[full F]`.
* We prove some basic "cancellation" lemmas for full and/or faithful functors, as well as a
construction for "dividing" a functor by a faithful functor, see `faithful.div`.
* `full F` carries data, so definitional properties of the preimage can be used when using
`F.preimage`. To obtain an instance of `full F` non-constructively, you can use `full_of_exists`
and `full_of_surjective`.
See `category_theory.equivalence.of_fully_faithful_ess_surj` for the fact that a functor is an
equivalence if and only if it is fully faithful and essentially surjective.
-/
-- declare the `v`'s first; see `category_theory.category` for an explanation
universes v₁ v₂ v₃ u₁ u₂ u₃
namespace category_theory
variables {C : Type u₁} [category.{v₁} C] {D : Type u₂} [category.{v₂} D]
/--
A functor `F : C ⥤ D` is full if for each `X Y : C`, `F.map` is surjective.
In fact, we use a constructive definition, so the `full F` typeclass contains data,
specifying a particular preimage of each `f : F.obj X ⟶ F.obj Y`.
See <https://stacks.math.columbia.edu/tag/001C>.
-/
class full (F : C ⥤ D) :=
(preimage : ∀ {X Y : C} (f : (F.obj X) ⟶ (F.obj Y)), X ⟶ Y)
(witness' : ∀ {X Y : C} (f : (F.obj X) ⟶ (F.obj Y)), F.map (preimage f) = f . obviously)
restate_axiom full.witness'
attribute [simp] full.witness
/--
A functor `F : C ⥤ D` is faithful if for each `X Y : C`, `F.map` is injective.
See <https://stacks.math.columbia.edu/tag/001C>.
-/
class faithful (F : C ⥤ D) : Prop :=
(map_injective' [] : ∀ {X Y : C}, function.injective (@functor.map _ _ _ _ F X Y) . obviously)
restate_axiom faithful.map_injective'
namespace functor
variables {X Y : C}
lemma map_injective (F : C ⥤ D) [faithful F] : function.injective $ @functor.map _ _ _ _ F X Y :=
faithful.map_injective F
lemma map_iso_injective (F : C ⥤ D) [faithful F] :
function.injective $ @functor.map_iso _ _ _ _ F X Y :=
λ i j h, iso.ext (map_injective F (congr_arg iso.hom h : _))
/-- The specified preimage of a morphism under a full functor. -/
def preimage (F : C ⥤ D) [full F] (f : F.obj X ⟶ F.obj Y) : X ⟶ Y :=
full.preimage.{v₁ v₂} f
@[simp] lemma image_preimage (F : C ⥤ D) [full F] {X Y : C} (f : F.obj X ⟶ F.obj Y) :
F.map (preimage F f) = f :=
by unfold preimage; obviously
lemma map_surjective (F : C ⥤ D) [full F] : function.surjective (@functor.map _ _ _ _ F X Y) :=
λ f, ⟨F.preimage f, F.image_preimage f⟩
/-- Deduce that `F` is full from the existence of preimages, using choice. -/
noncomputable def full_of_exists (F : C ⥤ D)
(h : ∀ (X Y : C) (f : F.obj X ⟶ F.obj Y), ∃ p, F.map p = f) : full F :=
by { choose p hp using h, exact ⟨p, hp⟩ }
/-- Deduce that `F` is full from surjectivity of `F.map`, using choice. -/
noncomputable def full_of_surjective (F : C ⥤ D)
(h : ∀ (X Y : C), function.surjective (@functor.map _ _ _ _ F X Y)) : full F :=
full_of_exists _ h
end functor
section
variables {F : C ⥤ D} [full F] [faithful F] {X Y Z : C}
@[simp] lemma preimage_id : F.preimage (𝟙 (F.obj X)) = 𝟙 X :=
F.map_injective (by simp)
@[simp] lemma preimage_comp (f : F.obj X ⟶ F.obj Y) (g : F.obj Y ⟶ F.obj Z) :
F.preimage (f ≫ g) = F.preimage f ≫ F.preimage g :=
F.map_injective (by simp)
@[simp] lemma preimage_map (f : X ⟶ Y) :
F.preimage (F.map f) = f :=
F.map_injective (by simp)
variables (F)
namespace functor
/-- If `F : C ⥤ D` is fully faithful, every isomorphism `F.obj X ≅ F.obj Y` has a preimage. -/
@[simps]
def preimage_iso (f : (F.obj X) ≅ (F.obj Y)) : X ≅ Y :=
{ hom := F.preimage f.hom,
inv := F.preimage f.inv,
hom_inv_id' := F.map_injective (by simp),
inv_hom_id' := F.map_injective (by simp), }
@[simp] lemma preimage_iso_map_iso (f : X ≅ Y) :
F.preimage_iso (F.map_iso f) = f :=
by { ext, simp, }
end functor
/--
If the image of a morphism under a fully faithful functor in an isomorphism,
then the original morphisms is also an isomorphism.
-/
lemma is_iso_of_fully_faithful (f : X ⟶ Y) [is_iso (F.map f)] : is_iso f :=
⟨⟨F.preimage (inv (F.map f)),
⟨F.map_injective (by simp), F.map_injective (by simp)⟩⟩⟩
/-- If `F` is fully faithful, we have an equivalence of hom-sets `X ⟶ Y` and `F X ⟶ F Y`. -/
@[simps]
def equiv_of_fully_faithful {X Y} : (X ⟶ Y) ≃ (F.obj X ⟶ F.obj Y) :=
{ to_fun := λ f, F.map f,
inv_fun := λ f, F.preimage f,
left_inv := λ f, by simp,
right_inv := λ f, by simp }
/-- If `F` is fully faithful, we have an equivalence of iso-sets `X ≅ Y` and `F X ≅ F Y`. -/
@[simps]
def iso_equiv_of_fully_faithful {X Y} : (X ≅ Y) ≃ (F.obj X ≅ F.obj Y) :=
{ to_fun := λ f, F.map_iso f,
inv_fun := λ f, F.preimage_iso f,
left_inv := λ f, by simp,
right_inv := λ f, by { ext, simp, } }
end
section
variables {E : Type*} [category E] {F G : C ⥤ D} (H : D ⥤ E) [full H] [faithful H]
/-- We can construct a natural transformation between functors by constructing a
natural transformation between those functors composed with a fully faithful functor. -/
@[simps]
def nat_trans_of_comp_fully_faithful (α : F ⋙ H ⟶ G ⋙ H) : F ⟶ G :=
{ app := λ X, (equiv_of_fully_faithful H).symm (α.app X),
naturality' := λ X Y f, by { dsimp, apply H.map_injective, simpa using α.naturality f, } }
/-- We can construct a natural isomorphism between functors by constructing a natural isomorphism
between those functors composed with a fully faithful functor. -/
@[simps]
def nat_iso_of_comp_fully_faithful (i : F ⋙ H ≅ G ⋙ H) : F ≅ G :=
nat_iso.of_components
(λ X, (iso_equiv_of_fully_faithful H).symm (i.app X))
(λ X Y f, by { dsimp, apply H.map_injective, simpa using i.hom.naturality f, })
lemma nat_iso_of_comp_fully_faithful_hom (i : F ⋙ H ≅ G ⋙ H) :
(nat_iso_of_comp_fully_faithful H i).hom = nat_trans_of_comp_fully_faithful H i.hom :=
by { ext, simp [nat_iso_of_comp_fully_faithful], }
lemma nat_iso_of_comp_fully_faithful_inv (i : F ⋙ H ≅ G ⋙ H) :
(nat_iso_of_comp_fully_faithful H i).inv = nat_trans_of_comp_fully_faithful H i.inv :=
by { ext, simp [←preimage_comp], dsimp, simp, }
end
end category_theory
namespace category_theory
variables {C : Type u₁} [category.{v₁} C]
instance full.id : full (𝟭 C) :=
{ preimage := λ _ _ f, f }
instance faithful.id : faithful (𝟭 C) := by obviously
variables {D : Type u₂} [category.{v₂} D] {E : Type u₃} [category.{v₃} E]
variables (F F' : C ⥤ D) (G : D ⥤ E)
instance faithful.comp [faithful F] [faithful G] : faithful (F ⋙ G) :=
{ map_injective' := λ _ _ _ _ p, F.map_injective (G.map_injective p) }
lemma faithful.of_comp [faithful $ F ⋙ G] : faithful F :=
{ map_injective' := λ X Y, (F ⋙ G).map_injective.of_comp }
section
variables {F F'}
/-- If `F` is full, and naturally isomorphic to some `F'`, then `F'` is also full. -/
def full.of_iso [full F] (α : F ≅ F') : full F' :=
{ preimage := λ X Y f, F.preimage ((α.app X).hom ≫ f ≫ (α.app Y).inv),
witness' := λ X Y f, by simp [←nat_iso.naturality_1 α], }
lemma faithful.of_iso [faithful F] (α : F ≅ F') : faithful F' :=
{ map_injective' := λ X Y f f' h, F.map_injective
(by rw [←nat_iso.naturality_1 α.symm, h, nat_iso.naturality_1 α.symm]) }
end
variables {F G}
lemma faithful.of_comp_iso {H : C ⥤ E} [ℋ : faithful H] (h : F ⋙ G ≅ H) : faithful F :=
@faithful.of_comp _ _ _ _ _ _ F G (faithful.of_iso h.symm)
alias faithful.of_comp_iso ← _root_.category_theory.iso.faithful_of_comp
-- We could prove this from `faithful.of_comp_iso` using `eq_to_iso`,
-- but that would introduce a cyclic import.
lemma faithful.of_comp_eq {H : C ⥤ E} [ℋ : faithful H] (h : F ⋙ G = H) : faithful F :=
@faithful.of_comp _ _ _ _ _ _ F G (h.symm ▸ ℋ)
alias faithful.of_comp_eq ← _root_.eq.faithful_of_comp
variables (F G)
/-- “Divide” a functor by a faithful functor. -/
protected def faithful.div (F : C ⥤ E) (G : D ⥤ E) [faithful G]
(obj : C → D) (h_obj : ∀ X, G.obj (obj X) = F.obj X)
(map : Π {X Y}, (X ⟶ Y) → (obj X ⟶ obj Y))
(h_map : ∀ {X Y} {f : X ⟶ Y}, G.map (map f) == F.map f) :
C ⥤ D :=
{ obj := obj,
map := @map,
map_id' :=
begin
assume X,
apply G.map_injective,
apply eq_of_heq,
transitivity F.map (𝟙 X), from h_map,
rw [F.map_id, G.map_id, h_obj X]
end,
map_comp' :=
begin
assume X Y Z f g,
apply G.map_injective,
apply eq_of_heq,
transitivity F.map (f ≫ g), from h_map,
rw [F.map_comp, G.map_comp],
congr' 1;
try { exact (h_obj _).symm };
exact h_map.symm
end }
-- This follows immediately from `functor.hext` (`functor.hext h_obj @h_map`),
-- but importing `category_theory.eq_to_hom` causes an import loop:
-- category_theory.eq_to_hom → category_theory.opposites →
-- category_theory.equivalence → category_theory.fully_faithful
lemma faithful.div_comp (F : C ⥤ E) [faithful F] (G : D ⥤ E) [faithful G]
(obj : C → D) (h_obj : ∀ X, G.obj (obj X) = F.obj X)
(map : Π {X Y}, (X ⟶ Y) → (obj X ⟶ obj Y))
(h_map : ∀ {X Y} {f : X ⟶ Y}, G.map (map f) == F.map f) :
(faithful.div F G obj @h_obj @map @h_map) ⋙ G = F :=
begin
casesI F with F_obj _ _ _, casesI G with G_obj _ _ _,
unfold faithful.div functor.comp,
unfold_projs at h_obj,
have: F_obj = G_obj ∘ obj := (funext h_obj).symm,
substI this,
congr,
funext,
exact eq_of_heq h_map
end
lemma faithful.div_faithful (F : C ⥤ E) [faithful F] (G : D ⥤ E) [faithful G]
(obj : C → D) (h_obj : ∀ X, G.obj (obj X) = F.obj X)
(map : Π {X Y}, (X ⟶ Y) → (obj X ⟶ obj Y))
(h_map : ∀ {X Y} {f : X ⟶ Y}, G.map (map f) == F.map f) :
faithful (faithful.div F G obj @h_obj @map @h_map) :=
(faithful.div_comp F G _ h_obj _ @h_map).faithful_of_comp
instance full.comp [full F] [full G] : full (F ⋙ G) :=
{ preimage := λ _ _ f, F.preimage (G.preimage f) }
/-- If `F ⋙ G` is full and `G` is faithful, then `F` is full. -/
def full.of_comp_faithful [full $ F ⋙ G] [faithful G] : full F :=
{ preimage := λ X Y f, (F ⋙ G).preimage (G.map f),
witness' := λ X Y f, G.map_injective ((F ⋙ G).image_preimage _) }
/-- If `F ⋙ G` is full and `G` is faithful, then `F` is full. -/
def full.of_comp_faithful_iso {F : C ⥤ D} {G : D ⥤ E} {H : C ⥤ E} [full H] [faithful G]
(h : F ⋙ G ≅ H) : full F :=
@full.of_comp_faithful _ _ _ _ _ _ F G (full.of_iso h.symm) _
/--
Given a natural isomorphism between `F ⋙ H` and `G ⋙ H` for a fully faithful functor `H`, we
can 'cancel' it to give a natural iso between `F` and `G`.
-/
def fully_faithful_cancel_right {F G : C ⥤ D} (H : D ⥤ E)
[full H] [faithful H] (comp_iso: F ⋙ H ≅ G ⋙ H) : F ≅ G :=
nat_iso.of_components
(λ X, H.preimage_iso (comp_iso.app X))
(λ X Y f, H.map_injective (by simpa using comp_iso.hom.naturality f))
@[simp]
lemma fully_faithful_cancel_right_hom_app {F G : C ⥤ D} {H : D ⥤ E}
[full H] [faithful H] (comp_iso: F ⋙ H ≅ G ⋙ H) (X : C) :
(fully_faithful_cancel_right H comp_iso).hom.app X = H.preimage (comp_iso.hom.app X) :=
rfl
@[simp]
lemma fully_faithful_cancel_right_inv_app {F G : C ⥤ D} {H : D ⥤ E}
[full H] [faithful H] (comp_iso: F ⋙ H ≅ G ⋙ H) (X : C) :
(fully_faithful_cancel_right H comp_iso).inv.app X = H.preimage (comp_iso.inv.app X) :=
rfl
end category_theory
|
0967cee2e570d12566ea2a6d9f6da15f5c1c5b56 | 05b503addd423dd68145d68b8cde5cd595d74365 | /src/linear_algebra/finsupp.lean | dd38f37a5739affc56f31a8ccad008a1b3142e7a | [
"Apache-2.0"
] | permissive | aestriplex/mathlib | 77513ff2b176d74a3bec114f33b519069788811d | e2fa8b2b1b732d7c25119229e3cdfba8370cb00f | refs/heads/master | 1,621,969,960,692 | 1,586,279,279,000 | 1,586,279,279,000 | null | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 17,175 | lean | /-
Copyright (c) 2019 Johannes Hölzl. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Author: Johannes Hölzl
Linear structures on function with finite support `α →₀ M`.
-/
import data.monoid_algebra linear_algebra.basic
noncomputable theory
open set linear_map submodule
open_locale classical
namespace finsupp
variables {α : Type*} {M : Type*} {R : Type*}
variables [ring R] [add_comm_group M] [module R M]
def lsingle (a : α) : M →ₗ[R] (α →₀ M) :=
⟨single a, assume a b, single_add, assume c b, (smul_single _ _ _).symm⟩
def lapply (a : α) : (α →₀ M) →ₗ[R] M := ⟨λg, g a, assume a b, rfl, assume a b, rfl⟩
section lsubtype_domain
variables (s : set α)
def lsubtype_domain : (α →₀ M) →ₗ[R] (s →₀ M) :=
⟨subtype_domain (λx, x ∈ s), assume a b, subtype_domain_add, assume c a, ext $ assume a, rfl⟩
lemma lsubtype_domain_apply (f : α →₀ M) :
(lsubtype_domain s : (α →₀ M) →ₗ[R] (s →₀ M)) f = subtype_domain (λx, x ∈ s) f := rfl
end lsubtype_domain
@[simp] lemma lsingle_apply (a : α) (b : M) : (lsingle a : M →ₗ[R] (α →₀ M)) b = single a b :=
rfl
@[simp] lemma lapply_apply (a : α) (f : α →₀ M) : (lapply a : (α →₀ M) →ₗ[R] M) f = f a :=
rfl
@[simp] lemma ker_lsingle (a : α) : (lsingle a : M →ₗ[R] (α →₀ M)).ker = ⊥ :=
ker_eq_bot.2 (injective_single a)
lemma lsingle_range_le_ker_lapply (s t : set α) (h : disjoint s t) :
(⨆a∈s, (lsingle a : M →ₗ[R] (α →₀ M)).range) ≤ (⨅a∈t, ker (lapply a)) :=
begin
refine supr_le (assume a₁, supr_le $ assume h₁, range_le_iff_comap.2 _),
simp only [(ker_comp _ _).symm, eq_top_iff, le_def', mem_ker, comap_infi, mem_infi],
assume b hb a₂ h₂,
have : a₁ ≠ a₂ := assume eq, h ⟨h₁, eq.symm ▸ h₂⟩,
exact single_eq_of_ne this
end
lemma infi_ker_lapply_le_bot : (⨅a, ker (lapply a : (α →₀ M) →ₗ[R] M)) ≤ ⊥ :=
begin
simp only [le_def', mem_infi, mem_ker, mem_bot, lapply_apply],
exact assume a h, finsupp.ext h
end
lemma supr_lsingle_range : (⨆a, (lsingle a : M →ₗ[R] (α →₀ M)).range) = ⊤ :=
begin
refine (eq_top_iff.2 $ le_def'.2 $ assume f _, _),
rw [← sum_single f],
refine sum_mem _ (assume a ha, submodule.mem_supr_of_mem _ a $ set.mem_image_of_mem _ trivial)
end
lemma disjoint_lsingle_lsingle (s t : set α) (hs : disjoint s t) :
disjoint (⨆a∈s, (lsingle a : M →ₗ[R] (α →₀ M)).range) (⨆a∈t, (lsingle a).range) :=
begin
refine disjoint.mono
(lsingle_range_le_ker_lapply _ _ $ disjoint_compl s)
(lsingle_range_le_ker_lapply _ _ $ disjoint_compl t)
(le_trans (le_infi $ assume i, _) infi_ker_lapply_le_bot),
classical,
by_cases his : i ∈ s,
{ by_cases hit : i ∈ t,
{ exact (hs ⟨his, hit⟩).elim },
exact inf_le_right_of_le (infi_le_of_le i $ infi_le _ hit) },
exact inf_le_left_of_le (infi_le_of_le i $ infi_le _ his)
end
lemma span_single_image (s : set M) (a : α) :
submodule.span R (single a '' s) = (submodule.span R s).map (lsingle a) :=
by rw ← span_image; refl
variables (M R)
def supported (s : set α) : submodule R (α →₀ M) :=
begin
refine ⟨ {p | ↑p.support ⊆ s }, _, _, _ ⟩,
{ simp only [subset_def, finset.mem_coe, set.mem_set_of_eq, mem_support_iff, zero_apply],
assume h ha, exact (ha rfl).elim },
{ assume p q hp hq,
refine subset.trans
(subset.trans (finset.coe_subset.2 support_add) _) (union_subset hp hq),
rw [finset.coe_union] },
{ assume a p hp,
refine subset.trans (finset.coe_subset.2 support_smul) hp }
end
variables {M}
lemma mem_supported {s : set α} (p : α →₀ M) : p ∈ (supported M R s) ↔ ↑p.support ⊆ s :=
iff.rfl
lemma mem_supported' {s : set α} (p : α →₀ M) :
p ∈ supported M R s ↔ ∀ x ∉ s, p x = 0 :=
by haveI := classical.dec_pred (λ (x : α), x ∈ s);
simp [mem_supported, set.subset_def, not_imp_comm]
lemma single_mem_supported {s : set α} {a : α} (b : M) (h : a ∈ s) :
single a b ∈ supported M R s :=
set.subset.trans support_single_subset (set.singleton_subset_iff.2 h)
lemma supported_eq_span_single [has_one M] (s : set α) :
supported R R s = span R ((λ i, single i 1) '' s) :=
begin
refine (span_eq_of_le _ _ (le_def'.2 $ λ l hl, _)).symm,
{ rintro _ ⟨_, hp, rfl ⟩ , exact single_mem_supported R 1 hp },
{ rw ← l.sum_single,
refine sum_mem _ (λ i il, _),
convert @smul_mem R (α →₀ R) _ _ _ _ (single i 1) (l i) _,
{ simp },
apply subset_span,
apply set.mem_image_of_mem _ (hl il) }
end
variables (M R)
def restrict_dom (s : set α) : (α →₀ M) →ₗ supported M R s :=
linear_map.cod_restrict _
{ to_fun := filter (∈ s),
add := λ l₁ l₂, filter_add,
smul := λ a l, filter_smul }
(λ l, (mem_supported' _ _).2 $ λ x, filter_apply_neg (∈ s) l)
variables {M R}
section
set_option class.instance_max_depth 50
@[simp] theorem restrict_dom_apply (s : set α) (l : α →₀ M) :
((restrict_dom M R s : (α →₀ M) →ₗ supported M R s) l : α →₀ M) = finsupp.filter (∈ s) l := rfl
end
theorem restrict_dom_comp_subtype (s : set α) :
(restrict_dom M R s).comp (submodule.subtype _) = linear_map.id :=
begin
ext l,
apply subtype.coe_ext.2,
simp,
ext a,
by_cases a ∈ s,
{ simp [h] },
{ rw [filter_apply_neg (λ x, x ∈ s) _ h],
exact ((mem_supported' R l.1).1 l.2 a h).symm }
end
theorem range_restrict_dom (s : set α) :
(restrict_dom M R s).range = ⊤ :=
begin
have := linear_map.range_comp (submodule.subtype _) (restrict_dom M R s),
rw [restrict_dom_comp_subtype, linear_map.range_id] at this,
exact eq_top_mono (submodule.map_mono le_top) this.symm
end
theorem supported_mono {s t : set α} (st : s ⊆ t) :
supported M R s ≤ supported M R t :=
λ l h, set.subset.trans h st
@[simp] theorem supported_empty : supported M R (∅ : set α) = ⊥ :=
eq_bot_iff.2 $ λ l h, (submodule.mem_bot R).2 $
by ext; simp [*, mem_supported'] at *
@[simp] theorem supported_univ : supported M R (set.univ : set α) = ⊤ :=
eq_top_iff.2 $ λ l _, set.subset_univ _
theorem supported_Union {δ : Type*} (s : δ → set α) :
supported M R (⋃ i, s i) = ⨆ i, supported M R (s i) :=
begin
refine le_antisymm _ (supr_le $ λ i, supported_mono $ set.subset_Union _ _),
haveI := classical.dec_pred (λ x, x ∈ (⋃ i, s i)),
suffices : ((submodule.subtype _).comp (restrict_dom M R (⋃ i, s i))).range ≤ ⨆ i, supported M R (s i),
{ rwa [linear_map.range_comp, range_restrict_dom, map_top, range_subtype] at this },
rw [range_le_iff_comap, eq_top_iff],
rintro l ⟨⟩, rw mem_coe,
apply finsupp.induction l, {exact zero_mem _},
refine λ x a l hl a0, add_mem _ _,
haveI := classical.dec_pred (λ x, ∃ i, x ∈ s i),
by_cases (∃ i, x ∈ s i); simp [h],
{ cases h with i hi,
exact le_supr (λ i, supported M R (s i)) i (single_mem_supported R _ hi) },
{ rw filter_single_of_neg,
{ simp },
{ exact h } }
end
theorem supported_union (s t : set α) :
supported M R (s ∪ t) = supported M R s ⊔ supported M R t :=
by erw [set.union_eq_Union, supported_Union, supr_bool_eq]; refl
theorem supported_Inter {ι : Type*} (s : ι → set α) :
supported M R (⋂ i, s i) = ⨅ i, supported M R (s i) :=
begin
refine le_antisymm (le_infi $ λ i, supported_mono $ set.Inter_subset _ _) _,
simp [le_def, infi_coe, set.subset_def],
exact λ l, set.subset_Inter
end
section
set_option class.instance_max_depth 37
def supported_equiv_finsupp (s : set α) :
(supported M R s) ≃ₗ[R] (s →₀ M) :=
(restrict_support_equiv s).to_linear_equiv
begin
show is_linear_map R ((lsubtype_domain s : (α →₀ M) →ₗ[R] (s →₀ M)).comp
(submodule.subtype (supported M R s))),
exact linear_map.is_linear _
end
end
def lsum (f : α → R →ₗ[R] M) : (α →₀ R) →ₗ[R] M :=
⟨λ d, d.sum (λ i, f i),
assume d₁ d₂, by simp [sum_add_index],
assume a d, by simp [sum_smul_index, smul_sum, -smul_eq_mul, smul_eq_mul.symm]⟩
@[simp] theorem lsum_apply (f : α → R →ₗ[R] M) (l : α →₀ R) :
(finsupp.lsum f : (α →₀ R) →ₗ M) l = l.sum (λ b, f b) := rfl
section lmap_domain
variables {α' : Type*} {α'' : Type*} (M R)
def lmap_domain (f : α → α') : (α →₀ M) →ₗ[R] (α' →₀ M) :=
⟨map_domain f, assume a b, map_domain_add, map_domain_smul⟩
@[simp] theorem lmap_domain_apply (f : α → α') (l : α →₀ M) :
(lmap_domain M R f : (α →₀ M) →ₗ[R] (α' →₀ M)) l = map_domain f l := rfl
@[simp] theorem lmap_domain_id : (lmap_domain M R id : (α →₀ M) →ₗ[R] α →₀ M) = linear_map.id :=
linear_map.ext $ λ l, map_domain_id
theorem lmap_domain_comp (f : α → α') (g : α' → α'') :
lmap_domain M R (g ∘ f) = (lmap_domain M R g).comp (lmap_domain M R f) :=
linear_map.ext $ λ l, map_domain_comp
theorem supported_comap_lmap_domain (f : α → α') (s : set α') :
supported M R (f ⁻¹' s) ≤ (supported M R s).comap (lmap_domain M R f) :=
λ l (hl : ↑l.support ⊆ f ⁻¹' s),
show ↑(map_domain f l).support ⊆ s, begin
rw [← set.image_subset_iff, ← finset.coe_image] at hl,
exact set.subset.trans map_domain_support hl
end
theorem lmap_domain_supported [nonempty α] (f : α → α') (s : set α) :
(supported M R s).map (lmap_domain M R f) = supported M R (f '' s) :=
begin
inhabit α,
refine le_antisymm (map_le_iff_le_comap.2 $
le_trans (supported_mono $ set.subset_preimage_image _ _)
(supported_comap_lmap_domain _ _ _ _)) _,
intros l hl,
refine ⟨(lmap_domain M R (function.inv_fun_on f s) : (α' →₀ M) →ₗ α →₀ M) l, λ x hx, _, _⟩,
{ rcases finset.mem_image.1 (map_domain_support hx) with ⟨c, hc, rfl⟩,
exact function.inv_fun_on_mem (by simpa using hl hc) },
{ rw [← linear_map.comp_apply, ← lmap_domain_comp],
refine (map_domain_congr $ λ c hc, _).trans map_domain_id,
exact function.inv_fun_on_eq (by simpa using hl hc) }
end
theorem lmap_domain_disjoint_ker (f : α → α') {s : set α}
(H : ∀ a b ∈ s, f a = f b → a = b) :
disjoint (supported M R s) (lmap_domain M R f).ker :=
begin
rintro l ⟨h₁, h₂⟩,
rw [mem_coe, mem_ker, lmap_domain_apply, map_domain] at h₂,
simp, ext x,
haveI := classical.dec_pred (λ x, x ∈ s),
by_cases xs : x ∈ s,
{ have : finsupp.sum l (λ a, finsupp.single (f a)) (f x) = 0, {rw h₂, refl},
rw [finsupp.sum_apply, finsupp.sum, finset.sum_eq_single x] at this,
{ simpa [finsupp.single_apply] },
{ intros y hy xy, simp [mt (H _ _ (h₁ hy) xs) xy] },
{ simp {contextual := tt} } },
{ by_contra h, exact xs (h₁ $ finsupp.mem_support_iff.2 h) }
end
end lmap_domain
section total
variables (α) {α' : Type*} (M) {M' : Type*} (R)
[add_comm_group M'] [module R M']
(v : α → M) {v' : α' → M'}
/-- Interprets (l : α →₀ R) as linear combination of the elements in the family (v : α → M) and
evaluates this linear combination. -/
protected def total : (α →₀ R) →ₗ M := finsupp.lsum (λ i, linear_map.id.smul_right (v i))
variables {α M v}
theorem total_apply (l : α →₀ R) :
finsupp.total α M R v l = l.sum (λ i a, a • v i) := rfl
@[simp] theorem total_single (c : R) (a : α) :
finsupp.total α M R v (single a c) = c • (v a) :=
by simp [total_apply, sum_single_index]
theorem total_range (h : function.surjective v) : (finsupp.total α M R v).range = ⊤ :=
begin
apply range_eq_top.2,
intros x,
apply exists.elim (h x),
exact λ i hi, ⟨single i 1, by simp [hi]⟩
end
lemma range_total : (finsupp.total α M R v).range = span R (range v) :=
begin
ext x,
split,
{ intros hx,
rw [linear_map.mem_range] at hx,
rcases hx with ⟨l, hl⟩,
rw ← hl,
rw finsupp.total_apply,
unfold finsupp.sum,
apply sum_mem (span R (range v)),
{ exact λ i hi, submodule.smul _ _ (subset_span (mem_range_self i)) },
apply_instance },
{ apply span_le.2,
intros x hx,
rcases hx with ⟨i, hi⟩,
rw [mem_coe, linear_map.mem_range],
use finsupp.single i 1,
simp [hi] }
end
theorem lmap_domain_total (f : α → α') (g : M →ₗ[R] M') (h : ∀ i, g (v i) = v' (f i)) :
(finsupp.total α' M' R v').comp (lmap_domain R R f) = g.comp (finsupp.total α M R v) :=
by ext l; simp [total_apply, finsupp.sum_map_domain_index, add_smul, h]
theorem total_emb_domain (f : α ↪ α') (l : α →₀ R) :
(finsupp.total α' M' R v') (emb_domain f l) = (finsupp.total α M' R (v' ∘ f)) l :=
by simp [total_apply, finsupp.sum, support_emb_domain, emb_domain_apply]
theorem total_map_domain (f : α → α') (hf : function.injective f) (l : α →₀ R) :
(finsupp.total α' M' R v') (map_domain f l) = (finsupp.total α M' R (v' ∘ f)) l :=
begin
have : map_domain f l = emb_domain ⟨f, hf⟩ l,
{ rw emb_domain_eq_map_domain ⟨f, hf⟩,
refl },
rw this,
apply total_emb_domain R ⟨f, hf⟩ l
end
theorem span_eq_map_total (s : set α):
span R (v '' s) = submodule.map (finsupp.total α M R v) (supported R R s) :=
begin
apply span_eq_of_le,
{ intros x hx,
rw set.mem_image at hx,
apply exists.elim hx,
intros i hi,
exact ⟨_, finsupp.single_mem_supported R 1 hi.1, by simp [hi.2]⟩ },
{ refine map_le_iff_le_comap.2 (λ z hz, _),
have : ∀i, z i • v i ∈ span R (v '' s),
{ intro c,
haveI := classical.dec_pred (λ x, x ∈ s),
by_cases c ∈ s,
{ exact smul_mem _ _ (subset_span (set.mem_image_of_mem _ h)) },
{ simp [(finsupp.mem_supported' R _).1 hz _ h] } },
refine sum_mem _ _, simp [this] }
end
theorem mem_span_iff_total {s : set α} {x : M} :
x ∈ span R (v '' s) ↔ ∃ l ∈ supported R R s, finsupp.total α M R v l = x :=
by rw span_eq_map_total; simp
variables (α) (M) (v)
protected def total_on (s : set α) : supported R R s →ₗ[R] span R (v '' s) :=
linear_map.cod_restrict _ ((finsupp.total _ _ _ v).comp (submodule.subtype (supported R R s))) $
λ ⟨l, hl⟩, (mem_span_iff_total _).2 ⟨l, hl, rfl⟩
variables {α} {M} {v}
theorem total_on_range (s : set α) : (finsupp.total_on α M R v s).range = ⊤ :=
by rw [finsupp.total_on, linear_map.range, linear_map.map_cod_restrict, ← linear_map.range_le_iff_comap,
range_subtype, map_top, linear_map.range_comp, range_subtype]; exact le_of_eq (span_eq_map_total _ _)
theorem total_comp (f : α' → α) :
(finsupp.total α' M R (v ∘ f)) = (finsupp.total α M R v).comp (lmap_domain R R f) :=
begin
ext l,
simp [total_apply],
rw sum_map_domain_index; simp [add_smul],
end
lemma total_comap_domain
(f : α → α') (l : α' →₀ R) (hf : set.inj_on f (f ⁻¹' l.support.to_set)) :
finsupp.total α M R v (finsupp.comap_domain f l hf) = (l.support.preimage hf).sum (λ i, (l (f i)) • (v i)) :=
by rw finsupp.total_apply; refl
end total
protected def dom_lcongr
{α₁ : Type*} {α₂ : Type*} (e : α₁ ≃ α₂) :
(α₁ →₀ M) ≃ₗ[R] (α₂ →₀ M) :=
(finsupp.dom_congr e).to_linear_equiv
begin
change is_linear_map R (lmap_domain M R e : (α₁ →₀ M) →ₗ[R] (α₂ →₀ M)),
exact linear_map.is_linear _
end
noncomputable def congr {α' : Type*} (s : set α) (t : set α') (e : s ≃ t) :
supported M R s ≃ₗ[R] supported M R t :=
begin
haveI := classical.dec_pred (λ x, x ∈ s),
haveI := classical.dec_pred (λ x, x ∈ t),
refine linear_equiv.trans (finsupp.supported_equiv_finsupp s)
(linear_equiv.trans _ (finsupp.supported_equiv_finsupp t).symm),
exact finsupp.dom_lcongr e
end
end finsupp
variables {R : Type*} {M : Type*} {N : Type*}
variables [ring R] [add_comm_group M] [module R M] [add_comm_group N] [module R N]
lemma linear_map.map_finsupp_total
(f : M →ₗ[R] N) {ι : Type*} [fintype ι] {g : ι → M} (l : ι →₀ R) :
f (finsupp.total ι M R g l) = finsupp.total ι N R (f ∘ g) l :=
by simp only [finsupp.total_apply, finsupp.total_apply, finsupp.sum, f.map_sum, f.map_smul]
lemma submodule.exists_finset_of_mem_supr
{ι : Sort*} (p : ι → submodule R M) {m : M} (hm : m ∈ ⨆ i, p i) :
∃ s : finset ι, m ∈ ⨆ i ∈ s, p i :=
begin
obtain ⟨f, hf, rfl⟩ : ∃ f ∈ finsupp.supported R R (⋃ i, ↑(p i)), finsupp.total M M R id f = m,
{ have aux : (id : M → M) '' (⋃ (i : ι), ↑(p i)) = (⋃ (i : ι), ↑(p i)) := set.image_id _,
rwa [supr_eq_span, ← aux, finsupp.mem_span_iff_total R] at hm },
let t : finset M := f.support,
have ht : ∀ x : {x // x ∈ t}, ∃ i, ↑x ∈ p i,
{ intros x,
rw finsupp.mem_supported at hf,
specialize hf x.2,
rwa set.mem_Union at hf },
choose g hg using ht,
let s : finset ι := finset.univ.image g,
use s,
simp only [mem_supr, supr_le_iff],
assume N hN,
rw [finsupp.total_apply, finsupp.sum, ← submodule.mem_coe],
apply is_add_submonoid.finset_sum_mem,
assume x hx,
apply submodule.smul_mem,
let i : ι := g ⟨x, hx⟩,
have hi : i ∈ s, { rw finset.mem_image, exact ⟨⟨x, hx⟩, finset.mem_univ _, rfl⟩ },
exact hN i hi (hg _),
end
|
5a3f6d4f28101f29b06dfa41674b89922aae8afb | 00de0c30dd1b090ed139f65c82ea6deb48c3f4c2 | /src/set_theory/ordinal.lean | 0cb0a750ea8ec8da50d62c374bcd5d5e6873a55b | [
"Apache-2.0"
] | permissive | paulvanwamelen/mathlib | 4b9c5c19eec71b475f3dd515cd8785f1c8515f26 | 79e296bdc9f83b9447dc1b81730d36f63a99f72d | refs/heads/master | 1,667,766,172,625 | 1,590,239,595,000 | 1,590,239,595,000 | 266,392,625 | 0 | 0 | Apache-2.0 | 1,590,257,277,000 | 1,590,257,277,000 | null | UTF-8 | Lean | false | false | 138,151 | lean | /-
Copyright (c) 2017 Johannes Hölzl. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Author: Mario Carneiro
Ordinal arithmetic.
Ordinals are defined as equivalences of well-ordered sets by order isomorphism.
-/
import set_theory.cardinal
noncomputable theory
open function cardinal set equiv
open_locale classical cardinal
universes u v w
variables {α : Type*} {β : Type*} {γ : Type*}
{r : α → α → Prop} {s : β → β → Prop} {t : γ → γ → Prop}
/-- If `r` is a relation on `α` and `s` in a relation on `β`, then `f : r ≼i s` is an order
embedding whose range is an initial segment. That is, whenever `b < f a` in `β` then `b` is in the
range of `f`. -/
structure initial_seg {α β : Type*} (r : α → α → Prop) (s : β → β → Prop) extends r ≼o s :=
(init : ∀ a b, s b (to_order_embedding a) → ∃ a', to_order_embedding a' = b)
local infix ` ≼i `:25 := initial_seg
namespace initial_seg
instance : has_coe (r ≼i s) (r ≼o s) := ⟨initial_seg.to_order_embedding⟩
instance : has_coe_to_fun (r ≼i s) := ⟨λ _, α → β, λ f x, (f : r ≼o s) x⟩
@[simp] theorem coe_fn_mk (f : r ≼o s) (o) :
(@initial_seg.mk _ _ r s f o : α → β) = f := rfl
@[simp] theorem coe_fn_to_order_embedding (f : r ≼i s) : (f.to_order_embedding : α → β) = f := rfl
@[simp] theorem coe_coe_fn (f : r ≼i s) : ((f : r ≼o s) : α → β) = f := rfl
theorem init' (f : r ≼i s) {a : α} {b : β} : s b (f a) → ∃ a', f a' = b :=
f.init _ _
theorem init_iff (f : r ≼i s) {a : α} {b : β} : s b (f a) ↔ ∃ a', f a' = b ∧ r a' a :=
⟨λ h, let ⟨a', e⟩ := f.init' h in ⟨a', e, (f : r ≼o s).ord.2 (e.symm ▸ h)⟩,
λ ⟨a', e, h⟩, e ▸ (f : r ≼o s).ord.1 h⟩
/-- An order isomorphism is an initial segment -/
def of_iso (f : r ≃o s) : r ≼i s :=
⟨f, λ a b h, ⟨f.symm b, order_iso.apply_symm_apply f _⟩⟩
/-- The identity function shows that `≼i` is reflexive -/
@[refl] protected def refl (r : α → α → Prop) : r ≼i r :=
⟨order_embedding.refl _, λ a b h, ⟨_, rfl⟩⟩
/-- Composition of functions shows that `≼i` is transitive -/
@[trans] protected def trans (f : r ≼i s) (g : s ≼i t) : r ≼i t :=
⟨f.1.trans g.1, λ a c h, begin
simp at h ⊢,
rcases g.2 _ _ h with ⟨b, rfl⟩, have h := g.1.ord.2 h,
rcases f.2 _ _ h with ⟨a', rfl⟩, exact ⟨a', rfl⟩
end⟩
@[simp] theorem refl_apply (x : α) : initial_seg.refl r x = x := rfl
@[simp] theorem trans_apply (f : r ≼i s) (g : s ≼i t) (a : α) : (f.trans g) a = g (f a) := rfl
theorem unique_of_extensional [is_extensional β s] :
well_founded r → subsingleton (r ≼i s) | ⟨h⟩ :=
⟨λ f g, begin
suffices : (f : α → β) = g, { cases f, cases g,
congr, exact order_embedding.coe_fn_injective this },
funext a, have := h a, induction this with a H IH,
refine @is_extensional.ext _ s _ _ _ (λ x, ⟨λ h, _, λ h, _⟩),
{ rcases f.init_iff.1 h with ⟨y, rfl, h'⟩,
rw IH _ h', exact (g : r ≼o s).ord.1 h' },
{ rcases g.init_iff.1 h with ⟨y, rfl, h'⟩,
rw ← IH _ h', exact (f : r ≼o s).ord.1 h' }
end⟩
instance [is_well_order β s] : subsingleton (r ≼i s) :=
⟨λ a, @subsingleton.elim _ (unique_of_extensional
(@order_embedding.well_founded _ _ r s a is_well_order.wf)) a⟩
protected theorem eq [is_well_order β s] (f g : r ≼i s) (a) : f a = g a :=
by rw subsingleton.elim f g
theorem antisymm.aux [is_well_order α r] (f : r ≼i s) (g : s ≼i r) : left_inverse g f :=
initial_seg.eq (f.trans g) (initial_seg.refl _)
/-- If we have order embeddings between `α` and `β` whose images are initial segments, and β is a well-order then `α` and `β` are order-isomorphic. -/
def antisymm [is_well_order β s] (f : r ≼i s) (g : s ≼i r) : r ≃o s :=
by haveI := f.to_order_embedding.is_well_order; exact
⟨⟨f, g, antisymm.aux f g, antisymm.aux g f⟩, f.ord'⟩
@[simp] theorem antisymm_to_fun [is_well_order β s]
(f : r ≼i s) (g : s ≼i r) : (antisymm f g : α → β) = f := rfl
@[simp] theorem antisymm_symm [is_well_order α r] [is_well_order β s]
(f : r ≼i s) (g : s ≼i r) : (antisymm f g).symm = antisymm g f :=
order_iso.coe_fn_injective rfl
theorem eq_or_principal [is_well_order β s] (f : r ≼i s) : surjective f ∨ ∃ b, ∀ x, s x b ↔ ∃ y, f y = x :=
or_iff_not_imp_right.2 $ λ h b,
acc.rec_on (is_well_order.wf.apply b : acc s b) $ λ x H IH,
not_forall_not.1 $ λ hn,
h ⟨x, λ y, ⟨(IH _), λ ⟨a, e⟩, by rw ← e; exact
(trichotomous _ _).resolve_right
(not_or (hn a) (λ hl, not_exists.2 hn (f.init' hl)))⟩⟩
/-- Restrict the codomain of an initial segment -/
def cod_restrict (p : set β) (f : r ≼i s) (H : ∀ a, f a ∈ p) : r ≼i subrel s p :=
⟨order_embedding.cod_restrict p f H, λ a ⟨b, m⟩ (h : s b (f a)),
let ⟨a', e⟩ := f.init' h in ⟨a', by clear _let_match; subst e; refl⟩⟩
@[simp] theorem cod_restrict_apply (p) (f : r ≼i s) (H a) : cod_restrict p f H a = ⟨f a, H a⟩ := rfl
def le_add (r : α → α → Prop) (s : β → β → Prop) : r ≼i sum.lex r s :=
⟨⟨⟨sum.inl, λ _ _, sum.inl.inj⟩, λ a b, sum.lex_inl_inl.symm⟩,
λ a b, by cases b; [exact λ _, ⟨_, rfl⟩, exact false.elim ∘ sum.lex_inr_inl]⟩
@[simp] theorem le_add_apply (r : α → α → Prop) (s : β → β → Prop)
(a) : le_add r s a = sum.inl a := rfl
end initial_seg
structure principal_seg {α β : Type*} (r : α → α → Prop) (s : β → β → Prop) extends r ≼o s :=
(top : β)
(down : ∀ b, s b top ↔ ∃ a, to_order_embedding a = b)
local infix ` ≺i `:25 := principal_seg
namespace principal_seg
instance : has_coe (r ≺i s) (r ≼o s) := ⟨principal_seg.to_order_embedding⟩
instance : has_coe_to_fun (r ≺i s) := ⟨λ _, α → β, λ f, f⟩
@[simp] theorem coe_fn_mk (f : r ≼o s) (t o) :
(@principal_seg.mk _ _ r s f t o : α → β) = f := rfl
@[simp] theorem coe_fn_to_order_embedding (f : r ≺i s) : (f.to_order_embedding : α → β) = f := rfl
@[simp] theorem coe_coe_fn (f : r ≺i s) : ((f : r ≼o s) : α → β) = f := rfl
theorem down' (f : r ≺i s) {b : β} : s b f.top ↔ ∃ a, f a = b :=
f.down _
theorem lt_top (f : r ≺i s) (a : α) : s (f a) f.top :=
f.down'.2 ⟨_, rfl⟩
theorem init [is_trans β s] (f : r ≺i s) {a : α} {b : β} (h : s b (f a)) : ∃ a', f a' = b :=
f.down'.1 $ trans h $ f.lt_top _
instance has_coe_initial_seg [is_trans β s] : has_coe (r ≺i s) (r ≼i s) :=
⟨λ f, ⟨f.to_order_embedding, λ a b, f.init⟩⟩
theorem coe_coe_fn' [is_trans β s] (f : r ≺i s) : ((f : r ≼i s) : α → β) = f := rfl
theorem init_iff [is_trans β s] (f : r ≺i s) {a : α} {b : β} : s b (f a) ↔ ∃ a', f a' = b ∧ r a' a :=
@initial_seg.init_iff α β r s f a b
theorem irrefl (r : α → α → Prop) [is_well_order α r] (f : r ≺i r) : false :=
begin
have := f.lt_top f.top,
rw [show f f.top = f.top, from
initial_seg.eq ↑f (initial_seg.refl r) f.top] at this,
exact irrefl _ this
end
def lt_le (f : r ≺i s) (g : s ≼i t) : r ≺i t :=
⟨@order_embedding.trans _ _ _ r s t f g, g f.top, λ a,
by simp only [g.init_iff, f.down', exists_and_distrib_left.symm,
exists_swap, order_embedding.trans_apply, exists_eq_right']; refl⟩
@[simp] theorem lt_le_apply (f : r ≺i s) (g : s ≼i t) (a : α) : (f.lt_le g) a = g (f a) :=
order_embedding.trans_apply _ _ _
@[simp] theorem lt_le_top (f : r ≺i s) (g : s ≼i t) : (f.lt_le g).top = g f.top := rfl
@[trans] protected def trans [is_trans γ t] (f : r ≺i s) (g : s ≺i t) : r ≺i t :=
lt_le f g
@[simp] theorem trans_apply [is_trans γ t] (f : r ≺i s) (g : s ≺i t) (a : α) : (f.trans g) a = g (f a) :=
lt_le_apply _ _ _
@[simp] theorem trans_top [is_trans γ t] (f : r ≺i s) (g : s ≺i t) : (f.trans g).top = g f.top := rfl
def equiv_lt (f : r ≃o s) (g : s ≺i t) : r ≺i t :=
⟨@order_embedding.trans _ _ _ r s t f g, g.top, λ c,
suffices (∃ (a : β), g a = c) ↔ ∃ (a : α), g (f a) = c, by simpa [g.down],
⟨λ ⟨b, h⟩, ⟨f.symm b, by simp only [h, order_iso.apply_symm_apply, order_iso.coe_coe_fn]⟩,
λ ⟨a, h⟩, ⟨f a, h⟩⟩⟩
def lt_equiv {r : α → α → Prop} {s : β → β → Prop} {t : γ → γ → Prop}
(f : principal_seg r s) (g : s ≃o t) : principal_seg r t :=
⟨@order_embedding.trans _ _ _ r s t f g, g f.top,
begin
intro x,
rw [← g.right_inv x, order_iso.to_equiv_to_fun, ← g.ord, f.down', exists_congr],
intro y, exact ⟨congr_arg g, λ h, g.to_equiv.bijective.1 h⟩
end⟩
@[simp] theorem equiv_lt_apply (f : r ≃o s) (g : s ≺i t) (a : α) : (equiv_lt f g) a = g (f a) :=
order_embedding.trans_apply _ _ _
@[simp] theorem equiv_lt_top (f : r ≃o s) (g : s ≺i t) : (equiv_lt f g).top = g.top := rfl
instance [is_well_order β s] : subsingleton (r ≺i s) :=
⟨λ f g, begin
have ef : (f : α → β) = g,
{ show ((f : r ≼i s) : α → β) = g,
rw @subsingleton.elim _ _ (f : r ≼i s) g, refl },
have et : f.top = g.top,
{ refine @is_extensional.ext _ s _ _ _ (λ x, _),
simp only [f.down, g.down, ef, coe_fn_to_order_embedding] },
cases f, cases g,
have := order_embedding.coe_fn_injective ef; congr'
end⟩
theorem top_eq [is_well_order γ t]
(e : r ≃o s) (f : r ≺i t) (g : s ≺i t) : f.top = g.top :=
by rw subsingleton.elim f (principal_seg.equiv_lt e g); refl
lemma top_lt_top {r : α → α → Prop} {s : β → β → Prop} {t : γ → γ → Prop}
[is_well_order γ t]
(f : principal_seg r s) (g : principal_seg s t) (h : principal_seg r t) : t h.top g.top :=
by { rw [subsingleton.elim h (f.trans g)], apply principal_seg.lt_top }
/-- Any element of a well order yields a principal segment -/
def of_element {α : Type*} (r : α → α → Prop) (a : α) : subrel r {b | r b a} ≺i r :=
⟨subrel.order_embedding _ _, a, λ b,
⟨λ h, ⟨⟨_, h⟩, rfl⟩, λ ⟨⟨_, h⟩, rfl⟩, h⟩⟩
@[simp] theorem of_element_apply {α : Type*} (r : α → α → Prop) (a : α) (b) :
of_element r a b = b.1 := rfl
@[simp] theorem of_element_top {α : Type*} (r : α → α → Prop) (a : α) :
(of_element r a).top = a := rfl
/-- Restrict the codomain of a principal segment -/
def cod_restrict (p : set β) (f : r ≺i s)
(H : ∀ a, f a ∈ p) (H₂ : f.top ∈ p) : r ≺i subrel s p :=
⟨order_embedding.cod_restrict p f H, ⟨f.top, H₂⟩, λ ⟨b, h⟩,
f.down'.trans $ exists_congr $ λ a,
show (⟨f a, H a⟩ : p).1 = _ ↔ _, from ⟨subtype.eq, congr_arg _⟩⟩
@[simp] theorem cod_restrict_apply (p) (f : r ≺i s) (H H₂ a) : cod_restrict p f H H₂ a = ⟨f a, H a⟩ := rfl
@[simp] theorem cod_restrict_top (p) (f : r ≺i s) (H H₂) : (cod_restrict p f H H₂).top = ⟨f.top, H₂⟩ := rfl
end principal_seg
def initial_seg.lt_or_eq [is_well_order β s] (f : r ≼i s) :
(r ≺i s) ⊕ (r ≃o s) :=
if h : surjective f then sum.inr (order_iso.of_surjective f h) else
have h' : _, from (initial_seg.eq_or_principal f).resolve_left h,
sum.inl ⟨f, classical.some h', classical.some_spec h'⟩
theorem initial_seg.lt_or_eq_apply_left [is_well_order β s]
(f : r ≼i s) (g : r ≺i s) (a : α) : g a = f a :=
@initial_seg.eq α β r s _ g f a
theorem initial_seg.lt_or_eq_apply_right [is_well_order β s]
(f : r ≼i s) (g : r ≃o s) (a : α) : g a = f a :=
initial_seg.eq (initial_seg.of_iso g) f a
def initial_seg.le_lt [is_well_order β s] [is_trans γ t] (f : r ≼i s) (g : s ≺i t) : r ≺i t :=
match f.lt_or_eq with
| sum.inl f' := f'.trans g
| sum.inr f' := principal_seg.equiv_lt f' g
end
@[simp] theorem initial_seg.le_lt_apply [is_well_order β s] [is_trans γ t]
(f : r ≼i s) (g : s ≺i t) (a : α) : (f.le_lt g) a = g (f a) :=
begin
delta initial_seg.le_lt, cases h : f.lt_or_eq with f' f',
{ simp only [principal_seg.trans_apply, f.lt_or_eq_apply_left] },
{ simp only [principal_seg.equiv_lt_apply, f.lt_or_eq_apply_right] }
end
namespace order_embedding
def collapse_F [is_well_order β s] (f : r ≼o s) : Π a, {b // ¬ s (f a) b} :=
(order_embedding.well_founded f $ is_well_order.wf).fix $ λ a IH, begin
let S := {b | ∀ a h, s (IH a h).1 b},
have : f a ∈ S, from λ a' h, ((trichotomous _ _)
.resolve_left $ λ h', (IH a' h).2 $ trans (f.ord.1 h) h')
.resolve_left $ λ h', (IH a' h).2 $ h' ▸ f.ord.1 h,
exact ⟨is_well_order.wf.min S ⟨_, this⟩,
is_well_order.wf.not_lt_min _ _ this⟩
end
theorem collapse_F.lt [is_well_order β s] (f : r ≼o s) {a : α}
: ∀ {a'}, r a' a → s (collapse_F f a').1 (collapse_F f a).1 :=
show (collapse_F f a).1 ∈ {b | ∀ a' (h : r a' a), s (collapse_F f a').1 b}, begin
unfold collapse_F, rw well_founded.fix_eq,
apply well_founded.min_mem _ _
end
theorem collapse_F.not_lt [is_well_order β s] (f : r ≼o s) (a : α)
{b} (h : ∀ a' (h : r a' a), s (collapse_F f a').1 b) : ¬ s b (collapse_F f a).1 :=
begin
unfold collapse_F, rw well_founded.fix_eq,
exact well_founded.not_lt_min _ _ _
(show b ∈ {b | ∀ a' (h : r a' a), s (collapse_F f a').1 b}, from h)
end
/-- Construct an initial segment from an order embedding. -/
def collapse [is_well_order β s] (f : r ≼o s) : r ≼i s :=
by haveI := order_embedding.is_well_order f; exact
⟨order_embedding.of_monotone
(λ a, (collapse_F f a).1) (λ a b, collapse_F.lt f),
λ a b, acc.rec_on (is_well_order.wf.apply b : acc s b) (λ b H IH a h, begin
let S := {a | ¬ s (collapse_F f a).1 b},
have : S.nonempty := ⟨_, asymm h⟩,
existsi (is_well_order.wf : well_founded r).min S this,
refine ((@trichotomous _ s _ _ _).resolve_left _).resolve_right _,
{ exact (is_well_order.wf : well_founded r).min_mem S this },
{ refine collapse_F.not_lt f _ (λ a' h', _),
by_contradiction hn,
exact is_well_order.wf.not_lt_min S this hn h' }
end) a⟩
theorem collapse_apply [is_well_order β s] (f : r ≼o s)
(a) : collapse f a = (collapse_F f a).1 := rfl
end order_embedding
section well_ordering_thm
parameter {σ : Type u}
open function
theorem nonempty_embedding_to_cardinal : nonempty (σ ↪ cardinal.{u}) :=
embedding.total.resolve_left $ λ ⟨⟨f, hf⟩⟩,
let g : σ → cardinal.{u} := inv_fun f in
let ⟨x, (hx : g x = 2 ^ sum g)⟩ := inv_fun_surjective hf (2 ^ sum g) in
have g x ≤ sum g, from le_sum.{u u} g x,
not_le_of_gt (by rw hx; exact cantor _) this
/-- An embedding of any type to the set of cardinals. -/
def embedding_to_cardinal : σ ↪ cardinal.{u} := classical.choice nonempty_embedding_to_cardinal
/-- The relation whose existence is given by the well-ordering theorem -/
def well_ordering_rel : σ → σ → Prop := embedding_to_cardinal ⁻¹'o (<)
instance well_ordering_rel.is_well_order : is_well_order σ well_ordering_rel :=
(order_embedding.preimage _ _).is_well_order
end well_ordering_thm
structure Well_order : Type (u+1) :=
(α : Type u)
(r : α → α → Prop)
(wo : is_well_order α r)
attribute [instance] Well_order.wo
namespace Well_order
instance : inhabited Well_order := ⟨⟨pempty, _, empty_relation.is_well_order⟩⟩
end Well_order
instance ordinal.is_equivalent : setoid Well_order :=
{ r := λ ⟨α, r, wo⟩ ⟨β, s, wo'⟩, nonempty (r ≃o s),
iseqv := ⟨λ⟨α, r, _⟩, ⟨order_iso.refl _⟩,
λ⟨α, r, _⟩ ⟨β, s, _⟩ ⟨e⟩, ⟨e.symm⟩,
λ⟨α, r, _⟩ ⟨β, s, _⟩ ⟨γ, t, _⟩ ⟨e₁⟩ ⟨e₂⟩, ⟨e₁.trans e₂⟩⟩ }
/-- `ordinal.{u}` is the type of well orders in `Type u`,
quotient by order isomorphism. -/
def ordinal : Type (u + 1) := quotient ordinal.is_equivalent
namespace ordinal
/-- The order type of a well order is an ordinal. -/
def type (r : α → α → Prop) [wo : is_well_order α r] : ordinal :=
⟦⟨α, r, wo⟩⟧
/-- The order type of an element inside a well order. -/
def typein (r : α → α → Prop) [is_well_order α r] (a : α) : ordinal :=
type (subrel r {b | r b a})
theorem type_def (r : α → α → Prop) [wo : is_well_order α r] :
@eq ordinal ⟦⟨α, r, wo⟩⟧ (type r) := rfl
@[simp] theorem type_def' (r : α → α → Prop) [is_well_order α r] {wo} :
@eq ordinal ⟦⟨α, r, wo⟩⟧ (type r) := rfl
theorem type_eq {α β} {r : α → α → Prop} {s : β → β → Prop}
[is_well_order α r] [is_well_order β s] :
type r = type s ↔ nonempty (r ≃o s) := quotient.eq
@[simp] lemma type_out (o : ordinal) : type o.out.r = o :=
by { refine eq.trans _ (by rw [←quotient.out_eq o]), cases quotient.out o, refl }
@[elab_as_eliminator] theorem induction_on {C : ordinal → Prop}
(o : ordinal) (H : ∀ α r [is_well_order α r], C (type r)) : C o :=
quot.induction_on o $ λ ⟨α, r, wo⟩, @H α r wo
/-- Ordinal less-equal is defined such that
well orders `r` and `s` satisfy `type r ≤ type s` if there exists
a function embedding `r` as an initial segment of `s`. -/
protected def le (a b : ordinal) : Prop :=
quotient.lift_on₂ a b (λ ⟨α, r, wo⟩ ⟨β, s, wo'⟩, nonempty (r ≼i s)) $
λ ⟨α₁, r₁, o₁⟩ ⟨α₂, r₂, o₂⟩ ⟨β₁, s₁, p₁⟩ ⟨β₂, s₂, p₂⟩ ⟨f⟩ ⟨g⟩,
propext ⟨
λ ⟨h⟩, ⟨(initial_seg.of_iso f.symm).trans $
h.trans (initial_seg.of_iso g)⟩,
λ ⟨h⟩, ⟨(initial_seg.of_iso f).trans $
h.trans (initial_seg.of_iso g.symm)⟩⟩
instance : has_le ordinal := ⟨ordinal.le⟩
theorem type_le {α β} {r : α → α → Prop} {s : β → β → Prop}
[is_well_order α r] [is_well_order β s] :
type r ≤ type s ↔ nonempty (r ≼i s) := iff.rfl
theorem type_le' {α β} {r : α → α → Prop} {s : β → β → Prop}
[is_well_order α r] [is_well_order β s] : type r ≤ type s ↔ nonempty (r ≼o s) :=
⟨λ ⟨f⟩, ⟨f⟩, λ ⟨f⟩, ⟨f.collapse⟩⟩
/-- Ordinal less-than is defined such that
well orders `r` and `s` satisfy `type r < type s` if there exists
a function embedding `r` as a principal segment of `s`. -/
def lt (a b : ordinal) : Prop :=
quotient.lift_on₂ a b (λ ⟨α, r, wo⟩ ⟨β, s, wo'⟩, nonempty (r ≺i s)) $
λ ⟨α₁, r₁, o₁⟩ ⟨α₂, r₂, o₂⟩ ⟨β₁, s₁, p₁⟩ ⟨β₂, s₂, p₂⟩ ⟨f⟩ ⟨g⟩,
by exactI propext ⟨
λ ⟨h⟩, ⟨principal_seg.equiv_lt f.symm $
h.lt_le (initial_seg.of_iso g)⟩,
λ ⟨h⟩, ⟨principal_seg.equiv_lt f $
h.lt_le (initial_seg.of_iso g.symm)⟩⟩
instance : has_lt ordinal := ⟨ordinal.lt⟩
@[simp] theorem type_lt {α β} {r : α → α → Prop} {s : β → β → Prop}
[is_well_order α r] [is_well_order β s] :
type r < type s ↔ nonempty (r ≺i s) := iff.rfl
instance : partial_order ordinal :=
{ le := (≤),
lt := (<),
le_refl := quot.ind $ by exact λ ⟨α, r, wo⟩, ⟨initial_seg.refl _⟩,
le_trans := λ a b c, quotient.induction_on₃ a b c $
λ ⟨α, r, _⟩ ⟨β, s, _⟩ ⟨γ, t, _⟩ ⟨f⟩ ⟨g⟩, ⟨f.trans g⟩,
lt_iff_le_not_le := λ a b, quotient.induction_on₂ a b $
λ ⟨α, r, _⟩ ⟨β, s, _⟩, by exactI
⟨λ ⟨f⟩, ⟨⟨f⟩, λ ⟨g⟩, (f.lt_le g).irrefl _⟩,
λ ⟨⟨f⟩, h⟩, sum.rec_on f.lt_or_eq (λ g, ⟨g⟩)
(λ g, (h ⟨initial_seg.of_iso g.symm⟩).elim)⟩,
le_antisymm := λ x b, show x ≤ b → b ≤ x → x = b, from
quotient.induction_on₂ x b $ λ ⟨α, r, _⟩ ⟨β, s, _⟩ ⟨h₁⟩ ⟨h₂⟩,
by exactI quot.sound ⟨initial_seg.antisymm h₁ h₂⟩ }
def initial_seg_out {α β : ordinal} (h : α ≤ β) : initial_seg α.out.r β.out.r :=
begin
rw [←quotient.out_eq α, ←quotient.out_eq β] at h, revert h,
cases quotient.out α, cases quotient.out β, exact classical.choice
end
def principal_seg_out {α β : ordinal} (h : α < β) : principal_seg α.out.r β.out.r :=
begin
rw [←quotient.out_eq α, ←quotient.out_eq β] at h, revert h,
cases quotient.out α, cases quotient.out β, exact classical.choice
end
def order_iso_out {α β : ordinal} (h : α = β) : order_iso α.out.r β.out.r :=
begin
rw [←quotient.out_eq α, ←quotient.out_eq β] at h, revert h,
cases quotient.out α, cases quotient.out β, exact classical.choice ∘ quotient.exact
end
theorem typein_lt_type (r : α → α → Prop) [is_well_order α r]
(a : α) : typein r a < type r :=
⟨principal_seg.of_element _ _⟩
@[simp] theorem typein_top {α β} {r : α → α → Prop} {s : β → β → Prop}
[is_well_order α r] [is_well_order β s] (f : r ≺i s) :
typein s f.top = type r :=
eq.symm $ quot.sound ⟨order_iso.of_surjective
(order_embedding.cod_restrict _ f f.lt_top)
(λ ⟨a, h⟩, by rcases f.down'.1 h with ⟨b, rfl⟩; exact ⟨b, rfl⟩)⟩
@[simp] theorem typein_apply {α β} {r : α → α → Prop} {s : β → β → Prop}
[is_well_order α r] [is_well_order β s] (f : r ≼i s) (a : α) :
ordinal.typein s (f a) = ordinal.typein r a :=
eq.symm $ quotient.sound ⟨order_iso.of_surjective
(order_embedding.cod_restrict _
((subrel.order_embedding _ _).trans f)
(λ ⟨x, h⟩, by rw [order_embedding.trans_apply]; exact f.to_order_embedding.ord.1 h))
(λ ⟨y, h⟩, by rcases f.init' h with ⟨a, rfl⟩;
exact ⟨⟨a, f.to_order_embedding.ord.2 h⟩, subtype.eq $ order_embedding.trans_apply _ _ _⟩)⟩
@[simp] theorem typein_lt_typein (r : α → α → Prop) [is_well_order α r]
{a b : α} : typein r a < typein r b ↔ r a b :=
⟨λ ⟨f⟩, begin
have : f.top.1 = a,
{ let f' := principal_seg.of_element r a,
let g' := f.trans (principal_seg.of_element r b),
have : g'.top = f'.top, {rw subsingleton.elim f' g'},
exact this },
rw ← this, exact f.top.2
end, λ h, ⟨principal_seg.cod_restrict _
(principal_seg.of_element r a)
(λ x, @trans _ r _ _ _ _ x.2 h) h⟩⟩
theorem typein_surj (r : α → α → Prop) [is_well_order α r]
{o} (h : o < type r) : ∃ a, typein r a = o :=
induction_on o (λ β s _ ⟨f⟩, by exactI ⟨f.top, typein_top _⟩) h
lemma injective_typein (r : α → α → Prop) [is_well_order α r] : injective (typein r) :=
injective_of_increasing r (<) (typein r) (λ x y, (typein_lt_typein r).2)
theorem typein_inj (r : α → α → Prop) [is_well_order α r]
{a b} : typein r a = typein r b ↔ a = b :=
injective.eq_iff (injective_typein r)
/-- `enum r o h` is the `o`-th element of `α` ordered by `r`.
That is, `enum` maps an initial segment of the ordinals, those
less than the order type of `r`, to the elements of `α`. -/
def enum (r : α → α → Prop) [is_well_order α r] (o) : o < type r → α :=
quot.rec_on o (λ ⟨β, s, _⟩ h, (classical.choice h).top) $
λ ⟨β, s, _⟩ ⟨γ, t, _⟩ ⟨h⟩, begin
resetI, refine funext (λ (H₂ : type t < type r), _),
have H₁ : type s < type r, {rwa type_eq.2 ⟨h⟩},
have : ∀ {o e} (H : o < type r), @@eq.rec
(λ (o : ordinal), o < type r → α)
(λ (h : type s < type r), (classical.choice h).top)
e H = (classical.choice H₁).top, {intros, subst e},
exact (this H₂).trans (principal_seg.top_eq h
(classical.choice H₁) (classical.choice H₂))
end
theorem enum_type {α β} {r : α → α → Prop} {s : β → β → Prop}
[is_well_order α r] [is_well_order β s] (f : s ≺i r)
{h : type s < type r} : enum r (type s) h = f.top :=
principal_seg.top_eq (order_iso.refl _) _ _
@[simp] theorem enum_typein (r : α → α → Prop) [is_well_order α r] (a : α)
{h : typein r a < type r} : enum r (typein r a) h = a :=
enum_type (principal_seg.of_element r a)
@[simp] theorem typein_enum (r : α → α → Prop) [is_well_order α r]
{o} (h : o < type r) : typein r (enum r o h) = o :=
let ⟨a, e⟩ := typein_surj r h in
by clear _let_match; subst e; rw enum_typein
def typein_iso (r : α → α → Prop) [is_well_order α r] : r ≃o subrel (<) (< type r) :=
⟨⟨λ x, ⟨typein r x, typein_lt_type r x⟩, λ x, enum r x.1 x.2, λ y, enum_typein r y,
λ ⟨y, hy⟩, subtype.eq (typein_enum r hy)⟩,
λ a b, (typein_lt_typein r).symm⟩
theorem enum_lt {r : α → α → Prop} [is_well_order α r]
{o₁ o₂ : ordinal} (h₁ : o₁ < type r) (h₂ : o₂ < type r) :
r (enum r o₁ h₁) (enum r o₂ h₂) ↔ o₁ < o₂ :=
by rw [← typein_lt_typein r, typein_enum, typein_enum]
lemma order_iso_enum' {α β : Type u} {r : α → α → Prop} {s : β → β → Prop}
[is_well_order α r] [is_well_order β s]
(f : order_iso r s) (o : ordinal) : ∀(hr : o < type r) (hs : o < type s),
f (enum r o hr) = enum s o hs :=
begin
refine induction_on o _, rintros γ t wo ⟨g⟩ ⟨h⟩,
resetI, rw [enum_type g, enum_type (principal_seg.lt_equiv g f)], refl
end
lemma order_iso_enum {α β : Type u} {r : α → α → Prop} {s : β → β → Prop}
[is_well_order α r] [is_well_order β s]
(f : order_iso r s) (o : ordinal) (hr : o < type r) :
f (enum r o hr) =
enum s o (by {convert hr using 1, apply quotient.sound, exact ⟨f.symm⟩ }) :=
order_iso_enum' _ _ _ _
theorem wf : @well_founded ordinal (<) :=
⟨λ a, induction_on a $ λ α r wo, by exactI
suffices ∀ a, acc (<) (typein r a), from
⟨_, λ o h, let ⟨a, e⟩ := typein_surj r h in e ▸ this a⟩,
λ a, acc.rec_on (wo.wf.apply a) $ λ x H IH, ⟨_, λ o h, begin
rcases typein_surj r (lt_trans h (typein_lt_type r _)) with ⟨b, rfl⟩,
exact IH _ ((typein_lt_typein r).1 h)
end⟩⟩
instance : has_well_founded ordinal := ⟨(<), wf⟩
/-- The cardinal of an ordinal is the cardinal of any
set with that order type. -/
def card (o : ordinal) : cardinal :=
quot.lift_on o (λ ⟨α, r, _⟩, mk α) $
λ ⟨α, r, _⟩ ⟨β, s, _⟩ ⟨e⟩, quotient.sound ⟨e.to_equiv⟩
@[simp] theorem card_type (r : α → α → Prop) [is_well_order α r] :
card (type r) = mk α := rfl
lemma card_typein {r : α → α → Prop} [wo : is_well_order α r] (x : α) :
mk {y // r y x} = (typein r x).card := rfl
theorem card_le_card {o₁ o₂ : ordinal} : o₁ ≤ o₂ → card o₁ ≤ card o₂ :=
induction_on o₁ $ λ α r _, induction_on o₂ $ λ β s _ ⟨⟨⟨f, _⟩, _⟩⟩, ⟨f⟩
instance : has_zero ordinal :=
⟨⟦⟨pempty, empty_relation, by apply_instance⟩⟧⟩
instance : inhabited ordinal := ⟨0⟩
theorem zero_eq_type_empty : 0 = @type empty empty_relation _ :=
quotient.sound ⟨⟨empty_equiv_pempty.symm, λ _ _, iff.rfl⟩⟩
@[simp] theorem card_zero : card 0 = 0 := rfl
theorem zero_le (o : ordinal) : 0 ≤ o :=
induction_on o $ λ α r _,
⟨⟨⟨embedding.of_not_nonempty $ λ ⟨a⟩, a.elim,
λ a, a.elim⟩, λ a, a.elim⟩⟩
@[simp] theorem le_zero {o : ordinal} : o ≤ 0 ↔ o = 0 :=
by simp only [le_antisymm_iff, zero_le, and_true]
theorem pos_iff_ne_zero {o : ordinal} : 0 < o ↔ o ≠ 0 :=
by simp only [lt_iff_le_and_ne, zero_le, true_and, ne.def, eq_comm]
instance : has_one ordinal :=
⟨⟦⟨punit, empty_relation, by apply_instance⟩⟧⟩
theorem one_eq_type_unit : 1 = @type unit empty_relation _ :=
quotient.sound ⟨⟨punit_equiv_punit, λ _ _, iff.rfl⟩⟩
@[simp] theorem card_one : card 1 = 1 := rfl
instance : has_add ordinal.{u} :=
⟨λo₁ o₂, quotient.lift_on₂ o₁ o₂
(λ ⟨α, r, wo⟩ ⟨β, s, wo'⟩, ⟦⟨α ⊕ β, sum.lex r s, by exactI sum.lex.is_well_order⟩⟧
: Well_order → Well_order → ordinal) $
λ ⟨α₁, r₁, o₁⟩ ⟨α₂, r₂, o₂⟩ ⟨β₁, s₁, p₁⟩ ⟨β₂, s₂, p₂⟩ ⟨f⟩ ⟨g⟩,
quot.sound ⟨order_iso.sum_lex_congr f g⟩⟩
@[simp] theorem type_add {α β : Type u} (r : α → α → Prop) (s : β → β → Prop)
[is_well_order α r] [is_well_order β s] : type r + type s = type (sum.lex r s) := rfl
/-- The ordinal successor is the smallest ordinal larger than `o`.
It is defined as `o + 1`. -/
def succ (o : ordinal) : ordinal := o + 1
theorem succ_eq_add_one (o) : succ o = o + 1 := rfl
theorem lt_succ_self (o : ordinal.{u}) : o < succ o :=
induction_on o $ λ α r _, ⟨⟨⟨⟨λ x, sum.inl x, λ _ _, sum.inl.inj⟩,
λ _ _, sum.lex_inl_inl.symm⟩,
sum.inr punit.star, λ b, sum.rec_on b
(λ x, ⟨λ _, ⟨x, rfl⟩, λ _, sum.lex.sep _ _⟩)
(λ x, sum.lex_inr_inr.trans ⟨false.elim, λ ⟨x, H⟩, sum.inl_ne_inr H⟩)⟩⟩
theorem succ_pos (o : ordinal) : 0 < succ o :=
lt_of_le_of_lt (zero_le _) (lt_succ_self _)
theorem succ_ne_zero (o : ordinal) : succ o ≠ 0 :=
ne_of_gt $ succ_pos o
theorem succ_le {a b : ordinal} : succ a ≤ b ↔ a < b :=
⟨lt_of_lt_of_le (lt_succ_self _),
induction_on a $ λ α r hr, induction_on b $ λ β s hs ⟨⟨f, t, hf⟩⟩, begin
refine ⟨⟨@order_embedding.of_monotone (α ⊕ punit) β _ _
(@sum.lex.is_well_order _ _ _ _ hr _).1.1
(@is_asymm_of_is_trans_of_is_irrefl _ _ hs.1.2.2 hs.1.2.1)
(sum.rec _ _) (λ a b, _), λ a b, _⟩⟩,
{ exact f }, { exact λ _, t },
{ rcases a with a|_; rcases b with b|_,
{ simpa only [sum.lex_inl_inl] using f.ord.1 },
{ intro _, rw hf, exact ⟨_, rfl⟩ },
{ exact false.elim ∘ sum.lex_inr_inl },
{ exact false.elim ∘ sum.lex_inr_inr.1 } },
{ rcases a with a|_,
{ intro h, have := @principal_seg.init _ _ _ _ hs.1.2.2 ⟨f, t, hf⟩ _ _ h,
cases this with w h, exact ⟨sum.inl w, h⟩ },
{ intro h, cases (hf b).1 h with w h, exact ⟨sum.inl w, h⟩ } }
end⟩
@[simp] theorem card_add (o₁ o₂ : ordinal) : card (o₁ + o₂) = card o₁ + card o₂ :=
induction_on o₁ $ λ α r _, induction_on o₂ $ λ β s _, rfl
@[simp] theorem card_succ (o : ordinal) : card (succ o) = card o + 1 :=
by simp only [succ, card_add, card_one]
@[simp] theorem card_nat (n : ℕ) : card.{u} n = n :=
by induction n; [refl, simp only [card_add, card_one, nat.cast_succ, *]]
theorem nat_cast_succ (n : ℕ) : (succ n : ordinal) = n.succ := rfl
instance : add_monoid ordinal.{u} :=
{ add := (+),
zero := 0,
zero_add := λ o, induction_on o $ λ α r _, eq.symm $ quotient.sound
⟨⟨(pempty_sum α).symm, λ a b, sum.lex_inr_inr.symm⟩⟩,
add_zero := λ o, induction_on o $ λ α r _, eq.symm $ quotient.sound
⟨⟨(sum_pempty α).symm, λ a b, sum.lex_inl_inl.symm⟩⟩,
add_assoc := λ o₁ o₂ o₃, quotient.induction_on₃ o₁ o₂ o₃ $
λ ⟨α, r, _⟩ ⟨β, s, _⟩ ⟨γ, t, _⟩, quot.sound
⟨⟨sum_assoc _ _ _, λ a b,
begin rcases a with ⟨a|a⟩|a; rcases b with ⟨b|b⟩|b;
simp only [sum_assoc_apply_in1, sum_assoc_apply_in2, sum_assoc_apply_in3,
sum.lex_inl_inl, sum.lex_inr_inr, sum.lex.sep, sum.lex_inr_inl] end⟩⟩ }
theorem add_succ (o₁ o₂ : ordinal) : o₁ + succ o₂ = succ (o₁ + o₂) :=
(add_assoc _ _ _).symm
@[simp] theorem succ_zero : succ 0 = 1 := zero_add _
theorem one_le_iff_pos {o : ordinal} : 1 ≤ o ↔ 0 < o :=
by rw [← succ_zero, succ_le]
theorem one_le_iff_ne_zero {o : ordinal} : 1 ≤ o ↔ o ≠ 0 :=
by rw [one_le_iff_pos, pos_iff_ne_zero]
theorem add_le_add_left {a b : ordinal} : a ≤ b → ∀ c, c + a ≤ c + b :=
induction_on a $ λ α₁ r₁ _, induction_on b $ λ α₂ r₂ _ ⟨⟨⟨f, fo⟩, fi⟩⟩ c,
induction_on c $ λ β s _,
⟨⟨⟨(embedding.refl _).sum_congr f,
λ a b, match a, b with
| sum.inl a, sum.inl b := sum.lex_inl_inl.trans sum.lex_inl_inl.symm
| sum.inl a, sum.inr b := by apply iff_of_true; apply sum.lex.sep
| sum.inr a, sum.inl b := by apply iff_of_false; exact sum.lex_inr_inl
| sum.inr a, sum.inr b := sum.lex_inr_inr.trans $ fo.trans sum.lex_inr_inr.symm
end⟩,
λ a b H, match a, b, H with
| _, sum.inl b, _ := ⟨sum.inl b, rfl⟩
| sum.inl a, sum.inr b, H := (sum.lex_inr_inl H).elim
| sum.inr a, sum.inr b, H := let ⟨w, h⟩ := fi _ _ (sum.lex_inr_inr.1 H) in
⟨sum.inr w, congr_arg sum.inr h⟩
end⟩⟩
theorem le_add_right (a b : ordinal) : a ≤ a + b :=
by simpa only [add_zero] using add_le_add_left (zero_le b) a
theorem add_le_add_iff_left (a) {b c : ordinal} : a + b ≤ a + c ↔ b ≤ c :=
⟨induction_on a $ λ α r hr, induction_on b $ λ β₁ s₁ hs₁, induction_on c $ λ β₂ s₂ hs₂ ⟨f⟩, ⟨
have fl : ∀ a, f (sum.inl a) = sum.inl a := λ a,
by simpa only [initial_seg.trans_apply, initial_seg.le_add_apply]
using @initial_seg.eq _ _ _ _ (@sum.lex.is_well_order _ _ _ _ hr hs₂)
((initial_seg.le_add r s₁).trans f) (initial_seg.le_add r s₂) a,
have ∀ b, {b' // f (sum.inr b) = sum.inr b'}, begin
intro b, cases e : f (sum.inr b),
{ rw ← fl at e, have := f.inj' e, contradiction },
{ exact ⟨_, rfl⟩ }
end,
let g (b) := (this b).1 in
have fr : ∀ b, f (sum.inr b) = sum.inr (g b), from λ b, (this b).2,
⟨⟨⟨g, λ x y h, by injection f.inj'
(by rw [fr, fr, h] : f (sum.inr x) = f (sum.inr y))⟩,
λ a b, by simpa only [sum.lex_inr_inr, fr, order_embedding.coe_fn_to_embedding,
initial_seg.coe_fn_to_order_embedding, function.embedding.coe_fn_mk]
using @order_embedding.ord _ _ _ _ f.to_order_embedding (sum.inr a) (sum.inr b)⟩,
λ a b H, begin
rcases f.init' (by rw fr; exact sum.lex_inr_inr.2 H) with ⟨a'|a', h⟩,
{ rw fl at h, cases h },
{ rw fr at h, exact ⟨a', sum.inr.inj h⟩ }
end⟩⟩,
λ h, add_le_add_left h _⟩
theorem add_left_cancel (a) {b c : ordinal} : a + b = a + c ↔ b = c :=
by simp only [le_antisymm_iff, add_le_add_iff_left]
/-- The universe lift operation for ordinals, which embeds `ordinal.{u}` as
a proper initial segment of `ordinal.{v}` for `v > u`. -/
def lift (o : ordinal.{u}) : ordinal.{max u v} :=
quotient.lift_on o (λ ⟨α, r, wo⟩,
@type _ _ (@order_embedding.is_well_order _ _ (@equiv.ulift.{u v} α ⁻¹'o r) r
(order_iso.preimage equiv.ulift.{u v} r) wo)) $
λ ⟨α, r, _⟩ ⟨β, s, _⟩ ⟨f⟩,
quot.sound ⟨(order_iso.preimage equiv.ulift r).trans $
f.trans (order_iso.preimage equiv.ulift s).symm⟩
theorem lift_type {α} (r : α → α → Prop) [is_well_order α r] :
∃ wo', lift (type r) = @type _ (@equiv.ulift.{u v} α ⁻¹'o r) wo' :=
⟨_, rfl⟩
theorem lift_umax : lift.{u (max u v)} = lift.{u v} :=
funext $ λ a, induction_on a $ λ α r _,
quotient.sound ⟨(order_iso.preimage equiv.ulift r).trans (order_iso.preimage equiv.ulift r).symm⟩
theorem lift_id' (a : ordinal) : lift a = a :=
induction_on a $ λ α r _,
quotient.sound ⟨order_iso.preimage equiv.ulift r⟩
@[simp] theorem lift_id : ∀ a, lift.{u u} a = a := lift_id'.{u u}
@[simp] theorem lift_lift (a : ordinal) : lift.{(max u v) w} (lift.{u v} a) = lift.{u (max v w)} a :=
induction_on a $ λ α r _,
quotient.sound ⟨(order_iso.preimage equiv.ulift _).trans $
(order_iso.preimage equiv.ulift _).trans (order_iso.preimage equiv.ulift _).symm⟩
theorem lift_type_le {α : Type u} {β : Type v} {r s} [is_well_order α r] [is_well_order β s] :
lift.{u (max v w)} (type r) ≤ lift.{v (max u w)} (type s) ↔ nonempty (r ≼i s) :=
⟨λ ⟨f⟩, ⟨(initial_seg.of_iso (order_iso.preimage equiv.ulift r).symm).trans $
f.trans (initial_seg.of_iso (order_iso.preimage equiv.ulift s))⟩,
λ ⟨f⟩, ⟨(initial_seg.of_iso (order_iso.preimage equiv.ulift r)).trans $
f.trans (initial_seg.of_iso (order_iso.preimage equiv.ulift s).symm)⟩⟩
theorem lift_type_eq {α : Type u} {β : Type v} {r s} [is_well_order α r] [is_well_order β s] :
lift.{u (max v w)} (type r) = lift.{v (max u w)} (type s) ↔ nonempty (r ≃o s) :=
quotient.eq.trans
⟨λ ⟨f⟩, ⟨(order_iso.preimage equiv.ulift r).symm.trans $
f.trans (order_iso.preimage equiv.ulift s)⟩,
λ ⟨f⟩, ⟨(order_iso.preimage equiv.ulift r).trans $
f.trans (order_iso.preimage equiv.ulift s).symm⟩⟩
theorem lift_type_lt {α : Type u} {β : Type v} {r s} [is_well_order α r] [is_well_order β s] :
lift.{u (max v w)} (type r) < lift.{v (max u w)} (type s) ↔ nonempty (r ≺i s) :=
by haveI := @order_embedding.is_well_order _ _ (@equiv.ulift.{u (max v w)} α ⁻¹'o r)
r (order_iso.preimage equiv.ulift.{u (max v w)} r) _;
haveI := @order_embedding.is_well_order _ _ (@equiv.ulift.{v (max u w)} β ⁻¹'o s)
s (order_iso.preimage equiv.ulift.{v (max u w)} s) _; exact
⟨λ ⟨f⟩, ⟨(f.equiv_lt (order_iso.preimage equiv.ulift r).symm).lt_le
(initial_seg.of_iso (order_iso.preimage equiv.ulift s))⟩,
λ ⟨f⟩, ⟨(f.equiv_lt (order_iso.preimage equiv.ulift r)).lt_le
(initial_seg.of_iso (order_iso.preimage equiv.ulift s).symm)⟩⟩
@[simp] theorem lift_le {a b : ordinal} : lift.{u v} a ≤ lift b ↔ a ≤ b :=
induction_on a $ λ α r _, induction_on b $ λ β s _,
by rw ← lift_umax; exactI lift_type_le
@[simp] theorem lift_inj {a b : ordinal} : lift a = lift b ↔ a = b :=
by simp only [le_antisymm_iff, lift_le]
@[simp] theorem lift_lt {a b : ordinal} : lift a < lift b ↔ a < b :=
by simp only [lt_iff_le_not_le, lift_le]
@[simp] theorem lift_zero : lift 0 = 0 :=
quotient.sound ⟨(order_iso.preimage equiv.ulift _).trans
⟨pempty_equiv_pempty, λ a b, iff.rfl⟩⟩
theorem zero_eq_lift_type_empty : 0 = lift.{0 u} (@type empty empty_relation _) :=
by rw [← zero_eq_type_empty, lift_zero]
@[simp] theorem lift_one : lift 1 = 1 :=
quotient.sound ⟨(order_iso.preimage equiv.ulift _).trans
⟨punit_equiv_punit, λ a b, iff.rfl⟩⟩
theorem one_eq_lift_type_unit : 1 = lift.{0 u} (@type unit empty_relation _) :=
by rw [← one_eq_type_unit, lift_one]
@[simp] theorem lift_add (a b) : lift (a + b) = lift a + lift b :=
quotient.induction_on₂ a b $ λ ⟨α, r, _⟩ ⟨β, s, _⟩,
quotient.sound ⟨(order_iso.preimage equiv.ulift _).trans
(order_iso.sum_lex_congr (order_iso.preimage equiv.ulift _)
(order_iso.preimage equiv.ulift _)).symm⟩
@[simp] theorem lift_succ (a) : lift (succ a) = succ (lift a) :=
by unfold succ; simp only [lift_add, lift_one]
@[simp] theorem lift_card (a) : (card a).lift = card (lift a) :=
induction_on a $ λ α r _, rfl
theorem lift_down' {a : cardinal.{u}} {b : ordinal.{max u v}}
(h : card b ≤ a.lift) : ∃ a', lift a' = b :=
let ⟨c, e⟩ := cardinal.lift_down h in
quotient.induction_on c (λ α, induction_on b $ λ β s _ e', begin
resetI,
rw [mk_def, card_type, ← cardinal.lift_id'.{(max u v) u} (mk β),
← cardinal.lift_umax.{u v}, lift_mk_eq.{u (max u v) (max u v)}] at e',
cases e' with f,
have g := order_iso.preimage f s,
haveI := (g : ⇑f ⁻¹'o s ≼o s).is_well_order,
have := lift_type_eq.{u (max u v) (max u v)}.2 ⟨g⟩,
rw [lift_id, lift_umax.{u v}] at this,
exact ⟨_, this⟩
end) e
theorem lift_down {a : ordinal.{u}} {b : ordinal.{max u v}}
(h : b ≤ lift a) : ∃ a', lift a' = b :=
@lift_down' (card a) _ (by rw lift_card; exact card_le_card h)
theorem le_lift_iff {a : ordinal.{u}} {b : ordinal.{max u v}} :
b ≤ lift a ↔ ∃ a', lift a' = b ∧ a' ≤ a :=
⟨λ h, let ⟨a', e⟩ := lift_down h in ⟨a', e, lift_le.1 $ e.symm ▸ h⟩,
λ ⟨a', e, h⟩, e ▸ lift_le.2 h⟩
theorem lt_lift_iff {a : ordinal.{u}} {b : ordinal.{max u v}} :
b < lift a ↔ ∃ a', lift a' = b ∧ a' < a :=
⟨λ h, let ⟨a', e⟩ := lift_down (le_of_lt h) in
⟨a', e, lift_lt.1 $ e.symm ▸ h⟩,
λ ⟨a', e, h⟩, e ▸ lift_lt.2 h⟩
/-- `ω` is the first infinite ordinal, defined as the order type of `ℕ`. -/
def omega : ordinal.{u} := lift $ @type ℕ (<) _
localized "notation `ω` := ordinal.omega.{0}" in ordinal
theorem card_omega : card omega = cardinal.omega := rfl
@[simp] theorem lift_omega : lift omega = omega := lift_lift _
theorem add_le_add_right {a b : ordinal} : a ≤ b → ∀ c, a + c ≤ b + c :=
induction_on a $ λ α₁ r₁ hr₁, induction_on b $ λ α₂ r₂ hr₂ ⟨⟨⟨f, fo⟩, fi⟩⟩ c,
induction_on c $ λ β s hs, (@type_le' _ _ _ _
(@sum.lex.is_well_order _ _ _ _ hr₁ hs)
(@sum.lex.is_well_order _ _ _ _ hr₂ hs)).2
⟨⟨embedding.sum_congr f (embedding.refl _), λ a b, begin
split; intro H,
{ cases H; constructor; [rwa ← fo, assumption] },
{ cases a with a a; cases b with b b; cases H; constructor; [rwa fo, assumption] }
end⟩⟩
theorem le_add_left (a b : ordinal) : a ≤ b + a :=
by simpa only [zero_add] using add_le_add_right (zero_le b) a
theorem le_total (a b : ordinal) : a ≤ b ∨ b ≤ a :=
match lt_or_eq_of_le (le_add_left b a), lt_or_eq_of_le (le_add_right a b) with
| or.inr h, _ := by rw h; exact or.inl (le_add_right _ _)
| _, or.inr h := by rw h; exact or.inr (le_add_left _ _)
| or.inl h₁, or.inl h₂ := induction_on a (λ α₁ r₁ _,
induction_on b $ λ α₂ r₂ _ ⟨f⟩ ⟨g⟩, begin
resetI,
rw [← typein_top f, ← typein_top g, le_iff_lt_or_eq,
le_iff_lt_or_eq, typein_lt_typein, typein_lt_typein],
rcases trichotomous_of (sum.lex r₁ r₂) g.top f.top with h|h|h;
[exact or.inl (or.inl h), {left, right, rw h}, exact or.inr (or.inl h)]
end) h₁ h₂
end
instance : decidable_linear_order ordinal :=
{ le_total := le_total,
decidable_le := classical.dec_rel _,
..ordinal.partial_order }
@[simp] lemma typein_le_typein (r : α → α → Prop) [is_well_order α r] {x x' : α} :
typein r x ≤ typein r x' ↔ ¬r x' x :=
by rw [←not_lt, typein_lt_typein]
lemma enum_le_enum (r : α → α → Prop) [is_well_order α r] {o o' : ordinal}
(ho : o < type r) (ho' : o' < type r) : ¬r (enum r o' ho') (enum r o ho) ↔ o ≤ o' :=
by rw [←@not_lt _ _ o' o, enum_lt ho']
theorem lt_succ {a b : ordinal} : a < succ b ↔ a ≤ b :=
by rw [← not_le, succ_le, not_lt]
theorem add_lt_add_iff_left (a) {b c : ordinal} : a + b < a + c ↔ b < c :=
by rw [← not_le, ← not_le, add_le_add_iff_left]
theorem lt_of_add_lt_add_right {a b c : ordinal} : a + b < c + b → a < c :=
lt_imp_lt_of_le_imp_le (λ h, add_le_add_right h _)
@[simp] theorem succ_lt_succ {a b : ordinal} : succ a < succ b ↔ a < b :=
by rw [lt_succ, succ_le]
@[simp] theorem succ_le_succ {a b : ordinal} : succ a ≤ succ b ↔ a ≤ b :=
le_iff_le_iff_lt_iff_lt.2 succ_lt_succ
theorem succ_inj {a b : ordinal} : succ a = succ b ↔ a = b :=
by simp only [le_antisymm_iff, succ_le_succ]
theorem add_le_add_iff_right {a b : ordinal} (n : ℕ) : a + n ≤ b + n ↔ a ≤ b :=
by induction n with n ih; [rw [nat.cast_zero, add_zero, add_zero],
rw [← nat_cast_succ, add_succ, add_succ, succ_le_succ, ih]]
theorem add_right_cancel {a b : ordinal} (n : ℕ) : a + n = b + n ↔ a = b :=
by simp only [le_antisymm_iff, add_le_add_iff_right]
@[simp] theorem card_eq_zero {o} : card o = 0 ↔ o = 0 :=
⟨induction_on o $ λ α r _ h, begin
refine le_antisymm (le_of_not_lt $
λ hn, ne_zero_iff_nonempty.2 _ h) (zero_le _),
rw [← succ_le, succ_zero] at hn, cases hn with f,
exact ⟨f punit.star⟩
end, λ e, by simp only [e, card_zero]⟩
theorem type_ne_zero_iff_nonempty [is_well_order α r] : type r ≠ 0 ↔ nonempty α :=
(not_congr (@card_eq_zero (type r))).symm.trans ne_zero_iff_nonempty
@[simp] theorem type_eq_zero_iff_empty [is_well_order α r] : type r = 0 ↔ ¬ nonempty α :=
(not_iff_comm.1 type_ne_zero_iff_nonempty).symm
instance : zero_ne_one_class ordinal.{u} :=
{ zero := 0, one := 1, zero_ne_one :=
ne.symm $ type_ne_zero_iff_nonempty.2 ⟨punit.star⟩ }
theorem zero_lt_one : (0 : ordinal) < 1 :=
lt_iff_le_and_ne.2 ⟨zero_le _, zero_ne_one⟩
/-- The ordinal predecessor of `o` is `o'` if `o = succ o'`,
and `o` otherwise. -/
def pred (o : ordinal.{u}) : ordinal.{u} :=
if h : ∃ a, o = succ a then classical.some h else o
@[simp] theorem pred_succ (o) : pred (succ o) = o :=
by have h : ∃ a, succ o = succ a := ⟨_, rfl⟩;
simpa only [pred, dif_pos h] using (succ_inj.1 $ classical.some_spec h).symm
theorem pred_le_self (o) : pred o ≤ o :=
if h : ∃ a, o = succ a then let ⟨a, e⟩ := h in
by rw [e, pred_succ]; exact le_of_lt (lt_succ_self _)
else by rw [pred, dif_neg h]
theorem pred_eq_iff_not_succ {o} : pred o = o ↔ ¬ ∃ a, o = succ a :=
⟨λ e ⟨a, e'⟩, by rw [e', pred_succ] at e; exact ne_of_lt (lt_succ_self _) e,
λ h, dif_neg h⟩
theorem pred_lt_iff_is_succ {o} : pred o < o ↔ ∃ a, o = succ a :=
iff.trans (by simp only [le_antisymm_iff, pred_le_self, true_and, not_le])
(iff_not_comm.1 pred_eq_iff_not_succ).symm
theorem succ_pred_iff_is_succ {o} : succ (pred o) = o ↔ ∃ a, o = succ a :=
⟨λ e, ⟨_, e.symm⟩, λ ⟨a, e⟩, by simp only [e, pred_succ]⟩
theorem succ_lt_of_not_succ {o} (h : ¬ ∃ a, o = succ a) {b} : succ b < o ↔ b < o :=
⟨lt_trans (lt_succ_self _), λ l,
lt_of_le_of_ne (succ_le.2 l) (λ e, h ⟨_, e.symm⟩)⟩
theorem lt_pred {a b} : a < pred b ↔ succ a < b :=
if h : ∃ a, b = succ a then let ⟨c, e⟩ := h in
by rw [e, pred_succ, succ_lt_succ]
else by simp only [pred, dif_neg h, succ_lt_of_not_succ h]
theorem pred_le {a b} : pred a ≤ b ↔ a ≤ succ b :=
le_iff_le_iff_lt_iff_lt.2 lt_pred
@[simp] theorem lift_is_succ {o} : (∃ a, lift o = succ a) ↔ (∃ a, o = succ a) :=
⟨λ ⟨a, h⟩,
let ⟨b, e⟩ := lift_down $ show a ≤ lift o, from le_of_lt $
h.symm ▸ lt_succ_self _ in
⟨b, lift_inj.1 $ by rw [h, ← e, lift_succ]⟩,
λ ⟨a, h⟩, ⟨lift a, by simp only [h, lift_succ]⟩⟩
@[simp] theorem lift_pred (o) : lift (pred o) = pred (lift o) :=
if h : ∃ a, o = succ a then
by cases h with a e; simp only [e, pred_succ, lift_succ]
else by rw [pred_eq_iff_not_succ.2 h,
pred_eq_iff_not_succ.2 (mt lift_is_succ.1 h)]
/-- A limit ordinal is an ordinal which is not zero and not a successor. -/
def is_limit (o : ordinal) : Prop := o ≠ 0 ∧ ∀ a < o, succ a < o
theorem not_zero_is_limit : ¬ is_limit 0
| ⟨h, _⟩ := h rfl
theorem not_succ_is_limit (o) : ¬ is_limit (succ o)
| ⟨_, h⟩ := lt_irrefl _ (h _ (lt_succ_self _))
theorem not_succ_of_is_limit {o} (h : is_limit o) : ¬ ∃ a, o = succ a
| ⟨a, e⟩ := not_succ_is_limit a (e ▸ h)
theorem succ_lt_of_is_limit {o} (h : is_limit o) {a} : succ a < o ↔ a < o :=
⟨lt_trans (lt_succ_self _), h.2 _⟩
theorem le_succ_of_is_limit {o} (h : is_limit o) {a} : o ≤ succ a ↔ o ≤ a :=
le_iff_le_iff_lt_iff_lt.2 $ succ_lt_of_is_limit h
theorem limit_le {o} (h : is_limit o) {a} : o ≤ a ↔ ∀ x < o, x ≤ a :=
⟨λ h x l, le_trans (le_of_lt l) h,
λ H, (le_succ_of_is_limit h).1 $ le_of_not_lt $ λ hn,
not_lt_of_le (H _ hn) (lt_succ_self _)⟩
theorem lt_limit {o} (h : is_limit o) {a} : a < o ↔ ∃ x < o, a < x :=
by simpa only [not_ball, not_le] using not_congr (@limit_le _ h a)
@[simp] theorem lift_is_limit (o) : is_limit (lift o) ↔ is_limit o :=
and_congr (not_congr $ by simpa only [lift_zero] using @lift_inj o 0)
⟨λ H a h, lift_lt.1 $ by simpa only [lift_succ] using H _ (lift_lt.2 h),
λ H a h, let ⟨a', e⟩ := lift_down (le_of_lt h) in
by rw [← e, ← lift_succ, lift_lt];
rw [← e, lift_lt] at h; exact H a' h⟩
theorem is_limit.pos {o : ordinal} (h : is_limit o) : 0 < o :=
lt_of_le_of_ne (zero_le _) h.1.symm
theorem is_limit.one_lt {o : ordinal} (h : is_limit o) : 1 < o :=
by simpa only [succ_zero] using h.2 _ h.pos
theorem is_limit.nat_lt {o : ordinal} (h : is_limit o) : ∀ n : ℕ, (n : ordinal) < o
| 0 := h.pos
| (n+1) := h.2 _ (is_limit.nat_lt n)
theorem zero_or_succ_or_limit (o : ordinal) :
o = 0 ∨ (∃ a, o = succ a) ∨ is_limit o :=
if o0 : o = 0 then or.inl o0 else
if h : ∃ a, o = succ a then or.inr (or.inl h) else
or.inr $ or.inr ⟨o0, λ a, (succ_lt_of_not_succ h).2⟩
instance : is_well_order ordinal (<) := ⟨wf⟩
@[elab_as_eliminator] def limit_rec_on {C : ordinal → Sort*}
(o : ordinal) (H₁ : C 0) (H₂ : ∀ o, C o → C (succ o))
(H₃ : ∀ o, is_limit o → (∀ o' < o, C o') → C o) : C o :=
wf.fix (λ o IH,
if o0 : o = 0 then by rw o0; exact H₁ else
if h : ∃ a, o = succ a then
by rw ← succ_pred_iff_is_succ.2 h; exact
H₂ _ (IH _ $ pred_lt_iff_is_succ.2 h)
else H₃ _ ⟨o0, λ a, (succ_lt_of_not_succ h).2⟩ IH) o
@[simp] theorem limit_rec_on_zero {C} (H₁ H₂ H₃) : @limit_rec_on C 0 H₁ H₂ H₃ = H₁ :=
by rw [limit_rec_on, well_founded.fix_eq, dif_pos rfl]; refl
@[simp] theorem limit_rec_on_succ {C} (o H₁ H₂ H₃) :
@limit_rec_on C (succ o) H₁ H₂ H₃ = H₂ o (@limit_rec_on C o H₁ H₂ H₃) :=
begin
have h : ∃ a, succ o = succ a := ⟨_, rfl⟩,
rw [limit_rec_on, well_founded.fix_eq,
dif_neg (succ_ne_zero o), dif_pos h],
generalize : limit_rec_on._proof_2 (succ o) h = h₂,
generalize : limit_rec_on._proof_3 (succ o) h = h₃,
revert h₂ h₃, generalize e : pred (succ o) = o', intros,
rw pred_succ at e, subst o', refl
end
@[simp] theorem limit_rec_on_limit {C} (o H₁ H₂ H₃ h) :
@limit_rec_on C o H₁ H₂ H₃ = H₃ o h (λ x h, @limit_rec_on C x H₁ H₂ H₃) :=
by rw [limit_rec_on, well_founded.fix_eq,
dif_neg h.1, dif_neg (not_succ_of_is_limit h)]; refl
lemma has_succ_of_is_limit {α} {r : α → α → Prop} [wo : is_well_order α r]
(h : (type r).is_limit) (x : α) : ∃y, r x y :=
begin
use enum r (typein r x).succ (h.2 _ (typein_lt_type r x)),
convert (enum_lt (typein_lt_type r x) _).mpr (lt_succ_self _), rw [enum_typein]
end
lemma type_subrel_lt (o : ordinal.{u}) :
type (subrel (<) {o' : ordinal | o' < o}) = ordinal.lift.{u u+1} o :=
begin
refine quotient.induction_on o _,
rintro ⟨α, r, wo⟩, resetI, apply quotient.sound,
constructor, symmetry, refine (order_iso.preimage equiv.ulift r).trans (typein_iso r)
end
lemma mk_initial_seg (o : ordinal.{u}) :
#{o' : ordinal | o' < o} = cardinal.lift.{u u+1} o.card :=
by rw [lift_card, ←type_subrel_lt, card_type]
/-- A normal ordinal function is a strictly increasing function which is
order-continuous. -/
def is_normal (f : ordinal → ordinal) : Prop :=
(∀ o, f o < f (succ o)) ∧ ∀ o, is_limit o → ∀ a, f o ≤ a ↔ ∀ b < o, f b ≤ a
theorem is_normal.limit_le {f} (H : is_normal f) : ∀ {o}, is_limit o →
∀ {a}, f o ≤ a ↔ ∀ b < o, f b ≤ a := H.2
theorem is_normal.limit_lt {f} (H : is_normal f) {o} (h : is_limit o) {a} :
a < f o ↔ ∃ b < o, a < f b :=
not_iff_not.1 $ by simpa only [exists_prop, not_exists, not_and, not_lt] using H.2 _ h a
theorem is_normal.lt_iff {f} (H : is_normal f) {a b} : f a < f b ↔ a < b :=
strict_mono.lt_iff_lt $ λ a b,
limit_rec_on b (not.elim (not_lt_of_le $ zero_le _))
(λ b IH h, (lt_or_eq_of_le (lt_succ.1 h)).elim
(λ h, lt_trans (IH h) (H.1 _))
(λ e, e ▸ H.1 _))
(λ b l IH h, lt_of_lt_of_le (H.1 a)
((H.2 _ l _).1 (le_refl _) _ (l.2 _ h)))
theorem is_normal.le_iff {f} (H : is_normal f) {a b} : f a ≤ f b ↔ a ≤ b :=
le_iff_le_iff_lt_iff_lt.2 H.lt_iff
theorem is_normal.inj {f} (H : is_normal f) {a b} : f a = f b ↔ a = b :=
by simp only [le_antisymm_iff, H.le_iff]
theorem is_normal.le_self {f} (H : is_normal f) (a) : a ≤ f a :=
limit_rec_on a (zero_le _)
(λ a IH, succ_le.2 $ lt_of_le_of_lt IH (H.1 _))
(λ a l IH, (limit_le l).2 $ λ b h,
le_trans (IH b h) $ H.le_iff.2 $ le_of_lt h)
theorem is_normal.le_set {f} (H : is_normal f) (p : ordinal → Prop)
(p0 : ∃ x, p x) (S)
(H₂ : ∀ o, S ≤ o ↔ ∀ a, p a → a ≤ o) {o} :
f S ≤ o ↔ ∀ a, p a → f a ≤ o :=
⟨λ h a pa, le_trans (H.le_iff.2 ((H₂ _).1 (le_refl _) _ pa)) h,
λ h, begin
revert H₂, apply limit_rec_on S,
{ intro H₂,
cases p0 with x px,
have := le_zero.1 ((H₂ _).1 (zero_le _) _ px),
rw this at px, exact h _ px },
{ intros S _ H₂,
rcases not_ball.1 (mt (H₂ S).2 $ not_le_of_lt $ lt_succ_self _) with ⟨a, h₁, h₂⟩,
exact le_trans (H.le_iff.2 $ succ_le.2 $ not_le.1 h₂) (h _ h₁) },
{ intros S L _ H₂, apply (H.2 _ L _).2, intros a h',
rcases not_ball.1 (mt (H₂ a).2 (not_le.2 h')) with ⟨b, h₁, h₂⟩,
exact le_trans (H.le_iff.2 $ le_of_lt $ not_le.1 h₂) (h _ h₁) }
end⟩
theorem is_normal.le_set' {f} (H : is_normal f) (p : α → Prop) (g : α → ordinal)
(p0 : ∃ x, p x) (S)
(H₂ : ∀ o, S ≤ o ↔ ∀ a, p a → g a ≤ o) {o} :
f S ≤ o ↔ ∀ a, p a → f (g a) ≤ o :=
(H.le_set (λ x, ∃ y, p y ∧ x = g y)
(let ⟨x, px⟩ := p0 in ⟨_, _, px, rfl⟩) _
(λ o, (H₂ o).trans ⟨λ H a ⟨y, h1, h2⟩, h2.symm ▸ H y h1,
λ H a h1, H (g a) ⟨a, h1, rfl⟩⟩)).trans
⟨λ H a h, H (g a) ⟨a, h, rfl⟩, λ H a ⟨y, h1, h2⟩, h2.symm ▸ H y h1⟩
theorem is_normal.refl : is_normal id :=
⟨λ x, lt_succ_self _, λ o l a, limit_le l⟩
theorem is_normal.trans {f g} (H₁ : is_normal f) (H₂ : is_normal g) :
is_normal (λ x, f (g x)) :=
⟨λ x, H₁.lt_iff.2 (H₂.1 _),
λ o l a, H₁.le_set' (< o) g ⟨_, l.pos⟩ _ (λ c, H₂.2 _ l _)⟩
theorem is_normal.is_limit {f} (H : is_normal f) {o} (l : is_limit o) :
is_limit (f o) :=
⟨ne_of_gt $ lt_of_le_of_lt (zero_le _) $ H.lt_iff.2 l.pos,
λ a h, let ⟨b, h₁, h₂⟩ := (H.limit_lt l).1 h in
lt_of_le_of_lt (succ_le.2 h₂) (H.lt_iff.2 h₁)⟩
theorem add_le_of_limit {a b c : ordinal.{u}}
(h : is_limit b) : a + b ≤ c ↔ ∀ b' < b, a + b' ≤ c :=
⟨λ h b' l, le_trans (add_le_add_left (le_of_lt l) _) h,
λ H, le_of_not_lt $
induction_on a (λ α r _, induction_on b $ λ β s _ h H l, begin
resetI,
suffices : ∀ x : β, sum.lex r s (sum.inr x) (enum _ _ l),
{ cases enum _ _ l with x x,
{ cases this (enum s 0 h.pos) },
{ exact irrefl _ (this _) } },
intros x,
rw [← typein_lt_typein (sum.lex r s), typein_enum],
have := H _ (h.2 _ (typein_lt_type s x)),
rw [add_succ, succ_le] at this,
refine lt_of_le_of_lt (type_le'.2
⟨order_embedding.of_monotone (λ a, _) (λ a b, _)⟩) this,
{ rcases a with ⟨a | b, h⟩,
{ exact sum.inl a },
{ exact sum.inr ⟨b, by cases h; assumption⟩ } },
{ rcases a with ⟨a | a, h₁⟩; rcases b with ⟨b | b, h₂⟩; cases h₁; cases h₂;
rintro ⟨⟩; constructor; assumption }
end) h H⟩
theorem add_is_normal (a : ordinal) : is_normal ((+) a) :=
⟨λ b, (add_lt_add_iff_left a).2 (lt_succ_self _),
λ b l c, add_le_of_limit l⟩
theorem add_is_limit (a) {b} : is_limit b → is_limit (a + b) :=
(add_is_normal a).is_limit
def typein.principal_seg {α : Type u} (r : α → α → Prop) [is_well_order α r] :
@principal_seg α ordinal.{u} r (<) :=
⟨order_embedding.of_monotone (typein r)
(λ a b, (typein_lt_typein r).2), type r, λ b,
⟨λ h, ⟨enum r _ h, typein_enum r h⟩,
λ ⟨a, e⟩, e ▸ typein_lt_type _ _⟩⟩
@[simp] theorem typein.principal_seg_coe (r : α → α → Prop) [is_well_order α r] :
(typein.principal_seg r : α → ordinal) = typein r := rfl
/-- The minimal element of a nonempty family of ordinals -/
def min {ι} (I : nonempty ι) (f : ι → ordinal) : ordinal :=
wf.min (set.range f) (let ⟨i⟩ := I in ⟨_, set.mem_range_self i⟩)
theorem min_eq {ι} (I) (f : ι → ordinal) : ∃ i, min I f = f i :=
let ⟨i, e⟩ := wf.min_mem (set.range f) _ in ⟨i, e.symm⟩
theorem min_le {ι I} (f : ι → ordinal) (i) : min I f ≤ f i :=
le_of_not_gt $ wf.not_lt_min (set.range f) _ (set.mem_range_self i)
theorem le_min {ι I} {f : ι → ordinal} {a} : a ≤ min I f ↔ ∀ i, a ≤ f i :=
⟨λ h i, le_trans h (min_le _ _),
λ h, let ⟨i, e⟩ := min_eq I f in e.symm ▸ h i⟩
/-- The minimal element of a nonempty set of ordinals -/
def omin (S : set ordinal.{u}) (H : ∃ x, x ∈ S) : ordinal.{u} :=
@min.{(u+2) u} S (let ⟨x, px⟩ := H in ⟨⟨x, px⟩⟩) subtype.val
theorem omin_mem (S H) : omin S H ∈ S :=
let ⟨⟨i, h⟩, e⟩ := @min_eq S _ _ in
(show omin S H = i, from e).symm ▸ h
theorem le_omin {S H a} : a ≤ omin S H ↔ ∀ i ∈ S, a ≤ i :=
le_min.trans set_coe.forall
theorem omin_le {S H i} (h : i ∈ S) : omin S H ≤ i :=
le_omin.1 (le_refl _) _ h
@[simp] theorem lift_min {ι} (I) (f : ι → ordinal) : lift (min I f) = min I (lift ∘ f) :=
le_antisymm (le_min.2 $ λ a, lift_le.2 $ min_le _ a) $
let ⟨i, e⟩ := min_eq I (lift ∘ f) in
by rw e; exact lift_le.2 (le_min.2 $ λ j, lift_le.1 $
by have := min_le (lift ∘ f) j; rwa e at this)
def lift.initial_seg : @initial_seg ordinal.{u} ordinal.{max u v} (<) (<) :=
⟨⟨⟨lift.{u v}, λ a b, lift_inj.1⟩, λ a b, lift_lt.symm⟩,
λ a b h, lift_down (le_of_lt h)⟩
@[simp] theorem lift.initial_seg_coe : (lift.initial_seg : ordinal → ordinal) = lift := rfl
/-- `univ.{u v}` is the order type of the ordinals of `Type u` as a member
of `ordinal.{v}` (when `u < v`). It is an inaccessible cardinal. -/
def univ := lift.{(u+1) v} (@type ordinal.{u} (<) _)
theorem univ_id : univ.{u (u+1)} = @type ordinal.{u} (<) _ := lift_id _
@[simp] theorem lift_univ : lift.{_ w} univ.{u v} = univ.{u (max v w)} := lift_lift _
theorem univ_umax : univ.{u (max (u+1) v)} = univ.{u v} := congr_fun lift_umax _
def lift.principal_seg : @principal_seg ordinal.{u} ordinal.{max (u+1) v} (<) (<) :=
⟨↑lift.initial_seg.{u (max (u+1) v)}, univ.{u v}, begin
refine λ b, induction_on b _, introsI β s _,
rw [univ, ← lift_umax], split; intro h,
{ rw ← lift_id (type s) at h ⊢,
cases lift_type_lt.1 h with f, cases f with f a hf,
existsi a, revert hf,
apply induction_on a, intros α r _ hf,
refine lift_type_eq.{u (max (u+1) v) (max (u+1) v)}.2
⟨(order_iso.of_surjective (order_embedding.of_monotone _ _) _).symm⟩,
{ exact λ b, enum r (f b) ((hf _).2 ⟨_, rfl⟩) },
{ refine λ a b h, (typein_lt_typein r).1 _,
rw [typein_enum, typein_enum],
exact f.ord.1 h },
{ intro a', cases (hf _).1 (typein_lt_type _ a') with b e,
existsi b, simp, simp [e] } },
{ cases h with a e, rw [← e],
apply induction_on a, intros α r _,
exact lift_type_lt.{u (u+1) (max (u+1) v)}.2
⟨typein.principal_seg r⟩ }
end⟩
@[simp] theorem lift.principal_seg_coe :
(lift.principal_seg.{u v} : ordinal → ordinal) = lift.{u (max (u+1) v)} := rfl
@[simp] theorem lift.principal_seg_top : lift.principal_seg.top = univ := rfl
theorem lift.principal_seg_top' :
lift.principal_seg.{u (u+1)}.top = @type ordinal.{u} (<) _ :=
by simp only [lift.principal_seg_top, univ_id]
/-- `a - b` is the unique ordinal satisfying
`b + (a - b) = a` when `b ≤ a`. -/
def sub (a b : ordinal.{u}) : ordinal.{u} :=
omin {o | a ≤ b+o} ⟨a, le_add_left _ _⟩
instance : has_sub ordinal := ⟨sub⟩
theorem le_add_sub (a b : ordinal) : a ≤ b + (a - b) :=
omin_mem {o | a ≤ b+o} _
theorem sub_le {a b c : ordinal} : a - b ≤ c ↔ a ≤ b + c :=
⟨λ h, le_trans (le_add_sub a b) (add_le_add_left h _),
λ h, omin_le h⟩
theorem lt_sub {a b c : ordinal} : a < b - c ↔ c + a < b :=
lt_iff_lt_of_le_iff_le sub_le
theorem add_sub_cancel (a b : ordinal) : a + b - a = b :=
le_antisymm (sub_le.2 $ le_refl _)
((add_le_add_iff_left a).1 $ le_add_sub _ _)
theorem sub_eq_of_add_eq {a b c : ordinal} (h : a + b = c) : c - a = b :=
h ▸ add_sub_cancel _ _
theorem sub_le_self (a b : ordinal) : a - b ≤ a :=
sub_le.2 $ le_add_left _ _
theorem add_sub_cancel_of_le {a b : ordinal} (h : b ≤ a) : b + (a - b) = a :=
le_antisymm begin
rcases zero_or_succ_or_limit (a-b) with e|⟨c,e⟩|l,
{ simp only [e, add_zero, h] },
{ rw [e, add_succ, succ_le, ← lt_sub, e], apply lt_succ_self },
{ exact (add_le_of_limit l).2 (λ c l, le_of_lt (lt_sub.1 l)) }
end (le_add_sub _ _)
@[simp] theorem sub_zero (a : ordinal) : a - 0 = a :=
by simpa only [zero_add] using add_sub_cancel 0 a
@[simp] theorem zero_sub (a : ordinal) : 0 - a = 0 :=
by rw ← le_zero; apply sub_le_self
@[simp] theorem sub_self (a : ordinal) : a - a = 0 :=
by simpa only [add_zero] using add_sub_cancel a 0
theorem sub_eq_zero_iff_le {a b : ordinal} : a - b = 0 ↔ a ≤ b :=
⟨λ h, by simpa only [h, add_zero] using le_add_sub a b,
λ h, by rwa [← le_zero, sub_le, add_zero]⟩
theorem sub_sub (a b c : ordinal) : a - b - c = a - (b + c) :=
eq_of_forall_ge_iff $ λ d, by rw [sub_le, sub_le, sub_le, add_assoc]
theorem add_sub_add_cancel (a b c : ordinal) : a + b - (a + c) = b - c :=
by rw [← sub_sub, add_sub_cancel]
theorem sub_is_limit {a b} (l : is_limit a) (h : b < a) : is_limit (a - b) :=
⟨ne_of_gt $ lt_sub.2 $ by rwa add_zero,
λ c h, by rw [lt_sub, add_succ]; exact l.2 _ (lt_sub.1 h)⟩
@[simp] theorem one_add_omega : 1 + omega.{u} = omega :=
begin
refine le_antisymm _ (le_add_left _ _),
rw [omega, one_eq_lift_type_unit, ← lift_add, lift_le, type_add],
have : is_well_order unit empty_relation := by apply_instance,
refine ⟨order_embedding.collapse (order_embedding.of_monotone _ _)⟩,
{ apply sum.rec, exact λ _, 0, exact nat.succ },
{ intros a b, cases a; cases b; intro H; cases H with _ _ H _ _ H;
[cases H, exact nat.succ_pos _, exact nat.succ_lt_succ H] }
end
@[simp, priority 990]
theorem one_add_of_omega_le {o} (h : omega ≤ o) : 1 + o = o :=
by rw [← add_sub_cancel_of_le h, ← add_assoc, one_add_omega]
instance : monoid ordinal.{u} :=
{ mul := λ a b, quotient.lift_on₂ a b
(λ ⟨α, r, wo⟩ ⟨β, s, wo'⟩, ⟦⟨β × α, prod.lex s r, by exactI prod.lex.is_well_order⟩⟧
: Well_order → Well_order → ordinal) $
λ ⟨α₁, r₁, o₁⟩ ⟨α₂, r₂, o₂⟩ ⟨β₁, s₁, p₁⟩ ⟨β₂, s₂, p₂⟩ ⟨f⟩ ⟨g⟩,
quot.sound ⟨order_iso.prod_lex_congr g f⟩,
one := 1,
mul_assoc := λ a b c, quotient.induction_on₃ a b c $ λ ⟨α, r, _⟩ ⟨β, s, _⟩ ⟨γ, t, _⟩,
eq.symm $ quotient.sound ⟨⟨prod_assoc _ _ _, λ a b, begin
rcases a with ⟨⟨a₁, a₂⟩, a₃⟩,
rcases b with ⟨⟨b₁, b₂⟩, b₃⟩,
simp [prod.lex_def, and_or_distrib_left, or_assoc, and_assoc]
end⟩⟩,
mul_one := λ a, induction_on a $ λ α r _, quotient.sound
⟨⟨punit_prod _, λ a b, by rcases a with ⟨⟨⟨⟩⟩, a⟩; rcases b with ⟨⟨⟨⟩⟩, b⟩;
simp only [prod.lex_def, empty_relation, false_or];
simp only [eq_self_iff_true, true_and]; refl⟩⟩,
one_mul := λ a, induction_on a $ λ α r _, quotient.sound
⟨⟨prod_punit _, λ a b, by rcases a with ⟨a, ⟨⟨⟩⟩⟩; rcases b with ⟨b, ⟨⟨⟩⟩⟩;
simp only [prod.lex_def, empty_relation, and_false, or_false]; refl⟩⟩ }
@[simp] theorem type_mul {α β : Type u} (r : α → α → Prop) (s : β → β → Prop)
[is_well_order α r] [is_well_order β s] : type r * type s = type (prod.lex s r) := rfl
@[simp] theorem lift_mul (a b) : lift (a * b) = lift a * lift b :=
quotient.induction_on₂ a b $ λ ⟨α, r, _⟩ ⟨β, s, _⟩,
quotient.sound ⟨(order_iso.preimage equiv.ulift _).trans
(order_iso.prod_lex_congr (order_iso.preimage equiv.ulift _)
(order_iso.preimage equiv.ulift _)).symm⟩
@[simp] theorem card_mul (a b) : card (a * b) = card a * card b :=
quotient.induction_on₂ a b $ λ ⟨α, r, _⟩ ⟨β, s, _⟩,
mul_comm (mk β) (mk α)
@[simp] theorem mul_zero (a : ordinal) : a * 0 = 0 :=
induction_on a $ λ α _ _, by exactI
type_eq_zero_iff_empty.2 (λ ⟨⟨e, _⟩⟩, e.elim)
@[simp] theorem zero_mul (a : ordinal) : 0 * a = 0 :=
induction_on a $ λ α _ _, by exactI
type_eq_zero_iff_empty.2 (λ ⟨⟨_, e⟩⟩, e.elim)
theorem mul_add (a b c : ordinal) : a * (b + c) = a * b + a * c :=
quotient.induction_on₃ a b c $ λ ⟨α, r, _⟩ ⟨β, s, _⟩ ⟨γ, t, _⟩,
quotient.sound ⟨⟨sum_prod_distrib _ _ _, begin
rintro ⟨a₁|a₁, a₂⟩ ⟨b₁|b₁, b₂⟩; simp only [prod.lex_def,
sum.lex_inl_inl, sum.lex.sep, sum.lex_inr_inl, sum.lex_inr_inr,
sum_prod_distrib_apply_left, sum_prod_distrib_apply_right];
simp only [sum.inl.inj_iff, true_or, false_and, false_or]
end⟩⟩
@[simp] theorem mul_add_one (a b : ordinal) : a * (b + 1) = a * b + a :=
by simp only [mul_add, mul_one]
@[simp] theorem mul_succ (a b : ordinal) : a * succ b = a * b + a := mul_add_one _ _
theorem mul_le_mul_left {a b} (c : ordinal) : a ≤ b → c * a ≤ c * b :=
quotient.induction_on₃ a b c $ λ ⟨α, r, _⟩ ⟨β, s, _⟩ ⟨γ, t, _⟩ ⟨f⟩, begin
resetI,
refine type_le'.2 ⟨order_embedding.of_monotone
(λ a, (f a.1, a.2))
(λ a b h, _)⟩, clear_,
cases h with a₁ b₁ a₂ b₂ h' a b₁ b₂ h',
{ exact prod.lex.left _ _ (f.to_order_embedding.ord.1 h') },
{ exact prod.lex.right _ h' }
end
theorem mul_le_mul_right {a b} (c : ordinal) : a ≤ b → a * c ≤ b * c :=
quotient.induction_on₃ a b c $ λ ⟨α, r, _⟩ ⟨β, s, _⟩ ⟨γ, t, _⟩ ⟨f⟩, begin
resetI,
refine type_le'.2 ⟨order_embedding.of_monotone
(λ a, (a.1, f a.2))
(λ a b h, _)⟩,
cases h with a₁ b₁ a₂ b₂ h' a b₁ b₂ h',
{ exact prod.lex.left _ _ h' },
{ exact prod.lex.right _ (f.to_order_embedding.ord.1 h') }
end
theorem mul_le_mul {a b c d : ordinal} (h₁ : a ≤ c) (h₂ : b ≤ d) : a * b ≤ c * d :=
le_trans (mul_le_mul_left _ h₂) (mul_le_mul_right _ h₁)
private lemma mul_le_of_limit_aux {α β r s} [is_well_order α r] [is_well_order β s]
{c} (h : is_limit (type s)) (H : ∀ b' < type s, type r * b' ≤ c)
(l : c < type r * type s) : false :=
begin
suffices : ∀ a b, prod.lex s r (b, a) (enum _ _ l),
{ cases enum _ _ l with b a, exact irrefl _ (this _ _) },
intros a b,
rw [← typein_lt_typein (prod.lex s r), typein_enum],
have := H _ (h.2 _ (typein_lt_type s b)),
rw [mul_succ] at this,
have := lt_of_lt_of_le ((add_lt_add_iff_left _).2
(typein_lt_type _ a)) this,
refine lt_of_le_of_lt _ this,
refine (type_le'.2 _),
constructor,
refine order_embedding.of_monotone (λ a, _) (λ a b, _),
{ rcases a with ⟨⟨b', a'⟩, h⟩,
by_cases e : b = b',
{ refine sum.inr ⟨a', _⟩,
subst e, cases h with _ _ _ _ h _ _ _ h,
{ exact (irrefl _ h).elim },
{ exact h } },
{ refine sum.inl (⟨b', _⟩, a'),
cases h with _ _ _ _ h _ _ _ h,
{ exact h }, { exact (e rfl).elim } } },
{ rcases a with ⟨⟨b₁, a₁⟩, h₁⟩,
rcases b with ⟨⟨b₂, a₂⟩, h₂⟩,
intro h, by_cases e₁ : b = b₁; by_cases e₂ : b = b₂,
{ substs b₁ b₂, simpa only [subrel_val, prod.lex_def, @irrefl _ s _ b, true_and, false_or, eq_self_iff_true, dif_pos, sum.lex_inr_inr] using h },
{ subst b₁, simp only [subrel_val, prod.lex_def, e₂, prod.lex_def, dif_pos, subrel_val, eq_self_iff_true, or_false, dif_neg, not_false_iff, sum.lex_inr_inl, false_and] at h ⊢,
cases h₂; [exact asymm h h₂_h, exact e₂ rfl] },
{ simp only [e₂, dif_pos, eq_self_iff_true, dif_neg e₁, not_false_iff, sum.lex.sep] },
{ simpa only [dif_neg e₁, dif_neg e₂, prod.lex_def, subrel_val, subtype.mk_eq_mk, sum.lex_inl_inl] using h } }
end
theorem mul_le_of_limit {a b c : ordinal.{u}}
(h : is_limit b) : a * b ≤ c ↔ ∀ b' < b, a * b' ≤ c :=
⟨λ h b' l, le_trans (mul_le_mul_left _ (le_of_lt l)) h,
λ H, le_of_not_lt $ induction_on a (λ α r _, induction_on b $ λ β s _,
by exactI mul_le_of_limit_aux) h H⟩
theorem mul_is_normal {a : ordinal} (h : 0 < a) : is_normal ((*) a) :=
⟨λ b, by rw mul_succ; simpa only [add_zero] using (add_lt_add_iff_left (a*b)).2 h,
λ b l c, mul_le_of_limit l⟩
theorem lt_mul_of_limit {a b c : ordinal.{u}}
(h : is_limit c) : a < b * c ↔ ∃ c' < c, a < b * c' :=
by simpa only [not_ball, not_le] using not_congr (@mul_le_of_limit b c a h)
theorem mul_lt_mul_iff_left {a b c : ordinal} (a0 : 0 < a) : a * b < a * c ↔ b < c :=
(mul_is_normal a0).lt_iff
theorem mul_le_mul_iff_left {a b c : ordinal} (a0 : 0 < a) : a * b ≤ a * c ↔ b ≤ c :=
(mul_is_normal a0).le_iff
theorem mul_lt_mul_of_pos_left {a b c : ordinal}
(h : a < b) (c0 : 0 < c) : c * a < c * b :=
(mul_lt_mul_iff_left c0).2 h
theorem mul_pos {a b : ordinal} (h₁ : 0 < a) (h₂ : 0 < b) : 0 < a * b :=
by simpa only [mul_zero] using mul_lt_mul_of_pos_left h₂ h₁
theorem mul_ne_zero {a b : ordinal} : a ≠ 0 → b ≠ 0 → a * b ≠ 0 :=
by simpa only [pos_iff_ne_zero] using mul_pos
theorem le_of_mul_le_mul_left {a b c : ordinal}
(h : c * a ≤ c * b) (h0 : 0 < c) : a ≤ b :=
le_imp_le_of_lt_imp_lt (λ h', mul_lt_mul_of_pos_left h' h0) h
theorem mul_right_inj {a b c : ordinal} (a0 : 0 < a) : a * b = a * c ↔ b = c :=
(mul_is_normal a0).inj
theorem mul_is_limit {a b : ordinal}
(a0 : 0 < a) : is_limit b → is_limit (a * b) :=
(mul_is_normal a0).is_limit
theorem mul_is_limit_left {a b : ordinal}
(l : is_limit a) (b0 : 0 < b) : is_limit (a * b) :=
begin
rcases zero_or_succ_or_limit b with rfl|⟨b,rfl⟩|lb,
{ exact (lt_irrefl _).elim b0 },
{ rw mul_succ, exact add_is_limit _ l },
{ exact mul_is_limit l.pos lb }
end
/-- `a / b` is the unique ordinal `o` satisfying
`a = b * o + o'` with `o' < b`. -/
protected def div (a b : ordinal.{u}) : ordinal.{u} :=
if h : b = 0 then 0 else
omin {o | a < b * succ o} ⟨a, succ_le.1 $
by simpa only [succ_zero, one_mul] using mul_le_mul_right (succ a) (succ_le.2 (pos_iff_ne_zero.2 h))⟩
instance : has_div ordinal := ⟨ordinal.div⟩
@[simp] theorem div_zero (a : ordinal) : a / 0 = 0 := dif_pos rfl
@[nolint def_lemma doc_blame] -- TODO: This should be a theorem but Lean fails to synthesize the placeholder
def div_def (a) {b : ordinal} (h : b ≠ 0) :
a / b = omin {o | a < b * succ o} _ := dif_neg h
theorem lt_mul_succ_div (a) {b : ordinal} (h : b ≠ 0) : a < b * succ (a / b) :=
by rw div_def a h; exact omin_mem {o | a < b * succ o} _
theorem lt_mul_div_add (a) {b : ordinal} (h : b ≠ 0) : a < b * (a / b) + b :=
by simpa only [mul_succ] using lt_mul_succ_div a h
theorem div_le {a b c : ordinal} (b0 : b ≠ 0) : a / b ≤ c ↔ a < b * succ c :=
⟨λ h, lt_of_lt_of_le (lt_mul_succ_div a b0) (mul_le_mul_left _ $ succ_le_succ.2 h),
λ h, by rw div_def a b0; exact omin_le h⟩
theorem lt_div {a b c : ordinal} (c0 : c ≠ 0) : a < b / c ↔ c * succ a ≤ b :=
by rw [← not_le, div_le c0, not_lt]
theorem le_div {a b c : ordinal} (c0 : c ≠ 0) :
a ≤ b / c ↔ c * a ≤ b :=
begin
apply limit_rec_on a,
{ simp only [mul_zero, zero_le] },
{ intros, rw [succ_le, lt_div c0] },
{ simp only [mul_le_of_limit, limit_le, iff_self, forall_true_iff] {contextual := tt} }
end
theorem div_lt {a b c : ordinal} (b0 : b ≠ 0) :
a / b < c ↔ a < b * c :=
lt_iff_lt_of_le_iff_le $ le_div b0
theorem div_le_of_le_mul {a b c : ordinal} (h : a ≤ b * c) : a / b ≤ c :=
if b0 : b = 0 then by simp only [b0, div_zero, zero_le] else
(div_le b0).2 $ lt_of_le_of_lt h $
mul_lt_mul_of_pos_left (lt_succ_self _) (pos_iff_ne_zero.2 b0)
theorem mul_lt_of_lt_div {a b c : ordinal} : a < b / c → c * a < b :=
lt_imp_lt_of_le_imp_le div_le_of_le_mul
@[simp] theorem zero_div (a : ordinal) : 0 / a = 0 :=
le_zero.1 $ div_le_of_le_mul $ zero_le _
theorem mul_div_le (a b : ordinal) : b * (a / b) ≤ a :=
if b0 : b = 0 then by simp only [b0, zero_mul, zero_le] else (le_div b0).1 (le_refl _)
theorem mul_add_div (a) {b : ordinal} (b0 : b ≠ 0) (c) : (b * a + c) / b = a + c / b :=
begin
apply le_antisymm,
{ apply (div_le b0).2,
rw [mul_succ, mul_add, add_assoc, add_lt_add_iff_left],
apply lt_mul_div_add _ b0 },
{ rw [le_div b0, mul_add, add_le_add_iff_left],
apply mul_div_le }
end
theorem div_eq_zero_of_lt {a b : ordinal} (h : a < b) : a / b = 0 :=
by rw [← le_zero, div_le $ pos_iff_ne_zero.1 $ lt_of_le_of_lt (zero_le _) h];
simpa only [succ_zero, mul_one] using h
@[simp] theorem mul_div_cancel (a) {b : ordinal} (b0 : b ≠ 0) : b * a / b = a :=
by simpa only [add_zero, zero_div] using mul_add_div a b0 0
@[simp] theorem div_one (a : ordinal) : a / 1 = a :=
by simpa only [one_mul] using mul_div_cancel a one_ne_zero
@[simp] theorem div_self {a : ordinal} (h : a ≠ 0) : a / a = 1 :=
by simpa only [mul_one] using mul_div_cancel 1 h
theorem mul_sub (a b c : ordinal) : a * (b - c) = a * b - a * c :=
if a0 : a = 0 then by simp only [a0, zero_mul, sub_self] else
eq_of_forall_ge_iff $ λ d,
by rw [sub_le, ← le_div a0, sub_le, ← le_div a0, mul_add_div _ a0]
theorem is_limit_add_iff {a b} : is_limit (a + b) ↔ is_limit b ∨ (b = 0 ∧ is_limit a) :=
begin
split; intro h,
{ by_cases h' : b = 0,
{ rw [h', add_zero] at h, right, exact ⟨h', h⟩ },
left, rw [←add_sub_cancel a b], apply sub_is_limit h,
suffices : a + 0 < a + b, simpa only [add_zero],
rwa [add_lt_add_iff_left, pos_iff_ne_zero] },
rcases h with h|⟨rfl, h⟩, exact add_is_limit a h, simpa only [add_zero]
end
/-- Divisibility is defined by right multiplication:
`a ∣ b` if there exists `c` such that `b = a * c`. -/
instance : has_dvd ordinal := ⟨λ a b, ∃ c, b = a * c⟩
theorem dvd_def {a b : ordinal} : a ∣ b ↔ ∃ c, b = a * c := iff.rfl
theorem dvd_mul (a b : ordinal) : a ∣ a * b := ⟨_, rfl⟩
theorem dvd_trans : ∀ {a b c : ordinal}, a ∣ b → b ∣ c → a ∣ c
| a _ _ ⟨b, rfl⟩ ⟨c, rfl⟩ := ⟨b * c, mul_assoc _ _ _⟩
theorem dvd_mul_of_dvd {a b : ordinal} (c) (h : a ∣ b) : a ∣ b * c :=
dvd_trans h (dvd_mul _ _)
theorem dvd_add_iff : ∀ {a b c : ordinal}, a ∣ b → (a ∣ b + c ↔ a ∣ c)
| a _ c ⟨b, rfl⟩ :=
⟨λ ⟨d, e⟩, ⟨d - b, by rw [mul_sub, ← e, add_sub_cancel]⟩,
λ ⟨d, e⟩, by rw [e, ← mul_add]; apply dvd_mul⟩
theorem dvd_add {a b c : ordinal} (h₁ : a ∣ b) : a ∣ c → a ∣ b + c :=
(dvd_add_iff h₁).2
theorem dvd_zero (a : ordinal) : a ∣ 0 := ⟨_, (mul_zero _).symm⟩
theorem zero_dvd {a : ordinal} : 0 ∣ a ↔ a = 0 :=
⟨λ ⟨h, e⟩, by simp only [e, zero_mul], λ e, e.symm ▸ dvd_zero _⟩
theorem one_dvd (a : ordinal) : 1 ∣ a := ⟨a, (one_mul _).symm⟩
theorem div_mul_cancel : ∀ {a b : ordinal}, a ≠ 0 → a ∣ b → a * (b / a) = b
| a _ a0 ⟨b, rfl⟩ := by rw [mul_div_cancel _ a0]
theorem le_of_dvd : ∀ {a b : ordinal}, b ≠ 0 → a ∣ b → a ≤ b
| a _ b0 ⟨b, rfl⟩ := by simpa only [mul_one] using mul_le_mul_left a
(one_le_iff_ne_zero.2 (λ h : b = 0, by simpa only [h, mul_zero] using b0))
theorem dvd_antisymm {a b : ordinal} (h₁ : a ∣ b) (h₂ : b ∣ a) : a = b :=
if a0 : a = 0 then by subst a; exact (zero_dvd.1 h₁).symm else
if b0 : b = 0 then by subst b; exact zero_dvd.1 h₂ else
le_antisymm (le_of_dvd b0 h₁) (le_of_dvd a0 h₂)
/-- `a % b` is the unique ordinal `o'` satisfying
`a = b * o + o'` with `o' < b`. -/
instance : has_mod ordinal := ⟨λ a b, a - b * (a / b)⟩
theorem mod_def (a b : ordinal) : a % b = a - b * (a / b) := rfl
@[simp] theorem mod_zero (a : ordinal) : a % 0 = a :=
by simp only [mod_def, div_zero, zero_mul, sub_zero]
theorem mod_eq_of_lt {a b : ordinal} (h : a < b) : a % b = a :=
by simp only [mod_def, div_eq_zero_of_lt h, mul_zero, sub_zero]
@[simp] theorem zero_mod (b : ordinal) : 0 % b = 0 :=
by simp only [mod_def, zero_div, mul_zero, sub_self]
theorem div_add_mod (a b : ordinal) : b * (a / b) + a % b = a :=
add_sub_cancel_of_le $ mul_div_le _ _
theorem mod_lt (a) {b : ordinal} (h : b ≠ 0) : a % b < b :=
(add_lt_add_iff_left (b * (a / b))).1 $
by rw div_add_mod; exact lt_mul_div_add a h
@[simp] theorem mod_self (a : ordinal) : a % a = 0 :=
if a0 : a = 0 then by simp only [a0, zero_mod] else
by simp only [mod_def, div_self a0, mul_one, sub_self]
@[simp] theorem mod_one (a : ordinal) : a % 1 = 0 :=
by simp only [mod_def, div_one, one_mul, sub_self]
end ordinal
namespace cardinal
open ordinal
/-- The ordinal corresponding to a cardinal `c` is the least ordinal
whose cardinal is `c`. -/
def ord (c : cardinal) : ordinal :=
begin
let ι := λ α, {r // is_well_order α r},
have : Π α, ι α := λ α, ⟨well_ordering_rel, by apply_instance⟩,
let F := λ α, ordinal.min ⟨this _⟩ (λ i:ι α, ⟦⟨α, i.1, i.2⟩⟧),
refine quot.lift_on c F _,
suffices : ∀ {α β}, α ≈ β → F α ≤ F β,
from λ α β h, le_antisymm (this h) (this (setoid.symm h)),
intros α β h, cases h with f, refine ordinal.le_min.2 (λ i, _),
haveI := @order_embedding.is_well_order _ _
(f ⁻¹'o i.1) _ ↑(order_iso.preimage f i.1) i.2,
rw ← show type (f ⁻¹'o i.1) = ⟦⟨β, i.1, i.2⟩⟧, from
quot.sound ⟨order_iso.preimage f i.1⟩,
exact ordinal.min_le (λ i:ι α, ⟦⟨α, i.1, i.2⟩⟧) ⟨_, _⟩
end
@[nolint def_lemma doc_blame] -- TODO: This should be a theorem but Lean fails to synthesize the placeholder
def ord_eq_min (α : Type u) : ord (mk α) =
@ordinal.min _ _ (λ i:{r // is_well_order α r}, ⟦⟨α, i.1, i.2⟩⟧) := rfl
theorem ord_eq (α) : ∃ (r : α → α → Prop) [wo : is_well_order α r],
ord (mk α) = @type α r wo :=
let ⟨⟨r, wo⟩, h⟩ := @ordinal.min_eq {r // is_well_order α r}
⟨⟨well_ordering_rel, by apply_instance⟩⟩
(λ i:{r // is_well_order α r}, ⟦⟨α, i.1, i.2⟩⟧) in
⟨r, wo, h⟩
theorem ord_le_type (r : α → α → Prop) [is_well_order α r] : ord (mk α) ≤ ordinal.type r :=
@ordinal.min_le {r // is_well_order α r}
⟨⟨well_ordering_rel, by apply_instance⟩⟩
(λ i:{r // is_well_order α r}, ⟦⟨α, i.1, i.2⟩⟧) ⟨r, _⟩
theorem ord_le {c o} : ord c ≤ o ↔ c ≤ o.card :=
quotient.induction_on c $ λ α, induction_on o $ λ β s _,
let ⟨r, _, e⟩ := ord_eq α in begin
resetI, simp only [mk_def, card_type], split; intro h,
{ rw e at h, exact let ⟨f⟩ := h in ⟨f.to_embedding⟩ },
{ cases h with f,
have g := order_embedding.preimage f s,
haveI := order_embedding.is_well_order g,
exact le_trans (ord_le_type _) (type_le'.2 ⟨g⟩) }
end
theorem lt_ord {c o} : o < ord c ↔ o.card < c :=
by rw [← not_le, ← not_le, ord_le]
@[simp] theorem card_ord (c) : (ord c).card = c :=
quotient.induction_on c $ λ α,
let ⟨r, _, e⟩ := ord_eq α in by simp only [mk_def, e, card_type]
theorem ord_card_le (o : ordinal) : o.card.ord ≤ o :=
ord_le.2 (le_refl _)
lemma lt_ord_succ_card (o : ordinal) : o < o.card.succ.ord :=
by { rw [lt_ord], apply cardinal.lt_succ_self }
@[simp] theorem ord_le_ord {c₁ c₂} : ord c₁ ≤ ord c₂ ↔ c₁ ≤ c₂ :=
by simp only [ord_le, card_ord]
@[simp] theorem ord_lt_ord {c₁ c₂} : ord c₁ < ord c₂ ↔ c₁ < c₂ :=
by simp only [lt_ord, card_ord]
@[simp] theorem ord_zero : ord 0 = 0 :=
le_antisymm (ord_le.2 $ zero_le _) (ordinal.zero_le _)
@[simp] theorem ord_nat (n : ℕ) : ord n = n :=
le_antisymm (ord_le.2 $ by simp only [card_nat]) $ begin
induction n with n IH,
{ apply ordinal.zero_le },
{ exact (@ordinal.succ_le n _).2 (lt_of_le_of_lt IH $
ord_lt_ord.2 $ nat_cast_lt.2 (nat.lt_succ_self n)) }
end
@[simp] theorem lift_ord (c) : (ord c).lift = ord (lift c) :=
eq_of_forall_ge_iff $ λ o, le_iff_le_iff_lt_iff_lt.2 $ begin
split; intro h,
{ rcases ordinal.lt_lift_iff.1 h with ⟨a, e, h⟩,
rwa [← e, lt_ord, ← lift_card, lift_lt, ← lt_ord] },
{ rw lt_ord at h,
rcases lift_down' (le_of_lt h) with ⟨o, rfl⟩,
rw [← lift_card, lift_lt] at h,
rwa [ordinal.lift_lt, lt_ord] }
end
lemma mk_ord_out (c : cardinal) : mk c.ord.out.α = c :=
by rw [←card_type c.ord.out.r, type_out, card_ord]
lemma card_typein_lt (r : α → α → Prop) [is_well_order α r] (x : α)
(h : ord (mk α) = type r) : card (typein r x) < mk α :=
by { rw [←ord_lt_ord, h], refine lt_of_le_of_lt (ord_card_le _) (typein_lt_type r x) }
lemma card_typein_out_lt (c : cardinal) (x : c.ord.out.α) : card (typein c.ord.out.r x) < c :=
by { convert card_typein_lt c.ord.out.r x _, rw [mk_ord_out], rw [type_out, mk_ord_out] }
lemma ord_injective : injective ord :=
by { intros c c' h, rw [←card_ord c, ←card_ord c', h] }
def ord.order_embedding : @order_embedding cardinal ordinal (<) (<) :=
order_embedding.of_monotone cardinal.ord $ λ a b, cardinal.ord_lt_ord.2
@[simp] theorem ord.order_embedding_coe :
(ord.order_embedding : cardinal → ordinal) = ord := rfl
/-- The cardinal `univ` is the cardinality of ordinal `univ`, or
equivalently the cardinal of `ordinal.{u}`, or `cardinal.{u}`,
as an element of `cardinal.{v}` (when `u < v`). -/
def univ := lift.{(u+1) v} (mk ordinal)
theorem univ_id : univ.{u (u+1)} = mk ordinal := lift_id _
@[simp] theorem lift_univ : lift.{_ w} univ.{u v} = univ.{u (max v w)} := lift_lift _
theorem univ_umax : univ.{u (max (u+1) v)} = univ.{u v} := congr_fun lift_umax _
theorem lift_lt_univ (c : cardinal) : lift.{u (u+1)} c < univ.{u (u+1)} :=
by simpa only [lift.principal_seg_coe, lift_ord, lift_succ, ord_le, succ_le] using le_of_lt
(lift.principal_seg.{u (u+1)}.lt_top (succ c).ord)
theorem lift_lt_univ' (c : cardinal) : lift.{u (max (u+1) v)} c < univ.{u v} :=
by simpa only [lift_lift, lift_univ, univ_umax] using
lift_lt.{_ (max (u+1) v)}.2 (lift_lt_univ c)
@[simp] theorem ord_univ : ord univ.{u v} = ordinal.univ.{u v} :=
le_antisymm (ord_card_le _) $ le_of_forall_lt $ λ o h,
lt_ord.2 begin
rcases lift.principal_seg.{u v}.down'.1
(by simpa only [lift.principal_seg_coe] using h) with ⟨o', rfl⟩,
simp only [lift.principal_seg_coe], rw [← lift_card],
apply lift_lt_univ'
end
theorem lt_univ {c} : c < univ.{u (u+1)} ↔ ∃ c', c = lift.{u (u+1)} c' :=
⟨λ h, begin
have := ord_lt_ord.2 h,
rw ord_univ at this,
cases lift.principal_seg.{u (u+1)}.down'.1
(by simpa only [lift.principal_seg_top]) with o e,
have := card_ord c,
rw [← e, lift.principal_seg_coe, ← lift_card] at this,
exact ⟨_, this.symm⟩
end, λ ⟨c', e⟩, e.symm ▸ lift_lt_univ _⟩
theorem lt_univ' {c} : c < univ.{u v} ↔ ∃ c', c = lift.{u (max (u+1) v)} c' :=
⟨λ h, let ⟨a, e, h'⟩ := lt_lift_iff.1 h in begin
rw [← univ_id] at h',
rcases lt_univ.{u}.1 h' with ⟨c', rfl⟩,
exact ⟨c', by simp only [e.symm, lift_lift]⟩
end, λ ⟨c', e⟩, e.symm ▸ lift_lt_univ' _⟩
end cardinal
namespace ordinal
@[simp] theorem card_univ : card univ = cardinal.univ := rfl
/-- The supremum of a family of ordinals -/
def sup {ι} (f : ι → ordinal) : ordinal :=
omin {c | ∀ i, f i ≤ c}
⟨(sup (cardinal.succ ∘ card ∘ f)).ord, λ i, le_of_lt $
cardinal.lt_ord.2 (lt_of_lt_of_le (cardinal.lt_succ_self _) (le_sup _ _))⟩
theorem le_sup {ι} (f : ι → ordinal) : ∀ i, f i ≤ sup f :=
omin_mem {c | ∀ i, f i ≤ c} _
theorem sup_le {ι} {f : ι → ordinal} {a} : sup f ≤ a ↔ ∀ i, f i ≤ a :=
⟨λ h i, le_trans (le_sup _ _) h, λ h, omin_le h⟩
theorem lt_sup {ι} {f : ι → ordinal} {a} : a < sup f ↔ ∃ i, a < f i :=
by simpa only [not_forall, not_le] using not_congr (@sup_le _ f a)
theorem is_normal.sup {f} (H : is_normal f)
{ι} {g : ι → ordinal} (h : nonempty ι) : f (sup g) = sup (f ∘ g) :=
eq_of_forall_ge_iff $ λ a,
by rw [sup_le, comp, H.le_set' (λ_:ι, true) g (let ⟨i⟩ := h in ⟨i, ⟨⟩⟩)];
intros; simp only [sup_le, true_implies_iff]
theorem sup_ord {ι} (f : ι → cardinal) : sup (λ i, (f i).ord) = (cardinal.sup f).ord :=
eq_of_forall_ge_iff $ λ a, by simp only [sup_le, cardinal.ord_le, cardinal.sup_le]
lemma sup_succ {ι} (f : ι → ordinal) : sup (λ i, succ (f i)) ≤ succ (sup f) :=
by { rw [ordinal.sup_le], intro i, rw ordinal.succ_le_succ, apply ordinal.le_sup }
lemma unbounded_range_of_sup_ge {α β : Type u} (r : α → α → Prop) [is_well_order α r] (f : β → α)
(h : sup.{u u} (typein r ∘ f) ≥ type r) : unbounded r (range f) :=
begin
apply (not_bounded_iff _).mp, rintro ⟨x, hx⟩, apply not_lt_of_ge h,
refine lt_of_le_of_lt _ (typein_lt_type r x), rw [sup_le], intro y,
apply le_of_lt, rw typein_lt_typein, apply hx, apply mem_range_self
end
/-- The supremum of a family of ordinals indexed by the set
of ordinals less than some `o : ordinal.{u}`.
(This is not a special case of `sup` over the subtype,
because `{a // a < o} : Type (u+1)` and `sup` only works over
families in `Type u`.) -/
def bsup (o : ordinal.{u}) : (Π a < o, ordinal.{max u v}) → ordinal.{max u v} :=
match o, o.out, o.out_eq with
| _, ⟨α, r, _⟩, rfl, f := by exactI sup (λ a, f (typein r a) (typein_lt_type _ _))
end
theorem bsup_le {o f a} : bsup.{u v} o f ≤ a ↔ ∀ i h, f i h ≤ a :=
match o, o.out, o.out_eq, f :
∀ o w (e : ⟦w⟧ = o) (f : Π (a : ordinal.{u}), a < o → ordinal.{(max u v)}),
bsup._match_1 o w e f ≤ a ↔ ∀ i h, f i h ≤ a with
| _, ⟨α, r, _⟩, rfl, f := by rw [bsup._match_1, sup_le]; exactI
⟨λ H i h, by simpa only [typein_enum] using H (enum r i h), λ H b, H _ _⟩
end
theorem bsup_type (r : α → α → Prop) [is_well_order α r] (f) :
bsup (type r) f = sup (λ a, f (typein r a) (typein_lt_type _ _)) :=
eq_of_forall_ge_iff $ λ o,
by rw [bsup_le, sup_le]; exact
⟨λ H b, H _ _, λ H i h, by simpa only [typein_enum] using H (enum r i h)⟩
theorem le_bsup {o} (f : Π a < o, ordinal) (i h) : f i h ≤ bsup o f :=
bsup_le.1 (le_refl _) _ _
theorem lt_bsup {o : ordinal} {f : Π a < o, ordinal}
(hf : ∀{a a'} (ha : a < o) (ha' : a' < o), a < a' → f a ha < f a' ha')
(ho : o.is_limit) (i h) : f i h < bsup o f :=
lt_of_lt_of_le (hf _ _ $ lt_succ_self i) (le_bsup f i.succ $ ho.2 _ h)
theorem bsup_id {o} (ho : is_limit o) : bsup.{u u} o (λ x _, x) = o :=
begin
apply le_antisymm, rw [bsup_le], intro i, apply le_of_lt,
rw [←not_lt], intro h, apply lt_irrefl (bsup.{u u} o (λ x _, x)),
apply lt_of_le_of_lt _ (lt_bsup _ ho _ h), refl, intros, assumption
end
theorem is_normal.bsup {f} (H : is_normal f)
{o : ordinal} : ∀ (g : Π a < o, ordinal) (h : o ≠ 0),
f (bsup o g) = bsup o (λ a h, f (g a h)) :=
induction_on o $ λ α r _ g h,
by resetI; rw [bsup_type,
H.sup (type_ne_zero_iff_nonempty.1 h), bsup_type]
theorem is_normal.bsup_eq {f} (H : is_normal f) {o : ordinal} (h : is_limit o) :
bsup.{u} o (λx _, f x) = f o :=
by { rw [←is_normal.bsup.{u u} H (λ x _, x) h.1, bsup_id h] }
/-- The ordinal exponential, defined by transfinite recursion. -/
def power (a b : ordinal) : ordinal :=
if a = 0 then 1 - b else
limit_rec_on b 1 (λ _ IH, IH * a) (λ b _, bsup.{u u} b)
instance : has_pow ordinal ordinal := ⟨power⟩
local infixr ^ := @pow ordinal ordinal ordinal.has_pow
theorem zero_power' (a : ordinal) : 0 ^ a = 1 - a :=
by simp only [pow, power, if_pos rfl]
@[simp] theorem zero_power {a : ordinal} (a0 : a ≠ 0) : 0 ^ a = 0 :=
by rwa [zero_power', sub_eq_zero_iff_le, one_le_iff_ne_zero]
@[simp] theorem power_zero (a : ordinal) : a ^ 0 = 1 :=
by by_cases a = 0; [simp only [pow, power, if_pos h, sub_zero],
simp only [pow, power, if_neg h, limit_rec_on_zero]]
@[simp] theorem power_succ (a b : ordinal) : a ^ succ b = a ^ b * a :=
if h : a = 0 then by subst a; simp only [zero_power (succ_ne_zero _), mul_zero]
else by simp only [pow, power, limit_rec_on_succ, if_neg h]
theorem power_limit {a b : ordinal} (a0 : a ≠ 0) (h : is_limit b) :
a ^ b = bsup.{u u} b (λ c _, a ^ c) :=
by simp only [pow, power, if_neg a0]; rw limit_rec_on_limit _ _ _ _ h; refl
theorem power_le_of_limit {a b c : ordinal} (a0 : a ≠ 0) (h : is_limit b) :
a ^ b ≤ c ↔ ∀ b' < b, a ^ b' ≤ c :=
by rw [power_limit a0 h, bsup_le]
theorem lt_power_of_limit {a b c : ordinal} (b0 : b ≠ 0) (h : is_limit c) :
a < b ^ c ↔ ∃ c' < c, a < b ^ c' :=
by rw [← not_iff_not, not_exists]; simp only [not_lt, power_le_of_limit b0 h, exists_prop, not_and]
@[simp] theorem power_one (a : ordinal) : a ^ 1 = a :=
by rw [← succ_zero, power_succ]; simp only [power_zero, one_mul]
@[simp] theorem one_power (a : ordinal) : 1 ^ a = 1 :=
begin
apply limit_rec_on a,
{ simp only [power_zero] },
{ intros _ ih, simp only [power_succ, ih, mul_one] },
refine λ b l IH, eq_of_forall_ge_iff (λ c, _),
rw [power_le_of_limit one_ne_zero l],
exact ⟨λ H, by simpa only [power_zero] using H 0 l.pos,
λ H b' h, by rwa IH _ h⟩,
end
theorem power_pos {a : ordinal} (b)
(a0 : 0 < a) : 0 < a ^ b :=
begin
have h0 : 0 < a ^ 0, {simp only [power_zero, zero_lt_one]},
apply limit_rec_on b,
{ exact h0 },
{ intros b IH, rw [power_succ],
exact mul_pos IH a0 },
{ exact λ b l _, (lt_power_of_limit (pos_iff_ne_zero.1 a0) l).2
⟨0, l.pos, h0⟩ },
end
theorem power_ne_zero {a : ordinal} (b)
(a0 : a ≠ 0) : a ^ b ≠ 0 :=
pos_iff_ne_zero.1 $ power_pos b $ pos_iff_ne_zero.2 a0
theorem power_is_normal {a : ordinal} (h : 1 < a) : is_normal ((^) a) :=
have a0 : 0 < a, from lt_trans zero_lt_one h,
⟨λ b, by simpa only [mul_one, power_succ] using
(mul_lt_mul_iff_left (power_pos b a0)).2 h,
λ b l c, power_le_of_limit (ne_of_gt a0) l⟩
theorem power_lt_power_iff_right {a b c : ordinal}
(a1 : 1 < a) : a ^ b < a ^ c ↔ b < c :=
(power_is_normal a1).lt_iff
theorem power_le_power_iff_right {a b c : ordinal}
(a1 : 1 < a) : a ^ b ≤ a ^ c ↔ b ≤ c :=
(power_is_normal a1).le_iff
theorem power_right_inj {a b c : ordinal}
(a1 : 1 < a) : a ^ b = a ^ c ↔ b = c :=
(power_is_normal a1).inj
theorem power_is_limit {a b : ordinal}
(a1 : 1 < a) : is_limit b → is_limit (a ^ b) :=
(power_is_normal a1).is_limit
theorem power_is_limit_left {a b : ordinal}
(l : is_limit a) (hb : b ≠ 0) : is_limit (a ^ b) :=
begin
rcases zero_or_succ_or_limit b with e|⟨b,rfl⟩|l',
{ exact absurd e hb },
{ rw power_succ,
exact mul_is_limit (power_pos _ l.pos) l },
{ exact power_is_limit l.one_lt l' }
end
theorem power_le_power_right {a b c : ordinal}
(h₁ : 0 < a) (h₂ : b ≤ c) : a ^ b ≤ a ^ c :=
begin
cases lt_or_eq_of_le (one_le_iff_pos.2 h₁) with h₁ h₁,
{ exact (power_le_power_iff_right h₁).2 h₂ },
{ subst a, simp only [one_power] }
end
theorem power_le_power_left {a b : ordinal} (c)
(ab : a ≤ b) : a ^ c ≤ b ^ c :=
begin
by_cases a0 : a = 0,
{ subst a, by_cases c0 : c = 0,
{ subst c, simp only [power_zero] },
{ simp only [zero_power c0, zero_le] } },
{ apply limit_rec_on c,
{ simp only [power_zero] },
{ intros c IH, simpa only [power_succ] using mul_le_mul IH ab },
{ exact λ c l IH, (power_le_of_limit a0 l).2
(λ b' h, le_trans (IH _ h) (power_le_power_right
(lt_of_lt_of_le (pos_iff_ne_zero.2 a0) ab) (le_of_lt h))) } }
end
theorem le_power_self {a : ordinal} (b) (a1 : 1 < a) : b ≤ a ^ b :=
(power_is_normal a1).le_self _
theorem power_lt_power_left_of_succ {a b c : ordinal}
(ab : a < b) : a ^ succ c < b ^ succ c :=
by rw [power_succ, power_succ]; exact
lt_of_le_of_lt
(mul_le_mul_right _ $ power_le_power_left _ $ le_of_lt ab)
(mul_lt_mul_of_pos_left ab (power_pos _ (lt_of_le_of_lt (zero_le _) ab)))
theorem power_add (a b c : ordinal) : a ^ (b + c) = a ^ b * a ^ c :=
begin
by_cases a0 : a = 0,
{ subst a,
by_cases c0 : c = 0, {simp only [c0, add_zero, power_zero, mul_one]},
have : b+c ≠ 0 := ne_of_gt (lt_of_lt_of_le
(pos_iff_ne_zero.2 c0) (le_add_left _ _)),
simp only [zero_power c0, zero_power this, mul_zero] },
cases eq_or_lt_of_le (one_le_iff_ne_zero.2 a0) with a1 a1,
{ subst a1, simp only [one_power, mul_one] },
apply limit_rec_on c,
{ simp only [add_zero, power_zero, mul_one] },
{ intros c IH,
rw [add_succ, power_succ, IH, power_succ, mul_assoc] },
{ intros c l IH,
refine eq_of_forall_ge_iff (λ d, (((power_is_normal a1).trans
(add_is_normal b)).limit_le l).trans _),
simp only [IH] {contextual := tt},
exact (((mul_is_normal $ power_pos b (pos_iff_ne_zero.2 a0)).trans
(power_is_normal a1)).limit_le l).symm }
end
theorem power_dvd_power (a) {b c : ordinal}
(h : b ≤ c) : a ^ b ∣ a ^ c :=
by rw [← add_sub_cancel_of_le h, power_add]; apply dvd_mul
theorem power_dvd_power_iff {a b c : ordinal}
(a1 : 1 < a) : a ^ b ∣ a ^ c ↔ b ≤ c :=
⟨λ h, le_of_not_lt $ λ hn,
not_le_of_lt ((power_lt_power_iff_right a1).2 hn) $
le_of_dvd (power_ne_zero _ $ one_le_iff_ne_zero.1 $ le_of_lt a1) h,
power_dvd_power _⟩
theorem power_mul (a b c : ordinal) : a ^ (b * c) = (a ^ b) ^ c :=
begin
by_cases b0 : b = 0, {simp only [b0, zero_mul, power_zero, one_power]},
by_cases a0 : a = 0,
{ subst a,
by_cases c0 : c = 0, {simp only [c0, mul_zero, power_zero]},
simp only [zero_power b0, zero_power c0, zero_power (mul_ne_zero b0 c0)] },
cases eq_or_lt_of_le (one_le_iff_ne_zero.2 a0) with a1 a1,
{ subst a1, simp only [one_power] },
apply limit_rec_on c,
{ simp only [mul_zero, power_zero] },
{ intros c IH,
rw [mul_succ, power_add, IH, power_succ] },
{ intros c l IH,
refine eq_of_forall_ge_iff (λ d, (((power_is_normal a1).trans
(mul_is_normal (pos_iff_ne_zero.2 b0))).limit_le l).trans _),
simp only [IH] {contextual := tt},
exact (power_le_of_limit (power_ne_zero _ a0) l).symm }
end
/-- The ordinal logarithm is the solution `u` to the equation
`x = b ^ u * v + w` where `v < b` and `w < b`. -/
def log (b : ordinal) (x : ordinal) : ordinal :=
if h : 1 < b then pred $
omin {o | x < b^o} ⟨succ x, succ_le.1 (le_power_self _ h)⟩
else 0
@[simp] theorem log_not_one_lt {b : ordinal} (b1 : ¬ 1 < b) (x : ordinal) : log b x = 0 :=
by simp only [log, dif_neg b1]
theorem log_def {b : ordinal} (b1 : 1 < b) (x : ordinal) : log b x =
pred (omin {o | x < b^o} (log._proof_1 b x b1)) :=
by simp only [log, dif_pos b1]
@[simp] theorem log_zero (b : ordinal) : log b 0 = 0 :=
if b1 : 1 < b then
by rw [log_def b1, ← le_zero, pred_le];
apply omin_le; change 0<b^succ 0;
rw [succ_zero, power_one];
exact lt_trans zero_lt_one b1
else by simp only [log_not_one_lt b1]
theorem succ_log_def {b x : ordinal} (b1 : 1 < b) (x0 : 0 < x) : succ (log b x) =
omin {o | x < b^o} (log._proof_1 b x b1) :=
begin
let t := omin {o | x < b^o} (log._proof_1 b x b1),
have : x < b ^ t := omin_mem {o | x < b^o} _,
rcases zero_or_succ_or_limit t with h|h|h,
{ refine (not_lt_of_le (one_le_iff_pos.2 x0) _).elim,
simpa only [h, power_zero] },
{ rw [show log b x = pred t, from log_def b1 x,
succ_pred_iff_is_succ.2 h] },
{ rcases (lt_power_of_limit (ne_of_gt $ lt_trans zero_lt_one b1) h).1 this with ⟨a, h₁, h₂⟩,
exact (not_le_of_lt h₁).elim (le_omin.1 (le_refl t) a h₂) }
end
theorem lt_power_succ_log {b : ordinal} (b1 : 1 < b) (x : ordinal) :
x < b ^ succ (log b x) :=
begin
cases lt_or_eq_of_le (zero_le x) with x0 x0,
{ rw [succ_log_def b1 x0], exact omin_mem {o | x < b^o} _ },
{ subst x, apply power_pos _ (lt_trans zero_lt_one b1) }
end
theorem power_log_le (b) {x : ordinal} (x0 : 0 < x) :
b ^ log b x ≤ x :=
begin
by_cases b0 : b = 0,
{ rw [b0, zero_power'],
refine le_trans (sub_le_self _ _) (one_le_iff_pos.2 x0) },
cases lt_or_eq_of_le (one_le_iff_ne_zero.2 b0) with b1 b1,
{ refine le_of_not_lt (λ h, not_le_of_lt (lt_succ_self (log b x)) _),
have := @omin_le {o | x < b^o} _ _ h,
rwa ← succ_log_def b1 x0 at this },
{ rw [← b1, one_power], exact one_le_iff_pos.2 x0 }
end
theorem le_log {b x c : ordinal} (b1 : 1 < b) (x0 : 0 < x) :
c ≤ log b x ↔ b ^ c ≤ x :=
⟨λ h, le_trans ((power_le_power_iff_right b1).2 h) (power_log_le b x0),
λ h, le_of_not_lt $ λ hn,
not_le_of_lt (lt_power_succ_log b1 x) $
le_trans ((power_le_power_iff_right b1).2 (succ_le.2 hn)) h⟩
theorem log_lt {b x c : ordinal} (b1 : 1 < b) (x0 : 0 < x) :
log b x < c ↔ x < b ^ c :=
lt_iff_lt_of_le_iff_le (le_log b1 x0)
theorem log_le_log (b) {x y : ordinal} (xy : x ≤ y) :
log b x ≤ log b y :=
if x0 : x = 0 then by simp only [x0, log_zero, zero_le] else
have x0 : 0 < x, from pos_iff_ne_zero.2 x0,
if b1 : 1 < b then
(le_log b1 (lt_of_lt_of_le x0 xy)).2 $ le_trans (power_log_le _ x0) xy
else by simp only [log_not_one_lt b1, zero_le]
theorem log_le_self (b x : ordinal) : log b x ≤ x :=
if x0 : x = 0 then by simp only [x0, log_zero, zero_le] else
if b1 : 1 < b then
le_trans (le_power_self _ b1) (power_log_le b (pos_iff_ne_zero.2 x0))
else by simp only [log_not_one_lt b1, zero_le]
@[simp] theorem nat_cast_mul {m n : ℕ} : ((m * n : ℕ) : ordinal) = m * n :=
by induction n with n IH; [simp only [nat.cast_zero, nat.mul_zero, mul_zero],
rw [nat.mul_succ, nat.cast_add, IH, nat.cast_succ, mul_add_one]]
@[simp] theorem nat_cast_power {m n : ℕ} : ((pow m n : ℕ) : ordinal) = m ^ n :=
by induction n with n IH; [simp only [nat.pow_zero, nat.cast_zero, power_zero, nat.cast_one],
rw [nat.pow_succ, nat_cast_mul, IH, nat.cast_succ, ← succ_eq_add_one, power_succ]]
@[simp] theorem nat_cast_le {m n : ℕ} : (m : ordinal) ≤ n ↔ m ≤ n :=
by rw [← cardinal.ord_nat, ← cardinal.ord_nat,
cardinal.ord_le_ord, cardinal.nat_cast_le]
@[simp] theorem nat_cast_lt {m n : ℕ} : (m : ordinal) < n ↔ m < n :=
by simp only [lt_iff_le_not_le, nat_cast_le]
@[simp] theorem nat_cast_inj {m n : ℕ} : (m : ordinal) = n ↔ m = n :=
by simp only [le_antisymm_iff, nat_cast_le]
@[simp] theorem nat_cast_eq_zero {n : ℕ} : (n : ordinal) = 0 ↔ n = 0 :=
@nat_cast_inj n 0
theorem nat_cast_ne_zero {n : ℕ} : (n : ordinal) ≠ 0 ↔ n ≠ 0 :=
not_congr nat_cast_eq_zero
@[simp] theorem nat_cast_pos {n : ℕ} : (0 : ordinal) < n ↔ 0 < n :=
@nat_cast_lt 0 n
@[simp] theorem nat_cast_sub {m n : ℕ} : ((m - n : ℕ) : ordinal) = m - n :=
(_root_.le_total m n).elim
(λ h, by rw [nat.sub_eq_zero_iff_le.2 h, sub_eq_zero_iff_le.2 (nat_cast_le.2 h)]; refl)
(λ h, (add_left_cancel n).1 $ by rw [← nat.cast_add,
nat.add_sub_cancel' h, add_sub_cancel_of_le (nat_cast_le.2 h)])
@[simp] theorem nat_cast_div {m n : ℕ} : ((m / n : ℕ) : ordinal) = m / n :=
if n0 : n = 0 then by simp only [n0, nat.div_zero, nat.cast_zero, div_zero] else
have n0':_, from nat_cast_ne_zero.2 n0,
le_antisymm
(by rw [le_div n0', ← nat_cast_mul, nat_cast_le, mul_comm];
apply nat.div_mul_le_self)
(by rw [div_le n0', succ, ← nat.cast_succ, ← nat_cast_mul,
nat_cast_lt, mul_comm, ← nat.div_lt_iff_lt_mul _ _ (nat.pos_of_ne_zero n0)];
apply nat.lt_succ_self)
@[simp] theorem nat_cast_mod {m n : ℕ} : ((m % n : ℕ) : ordinal) = m % n :=
by rw [← add_left_cancel (n*(m/n)), div_add_mod, ← nat_cast_div, ← nat_cast_mul, ← nat.cast_add,
add_comm, nat.mod_add_div]
@[simp] theorem nat_le_card {o} {n : ℕ} : (n : cardinal) ≤ card o ↔ (n : ordinal) ≤ o :=
⟨λ h, by rwa [← cardinal.ord_le, cardinal.ord_nat] at h,
λ h, card_nat n ▸ card_le_card h⟩
@[simp] theorem nat_lt_card {o} {n : ℕ} : (n : cardinal) < card o ↔ (n : ordinal) < o :=
by rw [← succ_le, ← cardinal.succ_le, ← cardinal.nat_succ, nat_le_card]; refl
@[simp] theorem card_lt_nat {o} {n : ℕ} : card o < n ↔ o < n :=
lt_iff_lt_of_le_iff_le nat_le_card
@[simp] theorem card_le_nat {o} {n : ℕ} : card o ≤ n ↔ o ≤ n :=
le_iff_le_iff_lt_iff_lt.2 nat_lt_card
@[simp] theorem card_eq_nat {o} {n : ℕ} : card o = n ↔ o = n :=
by simp only [le_antisymm_iff, card_le_nat, nat_le_card]
@[simp] theorem type_fin (n : ℕ) : @type (fin n) (<) _ = n :=
by rw [← card_eq_nat, card_type, mk_fin]
@[simp] theorem lift_nat_cast (n : ℕ) : lift n = n :=
by induction n with n ih; [simp only [nat.cast_zero, lift_zero],
simp only [nat.cast_succ, lift_add, ih, lift_one]]
theorem lift_type_fin (n : ℕ) : lift (@type (fin n) (<) _) = n :=
by simp only [type_fin, lift_nat_cast]
theorem fintype_card (r : α → α → Prop) [is_well_order α r] [fintype α] : type r = fintype.card α :=
by rw [← card_eq_nat, card_type, fintype_card]
end ordinal
namespace cardinal
open ordinal
@[simp] theorem ord_omega : ord.{u} omega = ordinal.omega :=
le_antisymm (ord_le.2 $ le_refl _) $
le_of_forall_lt $ λ o h, begin
rcases ordinal.lt_lift_iff.1 h with ⟨o, rfl, h'⟩,
rw [lt_ord, ← lift_card, ← lift_omega.{0 u},
lift_lt, ← typein_enum (<) h'],
exact lt_omega_iff_fintype.2 ⟨set.fintype_lt_nat _⟩
end
@[simp] theorem add_one_of_omega_le {c} (h : omega ≤ c) : c + 1 = c :=
by rw [add_comm, ← card_ord c, ← card_one,
← card_add, one_add_of_omega_le];
rwa [← ord_omega, ord_le_ord]
end cardinal
namespace ordinal
theorem lt_omega {o : ordinal.{u}} : o < omega ↔ ∃ n : ℕ, o = n :=
by rw [← cardinal.ord_omega, cardinal.lt_ord, lt_omega]; simp only [card_eq_nat]
theorem nat_lt_omega (n : ℕ) : (n : ordinal) < omega :=
lt_omega.2 ⟨_, rfl⟩
theorem omega_pos : 0 < omega := nat_lt_omega 0
theorem omega_ne_zero : omega ≠ 0 := ne_of_gt omega_pos
theorem one_lt_omega : 1 < omega := by simpa only [nat.cast_one] using nat_lt_omega 1
theorem omega_is_limit : is_limit omega :=
⟨omega_ne_zero, λ o h,
let ⟨n, e⟩ := lt_omega.1 h in
by rw [e]; exact nat_lt_omega (n+1)⟩
theorem omega_le {o : ordinal.{u}} : omega ≤ o ↔ ∀ n : ℕ, (n : ordinal) ≤ o :=
⟨λ h n, le_trans (le_of_lt (nat_lt_omega _)) h,
λ H, le_of_forall_lt $ λ a h,
let ⟨n, e⟩ := lt_omega.1 h in
by rw [e, ← succ_le]; exact H (n+1)⟩
theorem nat_lt_limit {o} (h : is_limit o) : ∀ n : ℕ, (n : ordinal) < o
| 0 := lt_of_le_of_ne (zero_le o) h.1.symm
| (n+1) := h.2 _ (nat_lt_limit n)
theorem omega_le_of_is_limit {o} (h : is_limit o) : omega ≤ o :=
omega_le.2 $ λ n, le_of_lt $ nat_lt_limit h n
theorem add_omega {a : ordinal} (h : a < omega) : a + omega = omega :=
begin
rcases lt_omega.1 h with ⟨n, rfl⟩,
clear h, induction n with n IH,
{ rw [nat.cast_zero, zero_add] },
{ rw [nat.cast_succ, add_assoc, one_add_of_omega_le (le_refl _), IH] }
end
theorem add_lt_omega {a b : ordinal} (ha : a < omega) (hb : b < omega) : a + b < omega :=
match a, b, lt_omega.1 ha, lt_omega.1 hb with
| _, _, ⟨m, rfl⟩, ⟨n, rfl⟩ := by rw [← nat.cast_add]; apply nat_lt_omega
end
theorem mul_lt_omega {a b : ordinal} (ha : a < omega) (hb : b < omega) : a * b < omega :=
match a, b, lt_omega.1 ha, lt_omega.1 hb with
| _, _, ⟨m, rfl⟩, ⟨n, rfl⟩ := by rw [← nat_cast_mul]; apply nat_lt_omega
end
theorem is_limit_iff_omega_dvd {a : ordinal} : is_limit a ↔ a ≠ 0 ∧ omega ∣ a :=
begin
refine ⟨λ l, ⟨l.1, ⟨a / omega, le_antisymm _ (mul_div_le _ _)⟩⟩, λ h, _⟩,
{ refine (limit_le l).2 (λ x hx, le_of_lt _),
rw [← div_lt omega_ne_zero, ← succ_le, le_div omega_ne_zero,
mul_succ, add_le_of_limit omega_is_limit],
intros b hb,
rcases lt_omega.1 hb with ⟨n, rfl⟩,
exact le_trans (add_le_add_right (mul_div_le _ _) _)
(le_of_lt $ lt_sub.1 $ nat_lt_limit (sub_is_limit l hx) _) },
{ rcases h with ⟨a0, b, rfl⟩,
refine mul_is_limit_left omega_is_limit
(pos_iff_ne_zero.2 $ mt _ a0),
intro e, simp only [e, mul_zero] }
end
local infixr ^ := @pow ordinal ordinal ordinal.has_pow
theorem power_lt_omega {a b : ordinal} (ha : a < omega) (hb : b < omega) : a ^ b < omega :=
match a, b, lt_omega.1 ha, lt_omega.1 hb with
| _, _, ⟨m, rfl⟩, ⟨n, rfl⟩ := by rw [← nat_cast_power]; apply nat_lt_omega
end
theorem add_omega_power {a b : ordinal} (h : a < omega ^ b) : a + omega ^ b = omega ^ b :=
begin
refine le_antisymm _ (le_add_left _ _),
revert h, apply limit_rec_on b,
{ intro h, rw [power_zero, ← succ_zero, lt_succ, le_zero] at h,
rw [h, zero_add] },
{ intros b _ h, rw [power_succ] at h,
rcases (lt_mul_of_limit omega_is_limit).1 h with ⟨x, xo, ax⟩,
refine le_trans (add_le_add_right (le_of_lt ax) _) _,
rw [power_succ, ← mul_add, add_omega xo] },
{ intros b l IH h, rcases (lt_power_of_limit omega_ne_zero l).1 h with ⟨x, xb, ax⟩,
refine (((add_is_normal a).trans (power_is_normal one_lt_omega))
.limit_le l).2 (λ y yb, _),
let z := max x y,
have := IH z (max_lt xb yb)
(lt_of_lt_of_le ax $ power_le_power_right omega_pos (le_max_left _ _)),
exact le_trans (add_le_add_left (power_le_power_right omega_pos (le_max_right _ _)) _)
(le_trans this (power_le_power_right omega_pos $ le_of_lt $ max_lt xb yb)) }
end
theorem add_lt_omega_power {a b c : ordinal} (h₁ : a < omega ^ c) (h₂ : b < omega ^ c) :
a + b < omega ^ c :=
by rwa [← add_omega_power h₁, add_lt_add_iff_left]
theorem add_absorp {a b c : ordinal} (h₁ : a < omega ^ b) (h₂ : omega ^ b ≤ c) : a + c = c :=
by rw [← add_sub_cancel_of_le h₂, ← add_assoc, add_omega_power h₁]
theorem add_absorp_iff {o : ordinal} (o0 : o > 0) : (∀ a < o, a + o = o) ↔ ∃ a, o = omega ^ a :=
⟨λ H, ⟨log omega o, begin
refine ((lt_or_eq_of_le (power_log_le _ o0))
.resolve_left $ λ h, _).symm,
have := H _ h,
have := lt_power_succ_log one_lt_omega o,
rw [power_succ, lt_mul_of_limit omega_is_limit] at this,
rcases this with ⟨a, ao, h'⟩,
rcases lt_omega.1 ao with ⟨n, rfl⟩, clear ao,
revert h', apply not_lt_of_le,
suffices e : omega ^ log omega o * ↑n + o = o,
{ simpa only [e] using le_add_right (omega ^ log omega o * ↑n) o },
induction n with n IH, {simp only [nat.cast_zero, mul_zero, zero_add]},
simp only [nat.cast_succ, mul_add_one, add_assoc, this, IH]
end⟩,
λ ⟨b, e⟩, e.symm ▸ λ a, add_omega_power⟩
theorem add_mul_limit_aux {a b c : ordinal} (ba : b + a = a)
(l : is_limit c)
(IH : ∀ c' < c, (a + b) * succ c' = a * succ c' + b) :
(a + b) * c = a * c :=
le_antisymm
((mul_le_of_limit l).2 $ λ c' h, begin
apply le_trans (mul_le_mul_left _ (le_of_lt $ lt_succ_self _)),
rw IH _ h,
apply le_trans (add_le_add_left _ _),
{ rw ← mul_succ, exact mul_le_mul_left _ (succ_le.2 $ l.2 _ h) },
{ rw ← ba, exact le_add_right _ _ }
end)
(mul_le_mul_right _ (le_add_right _ _))
theorem add_mul_succ {a b : ordinal} (c) (ba : b + a = a) :
(a + b) * succ c = a * succ c + b :=
begin
apply limit_rec_on c,
{ simp only [succ_zero, mul_one] },
{ intros c IH,
rw [mul_succ, IH, ← add_assoc, add_assoc _ b, ba, ← mul_succ] },
{ intros c l IH,
have := add_mul_limit_aux ba l IH,
rw [mul_succ, add_mul_limit_aux ba l IH, mul_succ, add_assoc] }
end
theorem add_mul_limit {a b c : ordinal} (ba : b + a = a)
(l : is_limit c) : (a + b) * c = a * c :=
add_mul_limit_aux ba l (λ c' _, add_mul_succ c' ba)
theorem mul_omega {a : ordinal} (a0 : 0 < a) (ha : a < omega) : a * omega = omega :=
le_antisymm
((mul_le_of_limit omega_is_limit).2 $ λ b hb, le_of_lt (mul_lt_omega ha hb))
(by simpa only [one_mul] using mul_le_mul_right omega (one_le_iff_pos.2 a0))
theorem mul_lt_omega_power {a b c : ordinal}
(c0 : 0 < c) (ha : a < omega ^ c) (hb : b < omega) : a * b < omega ^ c :=
if b0 : b = 0 then by simp only [b0, mul_zero, power_pos _ omega_pos] else begin
rcases zero_or_succ_or_limit c with rfl|⟨c,rfl⟩|l,
{ exact (lt_irrefl _).elim c0 },
{ rw power_succ at ha,
rcases ((mul_is_normal $ power_pos _ omega_pos).limit_lt
omega_is_limit).1 ha with ⟨n, hn, an⟩,
refine lt_of_le_of_lt (mul_le_mul_right _ (le_of_lt an)) _,
rw [power_succ, mul_assoc, mul_lt_mul_iff_left (power_pos _ omega_pos)],
exact mul_lt_omega hn hb },
{ rcases ((power_is_normal one_lt_omega).limit_lt l).1 ha with ⟨x, hx, ax⟩,
refine lt_of_le_of_lt (mul_le_mul (le_of_lt ax) (le_of_lt hb)) _,
rw [← power_succ, power_lt_power_iff_right one_lt_omega],
exact l.2 _ hx }
end
theorem mul_omega_dvd {a : ordinal}
(a0 : 0 < a) (ha : a < omega) : ∀ {b}, omega ∣ b → a * b = b
| _ ⟨b, rfl⟩ := by rw [← mul_assoc, mul_omega a0 ha]
theorem mul_omega_power_power {a b : ordinal} (a0 : 0 < a) (h : a < omega ^ omega ^ b) :
a * omega ^ omega ^ b = omega ^ omega ^ b :=
begin
by_cases b0 : b = 0, {rw [b0, power_zero, power_one] at h ⊢, exact mul_omega a0 h},
refine le_antisymm _ (by simpa only [one_mul] using mul_le_mul_right (omega^omega^b) (one_le_iff_pos.2 a0)),
rcases (lt_power_of_limit omega_ne_zero (power_is_limit_left omega_is_limit b0)).1 h
with ⟨x, xb, ax⟩,
refine le_trans (mul_le_mul_right _ (le_of_lt ax)) _,
rw [← power_add, add_omega_power xb]
end
theorem power_omega {a : ordinal} (a1 : 1 < a) (h : a < omega) : a ^ omega = omega :=
le_antisymm
((power_le_of_limit (one_le_iff_ne_zero.1 $ le_of_lt a1) omega_is_limit).2
(λ b hb, le_of_lt (power_lt_omega h hb)))
(le_power_self _ a1)
theorem CNF_aux {b o : ordinal} (b0 : b ≠ 0) (o0 : o ≠ 0) :
o % b ^ log b o < o :=
lt_of_lt_of_le
(mod_lt _ $ power_ne_zero _ b0)
(power_log_le _ $ pos_iff_ne_zero.2 o0)
@[elab_as_eliminator] noncomputable def CNF_rec {b : ordinal} (b0 : b ≠ 0)
{C : ordinal → Sort*}
(H0 : C 0)
(H : ∀ o, o ≠ 0 → o % b ^ log b o < o → C (o % b ^ log b o) → C o)
: ∀ o, C o
| o :=
if o0 : o = 0 then by rw o0; exact H0 else
have _, from CNF_aux b0 o0,
H o o0 this (CNF_rec (o % b ^ log b o))
using_well_founded {dec_tac := `[assumption]}
@[simp] theorem CNF_rec_zero {b} (b0) {C H0 H} : @CNF_rec b b0 C H0 H 0 = H0 :=
by rw [CNF_rec, dif_pos rfl]; refl
@[simp] theorem CNF_rec_ne_zero {b} (b0) {C H0 H o} (o0) :
@CNF_rec b b0 C H0 H o = H o o0 (CNF_aux b0 o0) (@CNF_rec b b0 C H0 H _) :=
by rw [CNF_rec, dif_neg o0]
/-- The Cantor normal form of an ordinal is the list of coefficients
in the base-`b` expansion of `o`.
CNF b (b ^ u₁ * v₁ + b ^ u₂ * v₂) = [(u₁, v₁), (u₂, v₂)] -/
def CNF (b := omega) (o : ordinal) : list (ordinal × ordinal) :=
if b0 : b = 0 then [] else
CNF_rec b0 [] (λ o o0 h IH, (log b o, o / b ^ log b o) :: IH) o
@[simp] theorem zero_CNF (o) : CNF 0 o = [] :=
dif_pos rfl
@[simp] theorem CNF_zero (b) : CNF b 0 = [] :=
if b0 : b = 0 then dif_pos b0 else
(dif_neg b0).trans $ CNF_rec_zero _
theorem CNF_ne_zero {b o : ordinal} (b0 : b ≠ 0) (o0 : o ≠ 0) :
CNF b o = (log b o, o / b ^ log b o) :: CNF b (o % b ^ log b o) :=
by unfold CNF; rw [dif_neg b0, dif_neg b0, CNF_rec_ne_zero b0 o0]
theorem one_CNF {o : ordinal} (o0 : o ≠ 0) :
CNF 1 o = [(0, o)] :=
by rw [CNF_ne_zero one_ne_zero o0, log_not_one_lt (lt_irrefl _), power_zero, mod_one, CNF_zero, div_one]
theorem CNF_foldr {b : ordinal} (b0 : b ≠ 0) (o) :
(CNF b o).foldr (λ p r, b ^ p.1 * p.2 + r) 0 = o :=
CNF_rec b0 (by rw CNF_zero; refl)
(λ o o0 h IH, by rw [CNF_ne_zero b0 o0, list.foldr_cons, IH, div_add_mod]) o
theorem CNF_pairwise_aux (b := omega) (o) :
(∀ p ∈ CNF b o, prod.fst p ≤ log b o) ∧
(CNF b o).pairwise (λ p q, q.1 < p.1) :=
begin
by_cases b0 : b = 0,
{ simp only [b0, zero_CNF, list.pairwise.nil, and_true], exact λ _, false.elim },
cases lt_or_eq_of_le (one_le_iff_ne_zero.2 b0) with b1 b1,
{ refine CNF_rec b0 _ _ o,
{ simp only [CNF_zero, list.pairwise.nil, and_true], exact λ _, false.elim },
intros o o0 H IH, cases IH with IH₁ IH₂,
simp only [CNF_ne_zero b0 o0, list.forall_mem_cons, list.pairwise_cons, IH₂, and_true],
refine ⟨⟨le_refl _, λ p m, _⟩, λ p m, _⟩,
{ exact le_trans (IH₁ p m) (log_le_log _ $ le_of_lt H) },
{ refine lt_of_le_of_lt (IH₁ p m) ((log_lt b1 _).2 _),
{ rw pos_iff_ne_zero, intro e,
rw e at m, simpa only [CNF_zero] using m },
{ exact mod_lt _ (power_ne_zero _ b0) } } },
{ by_cases o0 : o = 0,
{ simp only [o0, CNF_zero, list.pairwise.nil, and_true], exact λ _, false.elim },
rw [← b1, one_CNF o0],
simp only [list.mem_singleton, log_not_one_lt (lt_irrefl _), forall_eq, le_refl, true_and, list.pairwise_singleton] }
end
theorem CNF_pairwise (b := omega) (o) :
(CNF b o).pairwise (λ p q, prod.fst q < p.1) :=
(CNF_pairwise_aux _ _).2
theorem CNF_fst_le_log (b := omega) (o) :
∀ p ∈ CNF b o, prod.fst p ≤ log b o :=
(CNF_pairwise_aux _ _).1
theorem CNF_fst_le (b := omega) (o) (p ∈ CNF b o) : prod.fst p ≤ o :=
le_trans (CNF_fst_le_log _ _ p H) (log_le_self _ _)
theorem CNF_snd_lt {b : ordinal} (b1 : 1 < b) (o) :
∀ p ∈ CNF b o, prod.snd p < b :=
begin
have b0 := ne_of_gt (lt_trans zero_lt_one b1),
refine CNF_rec b0 (λ _, by rw [CNF_zero]; exact false.elim) _ o,
intros o o0 H IH,
simp only [CNF_ne_zero b0 o0, list.mem_cons_iff, list.forall_mem_cons', iff_true_intro IH, and_true],
rw [div_lt (power_ne_zero _ b0), ← power_succ],
exact lt_power_succ_log b1 _,
end
theorem CNF_sorted (b := omega) (o) :
((CNF b o).map prod.fst).sorted (>) :=
by rw [list.sorted, list.pairwise_map]; exact CNF_pairwise b o
/-- The next fixed point function, the least fixed point of the
normal function `f` above `a`. -/
def nfp (f : ordinal → ordinal) (a : ordinal) :=
sup (λ n : ℕ, f^[n] a)
theorem iterate_le_nfp (f a n) : f^[n] a ≤ nfp f a :=
le_sup _ n
theorem le_nfp_self (f a) : a ≤ nfp f a :=
iterate_le_nfp f a 0
theorem is_normal.lt_nfp {f} (H : is_normal f) {a b} :
f b < nfp f a ↔ b < nfp f a :=
lt_sup.trans $ iff.trans
(by exact
⟨λ ⟨n, h⟩, ⟨n, lt_of_le_of_lt (H.le_self _) h⟩,
λ ⟨n, h⟩, ⟨n+1, by rw nat.iterate_succ'; exact H.lt_iff.2 h⟩⟩)
lt_sup.symm
theorem is_normal.nfp_le {f} (H : is_normal f) {a b} :
nfp f a ≤ f b ↔ nfp f a ≤ b :=
le_iff_le_iff_lt_iff_lt.2 H.lt_nfp
theorem is_normal.nfp_le_fp {f} (H : is_normal f) {a b}
(ab : a ≤ b) (h : f b ≤ b) : nfp f a ≤ b :=
sup_le.2 $ λ i, begin
induction i with i IH generalizing a, {exact ab},
exact IH (le_trans (H.le_iff.2 ab) h),
end
theorem is_normal.nfp_fp {f} (H : is_normal f) (a) : f (nfp f a) = nfp f a :=
begin
refine le_antisymm _ (H.le_self _),
cases le_or_lt (f a) a with aa aa,
{ rwa le_antisymm (H.nfp_le_fp (le_refl _) aa) (le_nfp_self _ _) },
rcases zero_or_succ_or_limit (nfp f a) with e|⟨b, e⟩|l,
{ refine @le_trans _ _ _ (f a) _ (H.le_iff.2 _) (iterate_le_nfp f a 1),
simp only [e, zero_le] },
{ have : f b < nfp f a := H.lt_nfp.2 (by simp only [e, lt_succ_self]),
rw [e, lt_succ] at this,
have ab : a ≤ b,
{ rw [← lt_succ, ← e],
exact lt_of_lt_of_le aa (iterate_le_nfp f a 1) },
refine le_trans (H.le_iff.2 (H.nfp_le_fp ab this))
(le_trans this (le_of_lt _)),
simp only [e, lt_succ_self] },
{ exact (H.2 _ l _).2 (λ b h, le_of_lt (H.lt_nfp.2 h)) }
end
theorem is_normal.le_nfp {f} (H : is_normal f) {a b} :
f b ≤ nfp f a ↔ b ≤ nfp f a :=
⟨le_trans (H.le_self _), λ h,
by simpa only [H.nfp_fp] using H.le_iff.2 h⟩
theorem nfp_eq_self {f : ordinal → ordinal} {a} (h : f a = a) : nfp f a = a :=
le_antisymm (sup_le.mpr $ λ i, by rw [nat.iterate₀ h]) (le_nfp_self f a)
/-- The derivative of a normal function `f` is
the sequence of fixed points of `f`. -/
def deriv (f : ordinal → ordinal) (o : ordinal) : ordinal :=
limit_rec_on o (nfp f 0)
(λ a IH, nfp f (succ IH))
(λ a l, bsup.{u u} a)
@[simp] theorem deriv_zero (f) : deriv f 0 = nfp f 0 := limit_rec_on_zero _ _ _
@[simp] theorem deriv_succ (f o) : deriv f (succ o) = nfp f (succ (deriv f o)) :=
limit_rec_on_succ _ _ _ _
theorem deriv_limit (f) {o} : is_limit o →
deriv f o = bsup.{u u} o (λ a _, deriv f a) :=
limit_rec_on_limit _ _ _ _
theorem deriv_is_normal (f) : is_normal (deriv f) :=
⟨λ o, by rw [deriv_succ, ← succ_le]; apply le_nfp_self,
λ o l a, by rw [deriv_limit _ l, bsup_le]⟩
theorem is_normal.deriv_fp {f} (H : is_normal f) (o) : f (deriv.{u} f o) = deriv f o :=
begin
apply limit_rec_on o,
{ rw [deriv_zero, H.nfp_fp] },
{ intros o ih, rw [deriv_succ, H.nfp_fp] },
intros o l IH,
rw [deriv_limit _ l, is_normal.bsup.{u u u} H _ l.1],
refine eq_of_forall_ge_iff (λ c, _),
simp only [bsup_le, IH] {contextual:=tt}
end
theorem is_normal.fp_iff_deriv {f} (H : is_normal f)
{a} : f a ≤ a ↔ ∃ o, a = deriv f o :=
⟨λ ha, begin
suffices : ∀ o (_:a ≤ deriv f o), ∃ o, a = deriv f o,
from this a ((deriv_is_normal _).le_self _),
intro o, apply limit_rec_on o,
{ intros h₁,
refine ⟨0, le_antisymm h₁ _⟩,
rw deriv_zero,
exact H.nfp_le_fp (zero_le _) ha },
{ intros o IH h₁,
cases le_or_lt a (deriv f o), {exact IH h},
refine ⟨succ o, le_antisymm h₁ _⟩,
rw deriv_succ,
exact H.nfp_le_fp (succ_le.2 h) ha },
{ intros o l IH h₁,
cases eq_or_lt_of_le h₁, {exact ⟨_, h⟩},
rw [deriv_limit _ l, ← not_le, bsup_le, not_ball] at h,
exact let ⟨o', h, hl⟩ := h in IH o' h (le_of_not_le hl) }
end, λ ⟨o, e⟩, e.symm ▸ le_of_eq (H.deriv_fp _)⟩
end ordinal
namespace cardinal
section using_ordinals
open ordinal
theorem ord_is_limit {c} (co : omega ≤ c) : (ord c).is_limit :=
begin
refine ⟨λ h, omega_ne_zero _, λ a, lt_imp_lt_of_le_imp_le _⟩,
{ rw [← ordinal.le_zero, ord_le] at h,
simpa only [card_zero, le_zero] using le_trans co h },
{ intro h, rw [ord_le] at h ⊢,
rwa [← @add_one_of_omega_le (card a), ← card_succ],
rw [← ord_le, ← le_succ_of_is_limit, ord_le],
{ exact le_trans co h },
{ rw ord_omega, exact omega_is_limit } }
end
def aleph_idx.initial_seg : @initial_seg cardinal ordinal (<) (<) :=
@order_embedding.collapse cardinal ordinal (<) (<) _ cardinal.ord.order_embedding
/-- The `aleph'` index function, which gives the ordinal index of a cardinal.
(The `aleph'` part is because unlike `aleph` this counts also the
finite stages. So `aleph_idx n = n`, `aleph_idx ω = ω`,
`aleph_idx ℵ₁ = ω + 1` and so on.) -/
def aleph_idx : cardinal → ordinal := aleph_idx.initial_seg
@[simp] theorem aleph_idx.initial_seg_coe :
(aleph_idx.initial_seg : cardinal → ordinal) = aleph_idx := rfl
@[simp] theorem aleph_idx_lt {a b} : aleph_idx a < aleph_idx b ↔ a < b :=
aleph_idx.initial_seg.to_order_embedding.ord.symm
@[simp] theorem aleph_idx_le {a b} : aleph_idx a ≤ aleph_idx b ↔ a ≤ b :=
by rw [← not_lt, ← not_lt, aleph_idx_lt]
theorem aleph_idx.init {a b} : b < aleph_idx a → ∃ c, aleph_idx c = b :=
aleph_idx.initial_seg.init _ _
def aleph_idx.order_iso : @order_iso cardinal.{u} ordinal.{u} (<) (<) :=
@order_iso.of_surjective cardinal.{u} ordinal.{u} (<) (<) aleph_idx.initial_seg.{u} $
(initial_seg.eq_or_principal aleph_idx.initial_seg.{u}).resolve_right $
λ ⟨o, e⟩, begin
have : ∀ c, aleph_idx c < o := λ c, (e _).2 ⟨_, rfl⟩,
refine ordinal.induction_on o _ this, introsI α r _ h,
let s := sup.{u u} (λ a:α, inv_fun aleph_idx (ordinal.typein r a)),
apply not_le_of_gt (lt_succ_self s),
have I : injective aleph_idx := aleph_idx.initial_seg.to_embedding.inj,
simpa only [typein_enum, left_inverse_inv_fun I (succ s)] using
le_sup.{u u} (λ a, inv_fun aleph_idx (ordinal.typein r a))
(ordinal.enum r _ (h (succ s))),
end
@[simp] theorem aleph_idx.order_iso_coe :
(aleph_idx.order_iso : cardinal → ordinal) = aleph_idx := rfl
@[simp] theorem type_cardinal : @ordinal.type cardinal (<) _ = ordinal.univ.{u (u+1)} :=
by rw ordinal.univ_id; exact quotient.sound ⟨aleph_idx.order_iso⟩
@[simp] theorem mk_cardinal : mk cardinal = univ.{u (u+1)} :=
by simpa only [card_type, card_univ] using congr_arg card type_cardinal
def aleph'.order_iso := cardinal.aleph_idx.order_iso.symm
/-- The `aleph'` function gives the cardinals listed by their ordinal
index, and is the inverse of `aleph_idx`.
`aleph' n = n`, `aleph' ω = ω`, `aleph' (ω + 1) = ℵ₁, etc. -/
def aleph' : ordinal → cardinal := aleph'.order_iso
@[simp] theorem aleph'.order_iso_coe :
(aleph'.order_iso : ordinal → cardinal) = aleph' := rfl
@[simp] theorem aleph'_lt {o₁ o₂ : ordinal.{u}} : aleph' o₁ < aleph' o₂ ↔ o₁ < o₂ :=
aleph'.order_iso.ord.symm
@[simp] theorem aleph'_le {o₁ o₂ : ordinal.{u}} : aleph' o₁ ≤ aleph' o₂ ↔ o₁ ≤ o₂ :=
le_iff_le_iff_lt_iff_lt.2 aleph'_lt
@[simp] theorem aleph'_aleph_idx (c : cardinal.{u}) : aleph' c.aleph_idx = c :=
cardinal.aleph_idx.order_iso.to_equiv.symm_apply_apply c
@[simp] theorem aleph_idx_aleph' (o : ordinal.{u}) : (aleph' o).aleph_idx = o :=
cardinal.aleph_idx.order_iso.to_equiv.apply_symm_apply o
@[simp] theorem aleph'_zero : aleph' 0 = 0 :=
by rw [← le_zero, ← aleph'_aleph_idx 0, aleph'_le];
apply ordinal.zero_le
@[simp] theorem aleph'_succ {o : ordinal.{u}} : aleph' o.succ = (aleph' o).succ :=
le_antisymm
(cardinal.aleph_idx_le.1 $
by rw [aleph_idx_aleph', ordinal.succ_le, ← aleph'_lt, aleph'_aleph_idx];
apply cardinal.lt_succ_self)
(cardinal.succ_le.2 $ aleph'_lt.2 $ ordinal.lt_succ_self _)
@[simp] theorem aleph'_nat : ∀ n : ℕ, aleph' n = n
| 0 := aleph'_zero
| (n+1) := show aleph' (ordinal.succ n) = n.succ,
by rw [aleph'_succ, aleph'_nat, nat_succ]
theorem aleph'_le_of_limit {o : ordinal.{u}} (l : o.is_limit) {c} :
aleph' o ≤ c ↔ ∀ o' < o, aleph' o' ≤ c :=
⟨λ h o' h', le_trans (aleph'_le.2 $ le_of_lt h') h,
λ h, begin
rw [← aleph'_aleph_idx c, aleph'_le, ordinal.limit_le l],
intros x h',
rw [← aleph'_le, aleph'_aleph_idx],
exact h _ h'
end⟩
@[simp] theorem aleph'_omega : aleph' ordinal.omega = omega :=
eq_of_forall_ge_iff $ λ c, begin
simp only [aleph'_le_of_limit omega_is_limit, ordinal.lt_omega, exists_imp_distrib, omega_le],
exact forall_swap.trans (forall_congr $ λ n, by simp only [forall_eq, aleph'_nat]),
end
/-- aleph' and aleph_idx form an equivalence between `ordinal` and `cardinal` -/
@[simp] def aleph'_equiv : ordinal ≃ cardinal :=
⟨aleph', aleph_idx, aleph_idx_aleph', aleph'_aleph_idx⟩
/-- The `aleph` function gives the infinite cardinals listed by their
ordinal index. `aleph 0 = ω`, `aleph 1 = succ ω` is the first
uncountable cardinal, and so on. -/
def aleph (o : ordinal) : cardinal := aleph' (ordinal.omega + o)
@[simp] theorem aleph_lt {o₁ o₂ : ordinal.{u}} : aleph o₁ < aleph o₂ ↔ o₁ < o₂ :=
aleph'_lt.trans (ordinal.add_lt_add_iff_left _)
@[simp] theorem aleph_le {o₁ o₂ : ordinal.{u}} : aleph o₁ ≤ aleph o₂ ↔ o₁ ≤ o₂ :=
le_iff_le_iff_lt_iff_lt.2 aleph_lt
@[simp] theorem aleph_succ {o : ordinal.{u}} : aleph o.succ = (aleph o).succ :=
by rw [aleph, ordinal.add_succ, aleph'_succ]; refl
@[simp] theorem aleph_zero : aleph 0 = omega :=
by simp only [aleph, add_zero, aleph'_omega]
theorem omega_le_aleph' {o : ordinal} : omega ≤ aleph' o ↔ ordinal.omega ≤ o :=
by rw [← aleph'_omega, aleph'_le]
theorem omega_le_aleph (o : ordinal) : omega ≤ aleph o :=
by rw [aleph, omega_le_aleph']; apply ordinal.le_add_right
theorem ord_aleph_is_limit (o : ordinal) : is_limit (aleph o).ord :=
ord_is_limit $ omega_le_aleph _
theorem exists_aleph {c : cardinal} : omega ≤ c ↔ ∃ o, c = aleph o :=
⟨λ h, ⟨aleph_idx c - ordinal.omega,
by rw [aleph, ordinal.add_sub_cancel_of_le, aleph'_aleph_idx];
rwa [← omega_le_aleph', aleph'_aleph_idx]⟩,
λ ⟨o, e⟩, e.symm ▸ omega_le_aleph _⟩
theorem aleph'_is_normal : is_normal (ord ∘ aleph') :=
⟨λ o, ord_lt_ord.2 $ aleph'_lt.2 $ ordinal.lt_succ_self _,
λ o l a, by simp only [ord_le, aleph'_le_of_limit l]⟩
theorem aleph_is_normal : is_normal (ord ∘ aleph) :=
aleph'_is_normal.trans $ add_is_normal ordinal.omega
/- properties of mul -/
theorem mul_eq_self {c : cardinal} (h : omega ≤ c) : c * c = c :=
begin
refine le_antisymm _
(by simpa only [mul_one] using mul_le_mul_left c (le_trans (le_of_lt one_lt_omega) h)),
refine acc.rec_on (cardinal.wf.apply c) (λ c _,
quotient.induction_on c $ λ α IH ol, _) h,
rcases ord_eq α with ⟨r, wo, e⟩, resetI,
let := decidable_linear_order_of_STO' r,
have : is_well_order α (<) := wo,
let g : α × α → α := λ p, max p.1 p.2,
let f : α × α ↪ ordinal × (α × α) :=
⟨λ p:α×α, (typein (<) (g p), p), λ p q, congr_arg prod.snd⟩,
let s := f ⁻¹'o (prod.lex (<) (prod.lex (<) (<))),
have : is_well_order _ s := (order_embedding.preimage _ _).is_well_order,
suffices : type s ≤ type r, {exact card_le_card this},
refine le_of_forall_lt (λ o h, _),
rcases typein_surj s h with ⟨p, rfl⟩,
rw [← e, lt_ord],
refine lt_of_le_of_lt (_ : _ ≤ card (typein (<) (g p)).succ * card (typein (<) (g p)).succ) _,
{ have : {q|s q p} ⊆ (insert (g p) {x | x < (g p)}).prod (insert (g p) {x | x < (g p)}),
{ intros q h,
simp only [s, embedding.coe_fn_mk, order.preimage, typein_lt_typein, prod.lex_def, typein_inj] at h,
exact max_le_iff.1 (le_iff_lt_or_eq.2 $ h.imp_right and.left) },
suffices H : (insert (g p) {x | r x (g p)} : set α) ≃ ({x | r x (g p)} ⊕ punit),
{ exact ⟨(set.embedding_of_subset _ _ this).trans
((equiv.set.prod _ _).trans (H.prod_congr H)).to_embedding⟩ },
refine (equiv.set.insert _).trans
((equiv.refl _).sum_congr punit_equiv_punit),
apply @irrefl _ r },
cases lt_or_ge (card (typein (<) (g p)).succ) omega with qo qo,
{ exact lt_of_lt_of_le (mul_lt_omega qo qo) ol },
{ suffices, {exact lt_of_le_of_lt (IH _ this qo) this},
rw ← lt_ord, apply (ord_is_limit ol).2,
rw [mk_def, e], apply typein_lt_type }
end
end using_ordinals
theorem mul_eq_max {a b : cardinal} (ha : omega ≤ a) (hb : omega ≤ b) : a * b = max a b :=
le_antisymm
(mul_eq_self (le_trans ha (le_max_left a b)) ▸
mul_le_mul (le_max_left _ _) (le_max_right _ _)) $
max_le
(by simpa only [mul_one] using mul_le_mul_left a (le_trans (le_of_lt one_lt_omega) hb))
(by simpa only [one_mul] using mul_le_mul_right b (le_trans (le_of_lt one_lt_omega) ha))
theorem mul_lt_of_lt {a b c : cardinal} (hc : omega ≤ c)
(h1 : a < c) (h2 : b < c) : a * b < c :=
lt_of_le_of_lt (mul_le_mul (le_max_left a b) (le_max_right a b)) $
(lt_or_le (max a b) omega).elim
(λ h, lt_of_lt_of_le (mul_lt_omega h h) hc)
(λ h, by rw mul_eq_self h; exact max_lt h1 h2)
lemma mul_le_max_of_omega_le_left {a b : cardinal} (h : omega ≤ a) : a * b ≤ max a b :=
begin
convert mul_le_mul (le_max_left a b) (le_max_right a b), rw [mul_eq_self],
refine le_trans h (le_max_left a b)
end
lemma mul_eq_max_of_omega_le_left {a b : cardinal} (h : omega ≤ a) (h' : b ≠ 0) : a * b = max a b :=
begin
apply le_antisymm, apply mul_le_max_of_omega_le_left h,
cases le_or_gt omega b with hb hb, rw [mul_eq_max h hb],
have : b ≤ a, exact le_trans (le_of_lt hb) h,
rw [max_eq_left this], convert mul_le_mul_left _ (one_le_iff_ne_zero.mpr h'), rw [mul_one],
end
lemma mul_eq_left {a b : cardinal} (ha : omega ≤ a) (hb : b ≤ a) (hb' : b ≠ 0) : a * b = a :=
by { rw [mul_eq_max_of_omega_le_left ha hb', max_eq_left hb] }
lemma mul_eq_right {a b : cardinal} (hb : omega ≤ b) (ha : a ≤ b) (ha' : a ≠ 0) : a * b = b :=
by { rw [mul_comm, mul_eq_left hb ha ha'] }
lemma le_mul_left {a b : cardinal} (h : b ≠ 0) : a ≤ b * a :=
by { convert mul_le_mul_right _ (one_le_iff_ne_zero.mpr h), rw [one_mul] }
lemma le_mul_right {a b : cardinal} (h : b ≠ 0) : a ≤ a * b :=
by { rw [mul_comm], exact le_mul_left h }
lemma mul_eq_left_iff {a b : cardinal} : a * b = a ↔ ((max omega b ≤ a ∧ b ≠ 0) ∨ b = 1 ∨ a = 0) :=
begin
rw [max_le_iff], split,
{ intro h,
cases (le_or_lt omega a) with ha ha,
{ have : a ≠ 0, { rintro rfl, exact not_lt_of_le ha omega_pos },
left, use ha,
{ rw [← not_lt], intro hb, apply ne_of_gt _ h, refine lt_of_lt_of_le hb (le_mul_left this) },
{ rintro rfl, apply this, rw [_root_.mul_zero] at h, subst h }},
right, by_cases h2a : a = 0, { right, exact h2a },
have hb : b ≠ 0, { rintro rfl, apply h2a, rw [mul_zero] at h, subst h },
left, rw [← h, mul_lt_omega_iff, lt_omega, lt_omega] at ha,
rcases ha with rfl|rfl|⟨⟨n, rfl⟩, ⟨m, rfl⟩⟩, contradiction, contradiction,
rw [← ne] at h2a, rw [← one_le_iff_ne_zero] at h2a hb, norm_cast at h2a hb h ⊢,
apply le_antisymm _ hb, rw [← not_lt], intro h2b,
apply ne_of_gt _ h, rw [gt], conv_lhs { rw [← mul_one n] },
rwa [mul_lt_mul_left], apply nat.lt_of_succ_le h2a },
{ rintro (⟨⟨ha, hab⟩, hb⟩|rfl|rfl),
{ rw [mul_eq_max_of_omega_le_left ha hb, max_eq_left hab] },
all_goals {simp}}
end
/- properties of add -/
theorem add_eq_self {c : cardinal} (h : omega ≤ c) : c + c = c :=
le_antisymm
(by simpa only [nat.cast_bit0, nat.cast_one, mul_eq_self h, two_mul] using
mul_le_mul_right c (le_trans (le_of_lt $ nat_lt_omega 2) h))
(le_add_left c c)
theorem add_eq_max {a b : cardinal} (ha : omega ≤ a) : a + b = max a b :=
le_antisymm
(add_eq_self (le_trans ha (le_max_left a b)) ▸
add_le_add (le_max_left _ _) (le_max_right _ _)) $
max_le (le_add_right _ _) (le_add_left _ _)
theorem add_lt_of_lt {a b c : cardinal} (hc : omega ≤ c)
(h1 : a < c) (h2 : b < c) : a + b < c :=
lt_of_le_of_lt (add_le_add (le_max_left a b) (le_max_right a b)) $
(lt_or_le (max a b) omega).elim
(λ h, lt_of_lt_of_le (add_lt_omega h h) hc)
(λ h, by rw add_eq_self h; exact max_lt h1 h2)
lemma eq_of_add_eq_of_omega_le {a b c : cardinal} (h : a + b = c) (ha : a < c) (hc : omega ≤ c) :
b = c :=
begin
apply le_antisymm,
{ rw [← h], apply cardinal.le_add_left },
rw[← not_lt], intro hb,
have : a + b < c := add_lt_of_lt hc ha hb,
simpa [h, lt_irrefl] using this
end
lemma add_eq_left {a b : cardinal} (ha : omega ≤ a) (hb : b ≤ a) : a + b = a :=
by { rw [add_eq_max ha, max_eq_left hb] }
lemma add_eq_right {a b : cardinal} (hb : omega ≤ b) (ha : a ≤ b) : a + b = b :=
by { rw [add_comm, add_eq_left hb ha] }
lemma add_eq_left_iff {a b : cardinal} : a + b = a ↔ (max omega b ≤ a ∨ b = 0) :=
begin
rw [max_le_iff], split,
{ intro h, cases (le_or_lt omega a) with ha ha,
{ left, use ha, rw [← not_lt], intro hb, apply ne_of_gt _ h,
exact lt_of_lt_of_le hb (le_add_left b a) },
right, rw [← h, add_lt_omega_iff, lt_omega, lt_omega] at ha,
rcases ha with ⟨⟨n, rfl⟩, ⟨m, rfl⟩⟩, norm_cast at h ⊢,
rw [← add_right_inj, h, add_zero] },
{ rintro (⟨h1, h2⟩|h3), rw [add_eq_max h1, max_eq_left h2], rw [h3, add_zero] }
end
lemma add_eq_right_iff {a b : cardinal} : a + b = b ↔ (max omega a ≤ b ∨ a = 0) :=
by { rw [add_comm, add_eq_left_iff] }
lemma add_one_eq {a : cardinal} (ha : omega ≤ a) : a + 1 = a :=
have 1 ≤ a, from le_trans (le_of_lt one_lt_omega) ha,
add_eq_left ha this
protected lemma eq_of_add_eq_add_left {a b c : cardinal} (h : a + b = a + c) (ha : a < omega) :
b = c :=
begin
cases le_or_lt omega b with hb hb,
{ have : a < b := lt_of_lt_of_le ha hb,
rw [add_eq_right hb (le_of_lt this), eq_comm] at h,
rw [eq_of_add_eq_of_omega_le h this hb] },
{ have hc : c < omega,
{ rw [← not_le], intro hc,
apply lt_irrefl omega, apply lt_of_le_of_lt (le_trans hc (le_add_left _ a)),
rw [← h], apply add_lt_omega ha hb },
rw [lt_omega] at *,
rcases ha with ⟨n, rfl⟩, rcases hb with ⟨m, rfl⟩, rcases hc with ⟨k, rfl⟩,
norm_cast at h ⊢, apply eq_of_add_eq_add_left h }
end
protected lemma eq_of_add_eq_add_right {a b c : cardinal} (h : a + b = c + b) (hb : b < omega) :
a = c :=
by { rw [add_comm a b, add_comm c b] at h, exact cardinal.eq_of_add_eq_add_left h hb }
/- properties about power -/
theorem pow_le {κ μ : cardinal.{u}} (H1 : omega ≤ κ) (H2 : μ < omega) : κ ^ μ ≤ κ :=
let ⟨n, H3⟩ := lt_omega.1 H2 in
H3.symm ▸ (quotient.induction_on κ (λ α H1, nat.rec_on n
(le_of_lt $ lt_of_lt_of_le (by rw [nat.cast_zero, power_zero];
from one_lt_omega) H1)
(λ n ih, trans_rel_left _
(by rw [nat.cast_succ, power_add, power_one];
from mul_le_mul_right _ ih)
(mul_eq_self H1))) H1)
lemma power_self_eq {c : cardinal} (h : omega ≤ c) : c ^ c = 2 ^ c :=
begin
apply le_antisymm,
{ apply le_trans (power_le_power_right $ le_of_lt $ cantor c), rw [power_mul, mul_eq_self h] },
{ convert power_le_power_right (le_trans (le_of_lt $ nat_lt_omega 2) h), apply nat.cast_two.symm }
end
lemma power_nat_le {c : cardinal.{u}} {n : ℕ} (h : omega ≤ c) : c ^ (n : cardinal.{u}) ≤ c :=
pow_le h (nat_lt_omega n)
lemma powerlt_omega {c : cardinal} (h : omega ≤ c) : c ^< omega = c :=
begin
apply le_antisymm,
{ rw [powerlt_le], intro c', rw [lt_omega], rintro ⟨n, rfl⟩, apply power_nat_le h },
convert le_powerlt one_lt_omega, rw [power_one]
end
lemma powerlt_omega_le (c : cardinal) : c ^< omega ≤ max c omega :=
begin
cases le_or_gt omega c,
{ rw [powerlt_omega h], apply le_max_left },
rw [powerlt_le], intros c' hc',
refine le_trans (le_of_lt $ power_lt_omega h hc') (le_max_right _ _)
end
/- compute cardinality of various types -/
theorem mk_list_eq_mk {α : Type u} (H1 : omega ≤ mk α) : mk (list α) = mk α :=
eq.symm $ le_antisymm ⟨⟨λ x, [x], λ x y H, (list.cons.inj H).1⟩⟩ $
calc mk (list α)
= sum (λ n : ℕ, mk α ^ (n : cardinal.{u})) : mk_list_eq_sum_pow α
... ≤ sum (λ n : ℕ, mk α) : sum_le_sum _ _ $ λ n, pow_le H1 $ nat_lt_omega n
... = sum (λ n : ulift.{u} ℕ, mk α) : quotient.sound
⟨@sigma_congr_left _ _ (λ _, quotient.out (mk α)) equiv.ulift.symm⟩
... = omega * mk α : sum_const _ _
... = max (omega) (mk α) : mul_eq_max (le_refl _) H1
... = mk α : max_eq_right H1
lemma mk_bounded_set_le_of_omega_le (α : Type u) (c : cardinal) (hα : omega ≤ mk α) :
mk {t : set α // mk t ≤ c} ≤ mk α ^ c :=
begin
refine le_trans _ (by rw [←add_one_eq hα]), refine quotient.induction_on c _, clear c, intro β,
fapply mk_le_of_surjective,
{ intro f, use sum.inl ⁻¹' range f,
refine le_trans (mk_preimage_of_injective _ _ (λ x y, sum.inl.inj)) _,
apply mk_range_le },
rintro ⟨s, ⟨g⟩⟩,
use λ y, if h : ∃(x : s), g x = y then sum.inl (classical.some h).val else sum.inr ⟨⟩,
apply subtype.eq, ext,
split,
{ rintro ⟨y, h⟩, dsimp only at h, by_cases h' : ∃ (z : s), g z = y,
{ rw [dif_pos h'] at h, cases sum.inl.inj h, exact (classical.some h').2 },
{ rw [dif_neg h'] at h, cases h }},
{ intro h, have : ∃(z : s), g z = g ⟨x, h⟩, exact ⟨⟨x, h⟩, rfl⟩,
use g ⟨x, h⟩, dsimp only, rw [dif_pos this], congr',
suffices : classical.some this = ⟨x, h⟩, exact congr_arg subtype.val this,
apply g.2, exact classical.some_spec this }
end
lemma mk_bounded_set_le (α : Type u) (c : cardinal) :
mk {t : set α // mk t ≤ c} ≤ max (mk α) omega ^ c :=
begin
transitivity mk {t : set (ulift.{u} nat ⊕ α) // mk t ≤ c},
{ refine ⟨embedding.subtype_map _ _⟩, apply embedding.image,
use sum.inr, apply sum.inr.inj, intros s hs, exact le_trans mk_image_le hs },
refine le_trans
(mk_bounded_set_le_of_omega_le (ulift.{u} nat ⊕ α) c (le_add_right omega (mk α))) _,
rw [max_comm, ←add_eq_max]; refl
end
lemma mk_bounded_subset_le {α : Type u} (s : set α) (c : cardinal.{u}) :
mk {t : set α // t ⊆ s ∧ mk t ≤ c} ≤ max (mk s) omega ^ c :=
begin
refine le_trans _ (mk_bounded_set_le s c),
refine ⟨embedding.cod_restrict _ _ _⟩,
use λ t, subtype.val ⁻¹' t.1,
{ rintros ⟨t, ht1, ht2⟩ ⟨t', h1t', h2t'⟩ h, apply subtype.eq, dsimp only at h ⊢,
refine (preimage_eq_preimage' _ _).1 h; rw [subtype.range_val]; assumption },
rintro ⟨t, h1t, h2t⟩, exact le_trans (mk_preimage_of_injective _ _ subtype.val_injective) h2t
end
/- compl -/
lemma mk_compl_of_omega_le {α : Type*} (s : set α) (h : omega ≤ #α) (h2 : #s < #α) :
#(-s : set α) = #α :=
by { refine eq_of_add_eq_of_omega_le _ h2 h, exact mk_sum_compl s }
lemma mk_compl_finset_of_omega_le {α : Type*} (s : finset α) (h : omega ≤ #α) :
#(-↑s : set α) = #α :=
by { apply mk_compl_of_omega_le _ h, exact lt_of_lt_of_le (finset_card_lt_omega s) h }
lemma mk_compl_eq_mk_compl_infinite {α : Type*} {s t : set α} (h : omega ≤ #α) (hs : #s < #α)
(ht : #t < #α) : #(-s : set α) = #(-t : set α) :=
by { rw [mk_compl_of_omega_le s h hs, mk_compl_of_omega_le t h ht] }
lemma mk_compl_eq_mk_compl_finite_lift {α : Type u} {β : Type v} {s : set α} {t : set β}
(hα : #α < omega) (h1 : lift.{u (max v w)} (#α) = lift.{v (max u w)} (#β))
(h2 : lift.{u (max v w)} (#s) = lift.{v (max u w)} (#t)) :
lift.{u (max v w)} (#(-s : set α)) = lift.{v (max u w)} (#(-t : set β)) :=
begin
have hα' := hα, have h1' := h1,
rw [← mk_sum_compl s, ← mk_sum_compl t] at h1,
rw [← mk_sum_compl s, add_lt_omega_iff] at hα,
lift #s to ℕ using hα.1 with n hn,
lift #(- s : set α) to ℕ using hα.2 with m hm,
have : #(- t : set β) < omega,
{ refine lt_of_le_of_lt (mk_subtype_le _) _,
rw [← lift_lt, lift_omega, ← h1', ← lift_omega.{u (max v w)}, lift_lt], exact hα' },
lift #(- t : set β) to ℕ using this with k hk,
simp [nat_eq_lift_eq_iff] at h2, rw [nat_eq_lift_eq_iff.{v (max u w)}] at h2,
simp [h2.symm] at h1 ⊢, norm_cast at h1, simp at h1, exact h1
end
lemma mk_compl_eq_mk_compl_finite {α β : Type u} {s : set α} {t : set β}
(hα : #α < omega) (h1 : #α = #β) (h : #s = #t) : #(-s : set α) = #(-t : set β) :=
by { rw [← lift_inj], apply mk_compl_eq_mk_compl_finite_lift hα; rw [lift_inj]; assumption }
lemma mk_compl_eq_mk_compl_finite_same {α : Type*} {s t : set α} (hα : #α < omega)
(h : #s = #t) : #(-s : set α) = #(-t : set α) :=
mk_compl_eq_mk_compl_finite hα rfl h
/- extend an injection to an equiv -/
theorem extend_function {α β : Type*} {s : set α} (f : s ↪ β)
(h : nonempty ((-s : set α) ≃ (- range f : set β))) :
∃ (g : α ≃ β), ∀ x : s, g x = f x :=
begin
intros, have := h, cases this with g,
let h : α ≃ β := (set.sum_compl (s : set α)).symm.trans
((sum_congr (equiv.set.range f f.2) g).trans
(set.sum_compl (range f))),
refine ⟨h, _⟩, rintro ⟨x, hx⟩, simp [set.sum_compl_symm_apply_of_mem, hx]
end
theorem extend_function_finite {α β : Type*} {s : set α} (f : s ↪ β)
(hs : #α < omega) (h : nonempty (α ≃ β)) : ∃ (g : α ≃ β), ∀ x : s, g x = f x :=
begin
apply extend_function f,
have := h, cases this with g,
rw [← lift_mk_eq] at h,
rw [←lift_mk_eq, mk_compl_eq_mk_compl_finite_lift hs h],
rw [mk_range_eq_lift], exact f.2
end
theorem extend_function_of_lt {α β : Type*} {s : set α} (f : s ↪ β) (hs : #s < #α)
(h : nonempty (α ≃ β)) : ∃ (g : α ≃ β), ∀ x : s, g x = f x :=
begin
cases (le_or_lt omega (#α)) with hα hα,
{ apply extend_function f, have := h, cases this with g, rw [← lift_mk_eq] at h,
cases cardinal.eq.mp (mk_compl_of_omega_le s hα hs) with g2,
cases cardinal.eq.mp (mk_compl_of_omega_le (range f) _ _) with g3,
{ constructor, exact g2.trans (g.trans g3.symm) },
{ rw [← lift_le, ← h], refine le_trans _ (lift_le.mpr hα), simp },
rwa [← lift_lt, ← h, mk_range_eq_lift, lift_lt], exact f.2 },
{ exact extend_function_finite f hα h }
end
end cardinal
|
c4a86a68ea408281b89a692858b204fb176eff6a | 6e41ee3ac9b96e8980a16295cc21f131e731884f | /tests/lean/run/nat_bug3.lean | 83b5b1540c78e7ad5c29a65db471943666bd0479 | [
"Apache-2.0"
] | permissive | EgbertRijke/lean | 3426cfa0e5b3d35d12fc3fd7318b35574cb67dc3 | 4f2e0c6d7fc9274d953cfa1c37ab2f3e799ab183 | refs/heads/master | 1,610,834,871,476 | 1,422,159,801,000 | 1,422,159,801,000 | null | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 725 | lean | import logic
open eq.ops
namespace experiment
inductive nat : Type :=
zero : nat,
succ : nat → nat
namespace nat
definition plus (x y : nat) : nat
:= nat.rec x (λn r, succ r) y
definition to_nat [coercion] (n : num) : nat
:= num.rec zero (λn, pos_num.rec (succ zero) (λn r, plus r (plus r (succ zero))) (λn r, plus r r) n) n
definition add (x y : nat) : nat
:= plus x y
constant le : nat → nat → Prop
infixl `+` := add
infix `≤` := le
axiom add_one (n:nat) : n + (succ zero) = succ n
axiom add_le_right_inv {n m k : nat} (H : n + k ≤ m + k) : n ≤ m
theorem succ_le_cancel {n m : nat} (H : succ n ≤ succ m) : n ≤ m
:= add_le_right_inv (add_one m⁻¹ ▸ add_one n⁻¹ ▸ H)
end nat
end experiment
|
8fecebfbc8c6667f3cf8e70651617877504042e6 | 94e33a31faa76775069b071adea97e86e218a8ee | /src/logic/small.lean | 6e074716d53cd686cda3784854e54ecfe357606f | [
"Apache-2.0"
] | permissive | urkud/mathlib | eab80095e1b9f1513bfb7f25b4fa82fa4fd02989 | 6379d39e6b5b279df9715f8011369a301b634e41 | refs/heads/master | 1,658,425,342,662 | 1,658,078,703,000 | 1,658,078,703,000 | 186,910,338 | 0 | 0 | Apache-2.0 | 1,568,512,083,000 | 1,557,958,709,000 | Lean | UTF-8 | Lean | false | false | 5,238 | lean | /-
Copyright (c) 2021 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Scott Morrison
-/
import data.vector.basic
/-!
# Small types
A type is `w`-small if there exists an equivalence to some `S : Type w`.
We provide a noncomputable model `shrink α : Type w`, and `equiv_shrink α : α ≃ shrink α`.
A subsingleton type is `w`-small for any `w`.
If `α ≃ β`, then `small.{w} α ↔ small.{w} β`.
-/
universes u w v
/--
A type is `small.{w}` if there exists an equivalence to some `S : Type w`.
-/
class small (α : Type v) : Prop :=
(equiv_small : ∃ (S : Type w), nonempty (α ≃ S))
/--
Constructor for `small α` from an explicit witness type and equivalence.
-/
lemma small.mk' {α : Type v} {S : Type w} (e : α ≃ S) : small.{w} α :=
⟨⟨S, ⟨e⟩⟩⟩
/--
An arbitrarily chosen model in `Type w` for a `w`-small type.
-/
@[nolint has_inhabited_instance]
def shrink (α : Type v) [small.{w} α] : Type w :=
classical.some (@small.equiv_small α _)
/--
The noncomputable equivalence between a `w`-small type and a model.
-/
noncomputable
def equiv_shrink (α : Type v) [small.{w} α] : α ≃ shrink α :=
nonempty.some (classical.some_spec (@small.equiv_small α _))
@[priority 100]
instance small_self (α : Type v) : small.{v} α :=
small.mk' $ equiv.refl α
theorem small_map {α : Type*} {β : Type*} [hβ : small.{w} β] (e : α ≃ β) : small.{w} α :=
let ⟨γ, ⟨f⟩⟩ := hβ.equiv_small in small.mk' (e.trans f)
theorem small_lift (α : Type u) [hα : small.{v} α] : small.{max v w} α :=
let ⟨⟨γ, ⟨f⟩⟩⟩ := hα in small.mk' $ f.trans equiv.ulift.symm
@[priority 100]
instance small_max (α : Type v) : small.{max w v} α :=
small_lift.{v w} α
instance small_ulift (α : Type u) [small.{v} α] : small.{v} (ulift.{w} α) :=
small_map equiv.ulift
theorem small_type : small.{max (u+1) v} (Type u) := small_max.{max (u+1) v} _
section
open_locale classical
theorem small_congr {α : Type*} {β : Type*} (e : α ≃ β) : small.{w} α ↔ small.{w} β :=
⟨λ h, @small_map _ _ h e.symm, λ h, @small_map _ _ h e⟩
instance small_subtype (α : Type v) [small.{w} α] (P : α → Prop) : small.{w} { x // P x } :=
small_map (equiv_shrink α).subtype_equiv_of_subtype'
theorem small_of_injective {α : Type v} {β : Type w} [small.{u} β] {f : α → β}
(hf : function.injective f) : small.{u} α :=
small_map (equiv.of_injective f hf)
theorem small_of_surjective {α : Type v} {β : Type w} [small.{u} α] {f : α → β}
(hf : function.surjective f) : small.{u} β :=
small_of_injective (function.injective_surj_inv hf)
theorem small_subset {α : Type v} {s t : set α} (hts : t ⊆ s) [small.{u} s] : small.{u} t :=
let f : t → s := λ x, ⟨x, hts x.prop⟩ in
@small_of_injective _ _ _ f (λ x y hxy, subtype.ext (subtype.mk.inj hxy))
@[priority 100]
instance small_subsingleton (α : Type v) [subsingleton α] : small.{w} α :=
begin
rcases is_empty_or_nonempty α; resetI,
{ apply small_map (equiv.equiv_pempty α) },
{ apply small_map equiv.punit_of_nonempty_of_subsingleton, assumption' },
end
/-!
We don't define `small_of_fintype` or `small_of_encodable` in this file,
to keep imports to `logic` to a minimum.
-/
instance small_Pi {α} (β : α → Type*) [small.{w} α] [∀ a, small.{w} (β a)] :
small.{w} (Π a, β a) :=
⟨⟨Π a' : shrink α, shrink (β ((equiv_shrink α).symm a')),
⟨equiv.Pi_congr (equiv_shrink α) (λ a, by simpa using equiv_shrink (β a))⟩⟩⟩
instance small_sigma {α} (β : α → Type*) [small.{w} α] [∀ a, small.{w} (β a)] :
small.{w} (Σ a, β a) :=
⟨⟨Σ a' : shrink α, shrink (β ((equiv_shrink α).symm a')),
⟨equiv.sigma_congr (equiv_shrink α) (λ a, by simpa using equiv_shrink (β a))⟩⟩⟩
instance small_prod {α β} [small.{w} α] [small.{w} β] : small.{w} (α × β) :=
⟨⟨shrink α × shrink β,
⟨equiv.prod_congr (equiv_shrink α) (equiv_shrink β)⟩⟩⟩
instance small_sum {α β} [small.{w} α] [small.{w} β] : small.{w} (α ⊕ β) :=
⟨⟨shrink α ⊕ shrink β,
⟨equiv.sum_congr (equiv_shrink α) (equiv_shrink β)⟩⟩⟩
instance small_set {α} [small.{w} α] : small.{w} (set α) :=
⟨⟨set (shrink α), ⟨equiv.set.congr (equiv_shrink α)⟩⟩⟩
instance small_range {α : Type v} {β : Type w} (f : α → β) [small.{u} α] :
small.{u} (set.range f) :=
small_of_surjective set.surjective_onto_range
instance small_image {α : Type v} {β : Type w} (f : α → β) (S : set α) [small.{u} S] :
small.{u} (f '' S) :=
small_of_surjective set.surjective_onto_image
theorem not_small_type : ¬ small.{u} (Type (max u v))
| ⟨⟨S, ⟨e⟩⟩⟩ := @function.cantor_injective (Σ α, e.symm α)
(λ a, ⟨_, cast (e.3 _).symm a⟩)
(λ a b e, (cast_inj _).1 $ eq_of_heq (sigma.mk.inj e).2)
instance small_vector {α : Type v} {n : ℕ} [small.{u} α] :
small.{u} (vector α n) :=
small_of_injective (equiv.vector_equiv_fin α n).injective
instance small_list {α : Type v} [small.{u} α] :
small.{u} (list α) :=
begin
let e : (Σ n, vector α n) ≃ list α := equiv.sigma_fiber_equiv list.length,
exact small_of_surjective e.surjective,
end
end
|
c5e8b85a52d99e1bb9444474dd0d54e27dd746e0 | 3b1abba731363bfec018d9d2cfee7fd90e1dc93c | /RT_1_2.lean | 68acf75cf00bc524c3bc8534ab6bad71d4b55264 | [] | no_license | minchaowu/Ramsey.lean | dcf4e0845cca6dc02ef898f3fd9123c079c5a1a9 | 8ebbead4869bdf3f4788137411c5f36f2e72943a | refs/heads/master | 1,610,462,544,433 | 1,488,596,497,000 | 1,488,596,497,000 | 72,063,527 | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 5,773 | lean | import lemmas_for_RT_n_m
open classical set nat decidable prod subtype
noncomputable theory
proposition ne_empty_of_card_pos {A : Type} {s : set A} (H : card s > 0) : s ≠ ∅ :=
take H', begin rewrite [H' at H, card_empty at H], exact lt.irrefl 0 H end
proposition insert_subset {A : Type} {s t : set A} {a : A} (amem : a ∈ t) (ssubt : s ⊆ t) : insert a s ⊆ t := by+ intros x h; apply or.elim h;simp;intro h';apply ssubt h'
proposition eq_singleton_of_forall_eq {A : Type} {s : set A} {x : A} (xs : x ∈ s) (H : ∀₀ y ∈ s, y = x) : s = '{x} :=
ext (take y, iff.intro
(assume ys, mem_singleton_of_eq (H ys))
(assume yx, by rewrite (eq_of_mem_singleton yx); assumption))
lemma eq_of_card_eq_one {A : Type} {S : set A} (H : card S = 1) {x y : A} (Hx : x ∈ S) (Hy : y ∈ S) : x = y :=
have finS : finite S,
from by_contradiction (assume nfinS, begin rewrite (card_of_not_finite nfinS) at H, contradiction end),
by_contradiction
(assume H0 : x ≠ y,
have H1 : '{x, y} ⊆ S, from insert_subset Hx (insert_subset Hy (empty_subset _)),
have x ∉ '{y}, from assume H, H0 (eq_of_mem_singleton H),
have 2 ≤ 1, from calc
2 = card '{x, y} : by+ rewrite [card_insert_of_not_mem this, card_insert_of_not_mem (not_mem_empty _), card_empty]
... ≤ card S : @card_le_card_of_subset _ _ _ _ finS H1
... = 1 : H,
show false, from dec_trivial this)
proposition eq_singleton_of_card_eq_one {A : Type} {s : set A} {x : A} (H : card s = 1) (xs : x ∈ s) : s = '{x} :=
eq_singleton_of_forall_eq xs (take y, assume ys, eq.symm (eq_of_card_eq_one H xs ys))
proposition exists_eq_singleton_of_card_eq_one {A : Type} {s : set A} (H : card s = 1) : ∃ x, s = '{x} :=
have s ≠ ∅, from ne_empty_of_card_pos (by rewrite H; apply dec_trivial),
obtain (x : A) (xs : x ∈ s), from exists_mem_of_ne_empty this,
show _, from exists.intro x (eq_singleton_of_card_eq_one H xs)
section
parameter X : set ℕ
parameter c : set ℕ → ℕ
parameter Hinf : infinite X
parameter Hc : is_coloring X 1 2 c
definition c' (n : ℕ) := c '{n}
theorem finite_color_for_rt_1_2 (n : ℕ) (H : n ∈ X): c' n < 2 :=
have sub : '{n} ⊆ X, from
take x, assume Hx,
have x = n, from eq_of_mem_singleton Hx,
by+ simp,
have card : card '{n} = 1, from card_singleton n,
have fin : finite '{n}, from finite_singleton,
have '{n} ∈ tuples X 1, from and.intro sub (and.intro card fin),
Hc this
theorem existence_of_unique_color : ∃ i, infinite {n ∈ X | c' n = i} :=
by_contradiction
(suppose ¬ ∃ i, infinite {n ∈ X | c' n = i},
have H : ∀ i, ¬ infinite {n ∈ X | c' n = i}, from (and.left forall_iff_not_exists) this,
have ¬ infinite {n ∈ X | c' n = 0}, from H 0,
have fin_zero : finite {n ∈ X | c' n = 0}, from dne this,
have ¬ infinite {n ∈ X | c' n = 1}, from H 1,
have fin_one : finite {n ∈ X | c' n = 1}, from dne this,
have fin : finite ({n ∈ X | c' n = 0} ∪ {n ∈ X | c' n = 1}), from @finite_union _ _ _ fin_zero fin_one,
have infinite ({n ∈ X | c' n = 0} ∪ {n ∈ X | c' n = 1}), from
by_contradiction
(suppose ¬ infinite ({n ∈ X | c' n = 0} ∪ {n ∈ X | c' n = 1}),
have finite ({n ∈ X | c' n = 0} ∪ {n ∈ X | c' n = 1}), from dne this,
have ({n ∈ X | c' n = 0} ∪ {n ∈ X | c' n = 1}) ⊆ X, from
λ a, λ Ha, or.elim Ha
(λ Hl, and.left Hl)
(λ Hr, and.left Hr),
have ∃₀ x ∈ X, x ∉ ({n ∈ X | c' n = 0} ∪ {n ∈ X | c' n = 1}), from mem_of_infset Hinf this fin,
obtain k h, from this,
have neg : k ∉ ({n ∈ X | c' n = 0} ∪ {n ∈ X | c' n = 1}), from and.right h,
have c' k < 2, from finite_color_for_rt_1_2 k (and.left h),
have c' k = 0 ∨ c' k = 1, from lt_2_eq_0_or_1 this,
have k ∈ ({n ∈ X | c' n = 0} ∪ {n ∈ X | c' n = 1}), from
or.elim this
(λ Hl, or.intro_left (k ∈ X ∧ c' k = 1) (and.intro (and.left h) Hl))
(λ Hr, or.intro_right (k ∈ X ∧ c' k = 0) (and.intro (and.left h) Hr)),
neg this),
this fin)
definition homoset := {n ∈ X | c' n = some existence_of_unique_color}
theorem inf_homoset : infinite homoset := some_spec existence_of_unique_color
theorem sub_of_X_for_rt_1_2 : homoset ⊆ X := λ a, λ Ha, and.left Ha
theorem critical_lemma_for_rt_1_2 (x : set ℕ) (H : x ∈ tuples homoset 1) : c x = some existence_of_unique_color :=
have cardx : card x = 1, from and.left (and.right H),
have subx : x ⊆ homoset, from and.left H,
have ∃ a, x = '{a}, from exists_eq_singleton_of_card_eq_one cardx,
obtain a h, from this,
have a ∈ homoset, from
have a ∈ '{a}, from mem_singleton a,
have a ∈ x, by+ simp,
subx this,
have c '{a} = some existence_of_unique_color, from and.right this,
by+ simp
lemma alt_form_of_the_critical_lemma_for_rt_1_2 : ∀₀ a ∈ tuples homoset 1, ∀₀ b ∈ tuples homoset 1, c a = c b :=
take a, assume Ha, take b, assume Hb,
have c a = some existence_of_unique_color, from critical_lemma_for_rt_1_2 a Ha,
have c b = some existence_of_unique_color, from critical_lemma_for_rt_1_2 b Hb,
by+ simp
theorem homo_homoset : is_homogeneous X c 1 2 homoset :=
and.intro Hc (and.intro sub_of_X_for_rt_1_2 alt_form_of_the_critical_lemma_for_rt_1_2)
theorem goal_of_rt_1_2 : ∃ s, s ⊆ X ∧ infinite s ∧ is_homogeneous X c 1 2 s :=
have homoset ⊆ X ∧ infinite homoset ∧ is_homogeneous X c 1 2 homoset, from and.intro sub_of_X_for_rt_1_2 (and.intro inf_homoset homo_homoset),
exists.intro homoset this
end
check goal_of_rt_1_2
-- The principal of infinite pigeon hole.
theorem RT_1_2 : ∀ X : set ℕ, ∀ c : set ℕ → ℕ, infinite X → is_coloring X 1 2 c → ∃ S, S ⊆ X ∧ infinite S ∧ is_homogeneous X c 1 2 S :=
take X, take c, assume Hinf, assume Hc,
goal_of_rt_1_2 X c Hinf Hc
check RT_1_2
|
b053d5573d8086d1b74a16e0e86991a1863c5e64 | 74addaa0e41490cbaf2abd313a764c96df57b05d | /Mathlib/group_theory/group_action/basic_auto.lean | f00bdcd5fda493ddb6af157b909605ee44c85050 | [] | no_license | AurelienSaue/Mathlib4_auto | f538cfd0980f65a6361eadea39e6fc639e9dae14 | 590df64109b08190abe22358fabc3eae000943f2 | refs/heads/master | 1,683,906,849,776 | 1,622,564,669,000 | 1,622,564,669,000 | 371,723,747 | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 7,842 | lean | /-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes
-/
import Mathlib.PrePort
import Mathlib.Lean3Lib.init.default
import Mathlib.group_theory.group_action.defs
import Mathlib.group_theory.group_action.group
import Mathlib.group_theory.coset
import Mathlib.PostPort
universes u v u_1 w
namespace Mathlib
/-!
# Basic properties of group actions
-/
namespace mul_action
/-- The orbit of an element under an action. -/
def orbit (α : Type u) {β : Type v} [monoid α] [mul_action α β] (b : β) : set β :=
set.range fun (x : α) => x • b
theorem mem_orbit_iff {α : Type u} {β : Type v} [monoid α] [mul_action α β] {b₁ : β} {b₂ : β} :
b₂ ∈ orbit α b₁ ↔ ∃ (x : α), x • b₁ = b₂ :=
iff.rfl
@[simp] theorem mem_orbit {α : Type u} {β : Type v} [monoid α] [mul_action α β] (b : β) (x : α) :
x • b ∈ orbit α b :=
Exists.intro x rfl
@[simp] theorem mem_orbit_self {α : Type u} {β : Type v} [monoid α] [mul_action α β] (b : β) :
b ∈ orbit α b :=
sorry
/-- The stabilizer of an element under an action, i.e. what sends the element to itself. Note
that this is a set: for the group stabilizer see `stabilizer`. -/
def stabilizer_carrier (α : Type u) {β : Type v} [monoid α] [mul_action α β] (b : β) : set α :=
set_of fun (x : α) => x • b = b
@[simp] theorem mem_stabilizer_iff {α : Type u} {β : Type v} [monoid α] [mul_action α β] {b : β}
{x : α} : x ∈ stabilizer_carrier α b ↔ x • b = b :=
iff.rfl
/-- The set of elements fixed under the whole action. -/
def fixed_points (α : Type u) (β : Type v) [monoid α] [mul_action α β] : set β :=
set_of fun (b : β) => ∀ (x : α), x • b = b
/-- `fixed_by g` is the subfield of elements fixed by `g`. -/
def fixed_by (α : Type u) (β : Type v) [monoid α] [mul_action α β] (g : α) : set β :=
set_of fun (x : β) => g • x = x
theorem fixed_eq_Inter_fixed_by (α : Type u) (β : Type v) [monoid α] [mul_action α β] :
fixed_points α β = set.Inter fun (g : α) => fixed_by α β g :=
sorry
@[simp] theorem mem_fixed_points {α : Type u} (β : Type v) [monoid α] [mul_action α β] {b : β} :
b ∈ fixed_points α β ↔ ∀ (x : α), x • b = b :=
iff.rfl
@[simp] theorem mem_fixed_by {α : Type u} (β : Type v) [monoid α] [mul_action α β] {g : α} {b : β} :
b ∈ fixed_by α β g ↔ g • b = b :=
iff.rfl
theorem mem_fixed_points' {α : Type u} (β : Type v) [monoid α] [mul_action α β] {b : β} :
b ∈ fixed_points α β ↔ ∀ (b' : β), b' ∈ orbit α b → b' = b :=
sorry
/-- The stabilizer of a point `b` as a submonoid of `α`. -/
def stabilizer.submonoid (α : Type u) {β : Type v} [monoid α] [mul_action α β] (b : β) :
submonoid α :=
submonoid.mk (stabilizer_carrier α b) (one_smul α b) sorry
end mul_action
namespace mul_action
/-- The stabilizer of an element under an action, i.e. what sends the element to itself.
A subgroup. -/
def stabilizer (α : Type u) {β : Type v} [group α] [mul_action α β] (b : β) : subgroup α :=
subgroup.mk (submonoid.carrier sorry) sorry sorry sorry
theorem orbit_eq_iff {α : Type u} {β : Type v} [group α] [mul_action α β] {a : β} {b : β} :
orbit α a = orbit α b ↔ a ∈ orbit α b :=
sorry
/-- The stabilizer of a point `b` as a subgroup of `α`. -/
def stabilizer.subgroup (α : Type u) {β : Type v} [group α] [mul_action α β] (b : β) : subgroup α :=
subgroup.mk (submonoid.carrier (stabilizer.submonoid α b)) sorry sorry sorry
@[simp] theorem mem_orbit_smul (α : Type u) {β : Type v} [group α] [mul_action α β] (g : α)
(a : β) : a ∈ orbit α (g • a) :=
sorry
@[simp] theorem smul_mem_orbit_smul (α : Type u) {β : Type v} [group α] [mul_action α β] (g : α)
(h : α) (a : β) : g • a ∈ orbit α (h • a) :=
sorry
/-- The relation "in the same orbit". -/
def orbit_rel (α : Type u) (β : Type v) [group α] [mul_action α β] : setoid β :=
setoid.mk (fun (a b : β) => a ∈ orbit α b) sorry
/-- Action on left cosets. -/
def mul_left_cosets {α : Type u} [group α] (H : subgroup α) (x : α)
(y : quotient_group.quotient H) : quotient_group.quotient H :=
quotient.lift_on' y (fun (y : α) => quotient_group.mk (x * y)) sorry
protected instance quotient {α : Type u} [group α] (H : subgroup α) :
mul_action α (quotient_group.quotient H) :=
mk sorry sorry
@[simp] theorem quotient.smul_mk {α : Type u} [group α] (H : subgroup α) (a : α) (x : α) :
a • quotient_group.mk x = quotient_group.mk (a * x) :=
rfl
@[simp] theorem quotient.smul_coe {α : Type u_1} [comm_group α] (H : subgroup α) (a : α) (x : α) :
a • ↑x = ↑(a * x) :=
rfl
protected instance mul_left_cosets_comp_subtype_val {α : Type u} [group α] (H : subgroup α)
(I : subgroup α) : mul_action (↥I) (quotient_group.quotient H) :=
comp_hom (quotient_group.quotient H) (subgroup.subtype I)
/-- The canonical map from the quotient of the stabilizer to the set. -/
def of_quotient_stabilizer (α : Type u) {β : Type v} [group α] [mul_action α β] (x : β)
(g : quotient_group.quotient (stabilizer α x)) : β :=
quotient.lift_on' g (fun (_x : α) => _x • x) sorry
@[simp] theorem of_quotient_stabilizer_mk (α : Type u) {β : Type v} [group α] [mul_action α β]
(x : β) (g : α) : of_quotient_stabilizer α x (quotient_group.mk g) = g • x :=
rfl
theorem of_quotient_stabilizer_mem_orbit (α : Type u) {β : Type v} [group α] [mul_action α β]
(x : β) (g : quotient_group.quotient (stabilizer α x)) :
of_quotient_stabilizer α x g ∈ orbit α x :=
quotient.induction_on' g fun (g : α) => Exists.intro g rfl
theorem of_quotient_stabilizer_smul (α : Type u) {β : Type v} [group α] [mul_action α β] (x : β)
(g : α) (g' : quotient_group.quotient (stabilizer α x)) :
of_quotient_stabilizer α x (g • g') = g • of_quotient_stabilizer α x g' :=
quotient.induction_on' g' fun (_x : α) => mul_smul g _x x
theorem injective_of_quotient_stabilizer (α : Type u) {β : Type v} [group α] [mul_action α β]
(x : β) : function.injective (of_quotient_stabilizer α x) :=
sorry
/-- Orbit-stabilizer theorem. -/
def orbit_equiv_quotient_stabilizer (α : Type u) {β : Type v} [group α] [mul_action α β] (b : β) :
↥(orbit α b) ≃ quotient_group.quotient (stabilizer α b) :=
equiv.symm
(equiv.of_bijective
(fun (g : quotient_group.quotient (stabilizer α b)) =>
{ val := of_quotient_stabilizer α b g, property := of_quotient_stabilizer_mem_orbit α b g })
sorry)
@[simp] theorem orbit_equiv_quotient_stabilizer_symm_apply (α : Type u) {β : Type v} [group α]
[mul_action α β] (b : β) (a : α) :
↑(coe_fn (equiv.symm (orbit_equiv_quotient_stabilizer α b)) ↑a) = a • b :=
rfl
end mul_action
theorem list.smul_sum {α : Type u} {β : Type v} [monoid α] [add_monoid β] [distrib_mul_action α β]
{r : α} {l : List β} : r • list.sum l = list.sum (list.map (has_scalar.smul r) l) :=
add_monoid_hom.map_list_sum (const_smul_hom β r) l
theorem multiset.smul_sum {α : Type u} {β : Type v} [monoid α] [add_comm_monoid β]
[distrib_mul_action α β] {r : α} {s : multiset β} :
r • multiset.sum s = multiset.sum (multiset.map (has_scalar.smul r) s) :=
add_monoid_hom.map_multiset_sum (const_smul_hom β r) s
theorem finset.smul_sum {α : Type u} {β : Type v} {γ : Type w} [monoid α] [add_comm_monoid β]
[distrib_mul_action α β] {r : α} {f : γ → β} {s : finset γ} :
(r • finset.sum s fun (x : γ) => f x) = finset.sum s fun (x : γ) => r • f x :=
add_monoid_hom.map_sum (const_smul_hom β r) f s
end Mathlib |
b7ba9d492b2dca4701358e389405f5c3b8e952cd | 74addaa0e41490cbaf2abd313a764c96df57b05d | /Mathlib/tactic/nth_rewrite/default.lean | 26fcb10e7b7de4e0806f290b9c70c5c4f08e9f00 | [] | no_license | AurelienSaue/Mathlib4_auto | f538cfd0980f65a6361eadea39e6fc639e9dae14 | 590df64109b08190abe22358fabc3eae000943f2 | refs/heads/master | 1,683,906,849,776 | 1,622,564,669,000 | 1,622,564,669,000 | 371,723,747 | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 2,818 | lean | /-
Copyright (c) 2018 Keeley Hoek. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johan Commelin, Keeley Hoek, Scott Morrison
-/
import Mathlib.PrePort
import Mathlib.Lean3Lib.init.default
import Mathlib.tactic.nth_rewrite.congr
import Mathlib.PostPort
namespace Mathlib
/-!
# Advanced rewriting tactics
This file provides three interactive tactics
that give the user more control over where to perform a rewrite.
## Main definitions
* `nth_rewrite n rules`: performs only the `n`th possible rewrite using the `rules`.
* `nth_rewrite_lhs`: as above, but only rewrites on the left hand side of an equation or iff.
* `nth_rewrite_rhs`: as above, but only rewrites on the right hand side of an equation or iff.
## Implementation details
There are two alternative backends, provided by `.congr` and `.kabstract`.
The kabstract backend is not currently available through mathlib.
The kabstract backend is faster, but if there are multiple identical occurrences of the
same rewritable subexpression, all are rewritten simultaneously,
and this isn't always what we want.
(In particular, `rewrite_search` is much less capable on the `category_theory` library.)
-/
namespace tactic
/-- Returns the target of the goal when passed `none`,
otherwise, return the type of `h` in `some h`. -/
/-- Replace the target, or a hypothesis, depending on whether `none` or `some h` is given as the
first argument. -/
/-- Preprocess a rewrite rule for use in `get_nth_rewrite`. -/
/-- Get the `n`th rewrite of rewrite rules `q` in expression `e`,
or fail if there are not enough such rewrites. -/
/-- Rewrite the `n`th occurrence of the rewrite rules `q` of (optionally after zooming into) a
hypothesis or target `h` which is an application of a relation. -/
/-- Rewrite the `n`th occurrence of the rewrite rules `q` (optionally on a side)
at all the locations `loc`. -/
namespace interactive
/-- `nth_rewrite n rules` performs only the `n`th possible rewrite using the `rules`.
The tactics `nth_rewrite_lhs` and `nth_rewrite_rhs` are variants
that operate on the left and right hand sides of an equation or iff.
Note: `n` is zero-based, so `nth_rewrite 0 h`
will rewrite along `h` at the first possible location.
In more detail, given `rules = [h1, ..., hk]`,
this tactic will search for all possible locations
where one of `h1, ..., hk` can be rewritten,
and perform the `n`th occurrence.
Example: Given a goal of the form `a + x = x + b`, and hypothesis `h : x = y`,
the tactic `nth_rewrite 1 h` will change the goal to `a + x = y + b`.
The core `rewrite` has a `occs` configuration setting intended to achieve a similar
purpose, but this doesn't really work. (If a rule matches twice, but with different
values of arguments, the second match will not be identified.) -/
|
7e9d5f3b2698624bedd073cfb9286e150448130b | 432d948a4d3d242fdfb44b81c9e1b1baacd58617 | /src/linear_algebra/eigenspace.lean | 60179f2705d77956a4859295e467414d40b2a203 | [
"Apache-2.0"
] | permissive | JLimperg/aesop3 | 306cc6570c556568897ed2e508c8869667252e8a | a4a116f650cc7403428e72bd2e2c4cda300fe03f | refs/heads/master | 1,682,884,916,368 | 1,620,320,033,000 | 1,620,320,033,000 | null | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 24,973 | lean | /-
Copyright (c) 2020 Alexander Bentkamp. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Alexander Bentkamp
-/
import field_theory.algebraic_closure
import linear_algebra.finsupp
import linear_algebra.matrix
import order.preorder_hom
/-!
# Eigenvectors and eigenvalues
This file defines eigenspaces, eigenvalues, and eigenvalues, as well as their generalized
counterparts. We follow Axler's approach [axler2015] because it allows us to derive many properties
without choosing a basis and without using matrices.
An eigenspace of a linear map `f` for a scalar `μ` is the kernel of the map `(f - μ • id)`. The
nonzero elements of an eigenspace are eigenvectors `x`. They have the property `f x = μ • x`. If
there are eigenvectors for a scalar `μ`, the scalar `μ` is called an eigenvalue.
There is no consensus in the literature whether `0` is an eigenvector. Our definition of
`has_eigenvector` permits only nonzero vectors. For an eigenvector `x` that may also be `0`, we
write `x ∈ f.eigenspace μ`.
A generalized eigenspace of a linear map `f` for a natural number `k` and a scalar `μ` is the kernel
of the map `(f - μ • id) ^ k`. The nonzero elements of a generalized eigenspace are generalized
eigenvectors `x`. If there are generalized eigenvectors for a natural number `k` and a scalar `μ`,
the scalar `μ` is called a generalized eigenvalue.
## References
* [Sheldon Axler, *Linear Algebra Done Right*][axler2015]
* https://en.wikipedia.org/wiki/Eigenvalues_and_eigenvectors
## Tags
eigenspace, eigenvector, eigenvalue, eigen
-/
universes u v w
namespace module
namespace End
open module principal_ideal_ring polynomial finite_dimensional
variables {K R : Type v} {V M : Type w}
[comm_ring R] [add_comm_group M] [module R M] [field K] [add_comm_group V] [module K V]
/-- The submodule `eigenspace f μ` for a linear map `f` and a scalar `μ` consists of all vectors `x`
such that `f x = μ • x`. (Def 5.36 of [axler2015])-/
def eigenspace (f : End R M) (μ : R) : submodule R M :=
(f - algebra_map R (End R M) μ).ker
/-- A nonzero element of an eigenspace is an eigenvector. (Def 5.7 of [axler2015]) -/
def has_eigenvector (f : End R M) (μ : R) (x : M) : Prop :=
x ∈ eigenspace f μ ∧ x ≠ 0
/-- A scalar `μ` is an eigenvalue for a linear map `f` if there are nonzero vectors `x`
such that `f x = μ • x`. (Def 5.5 of [axler2015]) -/
def has_eigenvalue (f : End R M) (a : R) : Prop :=
eigenspace f a ≠ ⊥
lemma has_eigenvalue_of_has_eigenvector {f : End R M} {μ : R} {x : M} (h : has_eigenvector f μ x) :
has_eigenvalue f μ :=
begin
rw [has_eigenvalue, submodule.ne_bot_iff],
use x, exact h,
end
lemma mem_eigenspace_iff {f : End R M} {μ : R} {x : M} : x ∈ eigenspace f μ ↔ f x = μ • x :=
by rw [eigenspace, linear_map.mem_ker, linear_map.sub_apply, algebra_map_End_apply,
sub_eq_zero]
lemma eigenspace_div (f : End K V) (a b : K) (hb : b ≠ 0) :
eigenspace f (a / b) = (b • f - algebra_map K (End K V) a).ker :=
calc
eigenspace f (a / b) = eigenspace f (b⁻¹ * a) : by { rw [div_eq_mul_inv, mul_comm] }
... = (f - (b⁻¹ * a) • linear_map.id).ker : rfl
... = (f - b⁻¹ • a • linear_map.id).ker : by rw smul_smul
... = (f - b⁻¹ • algebra_map K (End K V) a).ker : rfl
... = (b • (f - b⁻¹ • algebra_map K (End K V) a)).ker : by rw linear_map.ker_smul _ b hb
... = (b • f - algebra_map K (End K V) a).ker : by rw [smul_sub, smul_inv_smul' hb]
lemma eigenspace_aeval_polynomial_degree_1
(f : End K V) (q : polynomial K) (hq : degree q = 1) :
eigenspace f (- q.coeff 0 / q.leading_coeff) = (aeval f q).ker :=
calc
eigenspace f (- q.coeff 0 / q.leading_coeff)
= (q.leading_coeff • f - algebra_map K (End K V) (- q.coeff 0)).ker
: by { rw eigenspace_div, intro h, rw leading_coeff_eq_zero_iff_deg_eq_bot.1 h at hq, cases hq }
... = (aeval f (C q.leading_coeff * X + C (q.coeff 0))).ker
: by { rw [C_mul', aeval_def], simpa [algebra_map, algebra.to_ring_hom], }
... = (aeval f q).ker
: by { congr, apply (eq_X_add_C_of_degree_eq_one hq).symm }
lemma ker_aeval_ring_hom'_unit_polynomial
(f : End K V) (c : units (polynomial K)) :
(aeval f (c : polynomial K)).ker = ⊥ :=
begin
rw polynomial.eq_C_of_degree_eq_zero (degree_coe_units c),
simp only [aeval_def, eval₂_C],
apply ker_algebra_map_End,
apply coeff_coe_units_zero_ne_zero c
end
theorem aeval_apply_of_has_eigenvector {f : End K V}
{p : polynomial K} {μ : K} {x : V} (h : f.has_eigenvector μ x) :
aeval f p x = (p.eval μ) • x :=
begin
apply p.induction_on,
{ intro a, simp [module.algebra_map_End_apply] },
{ intros p q hp hq, simp [hp, hq, add_smul] },
{ intros n a hna,
rw [mul_comm, pow_succ, mul_assoc, alg_hom.map_mul, linear_map.mul_apply, mul_comm, hna],
simp [algebra_map_End_apply, mem_eigenspace_iff.1 h.1, smul_smul, mul_comm] }
end
section minpoly
theorem is_root_of_has_eigenvalue {f : End K V} {μ : K} (h : f.has_eigenvalue μ) :
(minpoly K f).is_root μ :=
begin
rcases (submodule.ne_bot_iff _).1 h with ⟨w, ⟨H, ne0⟩⟩,
refine or.resolve_right (smul_eq_zero.1 _) ne0,
simp [← aeval_apply_of_has_eigenvector ⟨H, ne0⟩, minpoly.aeval K f],
end
variables [finite_dimensional K V] (f : End K V)
protected theorem is_integral : is_integral K f :=
is_integral_of_noetherian (by apply_instance) f
variables {f} {μ : K}
theorem has_eigenvalue_of_is_root (h : (minpoly K f).is_root μ) :
f.has_eigenvalue μ :=
begin
cases dvd_iff_is_root.2 h with p hp,
rw [has_eigenvalue, eigenspace],
intro con,
cases (linear_map.is_unit_iff _).2 con with u hu,
have p_ne_0 : p ≠ 0,
{ intro con,
apply minpoly.ne_zero f.is_integral,
rw [hp, con, mul_zero] },
have h_deg := minpoly.degree_le_of_ne_zero K f p_ne_0 _,
{ rw [hp, degree_mul, degree_X_sub_C, polynomial.degree_eq_nat_degree p_ne_0] at h_deg,
norm_cast at h_deg,
linarith, },
{ have h_aeval := minpoly.aeval K f,
revert h_aeval,
simp [hp, ← hu] },
end
theorem has_eigenvalue_iff_is_root :
f.has_eigenvalue μ ↔ (minpoly K f).is_root μ :=
⟨is_root_of_has_eigenvalue, has_eigenvalue_of_is_root⟩
end minpoly
/-- Every linear operator on a vector space over an algebraically closed field has
an eigenvalue. -/
-- This is Lemma 5.21 of [axler2015], although we are no longer following that proof.
lemma exists_eigenvalue [is_alg_closed K] [finite_dimensional K V] [nontrivial V] (f : End K V) :
∃ (c : K), f.has_eigenvalue c :=
begin
obtain ⟨c, nu⟩ := exists_spectrum_of_is_alg_closed_of_finite_dimensional K f,
use c,
rw linear_map.is_unit_iff at nu,
exact has_eigenvalue_of_has_eigenvector (exists_mem_ne_zero_of_ne_bot nu).some_spec,
end
/-- Eigenvectors corresponding to distinct eigenvalues of a linear operator are linearly
independent. (Lemma 5.10 of [axler2015])
We use the eigenvalues as indexing set to ensure that there is only one eigenvector for each
eigenvalue in the image of `xs`. -/
lemma eigenvectors_linear_independent (f : End K V) (μs : set K) (xs : μs → V)
(h_eigenvec : ∀ μ : μs, f.has_eigenvector μ (xs μ)) :
linear_independent K xs :=
begin
classical,
-- We need to show that if a linear combination `l` of the eigenvectors `xs` is `0`, then all
-- its coefficients are zero.
suffices : ∀ l, finsupp.total μs V K xs l = 0 → l = 0,
{ rw linear_independent_iff,
apply this },
intros l hl,
-- We apply induction on the finite set of eigenvalues whose eigenvectors have nonzero
-- coefficients, i.e. on the support of `l`.
induction h_l_support : l.support using finset.induction with μ₀ l_support' hμ₀ ih generalizing l,
-- If the support is empty, all coefficients are zero and we are done.
{ exact finsupp.support_eq_empty.1 h_l_support },
-- Now assume that the support of `l` contains at least one eigenvalue `μ₀`. We define a new
-- linear combination `l'` to apply the induction hypothesis on later. The linear combination `l'`
-- is derived from `l` by multiplying the coefficient of the eigenvector with eigenvalue `μ`
-- by `μ - μ₀`.
-- To get started, we define `l'` as a function `l'_f : μs → K` with potentially infinite support.
{ let l'_f : μs → K := (λ μ : μs, (↑μ - ↑μ₀) * l μ),
-- The support of `l'_f` is the support of `l` without `μ₀`.
have h_l_support' : ∀ (μ : μs), μ ∈ l_support' ↔ l'_f μ ≠ 0 ,
{ intro μ,
suffices : μ ∈ l_support' → μ ≠ μ₀,
{ simp [l'_f, ← finsupp.not_mem_support_iff, h_l_support, sub_eq_zero, ←subtype.ext_iff],
tauto },
rintro hμ rfl,
contradiction },
-- Now we can define `l'_f` as an actual linear combination `l'` because we know that the
-- support is finite.
let l' : μs →₀ K :=
{ to_fun := l'_f, support := l_support', mem_support_to_fun := h_l_support' },
-- The linear combination `l'` over `xs` adds up to `0`.
have total_l' : finsupp.total μs V K xs l' = 0,
{ let g := f - algebra_map K (End K V) μ₀,
have h_gμ₀: g (l μ₀ • xs μ₀) = 0,
by rw [linear_map.map_smul, linear_map.sub_apply, mem_eigenspace_iff.1 (h_eigenvec _).1,
algebra_map_End_apply, sub_self, smul_zero],
have h_useless_filter : finset.filter (λ (a : μs), l'_f a ≠ 0) l_support' = l_support',
{ rw finset.filter_congr _,
{ apply finset.filter_true },
{ apply_instance },
exact λ μ hμ, (iff_true _).mpr ((h_l_support' μ).1 hμ) },
have bodies_eq : ∀ (μ : μs), l'_f μ • xs μ = g (l μ • xs μ),
{ intro μ,
dsimp only [g, l'_f],
rw [linear_map.map_smul, linear_map.sub_apply, mem_eigenspace_iff.1 (h_eigenvec _).1,
algebra_map_End_apply, ←sub_smul, smul_smul, mul_comm] },
rw [←linear_map.map_zero g, ←hl, finsupp.total_apply, finsupp.total_apply,
finsupp.sum, finsupp.sum, linear_map.map_sum, h_l_support,
finset.sum_insert hμ₀, h_gμ₀, zero_add],
refine finset.sum_congr rfl (λ μ _, _),
apply bodies_eq },
-- Therefore, by the induction hypothesis, all coefficients in `l'` are zero.
have l'_eq_0 : l' = 0 := ih l' total_l' rfl,
-- By the defintion of `l'`, this means that `(μ - μ₀) * l μ = 0` for all `μ`.
have h_mul_eq_0 : ∀ μ : μs, (↑μ - ↑μ₀) * l μ = 0,
{ intro μ,
calc (↑μ - ↑μ₀) * l μ = l' μ : rfl
... = 0 : by { rw [l'_eq_0], refl } },
-- Thus, the coefficients in `l` for all `μ ≠ μ₀` are `0`.
have h_lμ_eq_0 : ∀ μ : μs, μ ≠ μ₀ → l μ = 0,
{ intros μ hμ,
apply or_iff_not_imp_left.1 (mul_eq_zero.1 (h_mul_eq_0 μ)),
rwa [sub_eq_zero, ←subtype.ext_iff] },
-- So if we sum over all these coefficients, we obtain `0`.
have h_sum_l_support'_eq_0 : finset.sum l_support' (λ (μ : ↥μs), l μ • xs μ) = 0,
{ rw ←finset.sum_const_zero,
apply finset.sum_congr rfl,
intros μ hμ,
rw h_lμ_eq_0,
apply zero_smul,
intro h,
rw h at hμ,
contradiction },
-- The only potentially nonzero coefficient in `l` is the one corresponding to `μ₀`. But since
-- the overall sum is `0` by assumption, this coefficient must also be `0`.
have : l μ₀ = 0,
{ rw [finsupp.total_apply, finsupp.sum, h_l_support,
finset.sum_insert hμ₀, h_sum_l_support'_eq_0, add_zero] at hl,
by_contra h,
exact (h_eigenvec μ₀).2 ((smul_eq_zero.1 hl).resolve_left h) },
-- Thus, all coefficients in `l` are `0`.
show l = 0,
{ ext μ,
by_cases h_cases : μ = μ₀,
{ rw h_cases,
assumption },
exact h_lμ_eq_0 μ h_cases } }
end
/-- The generalized eigenspace for a linear map `f`, a scalar `μ`, and an exponent `k ∈ ℕ` is the
kernel of `(f - μ • id) ^ k`. (Def 8.10 of [axler2015]). Furthermore, a generalized eigenspace for
some exponent `k` is contained in the generalized eigenspace for exponents larger than `k`. -/
def generalized_eigenspace (f : End R M) (μ : R) : ℕ →ₘ submodule R M :=
{ to_fun := λ k, ((f - algebra_map R (End R M) μ) ^ k).ker,
monotone' := λ k m hm,
begin
simp only [← pow_sub_mul_pow _ hm],
exact linear_map.ker_le_ker_comp
((f - algebra_map R (End R M) μ) ^ k) ((f - algebra_map R (End R M) μ) ^ (m - k)),
end }
@[simp] lemma mem_generalized_eigenspace (f : End R M) (μ : R) (k : ℕ) (m : M) :
m ∈ f.generalized_eigenspace μ k ↔ ((f - μ • 1)^k) m = 0 :=
iff.rfl
/-- A nonzero element of a generalized eigenspace is a generalized eigenvector.
(Def 8.9 of [axler2015])-/
def has_generalized_eigenvector (f : End R M) (μ : R) (k : ℕ) (x : M) : Prop :=
x ≠ 0 ∧ x ∈ generalized_eigenspace f μ k
/-- A scalar `μ` is a generalized eigenvalue for a linear map `f` and an exponent `k ∈ ℕ` if there
are generalized eigenvectors for `f`, `k`, and `μ`. -/
def has_generalized_eigenvalue (f : End R M) (μ : R) (k : ℕ) : Prop :=
generalized_eigenspace f μ k ≠ ⊥
/-- The generalized eigenrange for a linear map `f`, a scalar `μ`, and an exponent `k ∈ ℕ` is the
range of `(f - μ • id) ^ k`. -/
def generalized_eigenrange (f : End R M) (μ : R) (k : ℕ) : submodule R M :=
((f - algebra_map R (End R M) μ) ^ k).range
/-- The exponent of a generalized eigenvalue is never 0. -/
lemma exp_ne_zero_of_has_generalized_eigenvalue {f : End R M} {μ : R} {k : ℕ}
(h : f.has_generalized_eigenvalue μ k) : k ≠ 0 :=
begin
rintro rfl,
exact h linear_map.ker_id
end
/-- The union of the kernels of `(f - μ • id) ^ k` over all `k`. -/
def maximal_generalized_eigenspace (f : End R M) (μ : R) : submodule R M :=
⨆ k, f.generalized_eigenspace μ k
lemma generalized_eigenspace_le_maximal (f : End R M) (μ : R) (k : ℕ) :
f.generalized_eigenspace μ k ≤ f.maximal_generalized_eigenspace μ :=
le_supr _ _
@[simp] lemma mem_maximal_generalized_eigenspace (f : End R M) (μ : R) (m : M) :
m ∈ f.maximal_generalized_eigenspace μ ↔ ∃ (k : ℕ), ((f - μ • 1)^k) m = 0 :=
by simp only [maximal_generalized_eigenspace, ← mem_generalized_eigenspace,
submodule.mem_supr_of_chain]
/-- If there exists a natural number `k` such that the kernel of `(f - μ • id) ^ k` is the
maximal generalized eigenspace, then this value is the least such `k`. If not, this value is not
meaningful. -/
noncomputable def maximal_generalized_eigenspace_index (f : End R M) (μ : R) :=
monotonic_sequence_limit_index (f.generalized_eigenspace μ)
/-- For an endomorphism of a Noetherian module, the maximal eigenspace is always of the form kernel
`(f - μ • id) ^ k` for some `k`. -/
lemma maximal_generalized_eigenspace_eq [h : is_noetherian R M] (f : End R M) (μ : R) :
maximal_generalized_eigenspace f μ =
f.generalized_eigenspace μ (maximal_generalized_eigenspace_index f μ) :=
begin
rw is_noetherian_iff_well_founded at h,
exact (well_founded.supr_eq_monotonic_sequence_limit h (f.generalized_eigenspace μ) : _),
end
/-- A generalized eigenvalue for some exponent `k` is also
a generalized eigenvalue for exponents larger than `k`. -/
lemma has_generalized_eigenvalue_of_has_generalized_eigenvalue_of_le
{f : End R M} {μ : R} {k : ℕ} {m : ℕ} (hm : k ≤ m) (hk : f.has_generalized_eigenvalue μ k) :
f.has_generalized_eigenvalue μ m :=
begin
unfold has_generalized_eigenvalue at *,
contrapose! hk,
rw [←le_bot_iff, ←hk],
exact (f.generalized_eigenspace μ).monotone hm,
end
/-- The eigenspace is a subspace of the generalized eigenspace. -/
lemma eigenspace_le_generalized_eigenspace {f : End R M} {μ : R} {k : ℕ} (hk : 0 < k) :
f.eigenspace μ ≤ f.generalized_eigenspace μ k :=
(f.generalized_eigenspace μ).monotone (nat.succ_le_of_lt hk)
/-- All eigenvalues are generalized eigenvalues. -/
lemma has_generalized_eigenvalue_of_has_eigenvalue
{f : End R M} {μ : R} {k : ℕ} (hk : 0 < k) (hμ : f.has_eigenvalue μ) :
f.has_generalized_eigenvalue μ k :=
begin
apply has_generalized_eigenvalue_of_has_generalized_eigenvalue_of_le hk,
rw [has_generalized_eigenvalue, generalized_eigenspace, preorder_hom.coe_fun_mk, pow_one],
exact hμ,
end
/-- All generalized eigenvalues are eigenvalues. -/
lemma has_eigenvalue_of_has_generalized_eigenvalue
{f : End R M} {μ : R} {k : ℕ} (hμ : f.has_generalized_eigenvalue μ k) :
f.has_eigenvalue μ :=
begin
intros contra, apply hμ,
erw linear_map.ker_eq_bot at ⊢ contra, rw linear_map.coe_pow,
exact function.injective.iterate contra k,
end
/-- Generalized eigenvalues are actually just eigenvalues. -/
@[simp] lemma has_generalized_eigenvalue_iff_has_eigenvalue
{f : End R M} {μ : R} {k : ℕ} (hk : 0 < k) :
f.has_generalized_eigenvalue μ k ↔ f.has_eigenvalue μ :=
⟨has_eigenvalue_of_has_generalized_eigenvalue, has_generalized_eigenvalue_of_has_eigenvalue hk⟩
/-- Every generalized eigenvector is a generalized eigenvector for exponent `finrank K V`.
(Lemma 8.11 of [axler2015]) -/
lemma generalized_eigenspace_le_generalized_eigenspace_finrank
[finite_dimensional K V] (f : End K V) (μ : K) (k : ℕ) :
f.generalized_eigenspace μ k ≤ f.generalized_eigenspace μ (finrank K V) :=
ker_pow_le_ker_pow_finrank _ _
/-- Generalized eigenspaces for exponents at least `finrank K V` are equal to each other. -/
lemma generalized_eigenspace_eq_generalized_eigenspace_finrank_of_le [finite_dimensional K V]
(f : End K V) (μ : K) {k : ℕ} (hk : finrank K V ≤ k) :
f.generalized_eigenspace μ k = f.generalized_eigenspace μ (finrank K V) :=
ker_pow_eq_ker_pow_finrank_of_le hk
/-- If `f` maps a subspace `p` into itself, then the generalized eigenspace of the restriction
of `f` to `p` is the part of the generalized eigenspace of `f` that lies in `p`. -/
lemma generalized_eigenspace_restrict
(f : End R M) (p : submodule R M) (k : ℕ) (μ : R) (hfp : ∀ (x : M), x ∈ p → f x ∈ p) :
generalized_eigenspace (linear_map.restrict f hfp) μ k =
submodule.comap p.subtype (f.generalized_eigenspace μ k) :=
begin
simp only [generalized_eigenspace, preorder_hom.coe_fun_mk, ← linear_map.ker_comp],
induction k with k ih,
{ rw [pow_zero, pow_zero, linear_map.one_eq_id],
apply (submodule.ker_subtype _).symm },
{ erw [pow_succ', pow_succ', linear_map.ker_comp,
ih, ←linear_map.ker_comp, linear_map.comp_assoc], }
end
/-- Generalized eigenrange and generalized eigenspace for exponent `finrank K V` are disjoint. -/
lemma generalized_eigenvec_disjoint_range_ker [finite_dimensional K V] (f : End K V) (μ : K) :
disjoint (f.generalized_eigenrange μ (finrank K V)) (f.generalized_eigenspace μ (finrank K V)) :=
begin
have h := calc
submodule.comap ((f - algebra_map _ _ μ) ^ finrank K V)
(f.generalized_eigenspace μ (finrank K V))
= ((f - algebra_map _ _ μ) ^ finrank K V *
(f - algebra_map K (End K V) μ) ^ finrank K V).ker :
by { simpa only [generalized_eigenspace, preorder_hom.coe_fun_mk, ← linear_map.ker_comp] }
... = f.generalized_eigenspace μ (finrank K V + finrank K V) :
by { rw ←pow_add, refl }
... = f.generalized_eigenspace μ (finrank K V) :
by { rw generalized_eigenspace_eq_generalized_eigenspace_finrank_of_le, linarith },
rw [disjoint, generalized_eigenrange, linear_map.range_eq_map, submodule.map_inf_eq_map_inf_comap,
top_inf_eq, h],
apply submodule.map_comap_le
end
/-- The generalized eigenspace of an eigenvalue has positive dimension for positive exponents. -/
lemma pos_finrank_generalized_eigenspace_of_has_eigenvalue [finite_dimensional K V]
{f : End K V} {k : ℕ} {μ : K} (hx : f.has_eigenvalue μ) (hk : 0 < k):
0 < finrank K (f.generalized_eigenspace μ k) :=
calc
0 = finrank K (⊥ : submodule K V) : by rw finrank_bot
... < finrank K (f.eigenspace μ) : submodule.finrank_lt_finrank_of_lt (bot_lt_iff_ne_bot.2 hx)
... ≤ finrank K (f.generalized_eigenspace μ k) :
submodule.finrank_mono ((f.generalized_eigenspace μ).monotone (nat.succ_le_of_lt hk))
/-- A linear map maps a generalized eigenrange into itself. -/
lemma map_generalized_eigenrange_le {f : End K V} {μ : K} {n : ℕ} :
submodule.map f (f.generalized_eigenrange μ n) ≤ f.generalized_eigenrange μ n :=
calc submodule.map f (f.generalized_eigenrange μ n)
= (f * ((f - algebra_map _ _ μ) ^ n)).range : (linear_map.range_comp _ _).symm
... = (((f - algebra_map _ _ μ) ^ n) * f).range : by rw algebra.mul_sub_algebra_map_pow_commutes
... = submodule.map ((f - algebra_map _ _ μ) ^ n) f.range : linear_map.range_comp _ _
... ≤ f.generalized_eigenrange μ n : linear_map.map_le_range
/-- The generalized eigenvectors span the entire vector space (Lemma 8.21 of [axler2015]). -/
lemma supr_generalized_eigenspace_eq_top [is_alg_closed K] [finite_dimensional K V] (f : End K V) :
(⨆ (μ : K) (k : ℕ), f.generalized_eigenspace μ k) = ⊤ :=
begin
tactic.unfreeze_local_instances,
-- We prove the claim by strong induction on the dimension of the vector space.
induction h_dim : finrank K V using nat.strong_induction_on with n ih generalizing V,
cases n,
-- If the vector space is 0-dimensional, the result is trivial.
{ rw ←top_le_iff,
simp only [finrank_eq_zero.1 (eq.trans finrank_top h_dim), bot_le] },
-- Otherwise the vector space is nontrivial.
{ haveI : nontrivial V := finrank_pos_iff.1 (by { rw h_dim, apply nat.zero_lt_succ }),
-- Hence, `f` has an eigenvalue `μ₀`.
obtain ⟨μ₀, hμ₀⟩ : ∃ μ₀, f.has_eigenvalue μ₀ := exists_eigenvalue f,
-- We define `ES` to be the generalized eigenspace
let ES := f.generalized_eigenspace μ₀ (finrank K V),
-- and `ER` to be the generalized eigenrange.
let ER := f.generalized_eigenrange μ₀ (finrank K V),
-- `f` maps `ER` into itself.
have h_f_ER : ∀ (x : V), x ∈ ER → f x ∈ ER,
from λ x hx, map_generalized_eigenrange_le (submodule.mem_map_of_mem hx),
-- Therefore, we can define the restriction `f'` of `f` to `ER`.
let f' : End K ER := f.restrict h_f_ER,
-- The dimension of `ES` is positive
have h_dim_ES_pos : 0 < finrank K ES,
{ dsimp only [ES],
rw h_dim,
apply pos_finrank_generalized_eigenspace_of_has_eigenvalue hμ₀ (nat.zero_lt_succ n) },
-- and the dimensions of `ES` and `ER` add up to `finrank K V`.
have h_dim_add : finrank K ER + finrank K ES = finrank K V,
{ apply linear_map.finrank_range_add_finrank_ker },
-- Therefore the dimension `ER` mus be smaller than `finrank K V`.
have h_dim_ER : finrank K ER < n.succ, by linarith,
-- This allows us to apply the induction hypothesis on `ER`:
have ih_ER : (⨆ (μ : K) (k : ℕ), f'.generalized_eigenspace μ k) = ⊤,
from ih (finrank K ER) h_dim_ER f' rfl,
-- The induction hypothesis gives us a statement about subspaces of `ER`. We can transfer this
-- to a statement about subspaces of `V` via `submodule.subtype`:
have ih_ER' : (⨆ (μ : K) (k : ℕ), (f'.generalized_eigenspace μ k).map ER.subtype) = ER,
by simp only [(submodule.map_supr _ _).symm, ih_ER, submodule.map_subtype_top ER],
-- Moreover, every generalized eigenspace of `f'` is contained in the corresponding generalized
-- eigenspace of `f`.
have hff' : ∀ μ k,
(f'.generalized_eigenspace μ k).map ER.subtype ≤ f.generalized_eigenspace μ k,
{ intros,
rw generalized_eigenspace_restrict,
apply submodule.map_comap_le },
-- It follows that `ER` is contained in the span of all generalized eigenvectors.
have hER : ER ≤ ⨆ (μ : K) (k : ℕ), f.generalized_eigenspace μ k,
{ rw ← ih_ER',
apply supr_le_supr _,
exact λ μ, supr_le_supr (λ k, hff' μ k), },
-- `ES` is contained in this span by definition.
have hES : ES ≤ ⨆ (μ : K) (k : ℕ), f.generalized_eigenspace μ k,
from le_trans
(le_supr (λ k, f.generalized_eigenspace μ₀ k) (finrank K V))
(le_supr (λ (μ : K), ⨆ (k : ℕ), f.generalized_eigenspace μ k) μ₀),
-- Moreover, we know that `ER` and `ES` are disjoint.
have h_disjoint : disjoint ER ES,
from generalized_eigenvec_disjoint_range_ker f μ₀,
-- Since the dimensions of `ER` and `ES` add up to the dimension of `V`, it follows that the
-- span of all generalized eigenvectors is all of `V`.
show (⨆ (μ : K) (k : ℕ), f.generalized_eigenspace μ k) = ⊤,
{ rw [←top_le_iff, ←submodule.eq_top_of_disjoint ER ES h_dim_add h_disjoint],
apply sup_le hER hES } }
end
end End
end module
variables {K V : Type*} [field K] [add_comm_group V] [module K V] [finite_dimensional K V]
protected lemma linear_map.is_integral (f : V →ₗ[K] V) : is_integral K f :=
module.End.is_integral f
|
ea40b8c0665b99d9da17cb0c6b21f3e6839f14c6 | 74addaa0e41490cbaf2abd313a764c96df57b05d | /Mathlib/topology/category/Top/adjunctions_auto.lean | 6a74c8b2d4238533f60fa493791ebbee937b52a9 | [] | no_license | AurelienSaue/Mathlib4_auto | f538cfd0980f65a6361eadea39e6fc639e9dae14 | 590df64109b08190abe22358fabc3eae000943f2 | refs/heads/master | 1,683,906,849,776 | 1,622,564,669,000 | 1,622,564,669,000 | 371,723,747 | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 1,568 | lean | /-
Copyright (c) 2017 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Patrick Massot, Mario Carneiro
-/
import Mathlib.PrePort
import Mathlib.Lean3Lib.init.default
import Mathlib.topology.category.Top.basic
import Mathlib.category_theory.adjunction.basic
import Mathlib.PostPort
universes u
namespace Mathlib
namespace Top
/-- Equipping a type with the discrete topology is left adjoint to the forgetful functor `Top ⥤ Type`. -/
def adj₁ : discrete ⊣ category_theory.forget Top :=
category_theory.adjunction.mk
(fun (X : Type u) (Y : Top) =>
equiv.mk (fun (f : category_theory.functor.obj discrete X ⟶ Y) => ⇑f)
(fun (f : X ⟶ category_theory.functor.obj (category_theory.forget Top) Y) =>
continuous_map.mk f)
sorry sorry)
(category_theory.nat_trans.mk fun (X : Type u) => id)
(category_theory.nat_trans.mk fun (X : Top) => continuous_map.mk id)
/-- Equipping a type with the trivial topology is right adjoint to the forgetful functor `Top ⥤ Type`. -/
def adj₂ : category_theory.forget Top ⊣ trivial :=
category_theory.adjunction.mk
(fun (X : Top) (Y : Type u) =>
equiv.mk
(fun (f : category_theory.functor.obj (category_theory.forget Top) X ⟶ Y) =>
continuous_map.mk f)
(fun (f : X ⟶ category_theory.functor.obj trivial Y) => ⇑f) sorry sorry)
(category_theory.nat_trans.mk fun (X : Top) => continuous_map.mk id)
(category_theory.nat_trans.mk fun (X : Type u) => id)
end Mathlib |
9e36d63724b1507ecea82b83ea84c55b6c5c7081 | 57aec6ee746bc7e3a3dd5e767e53bd95beb82f6d | /tests/lean/run/meta4.lean | 1d8e41e84e26b35160462aa493042842d659faa5 | [
"Apache-2.0"
] | permissive | collares/lean4 | 861a9269c4592bce49b71059e232ff0bfe4594cc | 52a4f535d853a2c7c7eea5fee8a4fa04c682c1ee | refs/heads/master | 1,691,419,031,324 | 1,618,678,138,000 | 1,618,678,138,000 | 358,989,750 | 0 | 0 | Apache-2.0 | 1,618,696,333,000 | 1,618,696,333,000 | null | UTF-8 | Lean | false | false | 1,355 | lean | import Lean.Meta
open Lean
open Lean.Meta
def print (msg : MessageData) : MetaM Unit :=
trace[Meta.debug] msg
def checkM (x : MetaM Bool) : MetaM Unit :=
unless (← x) do throwError "check failed"
axiom Ax : forall (α β : Type), α → β → DecidableEq β
set_option trace.Meta.debug true
def tst1 : MetaM Unit := do
let cinfo ← getConstInfo `Ax;
let (_, _, e) ← forallMetaTelescopeReducing cinfo.type (some 0);
checkM (pure (!e.hasMVar));
print e;
let (_, _, e) ← forallMetaTelescopeReducing cinfo.type (some 1);
checkM (pure e.hasMVar);
checkM (pure e.isForall);
print e;
let (_, _, e) ← forallMetaTelescopeReducing cinfo.type (some 5);
checkM (pure e.hasMVar);
checkM (pure e.isForall);
print e;
let (_, _, e) ← forallMetaTelescopeReducing cinfo.type (some 6);
checkM (pure e.hasMVar);
checkM (pure (!e.isForall));
print e;
let (_, _, e') ← forallMetaTelescopeReducing cinfo.type;
print e';
checkM (isDefEq e e');
forallBoundedTelescope cinfo.type (some 0) $ fun xs body => checkM (pure (xs.size == 0));
forallBoundedTelescope cinfo.type (some 1) $ fun xs body => checkM (pure (xs.size == 1));
forallBoundedTelescope cinfo.type (some 6) $ fun xs body => do { print xs; checkM (pure (xs.size == 6)) };
forallBoundedTelescope cinfo.type (some 10) $ fun xs body => do { print xs; checkM (pure (xs.size == 6)) };
pure ()
#eval tst1
|
85cb763d03dd8c6dfdd733a791a46405b8862a22 | 4d2583807a5ac6caaffd3d7a5f646d61ca85d532 | /src/topology/algebra/ordered/intermediate_value.lean | c56811284fbcd4b03541545352404fab5c6ce621 | [
"Apache-2.0"
] | permissive | AntoineChambert-Loir/mathlib | 64aabb896129885f12296a799818061bc90da1ff | 07be904260ab6e36a5769680b6012f03a4727134 | refs/heads/master | 1,693,187,631,771 | 1,636,719,886,000 | 1,636,719,886,000 | null | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 30,595 | lean | /-
Copyright (c) 2021 Yury G. Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury G. Kudryashov, Alistair Tucker
-/
import topology.algebra.ordered.basic
/-!
# Intermediate Value Theorem
In this file we prove the Intermediate Value Theorem: if `f : α → β` is a function defined on a
connected set `s` that takes both values `≤ a` and values `≥ a` on `s`, then it is equal to `a` at
some point of `s`. We also prove that intervals in a dense conditionally complete order are
preconnected and any preconnected set is an interval. Then we specialize IVT to functions continuous
on intervals.
## Main results
* `is_preconnected_I??` : all intervals `I??` are preconnected,
* `is_preconnected.intermediate_value`, `intermediate_value_univ` : Intermediate Value Theorem for
connected sets and connected spaces, respectively;
* `intermediate_value_Icc`, `intermediate_value_Icc'`: Intermediate Value Theorem for functions
on closed intervals.
### Miscellaneous facts
* `is_closed.Icc_subset_of_forall_mem_nhds_within` : “Continuous induction” principle;
if `s ∩ [a, b]` is closed, `a ∈ s`, and for each `x ∈ [a, b) ∩ s` some of its right neighborhoods
is included `s`, then `[a, b] ⊆ s`.
* `is_closed.Icc_subset_of_forall_exists_gt`, `is_closed.mem_of_ge_of_forall_exists_gt` : two
other versions of the “continuous induction” principle.
## Tags
intermediate value theorem, connected space, connected set
-/
open filter order_dual topological_space function set
open_locale topological_space filter
universes u v w
/-!
### Intermediate value theorem on a (pre)connected space
In this section we prove the following theorem (see `is_preconnected.intermediate_value₂`): if `f`
and `g` are two functions continuous on a preconnected set `s`, `f a ≤ g a` at some `a ∈ s` and
`g b ≤ f b` at some `b ∈ s`, then `f c = g c` at some `c ∈ s`. We prove several versions of this
statement, including the classical IVT that corresponds to a constant function `g`.
-/
section
variables {X : Type u} {α : Type v} [topological_space X]
[linear_order α] [topological_space α] [order_closed_topology α]
/-- Intermediate value theorem for two functions: if `f` and `g` are two continuous functions
on a preconnected space and `f a ≤ g a` and `g b ≤ f b`, then for some `x` we have `f x = g x`. -/
lemma intermediate_value_univ₂ [preconnected_space X] {a b : X} {f g : X → α} (hf : continuous f)
(hg : continuous g) (ha : f a ≤ g a) (hb : g b ≤ f b) :
∃ x, f x = g x :=
begin
obtain ⟨x, h, hfg, hgf⟩ : (univ ∩ {x | f x ≤ g x ∧ g x ≤ f x}).nonempty,
from is_preconnected_closed_iff.1 preconnected_space.is_preconnected_univ _ _
(is_closed_le hf hg) (is_closed_le hg hf) (λ x hx, le_total _ _) ⟨a, trivial, ha⟩
⟨b, trivial, hb⟩,
exact ⟨x, le_antisymm hfg hgf⟩
end
lemma intermediate_value_univ₂_eventually₁ [preconnected_space X] {a : X} {l : filter X} [ne_bot l]
{f g : X → α} (hf : continuous f) (hg : continuous g) (ha : f a ≤ g a) (he : g ≤ᶠ[l] f) :
∃ x, f x = g x :=
let ⟨c, hc⟩ := he.frequently.exists in intermediate_value_univ₂ hf hg ha hc
lemma intermediate_value_univ₂_eventually₂ [preconnected_space X] {l₁ l₂ : filter X}
[ne_bot l₁] [ne_bot l₂] {f g : X → α} (hf : continuous f) (hg : continuous g)
(he₁ : f ≤ᶠ[l₁] g ) (he₂ : g ≤ᶠ[l₂] f) :
∃ x, f x = g x :=
let ⟨c₁, hc₁⟩ := he₁.frequently.exists, ⟨c₂, hc₂⟩ := he₂.frequently.exists in
intermediate_value_univ₂ hf hg hc₁ hc₂
/-- Intermediate value theorem for two functions: if `f` and `g` are two functions continuous
on a preconnected set `s` and for some `a b ∈ s` we have `f a ≤ g a` and `g b ≤ f b`,
then for some `x ∈ s` we have `f x = g x`. -/
lemma is_preconnected.intermediate_value₂ {s : set X} (hs : is_preconnected s)
{a b : X} (ha : a ∈ s) (hb : b ∈ s) {f g : X → α}
(hf : continuous_on f s) (hg : continuous_on g s) (ha' : f a ≤ g a) (hb' : g b ≤ f b) :
∃ x ∈ s, f x = g x :=
let ⟨x, hx⟩ := @intermediate_value_univ₂ s α _ _ _ _ (subtype.preconnected_space hs) ⟨a, ha⟩ ⟨b, hb⟩
_ _ (continuous_on_iff_continuous_restrict.1 hf) (continuous_on_iff_continuous_restrict.1 hg)
ha' hb'
in ⟨x, x.2, hx⟩
lemma is_preconnected.intermediate_value₂_eventually₁ {s : set X} (hs : is_preconnected s)
{a : X} {l : filter X} (ha : a ∈ s) [ne_bot l] (hl : l ≤ 𝓟 s) {f g : X → α}
(hf : continuous_on f s) (hg : continuous_on g s) (ha' : f a ≤ g a) (he : g ≤ᶠ[l] f) :
∃ x ∈ s, f x = g x :=
begin
rw continuous_on_iff_continuous_restrict at hf hg,
obtain ⟨b, h⟩ := @intermediate_value_univ₂_eventually₁ _ _ _ _ _ _ (subtype.preconnected_space hs)
⟨a, ha⟩ _ (comap_coe_ne_bot_of_le_principal hl) _ _ hf hg ha' (eventually_comap' he),
exact ⟨b, b.prop, h⟩,
end
lemma is_preconnected.intermediate_value₂_eventually₂ {s : set X} (hs : is_preconnected s)
{l₁ l₂ : filter X} [ne_bot l₁] [ne_bot l₂] (hl₁ : l₁ ≤ 𝓟 s) (hl₂ : l₂ ≤ 𝓟 s) {f g : X → α}
(hf : continuous_on f s) (hg : continuous_on g s) (he₁ : f ≤ᶠ[l₁] g) (he₂ : g ≤ᶠ[l₂] f) :
∃ x ∈ s, f x = g x :=
begin
rw continuous_on_iff_continuous_restrict at hf hg,
obtain ⟨b, h⟩ := @intermediate_value_univ₂_eventually₂ _ _ _ _ _ _ (subtype.preconnected_space hs)
_ _ (comap_coe_ne_bot_of_le_principal hl₁) (comap_coe_ne_bot_of_le_principal hl₂)
_ _ hf hg (eventually_comap' he₁) (eventually_comap' he₂),
exact ⟨b, b.prop, h⟩,
end
/-- **Intermediate Value Theorem** for continuous functions on connected sets. -/
lemma is_preconnected.intermediate_value {s : set X} (hs : is_preconnected s)
{a b : X} (ha : a ∈ s) (hb : b ∈ s) {f : X → α} (hf : continuous_on f s) :
Icc (f a) (f b) ⊆ f '' s :=
λ x hx, mem_image_iff_bex.2 $ hs.intermediate_value₂ ha hb hf continuous_on_const hx.1 hx.2
lemma is_preconnected.intermediate_value_Ico {s : set X} (hs : is_preconnected s)
{a : X} {l : filter X} (ha : a ∈ s) [ne_bot l] (hl : l ≤ 𝓟 s) {f : X → α}
(hf : continuous_on f s) {v : α} (ht : tendsto f l (𝓝 v)) :
Ico (f a) v ⊆ f '' s :=
λ y h, bex_def.1 $ hs.intermediate_value₂_eventually₁ ha hl
hf continuous_on_const h.1 (eventually_ge_of_tendsto_gt h.2 ht)
lemma is_preconnected.intermediate_value_Ioc {s : set X} (hs : is_preconnected s)
{a : X} {l : filter X} (ha : a ∈ s) [ne_bot l] (hl : l ≤ 𝓟 s) {f : X → α}
(hf : continuous_on f s) {v : α} (ht : tendsto f l (𝓝 v)) :
Ioc v (f a) ⊆ f '' s :=
λ y h, bex_def.1 $ bex.imp_right (λ x _, eq.symm) $ hs.intermediate_value₂_eventually₁ ha hl
continuous_on_const hf h.2 (eventually_le_of_tendsto_lt h.1 ht)
lemma is_preconnected.intermediate_value_Ioo {s : set X} (hs : is_preconnected s)
{l₁ l₂ : filter X} [ne_bot l₁] [ne_bot l₂] (hl₁ : l₁ ≤ 𝓟 s) (hl₂ : l₂ ≤ 𝓟 s) {f : X → α}
(hf : continuous_on f s) {v₁ v₂ : α} (ht₁ : tendsto f l₁ (𝓝 v₁)) (ht₂ : tendsto f l₂ (𝓝 v₂)) :
Ioo v₁ v₂ ⊆ f '' s :=
λ y h, bex_def.1 $ hs.intermediate_value₂_eventually₂ hl₁ hl₂
hf continuous_on_const (eventually_le_of_tendsto_lt h.1 ht₁) (eventually_ge_of_tendsto_gt h.2 ht₂)
lemma is_preconnected.intermediate_value_Ici {s : set X} (hs : is_preconnected s)
{a : X} {l : filter X} (ha : a ∈ s) [ne_bot l] (hl : l ≤ 𝓟 s) {f : X → α}
(hf : continuous_on f s) (ht : tendsto f l at_top) :
Ici (f a) ⊆ f '' s :=
λ y h, bex_def.1 $ hs.intermediate_value₂_eventually₁ ha hl
hf continuous_on_const h (tendsto_at_top.1 ht y)
lemma is_preconnected.intermediate_value_Iic {s : set X} (hs : is_preconnected s)
{a : X} {l : filter X} (ha : a ∈ s) [ne_bot l] (hl : l ≤ 𝓟 s) {f : X → α}
(hf : continuous_on f s) (ht : tendsto f l at_bot) :
Iic (f a) ⊆ f '' s :=
λ y h, bex_def.1 $ bex.imp_right (λ x _, eq.symm) $ hs.intermediate_value₂_eventually₁ ha hl
continuous_on_const hf h (tendsto_at_bot.1 ht y)
lemma is_preconnected.intermediate_value_Ioi {s : set X} (hs : is_preconnected s)
{l₁ l₂ : filter X} [ne_bot l₁] [ne_bot l₂] (hl₁ : l₁ ≤ 𝓟 s) (hl₂ : l₂ ≤ 𝓟 s) {f : X → α}
(hf : continuous_on f s) {v : α} (ht₁ : tendsto f l₁ (𝓝 v)) (ht₂ : tendsto f l₂ at_top) :
Ioi v ⊆ f '' s :=
λ y h, bex_def.1 $ hs.intermediate_value₂_eventually₂ hl₁ hl₂
hf continuous_on_const (eventually_le_of_tendsto_lt h ht₁) (tendsto_at_top.1 ht₂ y)
lemma is_preconnected.intermediate_value_Iio {s : set X} (hs : is_preconnected s)
{l₁ l₂ : filter X} [ne_bot l₁] [ne_bot l₂] (hl₁ : l₁ ≤ 𝓟 s) (hl₂ : l₂ ≤ 𝓟 s) {f : X → α}
(hf : continuous_on f s) {v : α} (ht₁ : tendsto f l₁ at_bot) (ht₂ : tendsto f l₂ (𝓝 v)) :
Iio v ⊆ f '' s :=
λ y h, bex_def.1 $ hs.intermediate_value₂_eventually₂ hl₁ hl₂
hf continuous_on_const (tendsto_at_bot.1 ht₁ y) (eventually_ge_of_tendsto_gt h ht₂)
lemma is_preconnected.intermediate_value_Iii {s : set X} (hs : is_preconnected s)
{l₁ l₂ : filter X} [ne_bot l₁] [ne_bot l₂] (hl₁ : l₁ ≤ 𝓟 s) (hl₂ : l₂ ≤ 𝓟 s) {f : X → α}
(hf : continuous_on f s) (ht₁ : tendsto f l₁ at_bot) (ht₂ : tendsto f l₂ at_top) :
univ ⊆ f '' s :=
λ y h, bex_def.1 $ hs.intermediate_value₂_eventually₂ hl₁ hl₂
hf continuous_on_const (tendsto_at_bot.1 ht₁ y) (tendsto_at_top.1 ht₂ y)
/-- **Intermediate Value Theorem** for continuous functions on connected spaces. -/
lemma intermediate_value_univ [preconnected_space X] (a b : X) {f : X → α} (hf : continuous f) :
Icc (f a) (f b) ⊆ range f :=
λ x hx, intermediate_value_univ₂ hf continuous_const hx.1 hx.2
/-- **Intermediate Value Theorem** for continuous functions on connected spaces. -/
lemma mem_range_of_exists_le_of_exists_ge [preconnected_space X] {c : α} {f : X → α}
(hf : continuous f) (h₁ : ∃ a, f a ≤ c) (h₂ : ∃ b, c ≤ f b) :
c ∈ range f :=
let ⟨a, ha⟩ := h₁, ⟨b, hb⟩ := h₂ in intermediate_value_univ a b hf ⟨ha, hb⟩
/-!
### (Pre)connected sets in a linear order
In this section we prove the following results:
* `is_preconnected.ord_connected`: any preconnected set `s` in a linear order is `ord_connected`,
i.e. `a ∈ s` and `b ∈ s` imply `Icc a b ⊆ s`;
* `is_preconnected.mem_intervals`: any preconnected set `s` in a conditionally complete linear order
is one of the intervals `set.Icc`, `set.`Ico`, `set.Ioc`, `set.Ioo`, ``set.Ici`, `set.Iic`,
`set.Ioi`, `set.Iio`; note that this is false for non-complete orders: e.g., in `ℝ \ {0}`, the set
of positive numbers cannot be represented as `set.Ioi _`.
-/
/-- If a preconnected set contains endpoints of an interval, then it includes the whole interval. -/
lemma is_preconnected.Icc_subset {s : set α} (hs : is_preconnected s)
{a b : α} (ha : a ∈ s) (hb : b ∈ s) :
Icc a b ⊆ s :=
by simpa only [image_id] using hs.intermediate_value ha hb continuous_on_id
lemma is_preconnected.ord_connected {s : set α} (h : is_preconnected s) :
ord_connected s :=
⟨λ x hx y hy, h.Icc_subset hx hy⟩
/-- If a preconnected set contains endpoints of an interval, then it includes the whole interval. -/
lemma is_connected.Icc_subset {s : set α} (hs : is_connected s)
{a b : α} (ha : a ∈ s) (hb : b ∈ s) :
Icc a b ⊆ s :=
hs.2.Icc_subset ha hb
/-- If preconnected set in a linear order space is unbounded below and above, then it is the whole
space. -/
lemma is_preconnected.eq_univ_of_unbounded {s : set α} (hs : is_preconnected s) (hb : ¬bdd_below s)
(ha : ¬bdd_above s) :
s = univ :=
begin
refine eq_univ_of_forall (λ x, _),
obtain ⟨y, ys, hy⟩ : ∃ y ∈ s, y < x := not_bdd_below_iff.1 hb x,
obtain ⟨z, zs, hz⟩ : ∃ z ∈ s, x < z := not_bdd_above_iff.1 ha x,
exact hs.Icc_subset ys zs ⟨le_of_lt hy, le_of_lt hz⟩
end
end
variables {α : Type u} {β : Type v} {γ : Type w}
[conditionally_complete_linear_order α] [topological_space α] [order_topology α]
[conditionally_complete_linear_order β] [topological_space β] [order_topology β]
[nonempty γ]
/-- A bounded connected subset of a conditionally complete linear order includes the open interval
`(Inf s, Sup s)`. -/
lemma is_connected.Ioo_cInf_cSup_subset {s : set α} (hs : is_connected s) (hb : bdd_below s)
(ha : bdd_above s) :
Ioo (Inf s) (Sup s) ⊆ s :=
λ x hx, let ⟨y, ys, hy⟩ := (is_glb_lt_iff (is_glb_cInf hs.nonempty hb)).1 hx.1 in
let ⟨z, zs, hz⟩ := (lt_is_lub_iff (is_lub_cSup hs.nonempty ha)).1 hx.2 in
hs.Icc_subset ys zs ⟨le_of_lt hy, le_of_lt hz⟩
lemma eq_Icc_cInf_cSup_of_connected_bdd_closed {s : set α} (hc : is_connected s) (hb : bdd_below s)
(ha : bdd_above s) (hcl : is_closed s) :
s = Icc (Inf s) (Sup s) :=
subset.antisymm (subset_Icc_cInf_cSup hb ha) $
hc.Icc_subset (hcl.cInf_mem hc.nonempty hb) (hcl.cSup_mem hc.nonempty ha)
lemma is_preconnected.Ioi_cInf_subset {s : set α} (hs : is_preconnected s) (hb : bdd_below s)
(ha : ¬bdd_above s) :
Ioi (Inf s) ⊆ s :=
begin
have sne : s.nonempty := @nonempty_of_not_bdd_above α _ s ⟨Inf ∅⟩ ha,
intros x hx,
obtain ⟨y, ys, hy⟩ : ∃ y ∈ s, y < x := (is_glb_lt_iff (is_glb_cInf sne hb)).1 hx,
obtain ⟨z, zs, hz⟩ : ∃ z ∈ s, x < z := not_bdd_above_iff.1 ha x,
exact hs.Icc_subset ys zs ⟨le_of_lt hy, le_of_lt hz⟩
end
lemma is_preconnected.Iio_cSup_subset {s : set α} (hs : is_preconnected s) (hb : ¬bdd_below s)
(ha : bdd_above s) :
Iio (Sup s) ⊆ s :=
@is_preconnected.Ioi_cInf_subset (order_dual α) _ _ _ s hs ha hb
/-- A preconnected set in a conditionally complete linear order is either one of the intervals
`[Inf s, Sup s]`, `[Inf s, Sup s)`, `(Inf s, Sup s]`, `(Inf s, Sup s)`, `[Inf s, +∞)`,
`(Inf s, +∞)`, `(-∞, Sup s]`, `(-∞, Sup s)`, `(-∞, +∞)`, or `∅`. The converse statement requires
`α` to be densely ordererd. -/
lemma is_preconnected.mem_intervals {s : set α} (hs : is_preconnected s) :
s ∈ ({Icc (Inf s) (Sup s), Ico (Inf s) (Sup s), Ioc (Inf s) (Sup s), Ioo (Inf s) (Sup s),
Ici (Inf s), Ioi (Inf s), Iic (Sup s), Iio (Sup s), univ, ∅} : set (set α)) :=
begin
rcases s.eq_empty_or_nonempty with rfl|hne,
{ apply_rules [or.inr, mem_singleton] },
have hs' : is_connected s := ⟨hne, hs⟩,
by_cases hb : bdd_below s; by_cases ha : bdd_above s,
{ rcases mem_Icc_Ico_Ioc_Ioo_of_subset_of_subset (hs'.Ioo_cInf_cSup_subset hb ha)
(subset_Icc_cInf_cSup hb ha) with hs|hs|hs|hs,
{ exact (or.inl hs) },
{ exact (or.inr $ or.inl hs) },
{ exact (or.inr $ or.inr $ or.inl hs) },
{ exact (or.inr $ or.inr $ or.inr $ or.inl hs) } },
{ refine (or.inr $ or.inr $ or.inr $ or.inr _),
cases mem_Ici_Ioi_of_subset_of_subset (hs.Ioi_cInf_subset hb ha) (λ x hx, cInf_le hb hx)
with hs hs,
{ exact or.inl hs },
{ exact or.inr (or.inl hs) } },
{ iterate 6 { apply or.inr },
cases mem_Iic_Iio_of_subset_of_subset (hs.Iio_cSup_subset hb ha) (λ x hx, le_cSup ha hx)
with hs hs,
{ exact or.inl hs },
{ exact or.inr (or.inl hs) } },
{ iterate 8 { apply or.inr },
exact or.inl (hs.eq_univ_of_unbounded hb ha) }
end
/-- A preconnected set is either one of the intervals `Icc`, `Ico`, `Ioc`, `Ioo`, `Ici`, `Ioi`,
`Iic`, `Iio`, or `univ`, or `∅`. The converse statement requires `α` to be densely ordered. Though
one can represent `∅` as `(Inf s, Inf s)`, we include it into the list of possible cases to improve
readability. -/
lemma set_of_is_preconnected_subset_of_ordered :
{s : set α | is_preconnected s} ⊆
-- bounded intervals
(range (uncurry Icc) ∪ range (uncurry Ico) ∪ range (uncurry Ioc) ∪ range (uncurry Ioo)) ∪
-- unbounded intervals and `univ`
(range Ici ∪ range Ioi ∪ range Iic ∪ range Iio ∪ {univ, ∅}) :=
begin
intros s hs,
rcases hs.mem_intervals with hs|hs|hs|hs|hs|hs|hs|hs|hs|hs,
{ exact (or.inl $ or.inl $ or.inl $ or.inl ⟨(Inf s, Sup s), hs.symm⟩) },
{ exact (or.inl $ or.inl $ or.inl $ or.inr ⟨(Inf s, Sup s), hs.symm⟩) },
{ exact (or.inl $ or.inl $ or.inr ⟨(Inf s, Sup s), hs.symm⟩) },
{ exact (or.inl $ or.inr ⟨(Inf s, Sup s), hs.symm⟩) },
{ exact (or.inr $ or.inl $ or.inl $ or.inl $ or.inl ⟨Inf s, hs.symm⟩) },
{ exact (or.inr $ or.inl $ or.inl $ or.inl $ or.inr ⟨Inf s, hs.symm⟩) },
{ exact (or.inr $ or.inl $ or.inl $ or.inr ⟨Sup s, hs.symm⟩) },
{ exact (or.inr $ or.inl $ or.inr ⟨Sup s, hs.symm⟩) },
{ exact (or.inr $ or.inr $ or.inl hs) },
{ exact (or.inr $ or.inr $ or.inr hs) }
end
/-!
### Intervals are connected
In this section we prove that a closed interval (hence, any `ord_connected` set) in a dense
conditionally complete linear order is preconnected.
-/
/-- A "continuous induction principle" for a closed interval: if a set `s` meets `[a, b]`
on a closed subset, contains `a`, and the set `s ∩ [a, b)` has no maximal point, then `b ∈ s`. -/
lemma is_closed.mem_of_ge_of_forall_exists_gt {a b : α} {s : set α} (hs : is_closed (s ∩ Icc a b))
(ha : a ∈ s) (hab : a ≤ b) (hgt : ∀ x ∈ s ∩ Ico a b, (s ∩ Ioc x b).nonempty) :
b ∈ s :=
begin
let S := s ∩ Icc a b,
replace ha : a ∈ S, from ⟨ha, left_mem_Icc.2 hab⟩,
have Sbd : bdd_above S, from ⟨b, λ z hz, hz.2.2⟩,
let c := Sup (s ∩ Icc a b),
have c_mem : c ∈ S, from hs.cSup_mem ⟨_, ha⟩ Sbd,
have c_le : c ≤ b, from cSup_le ⟨_, ha⟩ (λ x hx, hx.2.2),
cases eq_or_lt_of_le c_le with hc hc, from hc ▸ c_mem.1,
exfalso,
rcases hgt c ⟨c_mem.1, c_mem.2.1, hc⟩ with ⟨x, xs, cx, xb⟩,
exact not_lt_of_le (le_cSup Sbd ⟨xs, le_trans (le_cSup Sbd ha) (le_of_lt cx), xb⟩) cx
end
/-- A "continuous induction principle" for a closed interval: if a set `s` meets `[a, b]`
on a closed subset, contains `a`, and for any `a ≤ x < y ≤ b`, `x ∈ s`, the set `s ∩ (x, y]`
is not empty, then `[a, b] ⊆ s`. -/
lemma is_closed.Icc_subset_of_forall_exists_gt {a b : α} {s : set α} (hs : is_closed (s ∩ Icc a b))
(ha : a ∈ s) (hgt : ∀ x ∈ s ∩ Ico a b, ∀ y ∈ Ioi x, (s ∩ Ioc x y).nonempty) :
Icc a b ⊆ s :=
begin
assume y hy,
have : is_closed (s ∩ Icc a y),
{ suffices : s ∩ Icc a y = s ∩ Icc a b ∩ Icc a y,
{ rw this, exact is_closed.inter hs is_closed_Icc },
rw [inter_assoc],
congr,
exact (inter_eq_self_of_subset_right $ Icc_subset_Icc_right hy.2).symm },
exact is_closed.mem_of_ge_of_forall_exists_gt this ha hy.1
(λ x hx, hgt x ⟨hx.1, Ico_subset_Ico_right hy.2 hx.2⟩ y hx.2.2)
end
variables [densely_ordered α] {a b : α}
/-- A "continuous induction principle" for a closed interval: if a set `s` meets `[a, b]`
on a closed subset, contains `a`, and for any `x ∈ s ∩ [a, b)` the set `s` includes some open
neighborhood of `x` within `(x, +∞)`, then `[a, b] ⊆ s`. -/
lemma is_closed.Icc_subset_of_forall_mem_nhds_within {a b : α} {s : set α}
(hs : is_closed (s ∩ Icc a b)) (ha : a ∈ s)
(hgt : ∀ x ∈ s ∩ Ico a b, s ∈ 𝓝[Ioi x] x) :
Icc a b ⊆ s :=
begin
apply hs.Icc_subset_of_forall_exists_gt ha,
rintros x ⟨hxs, hxab⟩ y hyxb,
have : s ∩ Ioc x y ∈ 𝓝[Ioi x] x,
from inter_mem (hgt x ⟨hxs, hxab⟩) (Ioc_mem_nhds_within_Ioi ⟨le_refl _, hyxb⟩),
exact (nhds_within_Ioi_self_ne_bot' hxab.2).nonempty_of_mem this
end
/-- A closed interval in a densely ordered conditionally complete linear order is preconnected. -/
lemma is_preconnected_Icc : is_preconnected (Icc a b) :=
is_preconnected_closed_iff.2
begin
rintros s t hs ht hab ⟨x, hx⟩ ⟨y, hy⟩,
wlog hxy : x ≤ y := le_total x y using [x y s t, y x t s],
have xyab : Icc x y ⊆ Icc a b := Icc_subset_Icc hx.1.1 hy.1.2,
by_contradiction hst,
suffices : Icc x y ⊆ s,
from hst ⟨y, xyab $ right_mem_Icc.2 hxy, this $ right_mem_Icc.2 hxy, hy.2⟩,
apply (is_closed.inter hs is_closed_Icc).Icc_subset_of_forall_mem_nhds_within hx.2,
rintros z ⟨zs, hz⟩,
have zt : z ∈ tᶜ, from λ zt, hst ⟨z, xyab $ Ico_subset_Icc_self hz, zs, zt⟩,
have : tᶜ ∩ Ioc z y ∈ 𝓝[Ioi z] z,
{ rw [← nhds_within_Ioc_eq_nhds_within_Ioi hz.2],
exact mem_nhds_within.2 ⟨tᶜ, ht.is_open_compl, zt, subset.refl _⟩},
apply mem_of_superset this,
have : Ioc z y ⊆ s ∪ t, from λ w hw, hab (xyab ⟨le_trans hz.1 (le_of_lt hw.1), hw.2⟩),
exact λ w ⟨wt, wzy⟩, (this wzy).elim id (λ h, (wt h).elim)
end
lemma is_preconnected_interval : is_preconnected (interval a b) := is_preconnected_Icc
lemma set.ord_connected.is_preconnected {s : set α} (h : s.ord_connected) :
is_preconnected s :=
is_preconnected_of_forall_pair $ λ x y hx hy, ⟨interval x y, h.interval_subset hx hy,
left_mem_interval, right_mem_interval, is_preconnected_interval⟩
lemma is_preconnected_iff_ord_connected {s : set α} :
is_preconnected s ↔ ord_connected s :=
⟨is_preconnected.ord_connected, set.ord_connected.is_preconnected⟩
lemma is_preconnected_Ici : is_preconnected (Ici a) := ord_connected_Ici.is_preconnected
lemma is_preconnected_Iic : is_preconnected (Iic a) := ord_connected_Iic.is_preconnected
lemma is_preconnected_Iio : is_preconnected (Iio a) := ord_connected_Iio.is_preconnected
lemma is_preconnected_Ioi : is_preconnected (Ioi a) := ord_connected_Ioi.is_preconnected
lemma is_preconnected_Ioo : is_preconnected (Ioo a b) := ord_connected_Ioo.is_preconnected
lemma is_preconnected_Ioc : is_preconnected (Ioc a b) := ord_connected_Ioc.is_preconnected
lemma is_preconnected_Ico : is_preconnected (Ico a b) := ord_connected_Ico.is_preconnected
@[priority 100]
instance ordered_connected_space : preconnected_space α :=
⟨ord_connected_univ.is_preconnected⟩
/-- In a dense conditionally complete linear order, the set of preconnected sets is exactly
the set of the intervals `Icc`, `Ico`, `Ioc`, `Ioo`, `Ici`, `Ioi`, `Iic`, `Iio`, `(-∞, +∞)`,
or `∅`. Though one can represent `∅` as `(Inf s, Inf s)`, we include it into the list of
possible cases to improve readability. -/
lemma set_of_is_preconnected_eq_of_ordered :
{s : set α | is_preconnected s} =
-- bounded intervals
(range (uncurry Icc) ∪ range (uncurry Ico) ∪ range (uncurry Ioc) ∪ range (uncurry Ioo)) ∪
-- unbounded intervals and `univ`
(range Ici ∪ range Ioi ∪ range Iic ∪ range Iio ∪ {univ, ∅}) :=
begin
refine subset.antisymm set_of_is_preconnected_subset_of_ordered _,
simp only [subset_def, -mem_range, forall_range_iff, uncurry, or_imp_distrib, forall_and_distrib,
mem_union, mem_set_of_eq, insert_eq, mem_singleton_iff, forall_eq, forall_true_iff, and_true,
is_preconnected_Icc, is_preconnected_Ico, is_preconnected_Ioc,
is_preconnected_Ioo, is_preconnected_Ioi, is_preconnected_Iio, is_preconnected_Ici,
is_preconnected_Iic, is_preconnected_univ, is_preconnected_empty],
end
/-!
### Intermediate Value Theorem on an interval
In this section we prove several versions of the Intermediate Value Theorem for a function
continuous on an interval.
-/
variables {δ : Type*} [linear_order δ] [topological_space δ] [order_closed_topology δ]
/-- **Intermediate Value Theorem** for continuous functions on closed intervals, case
`f a ≤ t ≤ f b`.-/
lemma intermediate_value_Icc {a b : α} (hab : a ≤ b) {f : α → δ} (hf : continuous_on f (Icc a b)) :
Icc (f a) (f b) ⊆ f '' (Icc a b) :=
is_preconnected_Icc.intermediate_value (left_mem_Icc.2 hab) (right_mem_Icc.2 hab) hf
/-- **Intermediate Value Theorem** for continuous functions on closed intervals, case
`f a ≥ t ≥ f b`.-/
lemma intermediate_value_Icc' {a b : α} (hab : a ≤ b) {f : α → δ} (hf : continuous_on f (Icc a b)) :
Icc (f b) (f a) ⊆ f '' (Icc a b) :=
is_preconnected_Icc.intermediate_value (right_mem_Icc.2 hab) (left_mem_Icc.2 hab) hf
/-- **Intermediate Value Theorem** for continuous functions on closed intervals, unordered case. -/
lemma intermediate_value_interval {a b : α} {f : α → δ} (hf : continuous_on f (interval a b)) :
interval (f a) (f b) ⊆ f '' interval a b :=
by cases le_total (f a) (f b); simp [*, is_preconnected_interval.intermediate_value]
lemma intermediate_value_Ico {a b : α} (hab : a ≤ b) {f : α → δ} (hf : continuous_on f (Icc a b)) :
Ico (f a) (f b) ⊆ f '' (Ico a b) :=
or.elim (eq_or_lt_of_le hab) (λ he y h, absurd h.2 (not_lt_of_le (he ▸ h.1)))
(λ hlt, @is_preconnected.intermediate_value_Ico _ _ _ _ _ _ _ (is_preconnected_Ico)
_ _ ⟨refl a, hlt⟩ (right_nhds_within_Ico_ne_bot hlt) inf_le_right _ (hf.mono Ico_subset_Icc_self)
_ ((hf.continuous_within_at ⟨hab, refl b⟩).mono Ico_subset_Icc_self))
lemma intermediate_value_Ico' {a b : α} (hab : a ≤ b) {f : α → δ} (hf : continuous_on f (Icc a b)) :
Ioc (f b) (f a) ⊆ f '' (Ico a b) :=
or.elim (eq_or_lt_of_le hab) (λ he y h, absurd h.1 (not_lt_of_le (he ▸ h.2)))
(λ hlt, @is_preconnected.intermediate_value_Ioc _ _ _ _ _ _ _ (is_preconnected_Ico)
_ _ ⟨refl a, hlt⟩ (right_nhds_within_Ico_ne_bot hlt) inf_le_right _ (hf.mono Ico_subset_Icc_self)
_ ((hf.continuous_within_at ⟨hab, refl b⟩).mono Ico_subset_Icc_self))
lemma intermediate_value_Ioc {a b : α} (hab : a ≤ b) {f : α → δ} (hf : continuous_on f (Icc a b)) :
Ioc (f a) (f b) ⊆ f '' (Ioc a b) :=
or.elim (eq_or_lt_of_le hab) (λ he y h, absurd h.2 (not_le_of_lt (he ▸ h.1)))
(λ hlt, @is_preconnected.intermediate_value_Ioc _ _ _ _ _ _ _ (is_preconnected_Ioc)
_ _ ⟨hlt, refl b⟩ (left_nhds_within_Ioc_ne_bot hlt) inf_le_right _ (hf.mono Ioc_subset_Icc_self)
_ ((hf.continuous_within_at ⟨refl a, hab⟩).mono Ioc_subset_Icc_self))
lemma intermediate_value_Ioc' {a b : α} (hab : a ≤ b) {f : α → δ} (hf : continuous_on f (Icc a b)) :
Ico (f b) (f a) ⊆ f '' (Ioc a b) :=
or.elim (eq_or_lt_of_le hab) (λ he y h, absurd h.1 (not_le_of_lt (he ▸ h.2)))
(λ hlt, @is_preconnected.intermediate_value_Ico _ _ _ _ _ _ _ (is_preconnected_Ioc)
_ _ ⟨hlt, refl b⟩ (left_nhds_within_Ioc_ne_bot hlt) inf_le_right _ (hf.mono Ioc_subset_Icc_self)
_ ((hf.continuous_within_at ⟨refl a, hab⟩).mono Ioc_subset_Icc_self))
lemma intermediate_value_Ioo {a b : α} (hab : a ≤ b) {f : α → δ} (hf : continuous_on f (Icc a b)) :
Ioo (f a) (f b) ⊆ f '' (Ioo a b) :=
or.elim (eq_or_lt_of_le hab) (λ he y h, absurd h.2 (not_lt_of_lt (he ▸ h.1)))
(λ hlt, @is_preconnected.intermediate_value_Ioo _ _ _ _ _ _ _ (is_preconnected_Ioo)
_ _ (left_nhds_within_Ioo_ne_bot hlt) (right_nhds_within_Ioo_ne_bot hlt)
inf_le_right inf_le_right _ (hf.mono Ioo_subset_Icc_self)
_ _ ((hf.continuous_within_at ⟨refl a, hab⟩).mono Ioo_subset_Icc_self)
((hf.continuous_within_at ⟨hab, refl b⟩).mono Ioo_subset_Icc_self))
lemma intermediate_value_Ioo' {a b : α} (hab : a ≤ b) {f : α → δ} (hf : continuous_on f (Icc a b)) :
Ioo (f b) (f a) ⊆ f '' (Ioo a b) :=
or.elim (eq_or_lt_of_le hab) (λ he y h, absurd h.1 (not_lt_of_lt (he ▸ h.2)))
(λ hlt, @is_preconnected.intermediate_value_Ioo _ _ _ _ _ _ _ (is_preconnected_Ioo)
_ _ (right_nhds_within_Ioo_ne_bot hlt) (left_nhds_within_Ioo_ne_bot hlt)
inf_le_right inf_le_right _ (hf.mono Ioo_subset_Icc_self)
_ _ ((hf.continuous_within_at ⟨hab, refl b⟩).mono Ioo_subset_Icc_self)
((hf.continuous_within_at ⟨refl a, hab⟩).mono Ioo_subset_Icc_self))
/-- **Intermediate value theorem**: if `f` is continuous on an order-connected set `s` and `a`,
`b` are two points of this set, then `f` sends `s` to a superset of `Icc (f x) (f y)`. -/
lemma continuous_on.surj_on_Icc {s : set α} [hs : ord_connected s] {f : α → δ}
(hf : continuous_on f s) {a b : α} (ha : a ∈ s) (hb : b ∈ s) :
surj_on f s (Icc (f a) (f b)) :=
hs.is_preconnected.intermediate_value ha hb hf
/-- **Intermediate value theorem**: if `f` is continuous on an order-connected set `s` and `a`,
`b` are two points of this set, then `f` sends `s` to a superset of `[f x, f y]`. -/
lemma continuous_on.surj_on_interval {s : set α} [hs : ord_connected s] {f : α → δ}
(hf : continuous_on f s) {a b : α} (ha : a ∈ s) (hb : b ∈ s) :
surj_on f s (interval (f a) (f b)) :=
by cases le_total (f a) (f b) with hab hab; simp [hf.surj_on_Icc, *]
/-- A continuous function which tendsto `at_top` `at_top` and to `at_bot` `at_bot` is surjective. -/
lemma continuous.surjective {f : α → δ} (hf : continuous f) (h_top : tendsto f at_top at_top)
(h_bot : tendsto f at_bot at_bot) :
function.surjective f :=
λ p, mem_range_of_exists_le_of_exists_ge hf
(h_bot.eventually (eventually_le_at_bot p)).exists
(h_top.eventually (eventually_ge_at_top p)).exists
/-- A continuous function which tendsto `at_bot` `at_top` and to `at_top` `at_bot` is surjective. -/
lemma continuous.surjective' {f : α → δ} (hf : continuous f) (h_top : tendsto f at_bot at_top)
(h_bot : tendsto f at_top at_bot) :
function.surjective f :=
@continuous.surjective (order_dual α) _ _ _ _ _ _ _ _ _ hf h_top h_bot
/-- If a function `f : α → β` is continuous on a nonempty interval `s`, its restriction to `s`
tends to `at_bot : filter β` along `at_bot : filter ↥s` and tends to `at_top : filter β` along
`at_top : filter ↥s`, then the restriction of `f` to `s` is surjective. We formulate the
conclusion as `surj_on f s univ`. -/
lemma continuous_on.surj_on_of_tendsto {f : α → δ} {s : set α} [ord_connected s]
(hs : s.nonempty) (hf : continuous_on f s) (hbot : tendsto (λ x : s, f x) at_bot at_bot)
(htop : tendsto (λ x : s, f x) at_top at_top) :
surj_on f s univ :=
by haveI := classical.inhabited_of_nonempty hs.to_subtype;
exact (surj_on_iff_surjective.2 $
(continuous_on_iff_continuous_restrict.1 hf).surjective htop hbot)
/-- If a function `f : α → β` is continuous on a nonempty interval `s`, its restriction to `s`
tends to `at_top : filter β` along `at_bot : filter ↥s` and tends to `at_bot : filter β` along
`at_top : filter ↥s`, then the restriction of `f` to `s` is surjective. We formulate the
conclusion as `surj_on f s univ`. -/
lemma continuous_on.surj_on_of_tendsto' {f : α → δ} {s : set α} [ord_connected s]
(hs : s.nonempty) (hf : continuous_on f s) (hbot : tendsto (λ x : s, f x) at_bot at_top)
(htop : tendsto (λ x : s, f x) at_top at_bot) :
surj_on f s univ :=
@continuous_on.surj_on_of_tendsto α _ _ _ _ (order_dual δ) _ _ _ _ _ _ hs hf hbot htop
|
db56fcdd42e26ea685a5ed19c6b2a6dec62098c0 | 94e33a31faa76775069b071adea97e86e218a8ee | /src/measure_theory/integral/vitali_caratheodory.lean | 2a07f64a0eab1f0fdf92b6b7862566331fdf5a6d | [
"Apache-2.0"
] | permissive | urkud/mathlib | eab80095e1b9f1513bfb7f25b4fa82fa4fd02989 | 6379d39e6b5b279df9715f8011369a301b634e41 | refs/heads/master | 1,658,425,342,662 | 1,658,078,703,000 | 1,658,078,703,000 | 186,910,338 | 0 | 0 | Apache-2.0 | 1,568,512,083,000 | 1,557,958,709,000 | Lean | UTF-8 | Lean | false | false | 29,659 | lean | /-
Copyright (c) 2021 Sébastien Gouëzel. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Sébastien Gouëzel
-/
import measure_theory.measure.regular
import topology.semicontinuous
import measure_theory.integral.bochner
import topology.instances.ereal
/-!
# Vitali-Carathéodory theorem
Vitali-Carathéodory theorem asserts the following. Consider an integrable function `f : α → ℝ` on
a space with a regular measure. Then there exists a function `g : α → ereal` such that `f x < g x`
everywhere, `g` is lower semicontinuous, and the integral of `g` is arbitrarily close to that of
`f`. This theorem is proved in this file, as `exists_lt_lower_semicontinuous_integral_lt`.
Symmetrically, there exists `g < f` which is upper semicontinuous, with integral arbitrarily close
to that of `f`. It follows from the previous statement applied to `-f`. It is formalized under
the name `exists_upper_semicontinuous_lt_integral_gt`.
The most classical version of Vitali-Carathéodory theorem only ensures a large inequality
`f x ≤ g x`. For applications to the fundamental theorem of calculus, though, the strict inequality
`f x < g x` is important. Therefore, we prove the stronger version with strict inequalities in this
file. There is a price to pay: we require that the measure is `σ`-finite, which is not necessary for
the classical Vitali-Carathéodory theorem. Since this is satisfied in all applications, this is
not a real problem.
## Sketch of proof
Decomposing `f` as the difference of its positive and negative parts, it suffices to show that a
positive function can be bounded from above by a lower semicontinuous function, and from below
by an upper semicontinuous function, with integrals close to that of `f`.
For the bound from above, write `f` as a series `∑' n, cₙ * indicator (sₙ)` of simple functions.
Then, approximate `sₙ` by a larger open set `uₙ` with measure very close to that of `sₙ` (this is
possible by regularity of the measure), and set `g = ∑' n, cₙ * indicator (uₙ)`. It is
lower semicontinuous as a series of lower semicontinuous functions, and its integral is arbitrarily
close to that of `f`.
For the bound from below, use finitely many terms in the series, and approximate `sₙ` from inside by
a closed set `Fₙ`. Then `∑ n < N, cₙ * indicator (Fₙ)` is bounded from above by `f`, it is
upper semicontinuous as a finite sum of upper semicontinuous functions, and its integral is
arbitrarily close to that of `f`.
The main pain point in the implementation is that one needs to jump between the spaces `ℝ`, `ℝ≥0`,
`ℝ≥0∞` and `ereal` (and be careful that addition is not well behaved on `ereal`), and between
`lintegral` and `integral`.
We first show the bound from above for simple functions and the nonnegative integral
(this is the main nontrivial mathematical point), then deduce it for general nonnegative functions,
first for the nonnegative integral and then for the Bochner integral.
Then we follow the same steps for the lower bound.
Finally, we glue them together to obtain the main statement
`exists_lt_lower_semicontinuous_integral_lt`.
## Related results
Are you looking for a result on approximation by continuous functions (not just semicontinuous)?
See result `measure_theory.Lp.continuous_map_dense`, in the file
`measure_theory.continuous_map_dense`.
## References
[Rudin, *Real and Complex Analysis* (Theorem 2.24)][rudin2006real]
-/
open_locale ennreal nnreal
open measure_theory measure_theory.measure
variables {α : Type*} [topological_space α] [measurable_space α] [borel_space α] (μ : measure α)
[weakly_regular μ]
namespace measure_theory
local infixr ` →ₛ `:25 := simple_func
/-! ### Lower semicontinuous upper bound for nonnegative functions -/
/-- Given a simple function `f` with values in `ℝ≥0`, there exists a lower semicontinuous
function `g ≥ f` with integral arbitrarily close to that of `f`. Formulation in terms of
`lintegral`.
Auxiliary lemma for Vitali-Carathéodory theorem `exists_lt_lower_semicontinuous_integral_lt`. -/
lemma simple_func.exists_le_lower_semicontinuous_lintegral_ge (f : α →ₛ ℝ≥0)
{ε : ℝ≥0∞} (ε0 : ε ≠ 0) :
∃ g : α → ℝ≥0, (∀ x, f x ≤ g x) ∧ lower_semicontinuous g ∧
(∫⁻ x, g x ∂μ ≤ ∫⁻ x, f x ∂μ + ε) :=
begin
induction f using measure_theory.simple_func.induction with c s hs f₁ f₂ H h₁ h₂ generalizing ε,
{ let f := simple_func.piecewise s hs (simple_func.const α c) (simple_func.const α 0),
by_cases h : ∫⁻ x, f x ∂μ = ⊤,
{ refine ⟨λ x, c, λ x, _, lower_semicontinuous_const,
by simp only [ennreal.top_add, le_top, h]⟩,
simp only [simple_func.coe_const, simple_func.const_zero, simple_func.coe_zero,
set.piecewise_eq_indicator, simple_func.coe_piecewise],
exact set.indicator_le_self _ _ _ },
by_cases hc : c = 0,
{ refine ⟨λ x, 0, _, lower_semicontinuous_const, _⟩,
{ simp only [hc, set.indicator_zero', pi.zero_apply, simple_func.const_zero, implies_true_iff,
eq_self_iff_true, simple_func.coe_zero, set.piecewise_eq_indicator,
simple_func.coe_piecewise, le_zero_iff] },
{ simp only [lintegral_const, zero_mul, zero_le, ennreal.coe_zero] } },
have : μ s < μ s + ε / c,
{ have : (0 : ℝ≥0∞) < ε / c := ennreal.div_pos_iff.2 ⟨ε0, ennreal.coe_ne_top⟩,
simpa using ennreal.add_lt_add_left _ this,
simpa only [hs, hc, lt_top_iff_ne_top, true_and, simple_func.coe_const, function.const_apply,
lintegral_const, ennreal.coe_indicator, set.univ_inter, ennreal.coe_ne_top,
measurable_set.univ, with_top.mul_eq_top_iff, simple_func.const_zero, or_false,
lintegral_indicator, ennreal.coe_eq_zero, ne.def, not_false_iff, simple_func.coe_zero,
set.piecewise_eq_indicator, simple_func.coe_piecewise, false_and, restrict_apply] using h },
obtain ⟨u, su, u_open, μu⟩ : ∃ u ⊇ s, is_open u ∧ μ u < μ s + ε / c :=
s.exists_is_open_lt_of_lt _ this,
refine ⟨set.indicator u (λ x, c), λ x, _, u_open.lower_semicontinuous_indicator (zero_le _), _⟩,
{ simp only [simple_func.coe_const, simple_func.const_zero, simple_func.coe_zero,
set.piecewise_eq_indicator, simple_func.coe_piecewise],
exact set.indicator_le_indicator_of_subset su (λ x, zero_le _) _ },
{ suffices : (c : ℝ≥0∞) * μ u ≤ c * μ s + ε, by
simpa only [hs, u_open.measurable_set, simple_func.coe_const, function.const_apply,
lintegral_const, ennreal.coe_indicator, set.univ_inter, measurable_set.univ,
simple_func.const_zero, lintegral_indicator, simple_func.coe_zero,
set.piecewise_eq_indicator, simple_func.coe_piecewise, restrict_apply],
calc (c : ℝ≥0∞) * μ u ≤ c * (μ s + ε / c) : ennreal.mul_le_mul le_rfl μu.le
... = c * μ s + ε :
begin
simp_rw [mul_add],
rw ennreal.mul_div_cancel' _ ennreal.coe_ne_top,
simpa using hc,
end } },
{ rcases h₁ (ennreal.half_pos ε0).ne' with ⟨g₁, f₁_le_g₁, g₁cont, g₁int⟩,
rcases h₂ (ennreal.half_pos ε0).ne' with ⟨g₂, f₂_le_g₂, g₂cont, g₂int⟩,
refine ⟨λ x, g₁ x + g₂ x, λ x, add_le_add (f₁_le_g₁ x) (f₂_le_g₂ x), g₁cont.add g₂cont, _⟩,
simp only [simple_func.coe_add, ennreal.coe_add, pi.add_apply],
rw [lintegral_add_left f₁.measurable.coe_nnreal_ennreal,
lintegral_add_left g₁cont.measurable.coe_nnreal_ennreal],
convert add_le_add g₁int g₂int using 1,
simp only [],
conv_lhs { rw ← ennreal.add_halves ε },
abel }
end
open simple_func (eapprox_diff tsum_eapprox_diff)
/-- Given a measurable function `f` with values in `ℝ≥0`, there exists a lower semicontinuous
function `g ≥ f` with integral arbitrarily close to that of `f`. Formulation in terms of
`lintegral`.
Auxiliary lemma for Vitali-Carathéodory theorem `exists_lt_lower_semicontinuous_integral_lt`. -/
lemma exists_le_lower_semicontinuous_lintegral_ge
(f : α → ℝ≥0∞) (hf : measurable f) {ε : ℝ≥0∞} (εpos : ε ≠ 0) :
∃ g : α → ℝ≥0∞, (∀ x, f x ≤ g x) ∧ lower_semicontinuous g ∧ (∫⁻ x, g x ∂μ ≤ ∫⁻ x, f x ∂μ + ε) :=
begin
rcases ennreal.exists_pos_sum_of_encodable' εpos ℕ with ⟨δ, δpos, hδ⟩,
have : ∀ n, ∃ g : α → ℝ≥0, (∀ x, simple_func.eapprox_diff f n x ≤ g x) ∧ lower_semicontinuous g ∧
(∫⁻ x, g x ∂μ ≤ ∫⁻ x, simple_func.eapprox_diff f n x ∂μ + δ n) :=
λ n, simple_func.exists_le_lower_semicontinuous_lintegral_ge μ
(simple_func.eapprox_diff f n) (δpos n).ne',
choose g f_le_g gcont hg using this,
refine ⟨λ x, (∑' n, g n x), λ x, _, _, _⟩,
{ rw ← tsum_eapprox_diff f hf,
exact ennreal.tsum_le_tsum (λ n, ennreal.coe_le_coe.2 (f_le_g n x)) },
{ apply lower_semicontinuous_tsum (λ n, _),
exact ennreal.continuous_coe.comp_lower_semicontinuous (gcont n)
(λ x y hxy, ennreal.coe_le_coe.2 hxy) },
{ calc ∫⁻ x, ∑' (n : ℕ), g n x ∂μ
= ∑' n, ∫⁻ x, g n x ∂μ :
by rw lintegral_tsum (λ n, (gcont n).measurable.coe_nnreal_ennreal)
... ≤ ∑' n, (∫⁻ x, eapprox_diff f n x ∂μ + δ n) : ennreal.tsum_le_tsum hg
... = ∑' n, (∫⁻ x, eapprox_diff f n x ∂μ) + ∑' n, δ n : ennreal.tsum_add
... ≤ ∫⁻ (x : α), f x ∂μ + ε :
begin
refine add_le_add _ hδ.le,
rw [← lintegral_tsum],
{ simp_rw [tsum_eapprox_diff f hf, le_refl] },
{ assume n, exact (simple_func.measurable _).coe_nnreal_ennreal }
end }
end
/-- Given a measurable function `f` with values in `ℝ≥0` in a sigma-finite space, there exists a
lower semicontinuous function `g > f` with integral arbitrarily close to that of `f`.
Formulation in terms of `lintegral`.
Auxiliary lemma for Vitali-Carathéodory theorem `exists_lt_lower_semicontinuous_integral_lt`. -/
lemma exists_lt_lower_semicontinuous_lintegral_ge [sigma_finite μ]
(f : α → ℝ≥0) (fmeas : measurable f) {ε : ℝ≥0∞} (ε0 : ε ≠ 0) :
∃ g : α → ℝ≥0∞, (∀ x, (f x : ℝ≥0∞) < g x) ∧ lower_semicontinuous g ∧
(∫⁻ x, g x ∂μ ≤ ∫⁻ x, f x ∂μ + ε) :=
begin
have : ε / 2 ≠ 0 := (ennreal.half_pos ε0).ne',
rcases exists_pos_lintegral_lt_of_sigma_finite μ this with ⟨w, wpos, wmeas, wint⟩,
let f' := λ x, ((f x + w x : ℝ≥0) : ℝ≥0∞),
rcases exists_le_lower_semicontinuous_lintegral_ge μ f' (fmeas.add wmeas).coe_nnreal_ennreal this
with ⟨g, le_g, gcont, gint⟩,
refine ⟨g, λ x, _, gcont, _⟩,
{ calc (f x : ℝ≥0∞) < f' x : by simpa [← ennreal.coe_lt_coe] using add_lt_add_left (wpos x) (f x)
... ≤ g x : le_g x },
{ calc ∫⁻ (x : α), g x ∂μ
≤ ∫⁻ (x : α), f x + w x ∂μ + ε / 2 : gint
... = ∫⁻ (x : α), f x ∂ μ + ∫⁻ (x : α), w x ∂ μ + (ε / 2) :
by rw lintegral_add_right _ wmeas.coe_nnreal_ennreal
... ≤ ∫⁻ (x : α), f x ∂ μ + ε / 2 + ε / 2 :
add_le_add_right (add_le_add_left wint.le _) _
... = ∫⁻ (x : α), f x ∂μ + ε : by rw [add_assoc, ennreal.add_halves] },
end
/-- Given an almost everywhere measurable function `f` with values in `ℝ≥0` in a sigma-finite space,
there exists a lower semicontinuous function `g > f` with integral arbitrarily close to that of `f`.
Formulation in terms of `lintegral`.
Auxiliary lemma for Vitali-Carathéodory theorem `exists_lt_lower_semicontinuous_integral_lt`. -/
lemma exists_lt_lower_semicontinuous_lintegral_ge_of_ae_measurable [sigma_finite μ]
(f : α → ℝ≥0) (fmeas : ae_measurable f μ) {ε : ℝ≥0∞} (ε0 : ε ≠ 0) :
∃ g : α → ℝ≥0∞, (∀ x, (f x : ℝ≥0∞) < g x) ∧ lower_semicontinuous g ∧
(∫⁻ x, g x ∂μ ≤ ∫⁻ x, f x ∂μ + ε) :=
begin
have : ε / 2 ≠ 0 := (ennreal.half_pos ε0).ne',
rcases exists_lt_lower_semicontinuous_lintegral_ge μ (fmeas.mk f) fmeas.measurable_mk this
with ⟨g0, f_lt_g0, g0_cont, g0_int⟩,
rcases exists_measurable_superset_of_null fmeas.ae_eq_mk with ⟨s, hs, smeas, μs⟩,
rcases exists_le_lower_semicontinuous_lintegral_ge μ (s.indicator (λ x, ∞))
(measurable_const.indicator smeas) this
with ⟨g1, le_g1, g1_cont, g1_int⟩,
refine ⟨λ x, g0 x + g1 x, λ x, _, g0_cont.add g1_cont, _⟩,
{ by_cases h : x ∈ s,
{ have := le_g1 x,
simp only [h, set.indicator_of_mem, top_le_iff] at this,
simp [this] },
{ have : f x = fmeas.mk f x,
by { rw set.compl_subset_comm at hs, exact hs h },
rw this,
exact (f_lt_g0 x).trans_le le_self_add } },
{ calc ∫⁻ x, g0 x + g1 x ∂μ = ∫⁻ x, g0 x ∂μ + ∫⁻ x, g1 x ∂μ :
lintegral_add_left g0_cont.measurable _
... ≤ (∫⁻ x, f x ∂μ + ε / 2) + (0 + ε / 2) :
begin
refine add_le_add _ _,
{ convert g0_int using 2,
exact lintegral_congr_ae (fmeas.ae_eq_mk.fun_comp _) },
{ convert g1_int,
simp only [smeas, μs, lintegral_const, set.univ_inter, measurable_set.univ,
lintegral_indicator, mul_zero, restrict_apply] }
end
... = ∫⁻ x, f x ∂μ + ε : by simp only [add_assoc, ennreal.add_halves, zero_add] }
end
variable {μ}
/-- Given an integrable function `f` with values in `ℝ≥0` in a sigma-finite space, there exists a
lower semicontinuous function `g > f` with integral arbitrarily close to that of `f`.
Formulation in terms of `integral`.
Auxiliary lemma for Vitali-Carathéodory theorem `exists_lt_lower_semicontinuous_integral_lt`. -/
lemma exists_lt_lower_semicontinuous_integral_gt_nnreal [sigma_finite μ] (f : α → ℝ≥0)
(fint : integrable (λ x, (f x : ℝ)) μ) {ε : ℝ} (εpos : 0 < ε) :
∃ g : α → ℝ≥0∞, (∀ x, (f x : ℝ≥0∞) < g x) ∧ lower_semicontinuous g ∧ (∀ᵐ x ∂ μ, g x < ⊤)
∧ (integrable (λ x, (g x).to_real) μ) ∧ (∫ x, (g x).to_real ∂μ < ∫ x, f x ∂μ + ε) :=
begin
have fmeas : ae_measurable f μ,
by { convert fint.ae_strongly_measurable.real_to_nnreal.ae_measurable, ext1 x,
simp only [real.to_nnreal_coe] },
lift ε to ℝ≥0 using εpos.le,
obtain ⟨δ, δpos, hδε⟩ : ∃ δ : ℝ≥0, 0 < δ ∧ δ < ε, from exists_between εpos,
have int_f_ne_top : ∫⁻ (a : α), (f a) ∂μ ≠ ∞ :=
(has_finite_integral_iff_of_nnreal.1 fint.has_finite_integral).ne,
rcases exists_lt_lower_semicontinuous_lintegral_ge_of_ae_measurable μ f fmeas
(ennreal.coe_ne_zero.2 δpos.ne')
with ⟨g, f_lt_g, gcont, gint⟩,
have gint_ne : ∫⁻ (x : α), g x ∂μ ≠ ∞ := ne_top_of_le_ne_top (by simpa) gint,
have g_lt_top : ∀ᵐ (x : α) ∂μ, g x < ∞ := ae_lt_top gcont.measurable gint_ne,
have Ig : ∫⁻ (a : α), ennreal.of_real (g a).to_real ∂μ = ∫⁻ (a : α), g a ∂μ,
{ apply lintegral_congr_ae,
filter_upwards [g_lt_top] with _ hx,
simp only [hx.ne, ennreal.of_real_to_real, ne.def, not_false_iff], },
refine ⟨g, f_lt_g, gcont, g_lt_top, _, _⟩,
{ refine ⟨gcont.measurable.ennreal_to_real.ae_measurable.ae_strongly_measurable, _⟩,
simp only [has_finite_integral_iff_norm, real.norm_eq_abs,
abs_of_nonneg ennreal.to_real_nonneg],
convert gint_ne.lt_top using 1 },
{ rw [integral_eq_lintegral_of_nonneg_ae, integral_eq_lintegral_of_nonneg_ae],
{ calc
ennreal.to_real (∫⁻ (a : α), ennreal.of_real (g a).to_real ∂μ)
= ennreal.to_real (∫⁻ (a : α), g a ∂μ) : by congr' 1
... ≤ ennreal.to_real (∫⁻ (a : α), f a ∂μ + δ) :
begin
apply ennreal.to_real_mono _ gint,
simpa using int_f_ne_top,
end
... = ennreal.to_real (∫⁻ (a : α), f a ∂μ) + δ :
by rw [ennreal.to_real_add int_f_ne_top ennreal.coe_ne_top, ennreal.coe_to_real]
... < ennreal.to_real (∫⁻ (a : α), f a ∂μ) + ε :
add_lt_add_left hδε _
... = (∫⁻ (a : α), ennreal.of_real ↑(f a) ∂μ).to_real + ε :
by simp },
{ apply filter.eventually_of_forall (λ x, _), simp },
{ exact fmeas.coe_nnreal_real.ae_strongly_measurable, },
{ apply filter.eventually_of_forall (λ x, _), simp },
{ apply gcont.measurable.ennreal_to_real.ae_measurable.ae_strongly_measurable } }
end
/-! ### Upper semicontinuous lower bound for nonnegative functions -/
/-- Given a simple function `f` with values in `ℝ≥0`, there exists an upper semicontinuous
function `g ≤ f` with integral arbitrarily close to that of `f`. Formulation in terms of
`lintegral`.
Auxiliary lemma for Vitali-Carathéodory theorem `exists_lt_lower_semicontinuous_integral_lt`. -/
lemma simple_func.exists_upper_semicontinuous_le_lintegral_le
(f : α →ₛ ℝ≥0) (int_f : ∫⁻ x, f x ∂μ ≠ ∞) {ε : ℝ≥0∞} (ε0 : ε ≠ 0) :
∃ g : α → ℝ≥0, (∀ x, g x ≤ f x) ∧ upper_semicontinuous g ∧ (∫⁻ x, f x ∂μ ≤ ∫⁻ x, g x ∂μ + ε) :=
begin
induction f using measure_theory.simple_func.induction with c s hs f₁ f₂ H h₁ h₂ generalizing ε,
{ let f := simple_func.piecewise s hs (simple_func.const α c) (simple_func.const α 0),
by_cases hc : c = 0,
{ refine ⟨λ x, 0, _, upper_semicontinuous_const, _⟩,
{ simp only [hc, set.indicator_zero', pi.zero_apply, simple_func.const_zero, implies_true_iff,
eq_self_iff_true, simple_func.coe_zero, set.piecewise_eq_indicator,
simple_func.coe_piecewise, le_zero_iff] },
{ simp only [hc, set.indicator_zero', lintegral_const, zero_mul, pi.zero_apply,
simple_func.const_zero, zero_add, zero_le', simple_func.coe_zero,
set.piecewise_eq_indicator, ennreal.coe_zero, simple_func.coe_piecewise, zero_le] } },
have μs_lt_top : μ s < ∞,
by simpa only [hs, hc, lt_top_iff_ne_top, true_and, simple_func.coe_const, or_false,
lintegral_const, ennreal.coe_indicator, set.univ_inter, ennreal.coe_ne_top, restrict_apply
measurable_set.univ, with_top.mul_eq_top_iff, simple_func.const_zero, function.const_apply,
lintegral_indicator, ennreal.coe_eq_zero, ne.def, not_false_iff, simple_func.coe_zero,
set.piecewise_eq_indicator, simple_func.coe_piecewise, false_and] using int_f,
have : (0 : ℝ≥0∞) < ε / c := ennreal.div_pos_iff.2 ⟨ε0, ennreal.coe_ne_top⟩,
obtain ⟨F, Fs, F_closed, μF⟩ : ∃ F ⊆ s, is_closed F ∧ μ s < μ F + ε / c :=
hs.exists_is_closed_lt_add μs_lt_top.ne this.ne',
refine ⟨set.indicator F (λ x, c), λ x, _,
F_closed.upper_semicontinuous_indicator (zero_le _), _⟩,
{ simp only [simple_func.coe_const, simple_func.const_zero, simple_func.coe_zero,
set.piecewise_eq_indicator, simple_func.coe_piecewise],
exact set.indicator_le_indicator_of_subset Fs (λ x, zero_le _) _ },
{ suffices : (c : ℝ≥0∞) * μ s ≤ c * μ F + ε,
by simpa only [hs, F_closed.measurable_set, simple_func.coe_const, function.const_apply,
lintegral_const, ennreal.coe_indicator, set.univ_inter, measurable_set.univ,
simple_func.const_zero, lintegral_indicator, simple_func.coe_zero,
set.piecewise_eq_indicator, simple_func.coe_piecewise, restrict_apply],
calc (c : ℝ≥0∞) * μ s ≤ c * (μ F + ε / c) : ennreal.mul_le_mul le_rfl μF.le
... = c * μ F + ε :
begin
simp_rw [mul_add],
rw ennreal.mul_div_cancel' _ ennreal.coe_ne_top,
simpa using hc,
end } },
{ have A : ∫⁻ (x : α), f₁ x ∂μ + ∫⁻ (x : α), f₂ x ∂μ ≠ ⊤,
by rwa ← lintegral_add_left f₁.measurable.coe_nnreal_ennreal,
rcases h₁ (ennreal.add_ne_top.1 A).1 (ennreal.half_pos ε0).ne'
with ⟨g₁, f₁_le_g₁, g₁cont, g₁int⟩,
rcases h₂ (ennreal.add_ne_top.1 A).2 (ennreal.half_pos ε0).ne'
with ⟨g₂, f₂_le_g₂, g₂cont, g₂int⟩,
refine ⟨λ x, g₁ x + g₂ x, λ x, add_le_add (f₁_le_g₁ x) (f₂_le_g₂ x), g₁cont.add g₂cont, _⟩,
simp only [simple_func.coe_add, ennreal.coe_add, pi.add_apply],
rw [lintegral_add_left f₁.measurable.coe_nnreal_ennreal,
lintegral_add_left g₁cont.measurable.coe_nnreal_ennreal],
convert add_le_add g₁int g₂int using 1,
simp only [],
conv_lhs { rw ← ennreal.add_halves ε },
abel }
end
/-- Given an integrable function `f` with values in `ℝ≥0`, there exists an upper semicontinuous
function `g ≤ f` with integral arbitrarily close to that of `f`. Formulation in terms of
`lintegral`.
Auxiliary lemma for Vitali-Carathéodory theorem `exists_lt_lower_semicontinuous_integral_lt`. -/
lemma exists_upper_semicontinuous_le_lintegral_le
(f : α → ℝ≥0) (int_f : ∫⁻ x, f x ∂μ ≠ ∞) {ε : ℝ≥0∞} (ε0 : ε ≠ 0) :
∃ g : α → ℝ≥0, (∀ x, g x ≤ f x) ∧ upper_semicontinuous g ∧ (∫⁻ x, f x ∂μ ≤ ∫⁻ x, g x ∂μ + ε) :=
begin
obtain ⟨fs, fs_le_f, int_fs⟩ : ∃ (fs : α →ₛ ℝ≥0), (∀ x, fs x ≤ f x) ∧
(∫⁻ x, f x ∂μ ≤ ∫⁻ x, fs x ∂μ + ε/2) :=
begin
have := ennreal.lt_add_right int_f (ennreal.half_pos ε0).ne',
conv_rhs at this { rw lintegral_eq_nnreal (λ x, (f x : ℝ≥0∞)) μ },
erw ennreal.bsupr_add at this; [skip, exact ⟨0, λ x, by simp⟩],
simp only [lt_supr_iff] at this,
rcases this with ⟨fs, fs_le_f, int_fs⟩,
refine ⟨fs, λ x, by simpa only [ennreal.coe_le_coe] using fs_le_f x, _⟩,
convert int_fs.le,
rw ← simple_func.lintegral_eq_lintegral,
refl
end,
have int_fs_lt_top : ∫⁻ x, fs x ∂μ ≠ ∞,
{ apply ne_top_of_le_ne_top int_f (lintegral_mono (λ x, _)),
simpa only [ennreal.coe_le_coe] using fs_le_f x },
obtain ⟨g, g_le_fs, gcont, gint⟩ : ∃ g : α → ℝ≥0,
(∀ x, g x ≤ fs x) ∧ upper_semicontinuous g ∧ (∫⁻ x, fs x ∂μ ≤ ∫⁻ x, g x ∂μ + ε/2) :=
fs.exists_upper_semicontinuous_le_lintegral_le int_fs_lt_top (ennreal.half_pos ε0).ne',
refine ⟨g, λ x, (g_le_fs x).trans (fs_le_f x), gcont, _⟩,
calc ∫⁻ x, f x ∂μ ≤ ∫⁻ x, fs x ∂μ + ε / 2 : int_fs
... ≤ (∫⁻ x, g x ∂μ + ε / 2) + ε / 2 : add_le_add gint le_rfl
... = ∫⁻ x, g x ∂μ + ε : by rw [add_assoc, ennreal.add_halves]
end
/-- Given an integrable function `f` with values in `ℝ≥0`, there exists an upper semicontinuous
function `g ≤ f` with integral arbitrarily close to that of `f`. Formulation in terms of
`integral`.
Auxiliary lemma for Vitali-Carathéodory theorem `exists_lt_lower_semicontinuous_integral_lt`. -/
lemma exists_upper_semicontinuous_le_integral_le (f : α → ℝ≥0)
(fint : integrable (λ x, (f x : ℝ)) μ) {ε : ℝ} (εpos : 0 < ε) :
∃ g : α → ℝ≥0, (∀ x, g x ≤ f x) ∧ upper_semicontinuous g ∧ (integrable (λ x, (g x : ℝ)) μ)
∧ (∫ x, (f x : ℝ) ∂μ - ε ≤ ∫ x, g x ∂μ) :=
begin
lift ε to ℝ≥0 using εpos.le,
rw [nnreal.coe_pos, ← ennreal.coe_pos] at εpos,
have If : ∫⁻ x, f x ∂ μ < ∞ := has_finite_integral_iff_of_nnreal.1 fint.has_finite_integral,
rcases exists_upper_semicontinuous_le_lintegral_le f If.ne εpos.ne' with ⟨g, gf, gcont, gint⟩,
have Ig : ∫⁻ x, g x ∂ μ < ∞,
{ apply lt_of_le_of_lt (lintegral_mono (λ x, _)) If,
simpa using gf x },
refine ⟨g, gf, gcont, _, _⟩,
{ refine integrable.mono fint
gcont.measurable.coe_nnreal_real.ae_measurable.ae_strongly_measurable _,
exact filter.eventually_of_forall (λ x, by simp [gf x]) },
{ rw [integral_eq_lintegral_of_nonneg_ae, integral_eq_lintegral_of_nonneg_ae],
{ rw sub_le_iff_le_add,
convert ennreal.to_real_mono _ gint,
{ simp, },
{ rw ennreal.to_real_add Ig.ne ennreal.coe_ne_top, simp },
{ simpa using Ig.ne } },
{ apply filter.eventually_of_forall, simp },
{ exact gcont.measurable.coe_nnreal_real.ae_measurable.ae_strongly_measurable },
{ apply filter.eventually_of_forall, simp },
{ exact fint.ae_strongly_measurable } }
end
/-! ### Vitali-Carathéodory theorem -/
/-- **Vitali-Carathéodory Theorem**: given an integrable real function `f`, there exists an
integrable function `g > f` which is lower semicontinuous, with integral arbitrarily close
to that of `f`. This function has to be `ereal`-valued in general. -/
lemma exists_lt_lower_semicontinuous_integral_lt [sigma_finite μ]
(f : α → ℝ) (hf : integrable f μ) {ε : ℝ} (εpos : 0 < ε) :
∃ g : α → ereal, (∀ x, (f x : ereal) < g x) ∧ lower_semicontinuous g ∧
(integrable (λ x, ereal.to_real (g x)) μ) ∧ (∀ᵐ x ∂ μ, g x < ⊤) ∧
(∫ x, ereal.to_real (g x) ∂μ < ∫ x, f x ∂μ + ε) :=
begin
let δ : ℝ≥0 := ⟨ε/2, (half_pos εpos).le⟩,
have δpos : 0 < δ := half_pos εpos,
let fp : α → ℝ≥0 := λ x, real.to_nnreal (f x),
have int_fp : integrable (λ x, (fp x : ℝ)) μ := hf.real_to_nnreal,
rcases exists_lt_lower_semicontinuous_integral_gt_nnreal fp int_fp δpos
with ⟨gp, fp_lt_gp, gpcont, gp_lt_top, gp_integrable, gpint⟩,
let fm : α → ℝ≥0 := λ x, real.to_nnreal (-f x),
have int_fm : integrable (λ x, (fm x : ℝ)) μ := hf.neg.real_to_nnreal,
rcases exists_upper_semicontinuous_le_integral_le fm int_fm δpos
with ⟨gm, gm_le_fm, gmcont, gm_integrable, gmint⟩,
let g : α → ereal := λ x, (gp x : ereal) - (gm x),
have ae_g : ∀ᵐ x ∂ μ, (g x).to_real = (gp x : ereal).to_real - (gm x : ereal).to_real,
{ filter_upwards [gp_lt_top] with _ hx,
rw ereal.to_real_sub;
simp [hx.ne], },
refine ⟨g, _, _, _, _, _⟩,
show integrable (λ x, ereal.to_real (g x)) μ,
{ rw integrable_congr ae_g,
convert gp_integrable.sub gm_integrable,
ext x,
simp },
show ∫ (x : α), (g x).to_real ∂μ < ∫ (x : α), f x ∂μ + ε, from calc
∫ (x : α), (g x).to_real ∂μ = ∫ (x : α), ereal.to_real (gp x) - ereal.to_real (gm x) ∂μ :
integral_congr_ae ae_g
... = ∫ (x : α), ereal.to_real (gp x) ∂ μ - ∫ (x : α), gm x ∂μ :
begin
simp only [ereal.to_real_coe_ennreal, ennreal.coe_to_real, coe_coe],
exact integral_sub gp_integrable gm_integrable,
end
... < ∫ (x : α), ↑(fp x) ∂μ + ↑δ - ∫ (x : α), gm x ∂μ :
begin
apply sub_lt_sub_right,
convert gpint,
simp only [ereal.to_real_coe_ennreal],
end
... ≤ ∫ (x : α), ↑(fp x) ∂μ + ↑δ - (∫ (x : α), fm x ∂μ - δ) :
sub_le_sub_left gmint _
... = ∫ (x : α), f x ∂μ + 2 * δ :
by { simp_rw [integral_eq_integral_pos_part_sub_integral_neg_part hf, fp, fm], ring }
... = ∫ (x : α), f x ∂μ + ε :
by { congr' 1, field_simp [δ, mul_comm] },
show ∀ᵐ (x : α) ∂μ, g x < ⊤,
{ filter_upwards [gp_lt_top] with _ hx,
simp [g, ereal.sub_eq_add_neg, lt_top_iff_ne_top, lt_top_iff_ne_top.1 hx], },
show ∀ x, (f x : ereal) < g x,
{ assume x,
rw ereal.coe_real_ereal_eq_coe_to_nnreal_sub_coe_to_nnreal (f x),
refine ereal.sub_lt_sub_of_lt_of_le _ _ _ _,
{ simp only [ereal.coe_ennreal_lt_coe_ennreal_iff, coe_coe], exact (fp_lt_gp x) },
{ simp only [ennreal.coe_le_coe, ereal.coe_ennreal_le_coe_ennreal_iff, coe_coe],
exact (gm_le_fm x) },
{ simp only [ereal.coe_ennreal_ne_bot, ne.def, not_false_iff, coe_coe] },
{ simp only [ereal.coe_nnreal_ne_top, ne.def, not_false_iff, coe_coe] } },
show lower_semicontinuous g,
{ apply lower_semicontinuous.add',
{ exact continuous_coe_ennreal_ereal.comp_lower_semicontinuous gpcont
(λ x y hxy, ereal.coe_ennreal_le_coe_ennreal_iff.2 hxy) },
{ apply ereal.continuous_neg.comp_upper_semicontinuous_antitone _
(λ x y hxy, ereal.neg_le_neg_iff.2 hxy),
dsimp,
apply continuous_coe_ennreal_ereal.comp_upper_semicontinuous _
(λ x y hxy, ereal.coe_ennreal_le_coe_ennreal_iff.2 hxy),
exact ennreal.continuous_coe.comp_upper_semicontinuous gmcont
(λ x y hxy, ennreal.coe_le_coe.2 hxy) },
{ assume x,
exact ereal.continuous_at_add (by simp) (by simp) } }
end
/-- **Vitali-Carathéodory Theorem**: given an integrable real function `f`, there exists an
integrable function `g < f` which is upper semicontinuous, with integral arbitrarily close to that
of `f`. This function has to be `ereal`-valued in general. -/
lemma exists_upper_semicontinuous_lt_integral_gt [sigma_finite μ]
(f : α → ℝ) (hf : integrable f μ) {ε : ℝ} (εpos : 0 < ε) :
∃ g : α → ereal, (∀ x, (g x : ereal) < f x) ∧ upper_semicontinuous g ∧
(integrable (λ x, ereal.to_real (g x)) μ) ∧ (∀ᵐ x ∂μ, ⊥ < g x) ∧
(∫ x, f x ∂μ < ∫ x, ereal.to_real (g x) ∂μ + ε) :=
begin
rcases exists_lt_lower_semicontinuous_integral_lt (λ x, - f x) hf.neg εpos
with ⟨g, g_lt_f, gcont, g_integrable, g_lt_top, gint⟩,
refine ⟨λ x, - g x, _, _, _, _, _⟩,
{ exact λ x, ereal.neg_lt_iff_neg_lt.1 (by simpa only [ereal.coe_neg] using g_lt_f x) },
{ exact ereal.continuous_neg.comp_lower_semicontinuous_antitone gcont
(λ x y hxy, ereal.neg_le_neg_iff.2 hxy) },
{ convert g_integrable.neg,
ext x,
simp },
{ simpa [bot_lt_iff_ne_bot, lt_top_iff_ne_top] using g_lt_top },
{ simp_rw [integral_neg, lt_neg_add_iff_add_lt] at gint,
rw add_comm at gint,
simpa [integral_neg] using gint }
end
end measure_theory
|
4bf0fa3980a844b1cbffb32a30140798e9682de3 | 94e33a31faa76775069b071adea97e86e218a8ee | /src/algebra/group_ring_action.lean | 2416e321468f335118621c86f520ad18b81708ba | [
"Apache-2.0"
] | permissive | urkud/mathlib | eab80095e1b9f1513bfb7f25b4fa82fa4fd02989 | 6379d39e6b5b279df9715f8011369a301b634e41 | refs/heads/master | 1,658,425,342,662 | 1,658,078,703,000 | 1,658,078,703,000 | 186,910,338 | 0 | 0 | Apache-2.0 | 1,568,512,083,000 | 1,557,958,709,000 | Lean | UTF-8 | Lean | false | false | 4,405 | lean | /-
Copyright (c) 2020 Kenny Lau. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kenny Lau
-/
import algebra.ring.equiv
import group_theory.group_action.group
import ring_theory.subring.basic
/-!
# Group action on rings
This file defines the typeclass of monoid acting on semirings `mul_semiring_action M R`,
and the corresponding typeclass of invariant subrings.
Note that `algebra` does not satisfy the axioms of `mul_semiring_action`.
## Implementation notes
There is no separate typeclass for group acting on rings, group acting on fields, etc.
They are all grouped under `mul_semiring_action`.
## Tags
group action, invariant subring
-/
universes u v
open_locale big_operators
/-- Typeclass for multiplicative actions by monoids on semirings.
This combines `distrib_mul_action` with `mul_distrib_mul_action`. -/
class mul_semiring_action (M : Type u) (R : Type v) [monoid M] [semiring R]
extends distrib_mul_action M R :=
(smul_one : ∀ (g : M), (g • 1 : R) = 1)
(smul_mul : ∀ (g : M) (x y : R), g • (x * y) = (g • x) * (g • y))
section semiring
variables (M G : Type u) [monoid M] [group G]
variables (A R S F : Type v) [add_monoid A] [semiring R] [comm_semiring S] [division_ring F]
-- note we could not use `extends` since these typeclasses are made with `old_structure_cmd`
@[priority 100]
instance mul_semiring_action.to_mul_distrib_mul_action [h : mul_semiring_action M R] :
mul_distrib_mul_action M R :=
{ ..h }
/-- Each element of the monoid defines a semiring homomorphism. -/
@[simps]
def mul_semiring_action.to_ring_hom [mul_semiring_action M R] (x : M) : R →+* R :=
{ .. mul_distrib_mul_action.to_monoid_hom R x,
.. distrib_mul_action.to_add_monoid_hom R x }
theorem to_ring_hom_injective [mul_semiring_action M R] [has_faithful_smul M R] :
function.injective (mul_semiring_action.to_ring_hom M R) :=
λ m₁ m₂ h, eq_of_smul_eq_smul $ λ r, ring_hom.ext_iff.1 h r
/-- Each element of the group defines a semiring isomorphism. -/
@[simps]
def mul_semiring_action.to_ring_equiv [mul_semiring_action G R] (x : G) : R ≃+* R :=
{ .. distrib_mul_action.to_add_equiv R x,
.. mul_semiring_action.to_ring_hom G R x }
section
variables {M G R}
/-- A stronger version of `submonoid.distrib_mul_action`. -/
instance submonoid.mul_semiring_action [mul_semiring_action M R] (H : submonoid M) :
mul_semiring_action H R :=
{ smul := (•),
.. H.mul_distrib_mul_action,
.. H.distrib_mul_action }
/-- A stronger version of `subgroup.distrib_mul_action`. -/
instance subgroup.mul_semiring_action [mul_semiring_action G R] (H : subgroup G) :
mul_semiring_action H R :=
H.to_submonoid.mul_semiring_action
/-- A stronger version of `subsemiring.distrib_mul_action`. -/
instance subsemiring.mul_semiring_action {R'} [semiring R'] [mul_semiring_action R' R]
(H : subsemiring R') :
mul_semiring_action H R :=
H.to_submonoid.mul_semiring_action
/-- A stronger version of `subring.distrib_mul_action`. -/
instance subring.mul_semiring_action {R'} [ring R'] [mul_semiring_action R' R]
(H : subring R') :
mul_semiring_action H R :=
H.to_subsemiring.mul_semiring_action
end
section simp_lemmas
variables {M G A R F}
attribute [simp] smul_one smul_mul' smul_zero smul_add
/-- Note that `smul_inv'` refers to the group case, and `smul_inv` has an additional inverse
on `x`. -/
@[simp] lemma smul_inv'' [mul_semiring_action M F] (x : M) (m : F) : x • m⁻¹ = (x • m)⁻¹ :=
(mul_semiring_action.to_ring_hom M F x).map_inv _
end simp_lemmas
end semiring
section ring
variables (M : Type u) [monoid M] {R : Type v} [ring R] [mul_semiring_action M R]
variables (S : subring R)
open mul_action
/-- A typeclass for subrings invariant under a `mul_semiring_action`. -/
class is_invariant_subring : Prop :=
(smul_mem : ∀ (m : M) {x : R}, x ∈ S → m • x ∈ S)
instance is_invariant_subring.to_mul_semiring_action [is_invariant_subring M S] :
mul_semiring_action M S :=
{ smul := λ m x, ⟨m • x, is_invariant_subring.smul_mem m x.2⟩,
one_smul := λ s, subtype.eq $ one_smul M s,
mul_smul := λ m₁ m₂ s, subtype.eq $ mul_smul m₁ m₂ s,
smul_add := λ m s₁ s₂, subtype.eq $ smul_add m s₁ s₂,
smul_zero := λ m, subtype.eq $ smul_zero m,
smul_one := λ m, subtype.eq $ smul_one m,
smul_mul := λ m s₁ s₂, subtype.eq $ smul_mul' m s₁ s₂ }
end ring
|
11aaa67183f0f162ed518dc7fe0106637c06544f | 6432ea7a083ff6ba21ea17af9ee47b9c371760f7 | /src/lake/examples/bootstrap/lakefile.lean | 3b44e0853051eb00ae4f82c832e234624f02d8d2 | [
"Apache-2.0",
"LLVM-exception",
"NCSA",
"LGPL-3.0-only",
"LicenseRef-scancode-inner-net-2.0",
"BSD-3-Clause",
"LGPL-2.0-or-later",
"Spencer-94",
"LGPL-2.1-or-later",
"HPND",
"LicenseRef-scancode-pcre",
"ISC",
"LGPL-2.1-only",
"LicenseRef-scancode-other-permissive",
"SunPro",
"CMU-Mach"... | permissive | leanprover/lean4 | 4bdf9790294964627eb9be79f5e8f6157780b4cc | f1f9dc0f2f531af3312398999d8b8303fa5f096b | refs/heads/master | 1,693,360,665,786 | 1,693,350,868,000 | 1,693,350,868,000 | 129,571,436 | 2,827 | 311 | Apache-2.0 | 1,694,716,156,000 | 1,523,760,560,000 | Lean | UTF-8 | Lean | false | false | 181 | lean | import Lake
open System Lake DSL
package lake where
srcDir := ".." / ".."
lean_lib Lake
@[default_target]
lean_exe lake where
root := `Lake.Main
supportInterpreter := true
|
9923292840da4736101c2a6f86052e6583cc4708 | 05f637fa14ac28031cb1ea92086a0f4eb23ff2b1 | /tests/lean/lua13.lean | a05ec946ff3b6d64398023899a0604efc899845b | [
"Apache-2.0"
] | permissive | codyroux/lean0.1 | 1ce92751d664aacff0529e139083304a7bbc8a71 | 0dc6fb974aa85ed6f305a2f4b10a53a44ee5f0ef | refs/heads/master | 1,610,830,535,062 | 1,402,150,480,000 | 1,402,150,480,000 | 19,588,851 | 2 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 297 | lean | import Int.
variables x y z : Int
variable f : Int -> Int -> Int
(*
local t = parse_lean("fun w, f w (f y 0)")
print(t)
assert(t:closed())
local n, d, b = t:fields()
print(b)
assert(not b:closed())
local env = get_environment()
assert(env:find_object("Int"):get_name() == name("Int"))
*)
|
be5115cbc79d0f8c4e5d5b5a49821bf99903e0ae | cf39355caa609c0f33405126beee2739aa3cb77e | /tests/lean/field_access.lean | a573df2c5ebeb1715b3cc3561689319c9ef3e15c | [
"Apache-2.0"
] | permissive | leanprover-community/lean | 12b87f69d92e614daea8bcc9d4de9a9ace089d0e | cce7990ea86a78bdb383e38ed7f9b5ba93c60ce0 | refs/heads/master | 1,687,508,156,644 | 1,684,951,104,000 | 1,684,951,104,000 | 169,960,991 | 457 | 107 | Apache-2.0 | 1,686,744,372,000 | 1,549,790,268,000 | C++ | UTF-8 | Lean | false | false | 598 | lean | #check list.map
variable l : list nat
#check l.1 -- Error l is not a structure
#check (1, 2).5 -- Error insufficient fields
example (l : list nat) : list nat :=
l.mapp (λ x, x + 1) -- Error there is no list.mapp
example (A : Type) (a : A) : A :=
a.symm -- Error type of 'a' is not a constant application
example (A : Type) (a : A) : A :=
eq.sym -- Error unknown identifier
example (l : list nat) : list nat :=
l.map (λ x, x + 1)
example (l : list nat) : list nat :=
l.map (λ x, x + 1)
example (a b : nat) (h : a = b) : b = a :=
h.symm
example (a b : nat) (h : a = b) : b = a :=
h.symm
|
15e201f6221c7c86f21adbda5f06bfcc48921b9a | d406927ab5617694ec9ea7001f101b7c9e3d9702 | /src/analysis/convex/uniform.lean | 5a7fc0b019ddf39c15fee89385db4a825649f01c | [
"Apache-2.0"
] | permissive | alreadydone/mathlib | dc0be621c6c8208c581f5170a8216c5ba6721927 | c982179ec21091d3e102d8a5d9f5fe06c8fafb73 | refs/heads/master | 1,685,523,275,196 | 1,670,184,141,000 | 1,670,184,141,000 | 287,574,545 | 0 | 0 | Apache-2.0 | 1,670,290,714,000 | 1,597,421,623,000 | Lean | UTF-8 | Lean | false | false | 6,035 | lean | /-
Copyright (c) 2022 Yaël Dillies. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yaël Dillies
-/
import analysis.convex.strict_convex_space
/-!
# Uniformly convex spaces
This file defines uniformly convex spaces, which are real normed vector spaces in which for all
strictly positive `ε`, there exists some strictly positive `δ` such that `ε ≤ ‖x - y‖` implies
`‖x + y‖ ≤ 2 - δ` for all `x` and `y` of norm at most than `1`. This means that the triangle
inequality is strict with a uniform bound, as opposed to strictly convex spaces where the triangle
inequality is strict but not necessarily uniformly (`‖x + y‖ < ‖x‖ + ‖y‖` for all `x` and `y` not in
the same ray).
## Main declarations
`uniform_convex_space E` means that `E` is a uniformly convex space.
## TODO
* Milman-Pettis
* Hanner's inequalities
## Tags
convex, uniformly convex
-/
open set metric
open_locale convex pointwise
/-- A *uniformly convex space* is a real normed space where the triangle inequality is strict with a
uniform bound. Namely, over the `x` and `y` of norm `1`, `‖x + y‖` is uniformly bounded above
by a constant `< 2` when `‖x - y‖` is uniformly bounded below by a positive constant.
See also `uniform_convex_space.of_uniform_convex_closed_unit_ball`. -/
class uniform_convex_space (E : Type*) [seminormed_add_comm_group E] : Prop :=
(uniform_convex : ∀ ⦃ε : ℝ⦄, 0 < ε → ∃ δ, 0 < δ ∧
∀ ⦃x : E⦄, ‖x‖ = 1 → ∀ ⦃y⦄, ‖y‖ = 1 → ε ≤ ‖x - y‖ → ‖x + y‖ ≤ 2 - δ)
variables {E : Type*}
section seminormed_add_comm_group
variables (E) [seminormed_add_comm_group E] [uniform_convex_space E] {ε : ℝ}
lemma exists_forall_sphere_dist_add_le_two_sub (hε : 0 < ε) :
∃ δ, 0 < δ ∧ ∀ ⦃x : E⦄, ‖x‖ = 1 → ∀ ⦃y⦄, ‖y‖ = 1 → ε ≤ ‖x - y‖ → ‖x + y‖ ≤ 2 - δ :=
uniform_convex_space.uniform_convex hε
variables [normed_space ℝ E]
lemma exists_forall_closed_ball_dist_add_le_two_sub (hε : 0 < ε) :
∃ δ, 0 < δ ∧ ∀ ⦃x : E⦄, ‖x‖ ≤ 1 → ∀ ⦃y⦄, ‖y‖ ≤ 1 → ε ≤ ‖x - y‖ → ‖x + y‖ ≤ 2 - δ :=
begin
have hε' : 0 < ε / 3 := div_pos hε zero_lt_three,
obtain ⟨δ, hδ, h⟩ := exists_forall_sphere_dist_add_le_two_sub E hε',
set δ' := min (1/2) (min (ε/3) $ δ/3),
refine ⟨δ', lt_min one_half_pos $ lt_min hε' (div_pos hδ zero_lt_three), λ x hx y hy hxy, _⟩,
obtain hx' | hx' := le_or_lt (‖x‖) (1 - δ'),
{ exact (norm_add_le_of_le hx' hy).trans (sub_add_eq_add_sub _ _ _).le },
obtain hy' | hy' := le_or_lt (‖y‖) (1 - δ'),
{ exact (norm_add_le_of_le hx hy').trans (add_sub_assoc _ _ _).ge },
have hδ' : 0 < 1 - δ' := sub_pos_of_lt (min_lt_of_left_lt one_half_lt_one),
have h₁ : ∀ z : E, 1 - δ' < ‖z‖ → ‖‖z‖⁻¹ • z‖ = 1,
{ rintro z hz,
rw [norm_smul_of_nonneg (inv_nonneg.2 $ norm_nonneg _), inv_mul_cancel (hδ'.trans hz).ne'] },
have h₂ : ∀ z : E, ‖z‖ ≤ 1 → 1 - δ' ≤ ‖z‖ → ‖‖z‖⁻¹ • z - z‖ ≤ δ',
{ rintro z hz hδz,
nth_rewrite 2 ←one_smul ℝ z,
rwa [←sub_smul, norm_smul_of_nonneg (sub_nonneg_of_le $ one_le_inv (hδ'.trans_le hδz) hz),
sub_mul, inv_mul_cancel (hδ'.trans_le hδz).ne', one_mul, sub_le_comm] },
set x' := ‖x‖⁻¹ • x,
set y' := ‖y‖⁻¹ • y,
have hxy' : ε/3 ≤ ‖x' - y'‖ :=
calc ε/3 = ε - (ε/3 + ε/3) : by ring
... ≤ ‖x - y‖ - (‖x' - x‖ + ‖y' - y‖) : sub_le_sub hxy (add_le_add
((h₂ _ hx hx'.le).trans $ min_le_of_right_le $ min_le_left _ _) $
(h₂ _ hy hy'.le).trans $ min_le_of_right_le $ min_le_left _ _)
... ≤ _ : begin
have : ∀ x' y', x - y = x' - y' + (x - x') + (y' - y) := λ _ _, by abel,
rw [sub_le_iff_le_add, norm_sub_rev _ x, ←add_assoc, this],
exact norm_add₃_le _ _ _,
end,
calc ‖x + y‖ ≤ ‖x' + y'‖ + ‖x' - x‖ + ‖y' - y‖ : begin
have : ∀ x' y', x + y = x' + y' + (x - x') + (y - y') := λ _ _, by abel,
rw [norm_sub_rev, norm_sub_rev y', this],
exact norm_add₃_le _ _ _,
end
... ≤ 2 - δ + δ' + δ'
: add_le_add_three (h (h₁ _ hx') (h₁ _ hy') hxy') (h₂ _ hx hx'.le) (h₂ _ hy hy'.le)
... ≤ 2 - δ' : begin
rw [←le_sub_iff_add_le, ←le_sub_iff_add_le, sub_sub, sub_sub],
refine sub_le_sub_left _ _,
ring_nf,
rw ←mul_div_cancel' δ three_ne_zero,
exact mul_le_mul_of_nonneg_left (min_le_of_right_le $ min_le_right _ _) three_pos.le,
end,
end
lemma exists_forall_closed_ball_dist_add_le_two_mul_sub (hε : 0 < ε) (r : ℝ) :
∃ δ, 0 < δ ∧ ∀ ⦃x : E⦄, ‖x‖ ≤ r → ∀ ⦃y⦄, ‖y‖ ≤ r → ε ≤ ‖x - y‖ → ‖x + y‖ ≤ 2 * r - δ :=
begin
obtain hr | hr := le_or_lt r 0,
{ exact ⟨1, one_pos, λ x hx y hy h, (hε.not_le $ h.trans $ (norm_sub_le _ _).trans $
add_nonpos (hx.trans hr) (hy.trans hr)).elim⟩ },
obtain ⟨δ, hδ, h⟩ := exists_forall_closed_ball_dist_add_le_two_sub E (div_pos hε hr),
refine ⟨δ * r, mul_pos hδ hr, λ x hx y hy hxy, _⟩,
rw [←div_le_one hr, div_eq_inv_mul, ←norm_smul_of_nonneg (inv_nonneg.2 hr.le)] at hx hy;
try { apply_instance },
have := h hx hy,
simp_rw [←smul_add, ←smul_sub, norm_smul_of_nonneg (inv_nonneg.2 hr.le), ←div_eq_inv_mul,
div_le_div_right hr, div_le_iff hr, sub_mul] at this,
exact this hxy,
end
end seminormed_add_comm_group
variables [normed_add_comm_group E] [normed_space ℝ E] [uniform_convex_space E]
@[priority 100] -- See note [lower instance priority]
instance uniform_convex_space.to_strict_convex_space : strict_convex_space ℝ E :=
strict_convex_space.of_norm_add_ne_two $ λ x y hx hy hxy,
let ⟨δ, hδ, h⟩ := exists_forall_closed_ball_dist_add_le_two_sub E (norm_sub_pos_iff.2 hxy)
in ((h hx.le hy.le le_rfl).trans_lt $ sub_lt_self _ hδ).ne
|
e491788532bf947b87765aa7298e5d1d1f402df3 | 41ebf3cb010344adfa84907b3304db00e02db0a6 | /uexp/src/uexp/rules/pushAggregateThroughJoin3.lean | f0d1bb739553f6441e73b13e6ae2617cd45735b2 | [
"BSD-2-Clause"
] | permissive | ReinierKoops/Cosette | e061b2ba58b26f4eddf4cd052dcf7abd16dfe8fb | eb8dadd06ee05fe7b6b99de431dd7c4faef5cb29 | refs/heads/master | 1,686,483,953,198 | 1,624,293,498,000 | 1,624,293,498,000 | 378,997,885 | 0 | 0 | BSD-2-Clause | 1,624,293,485,000 | 1,624,293,484,000 | null | UTF-8 | Lean | false | false | 2,176 | lean | import ..sql
import ..tactics
import ..u_semiring
import ..extra_constants
import ..meta.ucongr
import ..meta.TDP
set_option profiler true
open Expr
open Proj
open Pred
open SQL
open tree
notation `int` := datatypes.int
variable integer_10: const datatypes.int
theorem rule:
forall ( Γ scm_t scm_account scm_bonus scm_dept scm_emp: Schema) (rel_t: relation scm_t) (rel_account: relation scm_account) (rel_bonus: relation scm_bonus) (rel_dept: relation scm_dept) (rel_emp: relation scm_emp) (t_k0 : Column int scm_t) (t_c1 : Column int scm_t) (t_f1_a0 : Column int scm_t) (t_f2_a0 : Column int scm_t) (t_f0_c0 : Column int scm_t) (t_f1_c0 : Column int scm_t) (t_f0_c1 : Column int scm_t) (t_f1_c2 : Column int scm_t) (t_f2_c3 : Column int scm_t) (account_acctno : Column int scm_account) (account_type : Column int scm_account) (account_balance : Column int scm_account) (bonus_ename : Column int scm_bonus) (bonus_job : Column int scm_bonus) (bonus_sal : Column int scm_bonus) (bonus_comm : Column int scm_bonus) (dept_deptno : Column int scm_dept) (dept_name : Column int scm_dept) (emp_empno : Column int scm_emp) (emp_ename : Column int scm_emp) (emp_job : Column int scm_emp) (emp_mgr : Column int scm_emp) (emp_hiredate : Column int scm_emp) (emp_comm : Column int scm_emp) (emp_sal : Column int scm_emp) (emp_deptno : Column int scm_emp) (emp_slacker : Column int scm_emp),
denoteSQL (DISTINCT (SELECT1 (combine (right⋅left⋅emp_empno) (right⋅right⋅dept_deptno)) FROM1 (product ((SELECT * FROM1 (table rel_emp) WHERE (equal (uvariable (right⋅emp_empno)) (constantExpr integer_10)))) (table rel_dept)) WHERE (castPred (combine (right⋅right⋅dept_deptno) (right⋅left⋅emp_empno) ) predicates.gt)) :SQL Γ _)
=
denoteSQL (DISTINCT (SELECT1 (combine (right⋅left⋅emp_empno) (right⋅right⋅dept_deptno)) FROM1 (product ((SELECT * FROM1 (table rel_emp) WHERE (equal (uvariable (right⋅emp_empno)) (constantExpr integer_10)))) (table rel_dept)) WHERE (castPred (combine (right⋅right⋅dept_deptno) (right⋅left⋅emp_empno) ) predicates.gt)) :SQL Γ _) :=
begin
intros,
unfold_all_denotations,
funext,
try {simp},
try {TDP' ucongr},
end |
d07f5451165b908d1f22bd86b7a313b3c4d63a1c | e61a235b8468b03aee0120bf26ec615c045005d2 | /stage0/src/Std/Data.lean | 3199055a781d263e4c6ebf00c3be16c70b965b35 | [
"Apache-2.0"
] | permissive | SCKelemen/lean4 | 140dc63a80539f7c61c8e43e1c174d8500ec3230 | e10507e6615ddbef73d67b0b6c7f1e4cecdd82bc | refs/heads/master | 1,660,973,595,917 | 1,590,278,033,000 | 1,590,278,033,000 | null | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 193 | lean | /-
Copyright (c) 2020 Microsoft Corporation. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Leonardo de Moura
-/
import Std.Data.BinomialHeap
|
0f066b5a85ccd13a372d2823e4048a383f10c685 | 74addaa0e41490cbaf2abd313a764c96df57b05d | /Mathlib/measure_theory/group.lean | c2160831c68313104746634f16eb96b768daea42 | [] | no_license | AurelienSaue/Mathlib4_auto | f538cfd0980f65a6361eadea39e6fc639e9dae14 | 590df64109b08190abe22358fabc3eae000943f2 | refs/heads/master | 1,683,906,849,776 | 1,622,564,669,000 | 1,622,564,669,000 | 371,723,747 | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 5,801 | lean | /-
Copyright (c) 2020 Floris van Doorn. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Floris van Doorn
-/
import Mathlib.PrePort
import Mathlib.Lean3Lib.init.default
import Mathlib.measure_theory.integration
import Mathlib.PostPort
universes u_1
namespace Mathlib
/-!
# Measures on Groups
We develop some properties of measures on (topological) groups
* We define properties on measures: left and right invariant measures.
* We define the measure `μ.inv : A ↦ μ(A⁻¹)` and show that it is right invariant iff
`μ` is left invariant.
-/
namespace measure_theory
/-- A measure `μ` on a topological group is left invariant
if the measure of left translations of a set are equal to the measure of the set itself.
To left translate sets we use preimage under left multiplication,
since preimages are nicer to work with than images. -/
def is_add_left_invariant {G : Type u_1} [measurable_space G] [Add G] (μ : set G → ennreal) :=
∀ (g : G) {A : set G} (h : is_measurable A), μ ((fun (h : G) => g + h) ⁻¹' A) = μ A
/-- A measure `μ` on a topological group is right invariant
if the measure of right translations of a set are equal to the measure of the set itself.
To right translate sets we use preimage under right multiplication,
since preimages are nicer to work with than images. -/
def is_add_right_invariant {G : Type u_1} [measurable_space G] [Add G] (μ : set G → ennreal) :=
∀ (g : G) {A : set G} (h : is_measurable A), μ ((fun (h : G) => h + g) ⁻¹' A) = μ A
namespace measure
theorem map_mul_left_eq_self {G : Type u_1} [measurable_space G] [topological_space G] [Mul G] [has_continuous_mul G] [borel_space G] {μ : measure G} : (∀ (g : G), coe_fn (map (Mul.mul g)) μ = μ) ↔ is_mul_left_invariant ⇑μ := sorry
theorem map_mul_right_eq_self {G : Type u_1} [measurable_space G] [topological_space G] [Mul G] [has_continuous_mul G] [borel_space G] {μ : measure G} : (∀ (g : G), coe_fn (map fun (h : G) => h * g) μ = μ) ↔ is_mul_right_invariant ⇑μ := sorry
/-- The measure `A ↦ μ (A⁻¹)`, where `A⁻¹` is the pointwise inverse of `A`. -/
protected def neg {G : Type u_1} [measurable_space G] [Neg G] (μ : measure G) : measure G :=
coe_fn (map Neg.neg) μ
theorem neg_apply {G : Type u_1} [measurable_space G] [add_group G] [topological_space G] [topological_add_group G] [borel_space G] (μ : measure G) {s : set G} (hs : is_measurable s) : coe_fn (measure.neg μ) s = coe_fn μ (-s) := sorry
@[simp] protected theorem neg_neg {G : Type u_1} [measurable_space G] [add_group G] [topological_space G] [topological_add_group G] [borel_space G] (μ : measure G) : measure.neg (measure.neg μ) = μ := sorry
theorem regular.neg {G : Type u_1} [measurable_space G] [add_group G] [topological_space G] [topological_add_group G] [borel_space G] {μ : measure G} [t2_space G] (hμ : regular μ) : regular (measure.neg μ) :=
regular.map hμ (homeomorph.neg G)
end measure
@[simp] theorem regular_inv_iff {G : Type u_1} [measurable_space G] [group G] [topological_space G] [topological_group G] [borel_space G] {μ : measure G} [t2_space G] : measure.regular (measure.inv μ) ↔ measure.regular μ := sorry
theorem is_add_left_invariant.neg {G : Type u_1} [measurable_space G] [add_group G] [topological_space G] [topological_add_group G] [borel_space G] {μ : measure G} (h : is_add_left_invariant ⇑μ) : is_add_right_invariant ⇑(measure.neg μ) := sorry
theorem is_mul_right_invariant.inv {G : Type u_1} [measurable_space G] [group G] [topological_space G] [topological_group G] [borel_space G] {μ : measure G} (h : is_mul_right_invariant ⇑μ) : is_mul_left_invariant ⇑(measure.inv μ) := sorry
@[simp] theorem is_mul_right_invariant_inv {G : Type u_1} [measurable_space G] [group G] [topological_space G] [topological_group G] [borel_space G] {μ : measure G} : is_mul_right_invariant ⇑(measure.inv μ) ↔ is_mul_left_invariant ⇑μ := sorry
@[simp] theorem is_add_left_invariant_neg {G : Type u_1} [measurable_space G] [add_group G] [topological_space G] [topological_add_group G] [borel_space G] {μ : measure G} : is_add_left_invariant ⇑(measure.neg μ) ↔ is_add_right_invariant ⇑μ := sorry
/-! Properties of regular left invariant measures -/
theorem is_mul_left_invariant.null_iff_empty {G : Type u_1} [measurable_space G] [topological_space G] [borel_space G] {μ : measure G} [group G] [topological_group G] (hμ : measure.regular μ) (h2μ : is_mul_left_invariant ⇑μ) (h3μ : μ ≠ 0) {s : set G} (hs : is_open s) : coe_fn μ s = 0 ↔ s = ∅ := sorry
theorem is_mul_left_invariant.null_iff {G : Type u_1} [measurable_space G] [topological_space G] [borel_space G] {μ : measure G} [group G] [topological_group G] (hμ : measure.regular μ) (h2μ : is_mul_left_invariant ⇑μ) {s : set G} (hs : is_open s) : coe_fn μ s = 0 ↔ s = ∅ ∨ μ = 0 := sorry
theorem is_mul_left_invariant.measure_ne_zero_iff_nonempty {G : Type u_1} [measurable_space G] [topological_space G] [borel_space G] {μ : measure G} [group G] [topological_group G] (hμ : measure.regular μ) (h2μ : is_mul_left_invariant ⇑μ) (h3μ : μ ≠ 0) {s : set G} (hs : is_open s) : coe_fn μ s ≠ 0 ↔ set.nonempty s := sorry
/-- For nonzero regular left invariant measures, the integral of a continuous nonnegative function
`f` is 0 iff `f` is 0. -/
-- @[to_additive] (fails for now)
theorem lintegral_eq_zero_of_is_mul_left_invariant {G : Type u_1} [measurable_space G] [topological_space G] [borel_space G] {μ : measure G} [group G] [topological_group G] (hμ : measure.regular μ) (h2μ : is_mul_left_invariant ⇑μ) (h3μ : μ ≠ 0) {f : G → ennreal} (hf : continuous f) : (lintegral μ fun (x : G) => f x) = 0 ↔ f = 0 := sorry
|
d1e6881da46b9b50ffb0967a5dc15f1840af6592 | 1abd1ed12aa68b375cdef28959f39531c6e95b84 | /src/order/bounds.lean | a44eb57c274d3d7e9fcb046091bbdec83ce5c4b6 | [
"Apache-2.0"
] | permissive | jumpy4/mathlib | d3829e75173012833e9f15ac16e481e17596de0f | af36f1a35f279f0e5b3c2a77647c6bf2cfd51a13 | refs/heads/master | 1,693,508,842,818 | 1,636,203,271,000 | 1,636,203,271,000 | null | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 37,989 | lean | /-
Copyright (c) 2017 Johannes Hölzl. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johannes Hölzl, Yury Kudryashov
-/
import data.set.intervals.basic
/-!
# Upper / lower bounds
In this file we define:
* `upper_bounds`, `lower_bounds` : the set of upper bounds (resp., lower bounds) of a set;
* `bdd_above s`, `bdd_below s` : the set `s` is bounded above (resp., below), i.e., the set of upper
(resp., lower) bounds of `s` is nonempty;
* `is_least s a`, `is_greatest s a` : `a` is a least (resp., greatest) element of `s`;
for a partial order, it is unique if exists;
* `is_lub s a`, `is_glb s a` : `a` is a least upper bound (resp., a greatest lower bound)
of `s`; for a partial order, it is unique if exists.
We also prove various lemmas about monotonicity, behaviour under `∪`, `∩`, `insert`, and provide
formulas for `∅`, `univ`, and intervals.
-/
open set order_dual (to_dual of_dual)
universes u v w x
variables {α : Type u} {β : Type v} {γ : Type w} {ι : Sort x}
section
variables [preorder α] [preorder β] {s t : set α} {a b : α}
/-!
### Definitions
-/
/-- The set of upper bounds of a set. -/
def upper_bounds (s : set α) : set α := { x | ∀ ⦃a⦄, a ∈ s → a ≤ x }
/-- The set of lower bounds of a set. -/
def lower_bounds (s : set α) : set α := { x | ∀ ⦃a⦄, a ∈ s → x ≤ a }
/-- A set is bounded above if there exists an upper bound. -/
def bdd_above (s : set α) := (upper_bounds s).nonempty
/-- A set is bounded below if there exists a lower bound. -/
def bdd_below (s : set α) := (lower_bounds s).nonempty
/-- `a` is a least element of a set `s`; for a partial order, it is unique if exists. -/
def is_least (s : set α) (a : α) : Prop := a ∈ s ∧ a ∈ lower_bounds s
/-- `a` is a greatest element of a set `s`; for a partial order, it is unique if exists -/
def is_greatest (s : set α) (a : α) : Prop := a ∈ s ∧ a ∈ upper_bounds s
/-- `a` is a least upper bound of a set `s`; for a partial order, it is unique if exists. -/
def is_lub (s : set α) : α → Prop := is_least (upper_bounds s)
/-- `a` is a greatest lower bound of a set `s`; for a partial order, it is unique if exists. -/
def is_glb (s : set α) : α → Prop := is_greatest (lower_bounds s)
lemma mem_upper_bounds : a ∈ upper_bounds s ↔ ∀ x ∈ s, x ≤ a := iff.rfl
lemma mem_lower_bounds : a ∈ lower_bounds s ↔ ∀ x ∈ s, a ≤ x := iff.rfl
/-- A set `s` is not bounded above if and only if for each `x` there exists `y ∈ s` such that `x`
is not greater than or equal to `y`. This version only assumes `preorder` structure and uses
`¬(y ≤ x)`. A version for linear orders is called `not_bdd_above_iff`. -/
lemma not_bdd_above_iff' : ¬bdd_above s ↔ ∀ x, ∃ y ∈ s, ¬(y ≤ x) :=
by simp [bdd_above, upper_bounds, set.nonempty]
/-- A set `s` is not bounded below if and only if for each `x` there exists `y ∈ s` such that `x`
is not less than or equal to `y`. This version only assumes `preorder` structure and uses
`¬(x ≤ y)`. A version for linear orders is called `not_bdd_below_iff`. -/
lemma not_bdd_below_iff' : ¬bdd_below s ↔ ∀ x, ∃ y ∈ s, ¬(x ≤ y) :=
@not_bdd_above_iff' (order_dual α) _ _
/-- A set `s` is not bounded above if and only if for each `x` there exists `y ∈ s` that is greater
than `x`. A version for preorders is called `not_bdd_above_iff'`. -/
lemma not_bdd_above_iff {α : Type*} [linear_order α] {s : set α} :
¬bdd_above s ↔ ∀ x, ∃ y ∈ s, x < y :=
by simp only [not_bdd_above_iff', not_le]
/-- A set `s` is not bounded below if and only if for each `x` there exists `y ∈ s` that is less
than `x`. A version for preorders is called `not_bdd_below_iff'`. -/
lemma not_bdd_below_iff {α : Type*} [linear_order α] {s : set α} :
¬bdd_below s ↔ ∀ x, ∃ y ∈ s, y < x :=
@not_bdd_above_iff (order_dual α) _ _
lemma bdd_above.dual (h : bdd_above s) : bdd_below (of_dual ⁻¹' s) := h
lemma bdd_below.dual (h : bdd_below s) : bdd_above (of_dual ⁻¹' s) := h
lemma is_least.dual (h : is_least s a) : is_greatest (of_dual ⁻¹' s) (to_dual a) := h
lemma is_greatest.dual (h : is_greatest s a) : is_least (of_dual ⁻¹' s) (to_dual a) := h
lemma is_lub.dual (h : is_lub s a) : is_glb (of_dual ⁻¹' s) (to_dual a) := h
lemma is_glb.dual (h : is_glb s a) : is_lub (of_dual ⁻¹' s) (to_dual a) := h
/-!
### Monotonicity
-/
lemma upper_bounds_mono_set ⦃s t : set α⦄ (hst : s ⊆ t) :
upper_bounds t ⊆ upper_bounds s :=
λ b hb x h, hb $ hst h
lemma lower_bounds_mono_set ⦃s t : set α⦄ (hst : s ⊆ t) :
lower_bounds t ⊆ lower_bounds s :=
λ b hb x h, hb $ hst h
lemma upper_bounds_mono_mem ⦃a b⦄ (hab : a ≤ b) : a ∈ upper_bounds s → b ∈ upper_bounds s :=
λ ha x h, le_trans (ha h) hab
lemma lower_bounds_mono_mem ⦃a b⦄ (hab : a ≤ b) : b ∈ lower_bounds s → a ∈ lower_bounds s :=
λ hb x h, le_trans hab (hb h)
lemma upper_bounds_mono ⦃s t : set α⦄ (hst : s ⊆ t) ⦃a b⦄ (hab : a ≤ b) :
a ∈ upper_bounds t → b ∈ upper_bounds s :=
λ ha, upper_bounds_mono_set hst $ upper_bounds_mono_mem hab ha
lemma lower_bounds_mono ⦃s t : set α⦄ (hst : s ⊆ t) ⦃a b⦄ (hab : a ≤ b) :
b ∈ lower_bounds t → a ∈ lower_bounds s :=
λ hb, lower_bounds_mono_set hst $ lower_bounds_mono_mem hab hb
/-- If `s ⊆ t` and `t` is bounded above, then so is `s`. -/
lemma bdd_above.mono ⦃s t : set α⦄ (h : s ⊆ t) : bdd_above t → bdd_above s :=
nonempty.mono $ upper_bounds_mono_set h
/-- If `s ⊆ t` and `t` is bounded below, then so is `s`. -/
lemma bdd_below.mono ⦃s t : set α⦄ (h : s ⊆ t) : bdd_below t → bdd_below s :=
nonempty.mono $ lower_bounds_mono_set h
/-- If `a` is a least upper bound for sets `s` and `p`, then it is a least upper bound for any
set `t`, `s ⊆ t ⊆ p`. -/
lemma is_lub.of_subset_of_superset {s t p : set α} (hs : is_lub s a) (hp : is_lub p a)
(hst : s ⊆ t) (htp : t ⊆ p) : is_lub t a :=
⟨upper_bounds_mono_set htp hp.1, lower_bounds_mono_set (upper_bounds_mono_set hst) hs.2⟩
/-- If `a` is a greatest lower bound for sets `s` and `p`, then it is a greater lower bound for any
set `t`, `s ⊆ t ⊆ p`. -/
lemma is_glb.of_subset_of_superset {s t p : set α} (hs : is_glb s a) (hp : is_glb p a)
(hst : s ⊆ t) (htp : t ⊆ p) : is_glb t a :=
hs.dual.of_subset_of_superset hp hst htp
lemma is_least.mono (ha : is_least s a) (hb : is_least t b) (hst : s ⊆ t) : b ≤ a :=
hb.2 (hst ha.1)
lemma is_greatest.mono (ha : is_greatest s a) (hb : is_greatest t b) (hst : s ⊆ t) : a ≤ b :=
hb.2 (hst ha.1)
lemma is_lub.mono (ha : is_lub s a) (hb : is_lub t b) (hst : s ⊆ t) : a ≤ b :=
hb.mono ha $ upper_bounds_mono_set hst
lemma is_glb.mono (ha : is_glb s a) (hb : is_glb t b) (hst : s ⊆ t) : b ≤ a :=
hb.mono ha $ lower_bounds_mono_set hst
lemma subset_lower_bounds_upper_bounds (s : set α) : s ⊆ lower_bounds (upper_bounds s) :=
λ x hx y hy, hy hx
lemma subset_upper_bounds_lower_bounds (s : set α) : s ⊆ upper_bounds (lower_bounds s) :=
λ x hx y hy, hy hx
lemma set.nonempty.bdd_above_lower_bounds (hs : s.nonempty) : bdd_above (lower_bounds s) :=
hs.mono (subset_upper_bounds_lower_bounds s)
lemma set.nonempty.bdd_below_upper_bounds (hs : s.nonempty) : bdd_below (upper_bounds s) :=
hs.mono (subset_lower_bounds_upper_bounds s)
/-!
### Conversions
-/
lemma is_least.is_glb (h : is_least s a) : is_glb s a := ⟨h.2, λ b hb, hb h.1⟩
lemma is_greatest.is_lub (h : is_greatest s a) : is_lub s a := ⟨h.2, λ b hb, hb h.1⟩
lemma is_lub.upper_bounds_eq (h : is_lub s a) : upper_bounds s = Ici a :=
set.ext $ λ b, ⟨λ hb, h.2 hb, λ hb, upper_bounds_mono_mem hb h.1⟩
lemma is_glb.lower_bounds_eq (h : is_glb s a) : lower_bounds s = Iic a := h.dual.upper_bounds_eq
lemma is_least.lower_bounds_eq (h : is_least s a) : lower_bounds s = Iic a :=
h.is_glb.lower_bounds_eq
lemma is_greatest.upper_bounds_eq (h : is_greatest s a) : upper_bounds s = Ici a :=
h.is_lub.upper_bounds_eq
lemma is_lub_le_iff (h : is_lub s a) : a ≤ b ↔ b ∈ upper_bounds s :=
by { rw h.upper_bounds_eq, refl }
lemma le_is_glb_iff (h : is_glb s a) : b ≤ a ↔ b ∈ lower_bounds s :=
by { rw h.lower_bounds_eq, refl }
lemma is_lub_iff_le_iff : is_lub s a ↔ ∀ b, a ≤ b ↔ b ∈ upper_bounds s :=
⟨λ h b, is_lub_le_iff h, λ H, ⟨(H _).1 le_rfl, λ b hb, (H b).2 hb⟩⟩
lemma is_glb_iff_le_iff : is_glb s a ↔ ∀ b, b ≤ a ↔ b ∈ lower_bounds s :=
@is_lub_iff_le_iff (order_dual α) _ _ _
/-- If `s` has a least upper bound, then it is bounded above. -/
lemma is_lub.bdd_above (h : is_lub s a) : bdd_above s := ⟨a, h.1⟩
/-- If `s` has a greatest lower bound, then it is bounded below. -/
lemma is_glb.bdd_below (h : is_glb s a) : bdd_below s := ⟨a, h.1⟩
/-- If `s` has a greatest element, then it is bounded above. -/
lemma is_greatest.bdd_above (h : is_greatest s a) : bdd_above s := ⟨a, h.2⟩
/-- If `s` has a least element, then it is bounded below. -/
lemma is_least.bdd_below (h : is_least s a) : bdd_below s := ⟨a, h.2⟩
lemma is_least.nonempty (h : is_least s a) : s.nonempty := ⟨a, h.1⟩
lemma is_greatest.nonempty (h : is_greatest s a) : s.nonempty := ⟨a, h.1⟩
/-!
### Union and intersection
-/
@[simp] lemma upper_bounds_union : upper_bounds (s ∪ t) = upper_bounds s ∩ upper_bounds t :=
subset.antisymm
(λ b hb, ⟨λ x hx, hb (or.inl hx), λ x hx, hb (or.inr hx)⟩)
(λ b hb x hx, hx.elim (λ hs, hb.1 hs) (λ ht, hb.2 ht))
@[simp] lemma lower_bounds_union : lower_bounds (s ∪ t) = lower_bounds s ∩ lower_bounds t :=
@upper_bounds_union (order_dual α) _ s t
lemma union_upper_bounds_subset_upper_bounds_inter :
upper_bounds s ∪ upper_bounds t ⊆ upper_bounds (s ∩ t) :=
union_subset
(upper_bounds_mono_set $ inter_subset_left _ _)
(upper_bounds_mono_set $ inter_subset_right _ _)
lemma union_lower_bounds_subset_lower_bounds_inter :
lower_bounds s ∪ lower_bounds t ⊆ lower_bounds (s ∩ t) :=
@union_upper_bounds_subset_upper_bounds_inter (order_dual α) _ s t
lemma is_least_union_iff {a : α} {s t : set α} :
is_least (s ∪ t) a ↔ (is_least s a ∧ a ∈ lower_bounds t ∨ a ∈ lower_bounds s ∧ is_least t a) :=
by simp [is_least, lower_bounds_union, or_and_distrib_right, and_comm (a ∈ t), and_assoc]
lemma is_greatest_union_iff :
is_greatest (s ∪ t) a ↔ (is_greatest s a ∧ a ∈ upper_bounds t ∨
a ∈ upper_bounds s ∧ is_greatest t a) :=
@is_least_union_iff (order_dual α) _ a s t
/-- If `s` is bounded, then so is `s ∩ t` -/
lemma bdd_above.inter_of_left (h : bdd_above s) : bdd_above (s ∩ t) :=
h.mono $ inter_subset_left s t
/-- If `t` is bounded, then so is `s ∩ t` -/
lemma bdd_above.inter_of_right (h : bdd_above t) : bdd_above (s ∩ t) :=
h.mono $ inter_subset_right s t
/-- If `s` is bounded, then so is `s ∩ t` -/
lemma bdd_below.inter_of_left (h : bdd_below s) : bdd_below (s ∩ t) :=
h.mono $ inter_subset_left s t
/-- If `t` is bounded, then so is `s ∩ t` -/
lemma bdd_below.inter_of_right (h : bdd_below t) : bdd_below (s ∩ t) :=
h.mono $ inter_subset_right s t
/-- If `s` and `t` are bounded above sets in a `semilattice_sup`, then so is `s ∪ t`. -/
lemma bdd_above.union [semilattice_sup γ] {s t : set γ} :
bdd_above s → bdd_above t → bdd_above (s ∪ t) :=
begin
rintros ⟨bs, hs⟩ ⟨bt, ht⟩,
use bs ⊔ bt,
rw upper_bounds_union,
exact ⟨upper_bounds_mono_mem le_sup_left hs,
upper_bounds_mono_mem le_sup_right ht⟩
end
/-- The union of two sets is bounded above if and only if each of the sets is. -/
lemma bdd_above_union [semilattice_sup γ] {s t : set γ} :
bdd_above (s ∪ t) ↔ bdd_above s ∧ bdd_above t :=
⟨λ h, ⟨h.mono $ subset_union_left s t, h.mono $ subset_union_right s t⟩,
λ h, h.1.union h.2⟩
lemma bdd_below.union [semilattice_inf γ] {s t : set γ} :
bdd_below s → bdd_below t → bdd_below (s ∪ t) :=
@bdd_above.union (order_dual γ) _ s t
/--The union of two sets is bounded above if and only if each of the sets is.-/
lemma bdd_below_union [semilattice_inf γ] {s t : set γ} :
bdd_below (s ∪ t) ↔ bdd_below s ∧ bdd_below t :=
@bdd_above_union (order_dual γ) _ s t
/-- If `a` is the least upper bound of `s` and `b` is the least upper bound of `t`,
then `a ⊔ b` is the least upper bound of `s ∪ t`. -/
lemma is_lub.union [semilattice_sup γ] {a b : γ} {s t : set γ}
(hs : is_lub s a) (ht : is_lub t b) :
is_lub (s ∪ t) (a ⊔ b) :=
⟨λ c h, h.cases_on (λ h, le_sup_of_le_left $ hs.left h) (λ h, le_sup_of_le_right $ ht.left h),
assume c hc, sup_le
(hs.right $ assume d hd, hc $ or.inl hd) (ht.right $ assume d hd, hc $ or.inr hd)⟩
/-- If `a` is the greatest lower bound of `s` and `b` is the greatest lower bound of `t`,
then `a ⊓ b` is the greatest lower bound of `s ∪ t`. -/
lemma is_glb.union [semilattice_inf γ] {a₁ a₂ : γ} {s t : set γ}
(hs : is_glb s a₁) (ht : is_glb t a₂) :
is_glb (s ∪ t) (a₁ ⊓ a₂) :=
hs.dual.union ht
/-- If `a` is the least element of `s` and `b` is the least element of `t`,
then `min a b` is the least element of `s ∪ t`. -/
lemma is_least.union [linear_order γ] {a b : γ} {s t : set γ}
(ha : is_least s a) (hb : is_least t b) : is_least (s ∪ t) (min a b) :=
⟨by cases (le_total a b) with h h; simp [h, ha.1, hb.1],
(ha.is_glb.union hb.is_glb).1⟩
/-- If `a` is the greatest element of `s` and `b` is the greatest element of `t`,
then `max a b` is the greatest element of `s ∪ t`. -/
lemma is_greatest.union [linear_order γ] {a b : γ} {s t : set γ}
(ha : is_greatest s a) (hb : is_greatest t b) : is_greatest (s ∪ t) (max a b) :=
⟨by cases (le_total a b) with h h; simp [h, ha.1, hb.1],
(ha.is_lub.union hb.is_lub).1⟩
lemma is_lub.inter_Ici_of_mem [linear_order γ] {s : set γ} {a b : γ} (ha : is_lub s a)
(hb : b ∈ s) : is_lub (s ∩ Ici b) a :=
⟨λ x hx, ha.1 hx.1, λ c hc, have hbc : b ≤ c, from hc ⟨hb, le_rfl⟩,
ha.2 $ λ x hx, (le_total x b).elim (λ hxb, hxb.trans hbc) $ λ hbx, hc ⟨hx, hbx⟩⟩
lemma is_glb.inter_Iic_of_mem [linear_order γ] {s : set γ} {a b : γ} (ha : is_glb s a)
(hb : b ∈ s) : is_glb (s ∩ Iic b) a :=
ha.dual.inter_Ici_of_mem hb
/-!
### Specific sets
#### Unbounded intervals
-/
lemma is_least_Ici : is_least (Ici a) a := ⟨left_mem_Ici, λ x, id⟩
lemma is_greatest_Iic : is_greatest (Iic a) a := ⟨right_mem_Iic, λ x, id⟩
lemma is_lub_Iic : is_lub (Iic a) a := is_greatest_Iic.is_lub
lemma is_glb_Ici : is_glb (Ici a) a := is_least_Ici.is_glb
lemma upper_bounds_Iic : upper_bounds (Iic a) = Ici a := is_lub_Iic.upper_bounds_eq
lemma lower_bounds_Ici : lower_bounds (Ici a) = Iic a := is_glb_Ici.lower_bounds_eq
lemma bdd_above_Iic : bdd_above (Iic a) := is_lub_Iic.bdd_above
lemma bdd_below_Ici : bdd_below (Ici a) := is_glb_Ici.bdd_below
lemma bdd_above_Iio : bdd_above (Iio a) := ⟨a, λ x hx, le_of_lt hx⟩
lemma bdd_below_Ioi : bdd_below (Ioi a) := ⟨a, λ x hx, le_of_lt hx⟩
section
variables [linear_order γ] [densely_ordered γ]
lemma is_lub_Iio {a : γ} : is_lub (Iio a) a :=
⟨λ x hx, le_of_lt hx, λ y hy, le_of_forall_ge_of_dense hy⟩
lemma is_glb_Ioi {a : γ} : is_glb (Ioi a) a := @is_lub_Iio (order_dual γ) _ _ a
lemma upper_bounds_Iio {a : γ} : upper_bounds (Iio a) = Ici a := is_lub_Iio.upper_bounds_eq
lemma lower_bounds_Ioi {a : γ} : lower_bounds (Ioi a) = Iic a := is_glb_Ioi.lower_bounds_eq
end
/-!
#### Singleton
-/
lemma is_greatest_singleton : is_greatest {a} a :=
⟨mem_singleton a, λ x hx, le_of_eq $ eq_of_mem_singleton hx⟩
lemma is_least_singleton : is_least {a} a :=
@is_greatest_singleton (order_dual α) _ a
lemma is_lub_singleton : is_lub {a} a := is_greatest_singleton.is_lub
lemma is_glb_singleton : is_glb {a} a := is_least_singleton.is_glb
lemma bdd_above_singleton : bdd_above ({a} : set α) := is_lub_singleton.bdd_above
lemma bdd_below_singleton : bdd_below ({a} : set α) := is_glb_singleton.bdd_below
@[simp] lemma upper_bounds_singleton : upper_bounds {a} = Ici a := is_lub_singleton.upper_bounds_eq
@[simp] lemma lower_bounds_singleton : lower_bounds {a} = Iic a := is_glb_singleton.lower_bounds_eq
/-!
#### Bounded intervals
-/
lemma bdd_above_Icc : bdd_above (Icc a b) := ⟨b, λ _, and.right⟩
lemma bdd_below_Icc : bdd_below (Icc a b) := ⟨a, λ _, and.left⟩
lemma bdd_above_Ico : bdd_above (Ico a b) := bdd_above_Icc.mono Ico_subset_Icc_self
lemma bdd_below_Ico : bdd_below (Ico a b) := bdd_below_Icc.mono Ico_subset_Icc_self
lemma bdd_above_Ioc : bdd_above (Ioc a b) := bdd_above_Icc.mono Ioc_subset_Icc_self
lemma bdd_below_Ioc : bdd_below (Ioc a b) := bdd_below_Icc.mono Ioc_subset_Icc_self
lemma bdd_above_Ioo : bdd_above (Ioo a b) := bdd_above_Icc.mono Ioo_subset_Icc_self
lemma bdd_below_Ioo : bdd_below (Ioo a b) := bdd_below_Icc.mono Ioo_subset_Icc_self
lemma is_greatest_Icc (h : a ≤ b) : is_greatest (Icc a b) b :=
⟨right_mem_Icc.2 h, λ x, and.right⟩
lemma is_lub_Icc (h : a ≤ b) : is_lub (Icc a b) b := (is_greatest_Icc h).is_lub
lemma upper_bounds_Icc (h : a ≤ b) : upper_bounds (Icc a b) = Ici b :=
(is_lub_Icc h).upper_bounds_eq
lemma is_least_Icc (h : a ≤ b) : is_least (Icc a b) a :=
⟨left_mem_Icc.2 h, λ x, and.left⟩
lemma is_glb_Icc (h : a ≤ b) : is_glb (Icc a b) a := (is_least_Icc h).is_glb
lemma lower_bounds_Icc (h : a ≤ b) : lower_bounds (Icc a b) = Iic a :=
(is_glb_Icc h).lower_bounds_eq
lemma is_greatest_Ioc (h : a < b) : is_greatest (Ioc a b) b :=
⟨right_mem_Ioc.2 h, λ x, and.right⟩
lemma is_lub_Ioc (h : a < b) : is_lub (Ioc a b) b :=
(is_greatest_Ioc h).is_lub
lemma upper_bounds_Ioc (h : a < b) : upper_bounds (Ioc a b) = Ici b :=
(is_lub_Ioc h).upper_bounds_eq
lemma is_least_Ico (h : a < b) : is_least (Ico a b) a :=
⟨left_mem_Ico.2 h, λ x, and.left⟩
lemma is_glb_Ico (h : a < b) : is_glb (Ico a b) a :=
(is_least_Ico h).is_glb
lemma lower_bounds_Ico (h : a < b) : lower_bounds (Ico a b) = Iic a :=
(is_glb_Ico h).lower_bounds_eq
section
variables [semilattice_sup γ] [densely_ordered γ]
lemma is_glb_Ioo {a b : γ} (h : a < b) :
is_glb (Ioo a b) a :=
⟨λ x hx, hx.1.le, λ x hx,
begin
cases eq_or_lt_of_le (le_sup_right : a ≤ x ⊔ a) with h₁ h₂,
{ exact h₁.symm ▸ le_sup_left },
obtain ⟨y, lty, ylt⟩ := exists_between h₂,
apply (not_lt_of_le (sup_le (hx ⟨lty, ylt.trans_le (sup_le _ h.le)⟩) lty.le) ylt).elim,
obtain ⟨u, au, ub⟩ := exists_between h,
apply (hx ⟨au, ub⟩).trans ub.le,
end⟩
lemma lower_bounds_Ioo {a b : γ} (hab : a < b) : lower_bounds (Ioo a b) = Iic a :=
(is_glb_Ioo hab).lower_bounds_eq
lemma is_glb_Ioc {a b : γ} (hab : a < b) : is_glb (Ioc a b) a :=
(is_glb_Ioo hab).of_subset_of_superset (is_glb_Icc hab.le) Ioo_subset_Ioc_self Ioc_subset_Icc_self
lemma lower_bound_Ioc {a b : γ} (hab : a < b) : lower_bounds (Ioc a b) = Iic a :=
(is_glb_Ioc hab).lower_bounds_eq
end
section
variables [semilattice_inf γ] [densely_ordered γ]
lemma is_lub_Ioo {a b : γ} (hab : a < b) : is_lub (Ioo a b) b :=
by simpa only [dual_Ioo] using is_glb_Ioo hab.dual
lemma upper_bounds_Ioo {a b : γ} (hab : a < b) : upper_bounds (Ioo a b) = Ici b :=
(is_lub_Ioo hab).upper_bounds_eq
lemma is_lub_Ico {a b : γ} (hab : a < b) : is_lub (Ico a b) b :=
by simpa only [dual_Ioc] using is_glb_Ioc hab.dual
lemma upper_bounds_Ico {a b : γ} (hab : a < b) : upper_bounds (Ico a b) = Ici b :=
(is_lub_Ico hab).upper_bounds_eq
end
lemma bdd_below_iff_subset_Ici : bdd_below s ↔ ∃ a, s ⊆ Ici a := iff.rfl
lemma bdd_above_iff_subset_Iic : bdd_above s ↔ ∃ a, s ⊆ Iic a := iff.rfl
lemma bdd_below_bdd_above_iff_subset_Icc : bdd_below s ∧ bdd_above s ↔ ∃ a b, s ⊆ Icc a b :=
by simp only [Ici_inter_Iic.symm, subset_inter_iff, bdd_below_iff_subset_Ici,
bdd_above_iff_subset_Iic, exists_and_distrib_left, exists_and_distrib_right]
/-!
#### Univ
-/
lemma is_greatest_univ [order_top γ] : is_greatest (univ : set γ) ⊤ :=
⟨mem_univ _, λ x hx, le_top⟩
@[simp] lemma order_top.upper_bounds_univ [order_top γ] : upper_bounds (univ : set γ) = {⊤} :=
by rw [is_greatest_univ.upper_bounds_eq, Ici_top]
lemma is_lub_univ [order_top γ] : is_lub (univ : set γ) ⊤ :=
is_greatest_univ.is_lub
@[simp] lemma order_bot.lower_bounds_univ [order_bot γ] : lower_bounds (univ : set γ) = {⊥} :=
@order_top.upper_bounds_univ (order_dual γ) _
lemma is_least_univ [order_bot γ] : is_least (univ : set γ) ⊥ :=
@is_greatest_univ (order_dual γ) _
lemma is_glb_univ [order_bot γ] : is_glb (univ : set γ) ⊥ :=
is_least_univ.is_glb
@[simp] lemma no_top_order.upper_bounds_univ [no_top_order α] : upper_bounds (univ : set α) = ∅ :=
eq_empty_of_subset_empty $ λ b hb, let ⟨x, hx⟩ := no_top b in
not_le_of_lt hx (hb trivial)
@[simp] lemma no_bot_order.lower_bounds_univ [no_bot_order α] : lower_bounds (univ : set α) = ∅ :=
@no_top_order.upper_bounds_univ (order_dual α) _ _
@[simp] lemma not_bdd_above_univ [no_top_order α] : ¬bdd_above (univ : set α) :=
by simp [bdd_above]
@[simp] lemma not_bdd_below_univ [no_bot_order α] : ¬bdd_below (univ : set α) :=
@not_bdd_above_univ (order_dual α) _ _
/-!
#### Empty set
-/
@[simp] lemma upper_bounds_empty : upper_bounds (∅ : set α) = univ :=
by simp only [upper_bounds, eq_univ_iff_forall, mem_set_of_eq, ball_empty_iff, forall_true_iff]
@[simp] lemma lower_bounds_empty : lower_bounds (∅ : set α) = univ :=
@upper_bounds_empty (order_dual α) _
@[simp] lemma bdd_above_empty [nonempty α] : bdd_above (∅ : set α) :=
by simp only [bdd_above, upper_bounds_empty, univ_nonempty]
@[simp] lemma bdd_below_empty [nonempty α] : bdd_below (∅ : set α) :=
by simp only [bdd_below, lower_bounds_empty, univ_nonempty]
lemma is_glb_empty [order_top γ] : is_glb ∅ (⊤:γ) :=
by simp only [is_glb, lower_bounds_empty, is_greatest_univ]
lemma is_lub_empty [order_bot γ] : is_lub ∅ (⊥:γ) :=
@is_glb_empty (order_dual γ) _
lemma is_lub.nonempty [no_bot_order α] (hs : is_lub s a) : s.nonempty :=
let ⟨a', ha'⟩ := no_bot a in
ne_empty_iff_nonempty.1 $ assume h,
have a ≤ a', from hs.right $ by simp only [h, upper_bounds_empty],
not_le_of_lt ha' this
lemma is_glb.nonempty [no_top_order α] (hs : is_glb s a) : s.nonempty := hs.dual.nonempty
lemma nonempty_of_not_bdd_above [ha : nonempty α] (h : ¬bdd_above s) : s.nonempty :=
nonempty.elim ha $ λ x, (not_bdd_above_iff'.1 h x).imp $ λ a ha, ha.fst
lemma nonempty_of_not_bdd_below [ha : nonempty α] (h : ¬bdd_below s) : s.nonempty :=
@nonempty_of_not_bdd_above (order_dual α) _ _ _ h
/-!
#### insert
-/
/-- Adding a point to a set preserves its boundedness above. -/
@[simp] lemma bdd_above_insert [semilattice_sup γ] (a : γ) {s : set γ} :
bdd_above (insert a s) ↔ bdd_above s :=
by simp only [insert_eq, bdd_above_union, bdd_above_singleton, true_and]
lemma bdd_above.insert [semilattice_sup γ] (a : γ) {s : set γ} (hs : bdd_above s) :
bdd_above (insert a s) :=
(bdd_above_insert a).2 hs
/--Adding a point to a set preserves its boundedness below.-/
@[simp] lemma bdd_below_insert [semilattice_inf γ] (a : γ) {s : set γ} :
bdd_below (insert a s) ↔ bdd_below s :=
by simp only [insert_eq, bdd_below_union, bdd_below_singleton, true_and]
lemma bdd_below.insert [semilattice_inf γ] (a : γ) {s : set γ} (hs : bdd_below s) :
bdd_below (insert a s) :=
(bdd_below_insert a).2 hs
lemma is_lub.insert [semilattice_sup γ] (a) {b} {s : set γ} (hs : is_lub s b) :
is_lub (insert a s) (a ⊔ b) :=
by { rw insert_eq, exact is_lub_singleton.union hs }
lemma is_glb.insert [semilattice_inf γ] (a) {b} {s : set γ} (hs : is_glb s b) :
is_glb (insert a s) (a ⊓ b) :=
by { rw insert_eq, exact is_glb_singleton.union hs }
lemma is_greatest.insert [linear_order γ] (a) {b} {s : set γ} (hs : is_greatest s b) :
is_greatest (insert a s) (max a b) :=
by { rw insert_eq, exact is_greatest_singleton.union hs }
lemma is_least.insert [linear_order γ] (a) {b} {s : set γ} (hs : is_least s b) :
is_least (insert a s) (min a b) :=
by { rw insert_eq, exact is_least_singleton.union hs }
@[simp] lemma upper_bounds_insert (a : α) (s : set α) :
upper_bounds (insert a s) = Ici a ∩ upper_bounds s :=
by rw [insert_eq, upper_bounds_union, upper_bounds_singleton]
@[simp] lemma lower_bounds_insert (a : α) (s : set α) :
lower_bounds (insert a s) = Iic a ∩ lower_bounds s :=
by rw [insert_eq, lower_bounds_union, lower_bounds_singleton]
/-- When there is a global maximum, every set is bounded above. -/
@[simp] protected lemma order_top.bdd_above [order_top γ] (s : set γ) : bdd_above s :=
⟨⊤, assume a ha, order_top.le_top a⟩
/-- When there is a global minimum, every set is bounded below. -/
@[simp] protected lemma order_bot.bdd_below [order_bot γ] (s : set γ) : bdd_below s :=
⟨⊥, assume a ha, order_bot.bot_le a⟩
/-!
#### Pair
-/
lemma is_lub_pair [semilattice_sup γ] {a b : γ} : is_lub {a, b} (a ⊔ b) :=
is_lub_singleton.insert _
lemma is_glb_pair [semilattice_inf γ] {a b : γ} : is_glb {a, b} (a ⊓ b) :=
is_glb_singleton.insert _
lemma is_least_pair [linear_order γ] {a b : γ} : is_least {a, b} (min a b) :=
is_least_singleton.insert _
lemma is_greatest_pair [linear_order γ] {a b : γ} : is_greatest {a, b} (max a b) :=
is_greatest_singleton.insert _
/-!
#### Lower/upper bounds
-/
@[simp] lemma is_lub_lower_bounds : is_lub (lower_bounds s) a ↔ is_glb s a :=
⟨λ H, ⟨λ x hx, H.2 $ subset_upper_bounds_lower_bounds s hx, H.1⟩, is_greatest.is_lub⟩
@[simp] lemma is_glb_upper_bounds : is_glb (upper_bounds s) a ↔ is_lub s a :=
@is_lub_lower_bounds (order_dual α) _ _ _
end
/-!
### (In)equalities with the least upper bound and the greatest lower bound
-/
section preorder
variables [preorder α] {s : set α} {a b : α}
lemma lower_bounds_le_upper_bounds (ha : a ∈ lower_bounds s) (hb : b ∈ upper_bounds s) :
s.nonempty → a ≤ b
| ⟨c, hc⟩ := le_trans (ha hc) (hb hc)
lemma is_glb_le_is_lub (ha : is_glb s a) (hb : is_lub s b) (hs : s.nonempty) : a ≤ b :=
lower_bounds_le_upper_bounds ha.1 hb.1 hs
lemma is_lub_lt_iff (ha : is_lub s a) : a < b ↔ ∃ c ∈ upper_bounds s, c < b :=
⟨λ hb, ⟨a, ha.1, hb⟩, λ ⟨c, hcs, hcb⟩, lt_of_le_of_lt (ha.2 hcs) hcb⟩
lemma lt_is_glb_iff (ha : is_glb s a) : b < a ↔ ∃ c ∈ lower_bounds s, b < c := is_lub_lt_iff ha.dual
lemma le_of_is_lub_le_is_glb {x y} (ha : is_glb s a) (hb : is_lub s b) (hab : b ≤ a)
(hx : x ∈ s) (hy : y ∈ s) : x ≤ y :=
calc x ≤ b : hb.1 hx
... ≤ a : hab
... ≤ y : ha.1 hy
end preorder
section partial_order
variables [partial_order α] {s : set α} {a b : α}
lemma is_least.unique (Ha : is_least s a) (Hb : is_least s b) : a = b :=
le_antisymm (Ha.right Hb.left) (Hb.right Ha.left)
lemma is_least.is_least_iff_eq (Ha : is_least s a) : is_least s b ↔ a = b :=
iff.intro Ha.unique (assume h, h ▸ Ha)
lemma is_greatest.unique (Ha : is_greatest s a) (Hb : is_greatest s b) : a = b :=
le_antisymm (Hb.right Ha.left) (Ha.right Hb.left)
lemma is_greatest.is_greatest_iff_eq (Ha : is_greatest s a) : is_greatest s b ↔ a = b :=
iff.intro Ha.unique (assume h, h ▸ Ha)
lemma is_lub.unique (Ha : is_lub s a) (Hb : is_lub s b) : a = b :=
Ha.unique Hb
lemma is_glb.unique (Ha : is_glb s a) (Hb : is_glb s b) : a = b :=
Ha.unique Hb
lemma set.subsingleton_of_is_lub_le_is_glb (Ha : is_glb s a) (Hb : is_lub s b) (hab : b ≤ a) :
s.subsingleton :=
λ x hx y hy, le_antisymm (le_of_is_lub_le_is_glb Ha Hb hab hx hy)
(le_of_is_lub_le_is_glb Ha Hb hab hy hx)
lemma is_glb_lt_is_lub_of_ne (Ha : is_glb s a) (Hb : is_lub s b)
{x y} (Hx : x ∈ s) (Hy : y ∈ s) (Hxy : x ≠ y) :
a < b :=
lt_iff_le_not_le.2
⟨lower_bounds_le_upper_bounds Ha.1 Hb.1 ⟨x, Hx⟩,
λ hab, Hxy $ set.subsingleton_of_is_lub_le_is_glb Ha Hb hab Hx Hy⟩
end partial_order
section linear_order
variables [linear_order α] {s : set α} {a b : α}
lemma lt_is_lub_iff (h : is_lub s a) : b < a ↔ ∃ c ∈ s, b < c :=
by simp only [← not_le, is_lub_le_iff h, mem_upper_bounds, not_forall]
lemma is_glb_lt_iff (h : is_glb s a) : a < b ↔ ∃ c ∈ s, c < b := lt_is_lub_iff h.dual
lemma is_lub.exists_between (h : is_lub s a) (hb : b < a) :
∃ c ∈ s, b < c ∧ c ≤ a :=
let ⟨c, hcs, hbc⟩ := (lt_is_lub_iff h).1 hb in ⟨c, hcs, hbc, h.1 hcs⟩
lemma is_lub.exists_between' (h : is_lub s a) (h' : a ∉ s) (hb : b < a) :
∃ c ∈ s, b < c ∧ c < a :=
let ⟨c, hcs, hbc, hca⟩ := h.exists_between hb
in ⟨c, hcs, hbc, hca.lt_of_ne $ λ hac, h' $ hac ▸ hcs⟩
lemma is_glb.exists_between (h : is_glb s a) (hb : a < b) :
∃ c ∈ s, a ≤ c ∧ c < b :=
let ⟨c, hcs, hbc⟩ := (is_glb_lt_iff h).1 hb in ⟨c, hcs, h.1 hcs, hbc⟩
lemma is_glb.exists_between' (h : is_glb s a) (h' : a ∉ s) (hb : a < b) :
∃ c ∈ s, a < c ∧ c < b :=
let ⟨c, hcs, hac, hcb⟩ := h.exists_between hb
in ⟨c, hcs, hac.lt_of_ne $ λ hac, h' $ hac.symm ▸ hcs, hcb⟩
end linear_order
/-!
### Least upper bound and the greatest lower bound in linear ordered additive commutative groups
-/
section linear_ordered_add_comm_group
variables [linear_ordered_add_comm_group α] {s : set α} {a ε : α}
lemma is_glb.exists_between_self_add (h : is_glb s a) (hε : 0 < ε) :
∃ b ∈ s, a ≤ b ∧ b < a + ε :=
h.exists_between $ lt_add_of_pos_right _ hε
lemma is_glb.exists_between_self_add' (h : is_glb s a) (h₂ : a ∉ s) (hε : 0 < ε) :
∃ b ∈ s, a < b ∧ b < a + ε :=
h.exists_between' h₂ $ lt_add_of_pos_right _ hε
lemma is_lub.exists_between_sub_self (h : is_lub s a) (hε : 0 < ε) : ∃ b ∈ s, a - ε < b ∧ b ≤ a :=
h.exists_between $ sub_lt_self _ hε
lemma is_lub.exists_between_sub_self' (h : is_lub s a) (h₂ : a ∉ s) (hε : 0 < ε) :
∃ b ∈ s, a - ε < b ∧ b < a :=
h.exists_between' h₂ $ sub_lt_self _ hε
end linear_ordered_add_comm_group
/-!
### Images of upper/lower bounds under monotone functions
-/
namespace monotone
variables [preorder α] [preorder β] {f : α → β} (Hf : monotone f) {a : α} {s : set α}
lemma mem_upper_bounds_image (Ha : a ∈ upper_bounds s) :
f a ∈ upper_bounds (f '' s) :=
ball_image_of_ball (assume x H, Hf (Ha ‹x ∈ s›))
lemma mem_lower_bounds_image (Ha : a ∈ lower_bounds s) :
f a ∈ lower_bounds (f '' s) :=
ball_image_of_ball (assume x H, Hf (Ha ‹x ∈ s›))
lemma image_upper_bounds_subset_upper_bounds_image (hf : monotone f) :
f '' upper_bounds s ⊆ upper_bounds (f '' s) :=
begin
rintro _ ⟨a, ha, rfl⟩,
exact hf.mem_upper_bounds_image ha,
end
lemma image_lower_bounds_subset_lower_bounds_image (hf : monotone f) :
f '' lower_bounds s ⊆ lower_bounds (f '' s) :=
hf.dual.image_upper_bounds_subset_upper_bounds_image
/-- The image under a monotone function of a set which is bounded above is bounded above. -/
lemma map_bdd_above (hf : monotone f) : bdd_above s → bdd_above (f '' s)
| ⟨C, hC⟩ := ⟨f C, hf.mem_upper_bounds_image hC⟩
/-- The image under a monotone function of a set which is bounded below is bounded below. -/
lemma map_bdd_below (hf : monotone f) : bdd_below s → bdd_below (f '' s)
| ⟨C, hC⟩ := ⟨f C, hf.mem_lower_bounds_image hC⟩
/-- A monotone map sends a least element of a set to a least element of its image. -/
lemma map_is_least (Ha : is_least s a) : is_least (f '' s) (f a) :=
⟨mem_image_of_mem _ Ha.1, Hf.mem_lower_bounds_image Ha.2⟩
/-- A monotone map sends a greatest element of a set to a greatest element of its image. -/
lemma map_is_greatest (Ha : is_greatest s a) : is_greatest (f '' s) (f a) :=
⟨mem_image_of_mem _ Ha.1, Hf.mem_upper_bounds_image Ha.2⟩
lemma is_lub_image_le (Ha : is_lub s a) {b : β} (Hb : is_lub (f '' s) b) :
b ≤ f a :=
Hb.2 (Hf.mem_upper_bounds_image Ha.1)
lemma le_is_glb_image (Ha : is_glb s a) {b : β} (Hb : is_glb (f '' s) b) :
f a ≤ b :=
Hb.2 (Hf.mem_lower_bounds_image Ha.1)
end monotone
namespace antitone
variables [preorder α] [preorder β] {f : α → β} (hf : antitone f) {a : α} {s : set α}
lemma mem_upper_bounds_image (ha : a ∈ lower_bounds s) :
f a ∈ upper_bounds (f '' s) :=
hf.dual_right.mem_lower_bounds_image ha
lemma mem_lower_bounds_image (ha : a ∈ upper_bounds s) :
f a ∈ lower_bounds (f '' s) :=
hf.dual_right.mem_upper_bounds_image ha
lemma image_lower_bounds_subset_upper_bounds_image (hf : antitone f) :
f '' lower_bounds s ⊆ upper_bounds (f '' s) :=
hf.dual_right.image_lower_bounds_subset_lower_bounds_image
lemma image_upper_bounds_subset_lower_bounds_image (hf : antitone f) :
f '' upper_bounds s ⊆ lower_bounds (f '' s) :=
hf.dual_right.image_upper_bounds_subset_upper_bounds_image
/-- The image under an antitone function of a set which is bounded above is bounded below. -/
lemma map_bdd_above (hf : antitone f) : bdd_above s → bdd_below (f '' s) :=
hf.dual_right.map_bdd_above
/-- The image under an antitone function of a set which is bounded below is bounded above. -/
lemma map_bdd_below (hf : antitone f) : bdd_below s → bdd_above (f '' s) :=
hf.dual_right.map_bdd_below
/-- An antitone map sends a greatest element of a set to a least element of its image. -/
lemma map_is_greatest (ha : is_greatest s a) : is_least (f '' s) (f a) :=
hf.dual_right.map_is_greatest ha
/-- An antitone map sends a least element of a set to a greatest element of its image. -/
lemma map_is_least (ha : is_least s a) : is_greatest (f '' s) (f a) :=
hf.dual_right.map_is_least ha
lemma is_lub_image_le (ha : is_glb s a) {b : β} (hb : is_lub (f '' s) b) : b ≤ f a :=
hf.dual_left.is_lub_image_le ha hb
lemma le_is_glb_image (ha : is_lub s a) {b : β} (hb : is_glb (f '' s) b) : f a ≤ b :=
hf.dual_left.le_is_glb_image ha hb
end antitone
lemma is_glb.of_image [preorder α] [preorder β] {f : α → β} (hf : ∀ {x y}, f x ≤ f y ↔ x ≤ y)
{s : set α} {x : α} (hx : is_glb (f '' s) (f x)) :
is_glb s x :=
⟨λ y hy, hf.1 $ hx.1 $ mem_image_of_mem _ hy,
λ y hy, hf.1 $ hx.2 $ monotone.mem_lower_bounds_image (λ x y, hf.2) hy⟩
lemma is_lub.of_image [preorder α] [preorder β] {f : α → β} (hf : ∀ {x y}, f x ≤ f y ↔ x ≤ y)
{s : set α} {x : α} (hx : is_lub (f '' s) (f x)) :
is_lub s x :=
@is_glb.of_image (order_dual α) (order_dual β) _ _ f (λ x y, hf) _ _ hx
lemma is_lub_pi {π : α → Type*} [Π a, preorder (π a)] {s : set (Π a, π a)} {f : Π a, π a} :
is_lub s f ↔ ∀ a, is_lub (function.eval a '' s) (f a) :=
begin
classical,
refine ⟨λ H a, ⟨(function.monotone_eval a).mem_upper_bounds_image H.1, λ b hb, _⟩, λ H, ⟨_, _⟩⟩,
{ suffices : function.update f a b ∈ upper_bounds s,
from function.update_same a b f ▸ H.2 this a,
refine λ g hg, le_update_iff.2 ⟨hb $ mem_image_of_mem _ hg, λ i hi, H.1 hg i⟩ },
{ exact λ g hg a, (H a).1 (mem_image_of_mem _ hg) },
{ exact λ g hg a, (H a).2 ((function.monotone_eval a).mem_upper_bounds_image hg) }
end
lemma is_glb_pi {π : α → Type*} [Π a, preorder (π a)] {s : set (Π a, π a)} {f : Π a, π a} :
is_glb s f ↔ ∀ a, is_glb (function.eval a '' s) (f a) :=
@is_lub_pi α (λ a, order_dual (π a)) _ s f
lemma is_lub_prod [preorder α] [preorder β] {s : set (α × β)} (p : α × β) :
is_lub s p ↔ is_lub (prod.fst '' s) p.1 ∧ is_lub (prod.snd '' s) p.2 :=
begin
refine ⟨λ H, ⟨⟨monotone_fst.mem_upper_bounds_image H.1, λ a ha, _⟩,
⟨monotone_snd.mem_upper_bounds_image H.1, λ a ha, _⟩⟩, λ H, ⟨_, _⟩⟩,
{ suffices : (a, p.2) ∈ upper_bounds s, from (H.2 this).1,
exact λ q hq, ⟨ha $ mem_image_of_mem _ hq, (H.1 hq).2⟩ },
{ suffices : (p.1, a) ∈ upper_bounds s, from (H.2 this).2,
exact λ q hq, ⟨(H.1 hq).1, ha $ mem_image_of_mem _ hq⟩ },
{ exact λ q hq, ⟨H.1.1 $ mem_image_of_mem _ hq, H.2.1 $ mem_image_of_mem _ hq⟩ },
{ exact λ q hq, ⟨H.1.2 $ monotone_fst.mem_upper_bounds_image hq,
H.2.2 $ monotone_snd.mem_upper_bounds_image hq⟩ }
end
lemma is_glb_prod [preorder α] [preorder β] {s : set (α × β)} (p : α × β) :
is_glb s p ↔ is_glb (prod.fst '' s) p.1 ∧ is_glb (prod.snd '' s) p.2 :=
@is_lub_prod (order_dual α) (order_dual β) _ _ _ _
namespace order_iso
variables [preorder α] [preorder β] (f : α ≃o β)
lemma upper_bounds_image {s : set α} :
upper_bounds (f '' s) = f '' upper_bounds s :=
subset.antisymm
(λ x hx, ⟨f.symm x, λ y hy, f.le_symm_apply.2 (hx $ mem_image_of_mem _ hy), f.apply_symm_apply x⟩)
f.monotone.image_upper_bounds_subset_upper_bounds_image
lemma lower_bounds_image {s : set α} :
lower_bounds (f '' s) = f '' lower_bounds s :=
@upper_bounds_image (order_dual α) (order_dual β) _ _ f.dual _
@[simp] lemma is_lub_image {s : set α} {x : β} :
is_lub (f '' s) x ↔ is_lub s (f.symm x) :=
⟨λ h, is_lub.of_image (λ _ _, f.le_iff_le) ((f.apply_symm_apply x).symm ▸ h),
λ h, is_lub.of_image (λ _ _, f.symm.le_iff_le) $ (f.symm_image_image s).symm ▸ h⟩
lemma is_lub_image' {s : set α} {x : α} :
is_lub (f '' s) (f x) ↔ is_lub s x :=
by rw [is_lub_image, f.symm_apply_apply]
@[simp] lemma is_glb_image {s : set α} {x : β} :
is_glb (f '' s) x ↔ is_glb s (f.symm x) :=
f.dual.is_lub_image
lemma is_glb_image' {s : set α} {x : α} :
is_glb (f '' s) (f x) ↔ is_glb s x :=
f.dual.is_lub_image'
@[simp] lemma is_lub_preimage {s : set β} {x : α} :
is_lub (f ⁻¹' s) x ↔ is_lub s (f x) :=
by rw [← f.symm_symm, ← image_eq_preimage, is_lub_image]
lemma is_lub_preimage' {s : set β} {x : β} :
is_lub (f ⁻¹' s) (f.symm x) ↔ is_lub s x :=
by rw [is_lub_preimage, f.apply_symm_apply]
@[simp] lemma is_glb_preimage {s : set β} {x : α} :
is_glb (f ⁻¹' s) x ↔ is_glb s (f x) :=
f.dual.is_lub_preimage
lemma is_glb_preimage' {s : set β} {x : β} :
is_glb (f ⁻¹' s) (f.symm x) ↔ is_glb s x :=
f.dual.is_lub_preimage'
end order_iso
|
b759f6c324cc480978d9589ef07b6048027be0d2 | cf39355caa609c0f33405126beee2739aa3cb77e | /tests/lean/widget/dangerousHtml.lean | 5809cac89f620432e81b16ab8b4382fa2be36f48 | [
"Apache-2.0"
] | permissive | leanprover-community/lean | 12b87f69d92e614daea8bcc9d4de9a9ace089d0e | cce7990ea86a78bdb383e38ed7f9b5ba93c60ce0 | refs/heads/master | 1,687,508,156,644 | 1,684,951,104,000 | 1,684,951,104,000 | 169,960,991 | 457 | 107 | Apache-2.0 | 1,686,744,372,000 | 1,549,790,268,000 | C++ | UTF-8 | Lean | false | false | 310 | lean | open widget
meta def danger : component tactic_state empty :=
component.pure (λ _,
[h "div" [attr.val "dangerouslySetInnerHTML"
$ json.object [("__html", "<div> hello this is some html. You can't inject script elements because they need to be <code>eval()</code>ed. </div>")]] []])
#html danger |
d7ab68b33778562d5d8dbf3e5b9264480d0df806 | 9dc8cecdf3c4634764a18254e94d43da07142918 | /src/algebra/module/submodule/pointwise.lean | f62ea5d75f7030f35d4c2476cb8b99179897484c | [
"Apache-2.0"
] | permissive | jcommelin/mathlib | d8456447c36c176e14d96d9e76f39841f69d2d9b | ee8279351a2e434c2852345c51b728d22af5a156 | refs/heads/master | 1,664,782,136,488 | 1,663,638,983,000 | 1,663,638,983,000 | 132,563,656 | 0 | 0 | Apache-2.0 | 1,663,599,929,000 | 1,525,760,539,000 | Lean | UTF-8 | Lean | false | false | 7,411 | lean | /-
Copyright (c) 2021 Eric Wieser. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Eric Wieser
-/
import group_theory.subgroup.pointwise
import linear_algebra.span
/-! # Pointwise instances on `submodule`s
This file provides:
* `submodule.has_pointwise_neg`
and the actions
* `submodule.pointwise_distrib_mul_action`
* `submodule.pointwise_mul_action_with_zero`
which matches the action of `mul_action_set`.
These actions are available in the `pointwise` locale.
## Implementation notes
Most of the lemmas in this file are direct copies of lemmas from
`group_theory/submonoid/pointwise.lean`.
-/
variables {α : Type*} {R : Type*} {M : Type*}
open_locale pointwise
namespace submodule
section neg
section semiring
variables [semiring R] [add_comm_group M] [module R M]
/-- The submodule with every element negated. Note if `R` is a ring and not just a semiring, this
is a no-op, as shown by `submodule.neg_eq_self`.
Recall that When `R` is the semiring corresponding to the nonnegative elements of `R'`,
`submodule R' M` is the type of cones of `M`. This instance reflects such cones about `0`.
This is available as an instance in the `pointwise` locale. -/
protected def has_pointwise_neg : has_neg (submodule R M) :=
{ neg := λ p,
{ carrier := -(p : set M),
smul_mem' := λ r m hm, set.mem_neg.2 $ smul_neg r m ▸ p.smul_mem r $ set.mem_neg.1 hm,
..(- p.to_add_submonoid) } }
localized "attribute [instance] submodule.has_pointwise_neg" in pointwise
open_locale pointwise
@[simp] lemma coe_set_neg (S : submodule R M) : ↑(-S) = -(S : set M) := rfl
@[simp] lemma neg_to_add_submonoid (S : submodule R M) :
(-S).to_add_submonoid = -S.to_add_submonoid := rfl
@[simp] lemma mem_neg {g : M} {S : submodule R M} : g ∈ -S ↔ -g ∈ S := iff.rfl
/-- `submodule.has_pointwise_neg` is involutive.
This is available as an instance in the `pointwise` locale. -/
protected def has_involutive_pointwise_neg : has_involutive_neg (submodule R M) :=
{ neg := has_neg.neg,
neg_neg := λ S, set_like.coe_injective $ neg_neg _ }
localized "attribute [instance] submodule.has_involutive_pointwise_neg" in pointwise
@[simp] lemma neg_le_neg (S T : submodule R M) : -S ≤ -T ↔ S ≤ T :=
set_like.coe_subset_coe.symm.trans set.neg_subset_neg
lemma neg_le (S T : submodule R M) : -S ≤ T ↔ S ≤ -T :=
set_like.coe_subset_coe.symm.trans set.neg_subset
/-- `submodule.has_pointwise_neg` as an order isomorphism. -/
def neg_order_iso : submodule R M ≃o submodule R M :=
{ to_equiv := equiv.neg _,
map_rel_iff' := neg_le_neg }
lemma closure_neg (s : set M) : span R (-s) = -(span R s) :=
begin
apply le_antisymm,
{ rw [span_le, coe_set_neg, ←set.neg_subset, neg_neg],
exact subset_span },
{ rw [neg_le, span_le, coe_set_neg, ←set.neg_subset],
exact subset_span }
end
@[simp]
lemma neg_inf (S T : submodule R M) : -(S ⊓ T) = (-S) ⊓ (-T) :=
set_like.coe_injective set.inter_neg
@[simp]
lemma neg_sup (S T : submodule R M) : -(S ⊔ T) = (-S) ⊔ (-T) :=
(neg_order_iso : submodule R M ≃o submodule R M).map_sup S T
@[simp]
lemma neg_bot : -(⊥ : submodule R M) = ⊥ :=
set_like.coe_injective $ (set.neg_singleton 0).trans $ congr_arg _ neg_zero
@[simp]
lemma neg_top : -(⊤ : submodule R M) = ⊤ :=
set_like.coe_injective $ set.neg_univ
@[simp]
lemma neg_infi {ι : Sort*} (S : ι → submodule R M) : -(⨅ i, S i) = ⨅ i, -S i :=
(neg_order_iso : submodule R M ≃o submodule R M).map_infi _
@[simp]
lemma neg_supr {ι : Sort*} (S : ι → submodule R M) : -(⨆ i, S i) = ⨆ i, -(S i) :=
(neg_order_iso : submodule R M ≃o submodule R M).map_supr _
end semiring
open_locale pointwise
@[simp] lemma neg_eq_self [ring R] [add_comm_group M] [module R M] (p : submodule R M) : -p = p :=
ext $ λ _, p.neg_mem_iff
end neg
variables [semiring R] [add_comm_monoid M] [module R M]
instance pointwise_add_comm_monoid : add_comm_monoid (submodule R M) :=
{ add := (⊔),
add_assoc := λ _ _ _, sup_assoc,
zero := ⊥,
zero_add := λ _, bot_sup_eq,
add_zero := λ _, sup_bot_eq,
add_comm := λ _ _, sup_comm }
@[simp] lemma add_eq_sup (p q : submodule R M) : p + q = p ⊔ q := rfl
@[simp] lemma zero_eq_bot : (0 : submodule R M) = ⊥ := rfl
instance : canonically_ordered_add_monoid (submodule R M) :=
{ zero := 0,
bot := ⊥,
add := (+),
add_le_add_left := λ a b, sup_le_sup_left,
exists_add_of_le := λ a b h, ⟨b, (sup_eq_right.2 h).symm⟩,
le_self_add := λ a b, le_sup_left,
..submodule.pointwise_add_comm_monoid,
..submodule.complete_lattice }
section
variables [monoid α] [distrib_mul_action α M] [smul_comm_class α R M]
/-- The action on a submodule corresponding to applying the action to every element.
This is available as an instance in the `pointwise` locale. -/
protected def pointwise_distrib_mul_action : distrib_mul_action α (submodule R M) :=
{ smul := λ a S, S.map (distrib_mul_action.to_linear_map R M a : M →ₗ[R] M),
one_smul := λ S,
(congr_arg (λ f : module.End R M, S.map f) (linear_map.ext $ by exact one_smul α)).trans
S.map_id,
mul_smul := λ a₁ a₂ S,
(congr_arg (λ f : module.End R M, S.map f) (linear_map.ext $ by exact mul_smul _ _)).trans
(S.map_comp _ _),
smul_zero := λ a, map_bot _,
smul_add := λ a S₁ S₂, map_sup _ _ _ }
localized "attribute [instance] submodule.pointwise_distrib_mul_action" in pointwise
open_locale pointwise
@[simp] lemma coe_pointwise_smul (a : α) (S : submodule R M) : ↑(a • S) = a • (S : set M) := rfl
@[simp] lemma pointwise_smul_to_add_submonoid (a : α) (S : submodule R M) :
(a • S).to_add_submonoid = a • S.to_add_submonoid := rfl
@[simp] lemma pointwise_smul_to_add_subgroup {R M : Type*}
[ring R] [add_comm_group M] [distrib_mul_action α M] [module R M] [smul_comm_class α R M]
(a : α) (S : submodule R M) :
(a • S).to_add_subgroup = a • S.to_add_subgroup := rfl
lemma smul_mem_pointwise_smul (m : M) (a : α) (S : submodule R M) : m ∈ S → a • m ∈ a • S :=
(set.smul_mem_smul_set : _ → _ ∈ a • (S : set M))
instance pointwise_central_scalar [distrib_mul_action αᵐᵒᵖ M] [smul_comm_class αᵐᵒᵖ R M]
[is_central_scalar α M] :
is_central_scalar α (submodule R M) :=
⟨λ a S, congr_arg (λ f : module.End R M, S.map f) $ linear_map.ext $ by exact op_smul_eq_smul _⟩
@[simp] lemma smul_le_self_of_tower {α : Type*}
[semiring α] [module α R] [module α M] [smul_comm_class α R M] [is_scalar_tower α R M]
(a : α) (S : submodule R M) : a • S ≤ S :=
begin
rintro y ⟨x, hx, rfl⟩,
exact smul_of_tower_mem _ a hx,
end
end
section
variables [semiring α] [module α M] [smul_comm_class α R M]
/-- The action on a submodule corresponding to applying the action to every element.
This is available as an instance in the `pointwise` locale.
This is a stronger version of `submodule.pointwise_distrib_mul_action`. Note that `add_smul` does
not hold so this cannot be stated as a `module`. -/
protected def pointwise_mul_action_with_zero : mul_action_with_zero α (submodule R M) :=
{ zero_smul := λ S,
(congr_arg (λ f : M →ₗ[R] M, S.map f) (linear_map.ext $ by exact zero_smul α)).trans S.map_zero,
.. submodule.pointwise_distrib_mul_action }
localized "attribute [instance] submodule.pointwise_mul_action_with_zero" in pointwise
end
end submodule
|
4dff1a111fe069c5c1c86c83638a4657b01f37de | d406927ab5617694ec9ea7001f101b7c9e3d9702 | /src/order/succ_pred/limit.lean | cdd69c0596b3374a891627f3ea888499b7835608 | [
"Apache-2.0"
] | permissive | alreadydone/mathlib | dc0be621c6c8208c581f5170a8216c5ba6721927 | c982179ec21091d3e102d8a5d9f5fe06c8fafb73 | refs/heads/master | 1,685,523,275,196 | 1,670,184,141,000 | 1,670,184,141,000 | 287,574,545 | 0 | 0 | Apache-2.0 | 1,670,290,714,000 | 1,597,421,623,000 | Lean | UTF-8 | Lean | false | false | 11,284 | lean | /-
Copyright (c) 2022 Violeta Hernández Palacios. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Violeta Hernández Palacios
-/
import order.succ_pred.basic
/-!
# Successor and predecessor limits
We define the predicate `order.is_succ_limit` for "successor limits", values that don't cover any
others. They are so named since they can't be the successors of anything smaller. We define
`order.is_pred_limit` analogously, and prove basic results.
## Todo
The plan is to eventually replace `ordinal.is_limit` and `cardinal.is_limit` with the common
predicate `order.is_succ_limit`.
-/
variables {α : Type*}
namespace order
open function set order_dual
/-! ### Successor limits -/
section has_lt
variables [has_lt α]
/-- A successor limit is a value that doesn't cover any other.
It's so named because in a successor order, a successor limit can't be the successor of anything
smaller. -/
def is_succ_limit (a : α) : Prop := ∀ b, ¬ b ⋖ a
lemma not_is_succ_limit_iff_exists_covby (a : α) : ¬ is_succ_limit a ↔ ∃ b, b ⋖ a :=
by simp [is_succ_limit]
@[simp] lemma is_succ_limit_of_dense [densely_ordered α] (a : α) : is_succ_limit a := λ b, not_covby
end has_lt
section preorder
variables [preorder α] {a : α}
protected lemma _root_.is_min.is_succ_limit : is_min a → is_succ_limit a :=
λ h b hab, not_is_min_of_lt hab.lt h
lemma is_succ_limit_bot [order_bot α] : is_succ_limit (⊥ : α) := is_min_bot.is_succ_limit
variables [succ_order α]
protected lemma is_succ_limit.is_max (h : is_succ_limit (succ a)) : is_max a :=
by { by_contra H, exact h a (covby_succ_of_not_is_max H) }
lemma not_is_succ_limit_succ_of_not_is_max (ha : ¬ is_max a) : ¬ is_succ_limit (succ a) :=
by { contrapose! ha, exact ha.is_max }
section no_max_order
variables [no_max_order α]
lemma is_succ_limit.succ_ne (h : is_succ_limit a) (b : α) : succ b ≠ a :=
by { rintro rfl, exact not_is_max _ h.is_max }
@[simp] lemma not_is_succ_limit_succ (a : α) : ¬ is_succ_limit (succ a) := λ h, h.succ_ne _ rfl
end no_max_order
section is_succ_archimedean
variable [is_succ_archimedean α]
lemma is_succ_limit.is_min_of_no_max [no_max_order α] (h : is_succ_limit a) : is_min a :=
λ b hb, begin
rcases hb.exists_succ_iterate with ⟨_ | n, rfl⟩,
{ exact le_rfl },
{ rw iterate_succ_apply' at h,
exact (not_is_succ_limit_succ _ h).elim }
end
@[simp] lemma is_succ_limit_iff_of_no_max [no_max_order α] : is_succ_limit a ↔ is_min a :=
⟨is_succ_limit.is_min_of_no_max, is_min.is_succ_limit⟩
lemma not_is_succ_limit_of_no_max [no_min_order α] [no_max_order α] : ¬ is_succ_limit a := by simp
end is_succ_archimedean
end preorder
section partial_order
variables [partial_order α] [succ_order α] {a b : α} {C : α → Sort*}
lemma is_succ_limit_of_succ_ne (h : ∀ b, succ b ≠ a) : is_succ_limit a := λ b hba, h b hba.succ_eq
lemma not_is_succ_limit_iff : ¬ is_succ_limit a ↔ ∃ b, ¬ is_max b ∧ succ b = a :=
begin
rw not_is_succ_limit_iff_exists_covby,
refine exists_congr (λ b, ⟨λ hba, ⟨hba.lt.not_is_max, hba.succ_eq⟩, _⟩),
rintro ⟨h, rfl⟩,
exact covby_succ_of_not_is_max h
end
/-- See `not_is_succ_limit_iff` for a version that states that `a` is a successor of a value other
than itself. -/
lemma mem_range_succ_of_not_is_succ_limit (h : ¬ is_succ_limit a) : a ∈ range (@succ α _ _) :=
by { cases not_is_succ_limit_iff.1 h with b hb, exact ⟨b, hb.2⟩ }
lemma is_succ_limit_of_succ_lt (H : ∀ a < b, succ a < b) : is_succ_limit b :=
λ a hab, (H a hab.lt).ne hab.succ_eq
lemma is_succ_limit.succ_lt (hb : is_succ_limit b) (ha : a < b) : succ a < b :=
begin
by_cases h : is_max a,
{ rwa h.succ_eq },
{ rw [lt_iff_le_and_ne, succ_le_iff_of_not_is_max h],
refine ⟨ha, λ hab, _⟩,
subst hab,
exact (h hb.is_max).elim }
end
lemma is_succ_limit.succ_lt_iff (hb : is_succ_limit b) : succ a < b ↔ a < b :=
⟨λ h, (le_succ a).trans_lt h, hb.succ_lt⟩
lemma is_succ_limit_iff_succ_lt : is_succ_limit b ↔ ∀ a < b, succ a < b :=
⟨λ hb a, hb.succ_lt, is_succ_limit_of_succ_lt⟩
/-- A value can be built by building it on successors and successor limits. -/
@[elab_as_eliminator] noncomputable def is_succ_limit_rec_on (b : α)
(hs : Π a, ¬ is_max a → C (succ a)) (hl : Π a, is_succ_limit a → C a) : C b :=
begin
by_cases hb : is_succ_limit b,
{ exact hl b hb },
{ have H := classical.some_spec (not_is_succ_limit_iff.1 hb),
rw ←H.2,
exact hs _ H.1 }
end
lemma is_succ_limit_rec_on_limit (hs : Π a, ¬ is_max a → C (succ a))
(hl : Π a, is_succ_limit a → C a) (hb : is_succ_limit b) :
@is_succ_limit_rec_on α _ _ C b hs hl = hl b hb :=
by { classical, exact dif_pos hb }
lemma is_succ_limit_rec_on_succ' (hs : Π a, ¬ is_max a → C (succ a))
(hl : Π a, is_succ_limit a → C a) {b : α} (hb : ¬ is_max b) :
@is_succ_limit_rec_on α _ _ C (succ b) hs hl = hs b hb :=
begin
have hb' := not_is_succ_limit_succ_of_not_is_max hb,
have H := classical.some_spec (not_is_succ_limit_iff.1 hb'),
rw is_succ_limit_rec_on,
simp only [cast_eq_iff_heq, hb', not_false_iff, eq_mpr_eq_cast, dif_neg],
congr,
{ exact (succ_eq_succ_iff_of_not_is_max H.1 hb).1 H.2 },
{ apply proof_irrel_heq }
end
section no_max_order
variables [no_max_order α]
@[simp] lemma is_succ_limit_rec_on_succ (hs : Π a, ¬ is_max a → C (succ a))
(hl : Π a, is_succ_limit a → C a) (b : α) :
@is_succ_limit_rec_on α _ _ C (succ b) hs hl = hs b (not_is_max b) :=
is_succ_limit_rec_on_succ' _ _ _
lemma is_succ_limit_iff_succ_ne : is_succ_limit a ↔ ∀ b, succ b ≠ a :=
⟨is_succ_limit.succ_ne, is_succ_limit_of_succ_ne⟩
lemma not_is_succ_limit_iff' : ¬ is_succ_limit a ↔ a ∈ range (@succ α _ _) :=
by { simp_rw [is_succ_limit_iff_succ_ne, not_forall, not_ne_iff], refl }
end no_max_order
section is_succ_archimedean
variable [is_succ_archimedean α]
protected lemma is_succ_limit.is_min (h : is_succ_limit a) : is_min a :=
λ b hb, begin
revert h,
refine succ.rec (λ _, le_rfl) (λ c hbc H hc, _) hb,
have := hc.is_max.succ_eq,
rw this at hc ⊢,
exact H hc
end
@[simp] lemma is_succ_limit_iff : is_succ_limit a ↔ is_min a :=
⟨is_succ_limit.is_min, is_min.is_succ_limit⟩
lemma not_is_succ_limit [no_min_order α] : ¬ is_succ_limit a := by simp
end is_succ_archimedean
end partial_order
/-! ### Predecessor limits -/
section has_lt
variables [has_lt α] {a : α}
/-- A predecessor limit is a value that isn't covered by any other.
It's so named because in a predecessor order, a predecessor limit can't be the predecessor of
anything greater. -/
def is_pred_limit (a : α) : Prop := ∀ b, ¬ a ⋖ b
lemma not_is_pred_limit_iff_exists_covby (a : α) : ¬ is_pred_limit a ↔ ∃ b, a ⋖ b :=
by simp [is_pred_limit]
lemma is_pred_limit_of_dense [densely_ordered α] (a : α) : is_pred_limit a := λ b, not_covby
@[simp] lemma is_succ_limit_to_dual_iff : is_succ_limit (to_dual a) ↔ is_pred_limit a :=
by simp [is_succ_limit, is_pred_limit]
@[simp] lemma is_pred_limit_to_dual_iff : is_pred_limit (to_dual a) ↔ is_succ_limit a :=
by simp [is_succ_limit, is_pred_limit]
alias is_succ_limit_to_dual_iff ↔ _ is_pred_limit.dual
alias is_pred_limit_to_dual_iff ↔ _ is_succ_limit.dual
end has_lt
section preorder
variables [preorder α] {a : α}
protected lemma _root_.is_max.is_pred_limit : is_max a → is_pred_limit a :=
λ h b hab, not_is_max_of_lt hab.lt h
lemma is_pred_limit_top [order_top α] : is_pred_limit (⊤ : α) := is_max_top.is_pred_limit
variables [pred_order α]
protected lemma is_pred_limit.is_min (h : is_pred_limit (pred a)) : is_min a :=
by { by_contra H, exact h a (pred_covby_of_not_is_min H) }
lemma not_is_pred_limit_pred_of_not_is_min (ha : ¬ is_min a) : ¬ is_pred_limit (pred a) :=
by { contrapose! ha, exact ha.is_min }
section no_min_order
variables [no_min_order α]
lemma is_pred_limit.pred_ne (h : is_pred_limit a) (b : α) : pred b ≠ a :=
by { rintro rfl, exact not_is_min _ h.is_min }
@[simp] lemma not_is_pred_limit_pred (a : α) : ¬ is_pred_limit (pred a) := λ h, h.pred_ne _ rfl
end no_min_order
section is_pred_archimedean
variables [is_pred_archimedean α]
protected lemma is_pred_limit.is_max_of_no_min [no_min_order α] (h : is_pred_limit a) : is_max a :=
h.dual.is_min_of_no_max
@[simp] lemma is_pred_limit_iff_of_no_min [no_min_order α] : is_pred_limit a ↔ is_max a :=
is_succ_limit_to_dual_iff.symm.trans is_succ_limit_iff_of_no_max
lemma not_is_pred_limit_of_no_min [no_min_order α] [no_max_order α] : ¬ is_pred_limit a :=
by simp
end is_pred_archimedean
end preorder
section partial_order
variables [partial_order α] [pred_order α] {a b : α} {C : α → Sort*}
lemma is_pred_limit_of_pred_ne (h : ∀ b, pred b ≠ a) : is_pred_limit a := λ b hba, h b hba.pred_eq
lemma not_is_pred_limit_iff : ¬ is_pred_limit a ↔ ∃ b, ¬ is_min b ∧ pred b = a :=
by { rw ←is_succ_limit_to_dual_iff, exact not_is_succ_limit_iff }
/-- See `not_is_pred_limit_iff` for a version that states that `a` is a successor of a value other
than itself. -/
lemma mem_range_pred_of_not_is_pred_limit (h : ¬ is_pred_limit a) : a ∈ range (@pred α _ _) :=
by { cases not_is_pred_limit_iff.1 h with b hb, exact ⟨b, hb.2⟩ }
lemma is_pred_limit_of_pred_lt (H : ∀ a > b, pred a < b) : is_pred_limit b :=
λ a hab, (H a hab.lt).ne hab.pred_eq
lemma is_pred_limit.lt_pred (h : is_pred_limit a) : a < b → a < pred b := h.dual.succ_lt
lemma is_pred_limit.lt_pred_iff (h : is_pred_limit a) : a < pred b ↔ a < b := h.dual.succ_lt_iff
lemma is_pred_limit_iff_lt_pred : is_pred_limit a ↔ ∀ ⦃b⦄, a < b → a < pred b :=
is_succ_limit_to_dual_iff.symm.trans is_succ_limit_iff_succ_lt
/-- A value can be built by building it on predecessors and predecessor limits. -/
@[elab_as_eliminator] noncomputable def is_pred_limit_rec_on (b : α)
(hs : Π a, ¬ is_min a → C (pred a)) (hl : Π a, is_pred_limit a → C a) : C b :=
@is_succ_limit_rec_on αᵒᵈ _ _ _ _ hs (λ a ha, hl _ ha.dual)
lemma is_pred_limit_rec_on_limit (hs : Π a, ¬ is_min a → C (pred a))
(hl : Π a, is_pred_limit a → C a) (hb : is_pred_limit b) :
@is_pred_limit_rec_on α _ _ C b hs hl = hl b hb :=
is_succ_limit_rec_on_limit _ _ hb.dual
lemma is_pred_limit_rec_on_pred' (hs : Π a, ¬ is_min a → C (pred a))
(hl : Π a, is_pred_limit a → C a) {b : α} (hb : ¬ is_min b) :
@is_pred_limit_rec_on α _ _ C (pred b) hs hl = hs b hb :=
is_succ_limit_rec_on_succ' _ _ _
section no_min_order
variables [no_min_order α]
@[simp] theorem is_pred_limit_rec_on_pred (hs : Π a, ¬ is_min a → C (pred a))
(hl : Π a, is_pred_limit a → C a) (b : α) :
@is_pred_limit_rec_on α _ _ C (pred b) hs hl = hs b (not_is_min b) :=
is_succ_limit_rec_on_succ _ _ _
end no_min_order
section is_pred_archimedean
variable [is_pred_archimedean α]
protected lemma is_pred_limit.is_max (h : is_pred_limit a) : is_max a := h.dual.is_min
@[simp] lemma is_pred_limit_iff : is_pred_limit a ↔ is_max a :=
is_succ_limit_to_dual_iff.symm.trans is_succ_limit_iff
lemma not_is_pred_limit [no_max_order α] : ¬ is_pred_limit a := by simp
end is_pred_archimedean
end partial_order
end order
|
e7ca00adadd3d97d944fd4ce894e473008f58d26 | cf39355caa609c0f33405126beee2739aa3cb77e | /library/init/meta/module_info.lean | 0f4e65a663605986f39516a39b6626293322bc68 | [
"Apache-2.0"
] | permissive | leanprover-community/lean | 12b87f69d92e614daea8bcc9d4de9a9ace089d0e | cce7990ea86a78bdb383e38ed7f9b5ba93c60ce0 | refs/heads/master | 1,687,508,156,644 | 1,684,951,104,000 | 1,684,951,104,000 | 169,960,991 | 457 | 107 | Apache-2.0 | 1,686,744,372,000 | 1,549,790,268,000 | C++ | UTF-8 | Lean | false | false | 4,404 | lean | /-
Copyright (c) 2019 Microsoft Corporation. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Gabriel Ebner
-/
prelude
import init.meta.environment init.meta.tactic
/-- Information about a currently loaded module (such as `data.dlist`). -/
meta constant module_info : Type
namespace module_info
/-- The absolute path to the `.lean` file containing the module (e.g. `".../data/dlist.lean"`). -/
@[reducible] meta def module_id := string
/-- The name of the module, as used in an import command (e.g. `data.dlist`). -/
@[reducible] meta def module_name := name
/--
Resolves a `module_name` to `module_id`, using the global search path.
**ONLY USE THIS FUNCTION IN (CI) SCRIPTS!**
-/
meta constant resolve_module_name (name : module_name) (cur_module : module_id := "") : module_id
/--
Retrieves the module with the given `module_id`.
**ONLY USE THIS FUNCTION IN (CI) SCRIPTS!**
This function is constant-time if the module is already a dependency.
-/
meta constant of_module_id (id : module_id) : module_info
/--
Retrieves the module with the given `module_name`.
**ONLY USE THIS FUNCTION IN (CI) SCRIPTS!**
This function is constant-time if the module is already a dependency.
-/
meta def of_module_name (name : module_name) (cur_module : module_id := "") : module_info :=
of_module_id (resolve_module_name name cur_module)
/-- Returns the `module_id` of the module. -/
protected meta constant id : module_info → module_id
meta instance : has_repr module_info := ⟨module_info.id⟩
meta instance : has_to_string module_info := ⟨module_info.id⟩
meta instance : has_to_format module_info := ⟨λ m, to_fmt m.id⟩
meta instance : has_to_tactic_format module_info := ⟨tactic.pp ∘ module_info.id⟩
end module_info
open module_info
namespace environment
/--
Imports the dependencies of a module into an environment.
**ONLY USE THIS FUNCTION IN (CI) SCRIPTS!**
Already imported dependencies will not be imported twice.
-/
meta constant import_dependencies : environment → module_info → environment
/--
Imports only the module (without the dependencies) into an environment.
**ONLY USE THIS FUNCTION IN (CI) SCRIPTS!**
-/
meta constant import_only : environment → module_info → environment
/--
Imports all declarations until `decl_name` of the module (without the dependencies) into an environment.
**ONLY USE THIS FUNCTION IN (CI) SCRIPTS!**
-/
meta constant import_only_until_decl (env : environment) (mod_info : module_info) (decl_name : name) : environment
/--
Imports a module including dependencies into an environment.
**ONLY USE THIS FUNCTION IN (CI) SCRIPTS!**
-/
meta def import' (env : environment) (mi : module_info) : environment :=
(env.import_dependencies mi).import_only mi
/--
Imports a module until `decl_name` including dependencies into an environment.
**ONLY USE THIS FUNCTION IN (CI) SCRIPTS!**
-/
meta def import_until_decl (env : environment) (mi : module_info) (decl_name : name) : environment :=
(env.import_dependencies mi).import_only_until_decl mi decl_name
/--
Creates an environment containing the module `id` including dependencies.
**ONLY USE THIS FUNCTION IN (CI) SCRIPTS!**
The environment `from_imported_module ".../data/dlist.lean"` is roughly equivalent to
the environment at the end of a file containing just `import data.dlist`.
-/
meta def from_imported_module (id : module_id) : environment :=
(mk_std 1025).import' (of_module_id id)
/--
Creates an environment containing the module `id` until `decl_name` including dependencies.
**ONLY USE THIS FUNCTION IN (CI) SCRIPTS!**
-/
meta def for_decl_of_imported_module (id : module_id) (decl_name : name) : environment :=
(mk_std 1025).import_until_decl (of_module_id id) decl_name
/--
Creates an environment containing the module `name` including dependencies.
**ONLY USE THIS FUNCTION IN (CI) SCRIPTS!**
-/
meta def from_imported_module_name (name : module_name) (cur_module := "") : environment :=
from_imported_module (resolve_module_name name cur_module)
/--
Creates an environment containing the module `name` until declaration `decl_name`
including dependencies.
**ONLY USE THIS FUNCTION IN (CI) SCRIPTS!**
-/
meta def for_decl_of_imported_module_name
(mod_nam : module_name) (decl : name) (cur_mod := "") : environment :=
for_decl_of_imported_module (resolve_module_name mod_nam cur_mod) decl
end environment |
4160bd5846212f8d64164af8bfc26b305be44482 | a9e33f9c83301c461f3c3ebc6799d9de1f6d4d20 | /notes/10.01.2019.Polymorphism.lean | 9cafecf49c4618ee8fcb18e3fc6c93969cd158a4 | [] | no_license | yl4df/Discrete-Mathematics | f1c9a6cf8cfb4686fb617637f69a481e1522f0c2 | c93ce9f6a6e36d194e350d9fa0a0360191e97fa0 | refs/heads/master | 1,598,714,938,443 | 1,572,275,647,000 | 1,572,275,647,000 | 218,074,726 | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 9,159 | lean | /-
A simple "boxed value" type. Think of
a value/term of this type as a box that
simply contains a value of another type.
In the first instace, the other type is ℕ.
-/
inductive boxed_nat : Type
| box_nat : nat → boxed_nat
open boxed_nat
def b1 := box_nat 3
def unbox_nat : boxed_nat → nat
| (box_nat n) := n
#eval unbox_nat b1
-- Exercise: implement a box_string type
-- Exercise: implement a box bool type
/-
Again, a problem of mostly repeated code
with a single point of variation: the type
of element held in a box.
-/
/-
Question: what's solution to multiplicity?
Answer: abstract variation to parameter.
Variation is in *type* of an argument.
Solution know as parametric polymorphism.
-/
-- Make the varying type a parameter!
-- We use Greek letters for type arg names
inductive boxed (α : Type) : Type
-- value of α is type of element to be boxed
| box : α → boxed
-- box takes *value* of type α, and boxes it
open boxed
/-
-/
def a : boxed nat := box 3
def a' := box 3 -- Lean infers a' type
def b := box "Hello" -- okay this is cool
def c := box ff -- wow, this is cool!
/-
A polymorphic function has a type parameter.
-/
def unbox' (α : Type) : boxed α → α
| (box v) := v
/-
An equivalent way to write this definition.
We will prefer the former representation. It
is clearer and easier to read and write.
-/
def unbox'' (α : Type) (b : boxed α) : α :=
match b with
| (box v) := v
end
/-
While what we've got is pretty cool, using
it is a little burdensome, in that we have
to explicitly specify Type-valued arguments
when using the unbox function.
-/
#eval unbox' nat a
#eval unbox' string b
#eval unbox' bool c
/-
Lean expects that type argument, so the
following won't work. The error message
says Lean is expecting an argument of type
"Sort". "Sort" in this context means Type.
We'll talk more about "Sort" later.
-/
#eval unbox a -- Argument is explicit
/-
Now Lean *can* in fact figure out what the
value of the Type argument must be when it
has a boxed value in hand, such as "a" or
"c" in the following examples.
-/
#eval unbox' _ a -- Lean can infer α!
#eval unbox' _ c -- Lean can infer α!
/-
If Lean can figure out what the value of
the type argument is, then we should be
able not to give it explicitly
-/
-- Solution: implicit (type) arguments
def unbox {α : Type} : boxed α → α
-- Use curly braces to indicate implicit arg
| (box v) := v
/-
Now you don't have to, and in you must not,
give a type value explicitly
-/
#eval unbox a
#eval unbox a'
#eval unbox b
#eval unbox c
/-
If we want to turn off implicit argument
inference and give type values explicitly,
we prefix the function application with @.
-/
#eval @unbox nat a
#eval @unbox nat a'
#eval @unbox string b
#eval @unbox bool c
/-
EXERCISES
-/
/-
Define a polymorphic type, (moption α). This
type will have two constructors: one, "none"
and the other "some : α → option". Note that
you do not have to write α after option in
the return type.
-/
inductive moption (α : Type) : Type
| none {} : moption
| some : α → moption
/-
Watch out, there is already an option
type in Lean, its namespace is opened,
and its some and none constructors are
already defined in the global namespace.
-/
#check option
#check some
#check none
/-
Be sure to use moption, moption.some,
and moption.none in work to follow.
-/
/-
The some constructor makes moption into
a type almost exactly the same as box,
while the none constructor adds one more
value/term to this type. The "option α"
type in functional programming is usually
used as the return type of a function that
can return either a normal value (some α)
or an error (none).
-/
/-
Write a polymorphic function, option_value,
that takes a value of type (option α), where
α is any type, along with a "default" value
of type α, and that returns as follows: if
the option is none, return the default value,
otherwise, if the option is (some v), return
the normal value, v. Make the type argument
implicit.
-/
def option_value {α : Type} :
moption α → α → α
| moption.none d := d
-- without {} in the constructor definition
-- we'd have needed to say (moption.none α)
| (moption.some v) d := v
def o1 := moption.some 3
def o2 := moption.some "Hi there"
def o3 := moption.some tt
/-
We have to turn off implicit arguments
when using the none constructor, as there
are no other arguments from which Lean
can infer the type argument's value.
-/
def e1 := @moption.none nat
def e2 := @moption.none string
def e3 := @moption.none bool
/-
Types and functions can be polymorphic in
more than one argument. Next week look at
a polymorphic type the terms of which we
will use to represent ordered pairs, as
they appear in ordinary high-school algebra.
-/
/-
First, let's see that we can define a type
to represent pairs of nats. We will use the
name "prod" to represent a type of pairs.
-/
inductive prod_nat_nat : Type
| pair : ℕ → ℕ → prod_nat_nat
def nn := prod_nat_nat.pair 2 3
#reduce nn
def fst_nat_nat : prod_nat_nat → nat
| (prod_nat_nat.pair x y) := x
def snd_nat_nat : prod_nat_nat → nat
| (prod_nat_nat.pair x y) := y
#reduce fst_nat_nat nn
#reduce snd_nat_nat nn
/-
You can see we're going to run right into
the same problem of a multiplicity of prod
types, one for each type of pair (given by
a pair of types) that we want to represent.
The solution is to def a type, and its
associated functions, polymorphic in two
type arguments.
-/
inductive mprod (α β : Type) : Type
| pair : α → β → mprod
def fst (α β : Type) : mprod α β → α
| (mprod.pair a b) := a
def snd (α β : Type) : mprod α β → β
| (mprod.pair a b) := b
/-
Exercise: write a polymorphic swap
function that takes a pair and reverses
its elements.
-/
def swap (α β : Type) : mprod α β → mprod β α
| (mprod.pair a b) := mprod.pair b a
/-
Exercise: In earlier work, we defined mcompose to be a function that takes two
functions of type ℕ → ℕ and returns their composition. Here we'll give it again but
will call it compose_n_n_n to reflect the
fact that all three types involved are
nat
-/
def mcompose_n_n_n :
(ℕ → ℕ) → (ℕ → ℕ) → (ℕ → ℕ)
| g f := λ n, g ( f n)
/-
Generalize this function so that for
arbitrary types, α, β, and γ, it returns
compositions of functions of types β → γ
and α → β. For example, if you wanted to
determine whether the length of a string
is even, you could first apply a function,
f, of type string → ℕ to obtain the length
of the string, then, to the result, apply
a function of type ℕ → bool that returns
true if the given length is even. Use
implicit type arguments.
-/
def mcompose {α γ β : Type} : (β → γ) → (α → β) → (α → γ)
| g f := λ (n : α), g (f n)
/-
Define is_str_ev to be bound to a
function that returns true iff its
argument's length is even. Use the
mcompose function to compute the
function rather than programming
it explicitly. Note: string.length
is the function in Lean that returns
the length of a string; and you can
use the mod operator, %, to determine
if a natural number is even or not.
Please define the type of is_str_ev
explicitly to be string → bool.
Test your function using eval.
-/
def is_str_ev : string → bool :=
mcompose
(λ n, n % 2 = 0)
(λ s, string.length s)
#eval is_str_ev "Hello Th"
/-
What is the type of a polymorphic function?
-/
#check mcompose
#check @mcompose
/-
The Π is an expression that gives names to
arguments earlier in an argument list, the
values of which can then be used later in
the same argument list! If we just wrote
Type → Type → Type → ??? → ??? → ???, we'd
have no way to refer to the values of the
first three arguments. Lean assigns the
names ?M_3, ?M_2, and ?M_1 when the type
parameters are implicit, and uses Π to
bind our names to these parameters when
we turn off implicit typing, in which case
the real substance of the function type is
made clear.
-/
/-
Homework:
#1. In a file called moption.lean,
define a polymorphic option abstract
data type. In a separate file called
moption_verify.lean import the first
file and write a set of definitions
that show how to use the data type
and that test its functions.
- fst
- snd
- swap
#2.
In a file called mlist.lean,
define a polymorphic list abstract
data type. Call your data type mlist.
Give it two constructors called nil
and cons. Do not use Lean's list data
type in this assignment.
- prepend: given (a : α) and (l : mlist α) return (cons a l)
- mhead: given (l : mlist α) return option containing head or none
- mtail: given (l : mlist α) return option containing tail or none
- mlength: given (l : mlist α), return length of l as a ℕ
- mmap: given (f : α → β) and (l : list α) return list β
- mfold: given (f : α → α → α) (id : α) and (l : list α) implement fold
In a separate file, called mlist_verify.lean, write
a set of test cases, details TBD.
#2. Do the same for a polymorphic mprod/pair abstract
data type. You can use the materials developed here
for this purpose.
-/
|
66d9be9d1e3ea2c0c0af6ed79d6a08bca13abc3c | 9dc8cecdf3c4634764a18254e94d43da07142918 | /test/positivity.lean | 782184eeabf4737558c74456b4b3016afdc2a581 | [
"Apache-2.0"
] | permissive | jcommelin/mathlib | d8456447c36c176e14d96d9e76f39841f69d2d9b | ee8279351a2e434c2852345c51b728d22af5a156 | refs/heads/master | 1,664,782,136,488 | 1,663,638,983,000 | 1,663,638,983,000 | 132,563,656 | 0 | 0 | Apache-2.0 | 1,663,599,929,000 | 1,525,760,539,000 | Lean | UTF-8 | Lean | false | false | 3,592 | lean | import algebra.order.smul
import analysis.normed.group.basic
import data.real.sqrt
import tactic.positivity
/-! # Tests for the `positivity` tactic
This tactic proves goals of the form `0 ≤ a` and `0 < a`.
-/
/- ## Numeric goals -/
example : 0 ≤ 0 := by positivity
example : 0 ≤ 3 := by positivity
example : 0 < 3 := by positivity
/- ## Goals working directly from a hypothesis -/
example {a : ℤ} (ha : 0 ≤ a) : 0 ≤ a := by positivity
example {a : ℤ} (ha : 0 < a) : 0 ≤ a := by positivity
example {a : ℤ} (ha : 0 < a) : 0 < a := by positivity
example {a : ℤ} (ha : 3 ≤ a) : 0 < a := by positivity
example {a : ℤ} (ha : 3 < a) : 0 ≤ a := by positivity
example {a : ℤ} (ha : 3 < a) : 0 < a := by positivity
example {a b : ℤ} (h : 0 ≤ a + b) : 0 ≤ a + b := by positivity
/- ## Tests of the @[positivity] plugin tactics (addition, multiplication, division) -/
example {a : ℤ} (ha : 3 < a) : 0 ≤ a + a := by positivity
example {a b : ℤ} (ha : 3 < a) (hb : 4 ≤ b) : 0 ≤ 3 + a + b + b + 14 := by positivity
example {H : Type*} [linear_ordered_add_comm_group H] {a b : H} (ha : 0 < a) (hb : 0 ≤ b) :
0 ≤ a + a + b :=
by positivity
example {a : ℤ} (ha : 3 < a) : 0 < a + a := by positivity
example {a b : ℚ} (ha : 3 < a) (hb : 4 ≤ b) : 0 < 3 + a * b / 7 + b + 7 + 14 := by positivity
example {a b : ℤ} (ha : 3 < a) (hb : 4 ≤ b) : 0 < 3 + a * b / 7 + b + 7 + 14 := by positivity
example {a : ℤ} (ha : 0 < a) : 0 < a / a := by positivity
example {a : ℕ} : 0 < a ^ 0 := by positivity
example {a : ℤ} (ha : 3 < a) : 0 ≤ a ^ 2 + a := by positivity
example {a : ℤ} (ha : 3 < a) : 0 ≤ a ^ 3 + a := by positivity
example {a : ℤ} (ha : 3 < a) : 0 < a ^ 2 + a := by positivity
example {a b : ℤ} (ha : 3 < a) (hb : b ≥ 4) : 0 ≤ 3 * a ^ 2 * b + b * 7 + 14 := by positivity
example {a b : ℤ} (ha : 3 < a) (hb : b ≥ 4) : 0 < 3 * a ^ 2 * b + b * 7 + 14 := by positivity
example {x : ℚ} (hx : 0 ≤ x) : 0 ≤ x⁻¹ := by positivity
example {a : ℤ} : 0 ≤ |a| := by positivity
example {a : ℤ} : 0 < |a| + 3 := by positivity
example {a : ℤ} (ha : 1 < a) : 0 < |(3:ℤ) + a| := by positivity
example {a : ℝ} (ha : 0 ≤ a) : 0 ≤ real.sqrt a := by positivity
example {a : ℝ} (ha : 0 ≤ a) : 0 < real.sqrt (a + 3) := by positivity
example {a b : ℤ} (ha : 3 < a) : 0 ≤ min a (b ^ 2) := by positivity
-- test that the tactic can ignore arithmetic operations whose associated extension tactic requires
-- more typeclass assumptions than are available
example {R : Type*} [has_zero R] [has_div R] [linear_order R] {a b c : R} (h1 : 0 < a) (h2 : 0 < b)
(h3 : 0 < c) :
0 < max (a / b) c :=
by positivity
example : 0 ≤ max 3 4 := by positivity
example {b : ℤ} : 0 ≤ max (-3) (b ^ 2) := by positivity
example {b : ℤ} : 0 ≤ max (b ^ 2) 0 := by positivity
example : 0 ≤ max (0:ℤ) (-3) := by positivity
example : 0 ≤ max (-3 : ℤ) 5 := by positivity
example {α β : Type*} [ordered_semiring α] [ordered_add_comm_monoid β] [smul_with_zero α β]
[ordered_smul α β] {a : α} (ha : 0 < a) {b : β} (hb : 0 < b) : 0 ≤ a • b := by positivity
example {V : Type*} [normed_add_comm_group V] (x : V) : 0 ≤ ∥x∥ := by positivity
example {X : Type*} [metric_space X] (x y : X) : 0 ≤ dist x y := by positivity
/- ## Tests that the tactic is agnostic on reversed inequalities -/
example {a : ℤ} (ha : a > 0) : 0 ≤ a := by positivity
example {a : ℤ} (ha : 0 < a) : a ≥ 0 := by positivity
example {a : ℤ} (ha : a > 0) : a ≥ 0 := by positivity
|
cea50822564329335c0b8c0b8028ebe25f7f7f25 | c062f1c97fdef9ac746f08754e7d766fd6789aa9 | /data/rat.lean | 759e68ab38fd4040d9b5da3a4331e626e0d659a6 | [] | no_license | emberian/library_dev | 00c7a985b21bdebe912f4127a363f2874e1e7555 | f3abd7db0238edc18a397540e361a1da2f51503c | refs/heads/master | 1,624,153,474,804 | 1,490,147,180,000 | 1,490,147,180,000 | null | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 15,593 | lean | /-
Copyright (c) 2017 Johannes Hölzl. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johannes Hölzl
Introduces the rational numbers as discrete, linear ordered field.
-/
import standard
/- linorder -/
section linear_order_cases_on
universes u v
variables {α : Type u} [decidable_linear_order α] {β : Sort v}
def linear_order_cases_on (a b : α) (h_eq : a = b → β) (h_lt : a < b → β) (h_gt : a > b → β) : β :=
if h₁ : a = b then h_eq h₁ else
if h₂ : a < b then h_lt h₂ else h_gt ((lt_or_gt_of_ne h₁)^.resolve_left h₂)
variables {a b : α} {h_eq : a = b → β} {h_lt : a < b → β} {h_gt : a > b → β}
lemma linear_order_cases_on_eq (h : a = b) : linear_order_cases_on a b h_eq h_lt h_gt = h_eq h :=
dif_pos h
lemma linear_order_cases_on_lt (h : a < b) : linear_order_cases_on a b h_eq h_lt h_gt = h_lt h :=
eq.trans (dif_neg $ ne_of_lt h) $ dif_pos h
lemma linear_order_cases_on_gt (h : a > b) : linear_order_cases_on a b h_eq h_lt h_gt = h_gt h :=
eq.trans (dif_neg $ (ne_of_lt h)^.symm) (dif_neg $ not_lt_of_ge $ le_of_lt h)
end linear_order_cases_on
/- linorder ring -/
section ordered_ring
universes u
variables {α : Type u} [linear_ordered_ring α] {a b : α}
lemma mul_nonneg_iff_right_nonneg_of_pos (h : 0 < a) : 0 ≤ b * a ↔ 0 ≤ b :=
⟨suppose 0 ≤ b * a, nonneg_of_mul_nonneg_right this h, suppose 0 ≤ b, mul_nonneg this $ le_of_lt h⟩
end ordered_ring
/- auxiliary -/
lemma not_antimono {a b : Prop} (nb : ¬ b) (h : (a → b)) : ¬ a :=
take ha, nb (h ha)
/- rational numbers -/
namespace rat
protected def num_denum := ℤ × {d:ℤ // d > 0}
protected def rel : rat.num_denum → rat.num_denum → Prop
| ⟨n₁, ⟨d₁, _⟩⟩ ⟨n₂, ⟨d₂, _⟩⟩ := n₁ * d₂ = n₂ * d₁
private lemma rel_trans : Π{p q r}, rat.rel p q → rat.rel q r → rat.rel p r
| ⟨n₁, ⟨d₁, _⟩⟩ ⟨n₂, ⟨d₂, _⟩⟩ ⟨n₃, ⟨d₃, _⟩⟩ :=
assume (h₁ : n₁ * d₂ = n₂ * d₁),
assume (h₂ : n₂ * d₃ = n₃ * d₂),
show n₁ * d₃ = n₃ * d₁,
from eq_of_mul_eq_mul_right (ne_of_lt ‹d₂ > 0›)^.symm (by cc)
instance setoid_rat.rel : setoid rat.num_denum :=
{r := rat.rel, iseqv :=
⟨take ⟨_, ⟨_, _⟩⟩, rfl,
take ⟨n₁, ⟨d₁, _⟩⟩ ⟨n₂, ⟨d₂, _⟩⟩ h, h^.symm,
take a b c, rel_trans⟩}
end rat
def rat := quotient rat.setoid_rat.rel
notation `ℚ` := rat
namespace rat
protected def zero : ℚ := ⟦⟨0, ⟨1, zero_lt_one⟩⟩⟧
instance : has_zero ℚ := ⟨rat.zero⟩
protected def one : ℚ := ⟦⟨1, ⟨1, zero_lt_one⟩⟩⟧
instance : has_one ℚ := ⟨rat.one⟩
private def add' : rat.num_denum → rat.num_denum → ℚ
| ⟨n₁, ⟨d₁, h₁⟩⟩ ⟨n₂, ⟨d₂, h₂⟩⟩ := ⟦⟨n₁ * d₂ + n₂ * d₁, ⟨d₁ * d₂, mul_pos h₁ h₂⟩⟩⟧
protected def add : ℚ → ℚ → ℚ :=
quotient.lift₂ add' $ λ⟨n₁, ⟨d₁, h₁⟩⟩ ⟨n₂, ⟨d₂, h₂⟩⟩ ⟨n₃, ⟨d₃, h₃⟩⟩ ⟨n₄, ⟨d₄, h₄⟩⟩,
assume (h₁ : n₁ * d₃ = n₃ * d₁) (h₂ : n₂ * d₄ = n₄ * d₂),
quotient.sound $
calc (n₁ * d₂ + n₂ * d₁) * (d₃ * d₄) =
(n₁ * d₃) * d₂ * d₄ + (n₂ * d₄) * (d₁ * d₃) : by simp [mul_add, add_mul]
... = (n₃ * d₁) * d₂ * d₄ + (n₄ * d₂) * (d₁ * d₃) : by rw [h₁, h₂]
... = (n₃ * d₄ + n₄ * d₃) * (d₁ * d₂) : by simp [mul_add, add_mul]
instance : has_add ℚ := ⟨rat.add⟩
private def neg' : rat.num_denum → ℚ
| ⟨n, d⟩ := ⟦⟨-n, d⟩⟧
protected def neg : ℚ → ℚ :=
quotient.lift neg' $ λ⟨n₁, ⟨d₁, h₁⟩⟩ ⟨n₂, ⟨d₂, h₂⟩⟩,
assume (h : n₁ * d₂ = n₂ * d₁),
quotient.sound $ show (-n₁) * d₂ = (-n₂) * d₁,
by simp [h]
instance : has_neg ℚ := ⟨rat.neg⟩
private def mul' : rat.num_denum → rat.num_denum → ℚ
| ⟨n₁, ⟨d₁, h₁⟩⟩ ⟨n₂, ⟨d₂, h₂⟩⟩ := ⟦⟨n₁ * n₂, ⟨d₁ * d₂, mul_pos h₁ h₂⟩⟩⟧
protected def mul : ℚ → ℚ → ℚ :=
quotient.lift₂ mul' $ λ⟨n₁, ⟨d₁, h₁⟩⟩ ⟨n₂, ⟨d₂, h₂⟩⟩ ⟨n₃, ⟨d₃, h₃⟩⟩ ⟨n₄, ⟨d₄, h₄⟩⟩,
assume (h₁ : n₁ * d₃ = n₃ * d₁) (h₂ : n₂ * d₄ = n₄ * d₂),
quotient.sound $
calc (n₁ * n₂) * (d₃ * d₄) =
(n₁ * d₃) * (n₂ * d₄) : by simp
... = (n₃ * d₁) * (n₄ * d₂) : by rw [h₁, h₂]
... = (n₃ * n₄) * (d₁ * d₂) : by simp
instance : has_mul ℚ := ⟨rat.mul⟩
private def inv' : rat.num_denum → ℚ
| ⟨n, ⟨d, h⟩⟩ := linear_order_cases_on n 0
(suppose n = 0, 0)
(suppose n < 0, ⟦⟨-d, ⟨-n, neg_pos_of_neg this⟩⟩⟧)
(suppose n > 0, ⟦⟨d, ⟨n, this⟩⟩⟧)
private lemma inv'_zero : Π{d : {d:ℤ // d > 0}}, inv' ⟨0, d⟩ = 0
| ⟨d, p⟩ := linear_order_cases_on_eq rfl
private lemma inv'_pos {n d : ℤ} {h : d > 0} (p : n > 0) : inv' ⟨n, ⟨d, h⟩⟩ = ⟦⟨d, ⟨n, p⟩⟩⟧ :=
linear_order_cases_on_gt p
private lemma inv'_neg {n d : ℤ} {h : d > 0} (p : n < 0) : inv' ⟨n, ⟨d, h⟩⟩ = ⟦⟨- d, ⟨- n, neg_pos_of_neg p⟩⟩⟧ :=
linear_order_cases_on_lt p
protected def inv : ℚ → ℚ :=
quotient.lift inv' $ λ⟨n₁, ⟨d₁, h₁⟩⟩ ⟨n₂, ⟨d₂, h₂⟩⟩,
assume h_eq : n₁ * d₂ = n₂ * d₁,
linear_order_cases_on n₁ 0
(suppose n₁ = 0,
have n₂ * d₁ = 0,
by simp [this] at h_eq; simp [h_eq],
have n₂ = 0,
from (eq_zero_or_eq_zero_of_mul_eq_zero this)^.resolve_right $ (ne_of_lt h₁)^.symm,
by simp [this, ‹n₁ = 0›, inv'_zero])
(suppose n₁ < 0,
have n₂ * d₁ < 0,
from h_eq ▸ mul_neg_of_neg_of_pos this ‹0 < d₂›,
have n₂ < 0,
from neg_of_mul_neg_right this $ le_of_lt ‹d₁ > 0›,
begin
rw [inv'_neg this, inv'_neg ‹n₁ < 0›],
apply quotient.sound,
simp [rat.rel, h_eq]
end)
(suppose n₁ > 0,
have n₂ * d₁ > 0,
from h_eq ▸ mul_pos this ‹0 < d₂›,
have n₂ > 0,
from pos_of_mul_pos_right this $ le_of_lt ‹d₁ > 0›,
begin
rw [inv'_pos this, inv'_pos ‹n₁ > 0›],
apply quotient.sound,
simp [rat.rel, h_eq]
end)
instance : has_inv ℚ := ⟨rat.inv⟩
variables (a b c : ℚ)
protected lemma add_zero : a + 0 = a :=
quotient.induction_on a $ λ⟨n, ⟨d, h⟩⟩, quotient.sound $
by simp [rat.rel]
protected lemma zero_add : 0 + a = a :=
quotient.induction_on a $ λ⟨n, ⟨d, h⟩⟩, quotient.sound $
by simp [rat.rel]
protected lemma add_comm : a + b = b + a :=
quotient.induction_on₂ a b $ λ⟨n₁, ⟨d₁, h₁⟩⟩ ⟨n₂, ⟨d₂, h₂⟩⟩, quotient.sound $
by simp [rat.rel]
protected lemma add_assoc : a + b + c = a + (b + c) :=
quotient.induction_on₃ a b c $ λ⟨n₁, ⟨d₁, h₁⟩⟩ ⟨n₂, ⟨d₂, h₂⟩⟩ ⟨n₃, ⟨d₃, h₃⟩⟩, quotient.sound $
by simp [rat.rel, mul_add, add_mul]
protected lemma add_left_neg : -a + a = 0 :=
quotient.induction_on a $ λ⟨n, ⟨d, h⟩⟩, quotient.sound $
by simp [rat.rel]
protected lemma mul_one : a * 1 = a :=
quotient.induction_on a $ λ⟨n, ⟨d, h⟩⟩, quotient.sound $
by simp [rat.rel]
protected lemma one_mul : 1 * a = a :=
quotient.induction_on a $ λ⟨n, ⟨d, h⟩⟩, quotient.sound $
by simp [rat.rel]
protected lemma mul_comm : a * b = b * a :=
quotient.induction_on₂ a b $ λ⟨n₁, ⟨d₁, h₁⟩⟩ ⟨n₂, ⟨d₂, h₂⟩⟩, quotient.sound $
by simp [rat.rel]
protected lemma mul_assoc : a * b * c = a * (b * c) :=
quotient.induction_on₃ a b c $ λ⟨n₁, ⟨d₁, h₁⟩⟩ ⟨n₂, ⟨d₂, h₂⟩⟩ ⟨n₃, ⟨d₃, h₃⟩⟩, quotient.sound $
by simp [rat.rel]
protected lemma add_mul : (a + b) * c = a * c + b * c :=
quotient.induction_on₃ a b c $ λ⟨n₁, ⟨d₁, h₁⟩⟩ ⟨n₂, ⟨d₂, h₂⟩⟩ ⟨n₃, ⟨d₃, h₃⟩⟩, quotient.sound $
by simp [rat.rel, mul_add, add_mul]
protected lemma mul_add : a * (b + c) = a * b + a * c :=
quotient.induction_on₃ a b c $ λ⟨n₁, ⟨d₁, h₁⟩⟩ ⟨n₂, ⟨d₂, h₂⟩⟩ ⟨n₃, ⟨d₃, h₃⟩⟩, quotient.sound $
by simp [rat.rel, mul_add, add_mul]
private lemma rat_eq_zero : ∀{a : rat.num_denum}, ⟦a⟧ = (0:ℚ) → a.1 = 0
| ⟨n, ⟨d, h⟩⟩ eq_0 :=
have n * 1 = 0 * d, from quotient.exact eq_0,
begin simp at this, assumption end
private lemma eq_zero_of_rat_eq_zero : ∀{a : rat.num_denum}, a.1 = 0 → ⟦a⟧ = (0:ℚ)
| ⟨n, ⟨d, h⟩⟩ _ := begin simp [‹n = 0›], apply quotient.sound, simp [rat.rel] end
private lemma rat_eq_zero_iff {a : rat.num_denum} : ⟦a⟧ = (0:ℚ) ↔ a.1 = 0 :=
⟨rat_eq_zero, eq_zero_of_rat_eq_zero⟩
protected lemma zero_ne_one : 0 ≠ (1:ℚ) :=
take h, zero_ne_one (rat_eq_zero h^.symm)^.symm
protected lemma mul_inv_cancel : a ≠ 0 → a * a⁻¹ = 1 :=
quotient.induction_on a $ λ⟨n, ⟨d, h⟩⟩ neq0,
let a : rat.num_denum := ⟨n, ⟨d, h⟩⟩ in
linear_order_cases_on n 0
(suppose n = 0, by rw [this, @eq_zero_of_rat_eq_zero ⟨0, ⟨d, h⟩⟩ rfl] at neq0; contradiction)
(suppose n < 0,
have @inv rat _ ⟦a⟧ = ⟦⟨-d, ⟨-n, neg_pos_of_neg this⟩⟩⟧,
from @inv'_neg n d h _,
begin simp [this], apply quotient.sound, simp [rat.rel] end)
(suppose n > 0,
have @inv rat _ ⟦a⟧ = ⟦⟨d, ⟨n, this⟩⟩⟧,
from @inv'_pos n d h _,
begin simp [this], apply quotient.sound, simp [rat.rel] end)
protected lemma inv_mul_cancel (h : a ≠ 0) : a⁻¹ * a = 1 :=
eq.trans (rat.mul_comm _ _) (rat.mul_inv_cancel _ h)
instance decidable_eq_rat.rel : Π{a b : rat.num_denum}, decidable (rat.rel a b)
| ⟨n₁, ⟨d₁, h₁⟩⟩ ⟨n₂, ⟨d₂, h₂⟩⟩ := show decidable (n₁ * d₂ = n₂ * d₁), by apply_instance
instance decidable_eq_rat : decidable_eq ℚ :=
by dunfold rat; apply_instance
instance field_rat : discrete_field ℚ :=
{ zero := rat.zero,
add := rat.add,
neg := rat.neg,
one := rat.one,
mul := rat.mul,
inv := rat.inv,
zero_add := rat.zero_add,
add_zero := rat.add_zero,
add_comm := rat.add_comm,
add_assoc := rat.add_assoc,
add_left_neg := rat.add_left_neg,
mul_one := rat.mul_one,
one_mul := rat.one_mul,
mul_comm := rat.mul_comm,
mul_assoc := rat.mul_assoc,
left_distrib := rat.mul_add,
right_distrib := rat.add_mul,
zero_ne_one := rat.zero_ne_one,
mul_inv_cancel := rat.mul_inv_cancel,
inv_mul_cancel := rat.inv_mul_cancel,
has_decidable_eq := by apply_instance,
inv_zero := quotient.sound rfl }
private def nonneg' : rat.num_denum → Prop
| ⟨n₁, ⟨d₁, h₁⟩⟩ := 0 ≤ n₁
protected def nonneg : ℚ → Prop :=
quotient.lift nonneg' $ λ⟨n₁, ⟨d₁, h₁⟩⟩ ⟨n₂, ⟨d₂, h₂⟩⟩ (h : n₁ * d₂ = n₂ * d₁),
propext $ calc (0 ≤ n₁) ↔ (0 ≤ n₁ * d₂) : (mul_nonneg_iff_right_nonneg_of_pos h₂)^.symm
... ↔ (0 ≤ n₂ * d₁) : by rw h
... ↔ (0 ≤ n₂) : mul_nonneg_iff_right_nonneg_of_pos h₁
protected def nonneg_add : rat.nonneg a → rat.nonneg b → rat.nonneg (a + b) :=
quotient.induction_on₂ a b $ λ⟨n₁, ⟨d₁, h₁⟩⟩ ⟨n₂, ⟨d₂, h₂⟩⟩ _ _,
add_nonneg (mul_nonneg ‹0 ≤ n₁› (le_of_lt ‹0 < d₂›)) (mul_nonneg ‹0 ≤ n₂› (le_of_lt ‹0 < d₁›))
protected def nonneg_mul : rat.nonneg a → rat.nonneg b → rat.nonneg (a * b) :=
quotient.induction_on₂ a b $ λ⟨n₁, ⟨d₁, h₁⟩⟩ ⟨n₂, ⟨d₂, h₂⟩⟩ _ _,
mul_nonneg ‹0 ≤ n₁› ‹0 ≤ n₂›
protected def nonneg_antisymm : rat.nonneg a → rat.nonneg (-a) → a = 0 :=
quotient.induction_on a $ λ⟨n₁, ⟨d₁, h₁⟩⟩ (h₂ : 0 ≤ n₁) (h₃ : 0 ≤ -n₁), quotient.sound $
le_antisymm (by simp; exact le_neg_of_le_neg h₃) (by simp; exact h₂)
protected def nonneg_total : rat.nonneg a ∨ rat.nonneg (-a) :=
quotient.induction_on a $ λ⟨n₁, ⟨d₁, h₁⟩⟩,
show 0 ≤ n₁ ∨ 0 ≤ -n₁,
from or.imp_right neg_nonneg_of_nonpos (le_total 0 n₁)
@[instance]
def decidable_nonneg : decidable (rat.nonneg a) :=
quotient.rec_on_subsingleton a
(λ⟨n, ⟨d, h⟩⟩, if h : 0 ≤ n then is_true h else is_false h)
protected def le (a b : ℚ) := rat.nonneg (b - a)
instance : has_le ℚ := ⟨rat.le⟩
protected lemma le_refl : a ≤ a :=
show rat.nonneg (a - a), begin rw [sub_self], exact le_refl (0 : int) end
instance : linear_strong_order_pair ℚ :=
{ le := rat.le,
lt := λa b, a ≤ b ∧ a ≠ b,
le_iff_lt_or_eq := take a b,
⟨suppose a ≤ b, if h : a = b then or.inr h else or.inl ⟨this, h⟩,
or.rec and.left (suppose a = b, show a ≤ b, from this ▸ rat.le_refl _)⟩,
lt_irrefl := take a ⟨_, h⟩, h rfl,
le_refl := rat.le_refl,
le_trans := take a b c h_ab h_bc,
have rat.nonneg (b - a + (c - b)),
from rat.nonneg_add _ _ h_ab h_bc,
show rat.nonneg (c - a),
by simp at this; assumption,
le_antisymm := take a b h_ab h_ba,
have a = - - b,
from eq_neg_of_add_eq_zero $ rat.nonneg_antisymm _ h_ba (by simp; assumption),
by rw neg_neg at this; assumption,
le_total := take a b,
have rat.nonneg (b - a) ∨ rat.nonneg (- (b - a)),
from rat.nonneg_total _,
by rw neg_sub at this; assumption }
protected def zero_le_of_nonneg : rat.nonneg a → 0 ≤ a :=
quotient.induction_on a $ take ⟨n, ⟨d, h⟩⟩ _, show 0 ≤ n * 1 + (- 0) * d,
by simp; assumption
protected def nonneg_of_zero_le : 0 ≤ a → rat.nonneg a :=
quotient.induction_on a $ take ⟨n, ⟨d, h⟩⟩, suppose 0 ≤ n * 1 + (- 0) * d,
by simp at this; assumption
instance : discrete_linear_ordered_field ℚ :=
{ rat.field_rat with
le := le,
lt := lt,
le_refl := le_refl,
le_trans := take a b c, le_trans,
le_antisymm := take a b, le_antisymm,
le_total := le_total,
le_iff_lt_or_eq := take a b, le_iff_lt_or_eq,
lt_irrefl := lt_irrefl,
le_of_lt := take a b, le_of_lt,
lt_of_lt_of_le := take a b c, lt_of_lt_of_le,
lt_of_le_of_lt := take a b c, lt_of_le_of_lt,
zero_lt_one := ⟨rat.zero_le_of_nonneg _ (@zero_le_one int _), zero_ne_one⟩,
add_le_add_left := take a b (h_ab : rat.nonneg (b - a)) c,
show rat.nonneg ((c + b) - (c + a)), by rw add_sub_add_left_eq_sub; assumption,
add_lt_add_left := take a b ⟨a_le_b, a_ne_b⟩ c,
show rat.nonneg ((c + b) - (c + a)) ∧ c + a ≠ c + b,
by rw [add_sub_add_left_eq_sub]; exact ⟨a_le_b, not_antimono a_ne_b add_left_cancel⟩,
mul_nonneg := take a b ha hb, rat.zero_le_of_nonneg _ $
rat.nonneg_mul _ _ (rat.nonneg_of_zero_le a ha) (rat.nonneg_of_zero_le b hb),
mul_pos := take a b ⟨nn_a, a_ne_zero⟩ ⟨nn_b, b_ne_zero⟩,
⟨rat.zero_le_of_nonneg _ $ rat.nonneg_mul _ _
(rat.nonneg_of_zero_le a nn_a) (rat.nonneg_of_zero_le b nn_b),
(mul_ne_zero a_ne_zero^.symm b_ne_zero^.symm)^.symm⟩,
decidable_eq := by apply_instance,
decidable_le := take a b, rat.decidable_nonneg (b - a),
decidable_lt := take a b, show decidable (rat.nonneg (b - a) ∧ a ≠ b), by apply_instance }
end rat
|
131351114d8797806f5a5044308c9be5b3e4cf24 | 74addaa0e41490cbaf2abd313a764c96df57b05d | /Mathlib/measure_theory/bochner_integration_auto.lean | 90ea8bd5895df336ad003ce50a061cfa06a6c0cc | [] | no_license | AurelienSaue/Mathlib4_auto | f538cfd0980f65a6361eadea39e6fc639e9dae14 | 590df64109b08190abe22358fabc3eae000943f2 | refs/heads/master | 1,683,906,849,776 | 1,622,564,669,000 | 1,622,564,669,000 | 371,723,747 | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 69,180 | lean | /-
Copyright (c) 2019 Zhouhang Zhou. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Zhouhang Zhou, Yury Kudryashov
-/
import Mathlib.PrePort
import Mathlib.Lean3Lib.init.default
import Mathlib.measure_theory.simple_func_dense
import Mathlib.analysis.normed_space.bounded_linear_maps
import Mathlib.topology.sequences
import Mathlib.PostPort
universes u_1 u_2 u_3 u_4
namespace Mathlib
/-!
# Bochner integral
The Bochner integral extends the definition of the Lebesgue integral to functions that map from a
measure space into a Banach space (complete normed vector space). It is constructed here by
extending the integral on simple functions.
## Main definitions
The Bochner integral is defined following these steps:
1. Define the integral on simple functions of the type `simple_func α E` (notation : `α →ₛ E`)
where `E` is a real normed space.
(See `simple_func.bintegral` and section `bintegral` for details. Also see `simple_func.integral`
for the integral on simple functions of the type `simple_func α ennreal`.)
2. Use `α →ₛ E` to cut out the simple functions from L1 functions, and define integral
on these. The type of simple functions in L1 space is written as `α →₁ₛ[μ] E`.
3. Show that the embedding of `α →₁ₛ[μ] E` into L1 is a dense and uniform one.
4. Show that the integral defined on `α →₁ₛ[μ] E` is a continuous linear map.
5. Define the Bochner integral on L1 functions by extending the integral on integrable simple
functions `α →₁ₛ[μ] E` using `continuous_linear_map.extend`. Define the Bochner integral on
functions as the Bochner integral of its equivalence class in L1 space.
## Main statements
1. Basic properties of the Bochner integral on functions of type `α → E`, where `α` is a measure
space and `E` is a real normed space.
* `integral_zero` : `∫ 0 ∂μ = 0`
* `integral_add` : `∫ x, f x + g x ∂μ = ∫ x, f ∂μ + ∫ x, g x ∂μ`
* `integral_neg` : `∫ x, - f x ∂μ = - ∫ x, f x ∂μ`
* `integral_sub` : `∫ x, f x - g x ∂μ = ∫ x, f x ∂μ - ∫ x, g x ∂μ`
* `integral_smul` : `∫ x, r • f x ∂μ = r • ∫ x, f x ∂μ`
* `integral_congr_ae` : `f =ᵐ[μ] g → ∫ x, f x ∂μ = ∫ x, g x ∂μ`
* `norm_integral_le_integral_norm` : `∥∫ x, f x ∂μ∥ ≤ ∫ x, ∥f x∥ ∂μ`
2. Basic properties of the Bochner integral on functions of type `α → ℝ`, where `α` is a measure
space.
* `integral_nonneg_of_ae` : `0 ≤ᵐ[μ] f → 0 ≤ ∫ x, f x ∂μ`
* `integral_nonpos_of_ae` : `f ≤ᵐ[μ] 0 → ∫ x, f x ∂μ ≤ 0`
* `integral_mono_ae` : `f ≤ᵐ[μ] g → ∫ x, f x ∂μ ≤ ∫ x, g x ∂μ`
* `integral_nonneg` : `0 ≤ f → 0 ≤ ∫ x, f x ∂μ`
* `integral_nonpos` : `f ≤ 0 → ∫ x, f x ∂μ ≤ 0`
* `integral_mono` : `f ≤ᵐ[μ] g → ∫ x, f x ∂μ ≤ ∫ x, g x ∂μ`
3. Propositions connecting the Bochner integral with the integral on `ennreal`-valued functions,
which is called `lintegral` and has the notation `∫⁻`.
* `integral_eq_lintegral_max_sub_lintegral_min` : `∫ x, f x ∂μ = ∫⁻ x, f⁺ x ∂μ - ∫⁻ x, f⁻ x ∂μ`,
where `f⁺` is the positive part of `f` and `f⁻` is the negative part of `f`.
* `integral_eq_lintegral_of_nonneg_ae` : `0 ≤ᵐ[μ] f → ∫ x, f x ∂μ = ∫⁻ x, f x ∂μ`
4. `tendsto_integral_of_dominated_convergence` : the Lebesgue dominated convergence theorem
## Notes
Some tips on how to prove a proposition if the API for the Bochner integral is not enough so that
you need to unfold the definition of the Bochner integral and go back to simple functions.
One method is to use the theorem `integrable.induction` in the file `set_integral`, which allows
you to prove something for an arbitrary measurable + integrable function.
Another method is using the following steps.
See `integral_eq_lintegral_max_sub_lintegral_min` for a complicated example, which proves that
`∫ f = ∫⁻ f⁺ - ∫⁻ f⁻`, with the first integral sign being the Bochner integral of a real-valued
function `f : α → ℝ`, and second and third integral sign being the integral on ennreal-valued
functions (called `lintegral`). The proof of `integral_eq_lintegral_max_sub_lintegral_min` is
scattered in sections with the name `pos_part`.
Here are the usual steps of proving that a property `p`, say `∫ f = ∫⁻ f⁺ - ∫⁻ f⁻`, holds for all
functions :
1. First go to the `L¹` space.
For example, if you see `ennreal.to_real (∫⁻ a, ennreal.of_real $ ∥f a∥)`, that is the norm of
`f` in `L¹` space. Rewrite using `l1.norm_of_fun_eq_lintegral_norm`.
2. Show that the set `{f ∈ L¹ | ∫ f = ∫⁻ f⁺ - ∫⁻ f⁻}` is closed in `L¹` using `is_closed_eq`.
3. Show that the property holds for all simple functions `s` in `L¹` space.
Typically, you need to convert various notions to their `simple_func` counterpart, using lemmas
like `l1.integral_coe_eq_integral`.
4. Since simple functions are dense in `L¹`,
```
univ = closure {s simple}
= closure {s simple | ∫ s = ∫⁻ s⁺ - ∫⁻ s⁻} : the property holds for all simple functions
⊆ closure {f | ∫ f = ∫⁻ f⁺ - ∫⁻ f⁻}
= {f | ∫ f = ∫⁻ f⁺ - ∫⁻ f⁻} : closure of a closed set is itself
```
Use `is_closed_property` or `dense_range.induction_on` for this argument.
## Notations
* `α →ₛ E` : simple functions (defined in `measure_theory/integration`)
* `α →₁[μ] E` : functions in L1 space, i.e., equivalence classes of integrable functions (defined in
`measure_theory/l1_space`)
* `α →₁ₛ[μ] E` : simple functions in L1 space, i.e., equivalence classes of integrable simple
functions
Note : `ₛ` is typed using `\_s`. Sometimes it shows as a box if font is missing.
## Tags
Bochner integral, simple function, function space, Lebesgue dominated convergence theorem
-/
namespace measure_theory
namespace simple_func
/-- Positive part of a simple function. -/
def pos_part {α : Type u_1} {E : Type u_2} [measurable_space α] [linear_order E] [HasZero E]
(f : simple_func α E) : simple_func α E :=
map (fun (b : E) => max b 0) f
/-- Negative part of a simple function. -/
def neg_part {α : Type u_1} {E : Type u_2} [measurable_space α] [linear_order E] [HasZero E] [Neg E]
(f : simple_func α E) : simple_func α E :=
pos_part (-f)
theorem pos_part_map_norm {α : Type u_1} [measurable_space α] (f : simple_func α ℝ) :
map norm (pos_part f) = pos_part f :=
sorry
theorem neg_part_map_norm {α : Type u_1} [measurable_space α] (f : simple_func α ℝ) :
map norm (neg_part f) = neg_part f :=
eq.mpr
(id (Eq._oldrec (Eq.refl (map norm (neg_part f) = neg_part f)) (neg_part.equations._eqn_1 f)))
(pos_part_map_norm (-f))
theorem pos_part_sub_neg_part {α : Type u_1} [measurable_space α] (f : simple_func α ℝ) :
pos_part f - neg_part f = f :=
sorry
end simple_func
end measure_theory
namespace measure_theory
namespace simple_func
/-!
### The Bochner integral of simple functions
Define the Bochner integral of simple functions of the type `α →ₛ β` where `β` is a normed group,
and prove basic property of this integral.
-/
/-- For simple functions with a `normed_group` as codomain, being integrable is the same as having
finite volume support. -/
theorem integrable_iff_fin_meas_supp {α : Type u_1} {E : Type u_2} [measurable_space α]
[normed_group E] [measurable_space E] {f : simple_func α E} {μ : measure α} :
integrable ⇑f ↔ simple_func.fin_meas_supp f μ :=
sorry
theorem fin_meas_supp.integrable {α : Type u_1} {E : Type u_2} [measurable_space α] [normed_group E]
[measurable_space E] {μ : measure α} {f : simple_func α E} (h : simple_func.fin_meas_supp f μ) :
integrable ⇑f :=
iff.mpr integrable_iff_fin_meas_supp h
theorem integrable_pair {α : Type u_1} {E : Type u_2} {F : Type u_3} [measurable_space α]
[normed_group E] [measurable_space E] [normed_group F] {μ : measure α} [measurable_space F]
{f : simple_func α E} {g : simple_func α F} :
integrable ⇑f → integrable ⇑g → integrable ⇑(pair f g) :=
sorry
/-- Bochner integral of simple functions whose codomain is a real `normed_space`. -/
def integral {α : Type u_1} {F : Type u_3} [measurable_space α] [normed_group F] [normed_space ℝ F]
(μ : measure α) (f : simple_func α F) : F :=
finset.sum (simple_func.range f)
fun (x : F) => ennreal.to_real (coe_fn μ (⇑f ⁻¹' singleton x)) • x
theorem integral_eq_sum_filter {α : Type u_1} {F : Type u_3} [measurable_space α] [normed_group F]
[normed_space ℝ F] (f : simple_func α F) (μ : measure α) :
integral μ f =
finset.sum (finset.filter (fun (x : F) => x ≠ 0) (simple_func.range f))
fun (x : F) => ennreal.to_real (coe_fn μ (⇑f ⁻¹' singleton x)) • x :=
sorry
/-- The Bochner integral is equal to a sum over any set that includes `f.range` (except `0`). -/
theorem integral_eq_sum_of_subset {α : Type u_1} {F : Type u_3} [measurable_space α]
[normed_group F] [normed_space ℝ F] {f : simple_func α F} {μ : measure α} {s : finset F}
(hs : finset.filter (fun (x : F) => x ≠ 0) (simple_func.range f) ⊆ s) :
integral μ f =
finset.sum s fun (x : F) => ennreal.to_real (coe_fn μ (⇑f ⁻¹' singleton x)) • x :=
sorry
/-- Calculate the integral of `g ∘ f : α →ₛ F`, where `f` is an integrable function from `α` to `E`
and `g` is a function from `E` to `F`. We require `g 0 = 0` so that `g ∘ f` is integrable. -/
theorem map_integral {α : Type u_1} {E : Type u_2} {F : Type u_3} [measurable_space α]
[normed_group E] [measurable_space E] [normed_group F] {μ : measure α} [normed_space ℝ F]
(f : simple_func α E) (g : E → F) (hf : integrable ⇑f) (hg : g 0 = 0) :
integral μ (map g f) =
finset.sum (simple_func.range f)
fun (x : E) => ennreal.to_real (coe_fn μ (⇑f ⁻¹' singleton x)) • g x :=
sorry
/-- `simple_func.integral` and `simple_func.lintegral` agree when the integrand has type
`α →ₛ ennreal`. But since `ennreal` is not a `normed_space`, we need some form of coercion.
See `integral_eq_lintegral` for a simpler version. -/
theorem integral_eq_lintegral' {α : Type u_1} {E : Type u_2} [measurable_space α] [normed_group E]
[measurable_space E] {μ : measure α} {f : simple_func α E} {g : E → ennreal}
(hf : integrable ⇑f) (hg0 : g 0 = 0) (hgt : ∀ (b : E), g b < ⊤) :
integral μ (map (ennreal.to_real ∘ g) f) =
ennreal.to_real (lintegral μ fun (a : α) => g (coe_fn f a)) :=
sorry
theorem integral_congr {α : Type u_1} {E : Type u_2} [measurable_space α] [normed_group E]
[measurable_space E] {μ : measure α} [normed_space ℝ E] {f : simple_func α E}
{g : simple_func α E} (hf : integrable ⇑f) (h : filter.eventually_eq (measure.ae μ) ⇑f ⇑g) :
integral μ f = integral μ g :=
sorry
/-- `simple_func.bintegral` and `simple_func.integral` agree when the integrand has type
`α →ₛ ennreal`. But since `ennreal` is not a `normed_space`, we need some form of coercion. -/
theorem integral_eq_lintegral {α : Type u_1} [measurable_space α] {μ : measure α}
{f : simple_func α ℝ} (hf : integrable ⇑f) (h_pos : filter.eventually_le (measure.ae μ) 0 ⇑f) :
integral μ f = ennreal.to_real (lintegral μ fun (a : α) => ennreal.of_real (coe_fn f a)) :=
sorry
theorem integral_add {α : Type u_1} {E : Type u_2} [measurable_space α] [normed_group E]
[measurable_space E] {μ : measure α} [normed_space ℝ E] {f : simple_func α E}
{g : simple_func α E} (hf : integrable ⇑f) (hg : integrable ⇑g) :
integral μ (f + g) = integral μ f + integral μ g :=
sorry
theorem integral_neg {α : Type u_1} {E : Type u_2} [measurable_space α] [normed_group E]
[measurable_space E] {μ : measure α} [normed_space ℝ E] {f : simple_func α E}
(hf : integrable ⇑f) : integral μ (-f) = -integral μ f :=
sorry
theorem integral_sub {α : Type u_1} {E : Type u_2} [measurable_space α] [normed_group E]
[measurable_space E] {μ : measure α} [normed_space ℝ E] [borel_space E] {f : simple_func α E}
{g : simple_func α E} (hf : integrable ⇑f) (hg : integrable ⇑g) :
integral μ (f - g) = integral μ f - integral μ g :=
sorry
theorem integral_smul {α : Type u_1} {E : Type u_2} [measurable_space α] [normed_group E]
[measurable_space E] {μ : measure α} [normed_space ℝ E] (r : ℝ) {f : simple_func α E}
(hf : integrable ⇑f) : integral μ (r • f) = r • integral μ f :=
sorry
theorem norm_integral_le_integral_norm {α : Type u_1} {E : Type u_2} [measurable_space α]
[normed_group E] [measurable_space E] {μ : measure α} [normed_space ℝ E] (f : simple_func α E)
(hf : integrable ⇑f) : norm (integral μ f) ≤ integral μ (map norm f) :=
sorry
theorem integral_add_measure {α : Type u_1} {E : Type u_2} [measurable_space α] [normed_group E]
[measurable_space E] {μ : measure α} [normed_space ℝ E]
{ν :
autoParam (measure α)
(Lean.Syntax.ident Lean.SourceInfo.none
(String.toSubstring "Mathlib.measure_theory.volume_tac")
(Lean.Name.mkStr
(Lean.Name.mkStr (Lean.Name.mkStr Lean.Name.anonymous "Mathlib") "measure_theory")
"volume_tac")
[])}
(f : simple_func α E) (hf : integrable ⇑f) : integral (μ + ν) f = integral μ f + integral ν f :=
sorry
end simple_func
namespace l1
-- We use `Type*` instead of `add_subgroup` because otherwise we loose dot notation.
/-- `l1.simple_func` is a subspace of L1 consisting of equivalence classes of an integrable simple
function. -/
def simple_func (α : Type u_1) (E : Type u_2) [measurable_space α] [normed_group E]
[topological_space.second_countable_topology E] [measurable_space E] [borel_space E]
(μ : measure α) :=
↥(add_subgroup.mk
(set_of
fun (f : l1 α E μ) =>
∃ (s : simple_func α E), ae_eq_fun.mk (⇑s) (simple_func.ae_measurable s) = ↑f)
sorry sorry sorry)
namespace simple_func
/-! Simple functions in L1 space form a `normed_space`. -/
protected instance measure_theory.l1.has_coe {α : Type u_1} {E : Type u_2} [measurable_space α]
[normed_group E] [topological_space.second_countable_topology E] [measurable_space E]
[borel_space E] {μ : measure α} : has_coe (simple_func α E μ) (l1 α E μ) :=
Mathlib.coe_subtype
protected instance has_coe_to_fun {α : Type u_1} {E : Type u_2} [measurable_space α]
[normed_group E] [topological_space.second_countable_topology E] [measurable_space E]
[borel_space E] {μ : measure α} : has_coe_to_fun (simple_func α E μ) :=
has_coe_to_fun.mk (fun (f : simple_func α E μ) => α → E) fun (f : simple_func α E μ) => ⇑↑f
@[simp] theorem coe_coe {α : Type u_1} {E : Type u_2} [measurable_space α] [normed_group E]
[topological_space.second_countable_topology E] [measurable_space E] [borel_space E]
{μ : measure α} (f : simple_func α E μ) : ⇑↑f = ⇑f :=
rfl
protected theorem eq {α : Type u_1} {E : Type u_2} [measurable_space α] [normed_group E]
[topological_space.second_countable_topology E] [measurable_space E] [borel_space E]
{μ : measure α} {f : simple_func α E μ} {g : simple_func α E μ} : ↑f = ↑g → f = g :=
subtype.eq
protected theorem eq' {α : Type u_1} {E : Type u_2} [measurable_space α] [normed_group E]
[topological_space.second_countable_topology E] [measurable_space E] [borel_space E]
{μ : measure α} {f : simple_func α E μ} {g : simple_func α E μ} : ↑f = ↑g → f = g :=
subtype.eq ∘ subtype.eq
protected theorem eq_iff {α : Type u_1} {E : Type u_2} [measurable_space α] [normed_group E]
[topological_space.second_countable_topology E] [measurable_space E] [borel_space E]
{μ : measure α} {f : simple_func α E μ} {g : simple_func α E μ} : ↑f = ↑g ↔ f = g :=
iff.symm subtype.ext_iff
protected theorem eq_iff' {α : Type u_1} {E : Type u_2} [measurable_space α] [normed_group E]
[topological_space.second_countable_topology E] [measurable_space E] [borel_space E]
{μ : measure α} {f : simple_func α E μ} {g : simple_func α E μ} : ↑f = ↑g ↔ f = g :=
{ mp := simple_func.eq', mpr := congr_arg fun {f : simple_func α E μ} => ↑f }
/-- L1 simple functions forms a `emetric_space`, with the emetric being inherited from L1 space,
i.e., `edist f g = ∫⁻ a, edist (f a) (g a)`.
Not declared as an instance as `α →₁ₛ[μ] β` will only be useful in the construction of the Bochner
integral. -/
protected def emetric_space {α : Type u_1} {E : Type u_2} [measurable_space α] [normed_group E]
[topological_space.second_countable_topology E] [measurable_space E] [borel_space E]
{μ : measure α} : emetric_space (simple_func α E μ) :=
subtype.emetric_space
/-- L1 simple functions forms a `metric_space`, with the metric being inherited from L1 space,
i.e., `dist f g = ennreal.to_real (∫⁻ a, edist (f a) (g a)`).
Not declared as an instance as `α →₁ₛ[μ] β` will only be useful in the construction of the Bochner
integral. -/
protected def metric_space {α : Type u_1} {E : Type u_2} [measurable_space α] [normed_group E]
[topological_space.second_countable_topology E] [measurable_space E] [borel_space E]
{μ : measure α} : metric_space (simple_func α E μ) :=
subtype.metric_space
/-- Functions `α →₁ₛ[μ] E` form an additive commutative group. -/
protected def add_comm_group {α : Type u_1} {E : Type u_2} [measurable_space α] [normed_group E]
[topological_space.second_countable_topology E] [measurable_space E] [borel_space E]
{μ : measure α} : add_comm_group (simple_func α E μ) :=
add_subgroup.to_add_comm_group
(add_subgroup.mk
(set_of
fun (f : l1 α E μ) =>
∃ (s : simple_func α E), ae_eq_fun.mk (⇑s) (simple_func.ae_measurable s) = ↑f)
(_proof_3 α E μ) (_proof_4 α E μ) (_proof_5 α E μ))
protected instance inhabited {α : Type u_1} {E : Type u_2} [measurable_space α] [normed_group E]
[topological_space.second_countable_topology E] [measurable_space E] [borel_space E]
{μ : measure α} : Inhabited (simple_func α E μ) :=
{ default := 0 }
@[simp] theorem coe_zero {α : Type u_1} {E : Type u_2} [measurable_space α] [normed_group E]
[topological_space.second_countable_topology E] [measurable_space E] [borel_space E]
{μ : measure α} : ↑0 = 0 :=
rfl
@[simp] theorem coe_add {α : Type u_1} {E : Type u_2} [measurable_space α] [normed_group E]
[topological_space.second_countable_topology E] [measurable_space E] [borel_space E]
{μ : measure α} (f : simple_func α E μ) (g : simple_func α E μ) : ↑(f + g) = ↑f + ↑g :=
rfl
@[simp] theorem coe_neg {α : Type u_1} {E : Type u_2} [measurable_space α] [normed_group E]
[topological_space.second_countable_topology E] [measurable_space E] [borel_space E]
{μ : measure α} (f : simple_func α E μ) : ↑(-f) = -↑f :=
rfl
@[simp] theorem coe_sub {α : Type u_1} {E : Type u_2} [measurable_space α] [normed_group E]
[topological_space.second_countable_topology E] [measurable_space E] [borel_space E]
{μ : measure α} (f : simple_func α E μ) (g : simple_func α E μ) : ↑(f - g) = ↑f - ↑g :=
rfl
@[simp] theorem edist_eq {α : Type u_1} {E : Type u_2} [measurable_space α] [normed_group E]
[topological_space.second_countable_topology E] [measurable_space E] [borel_space E]
{μ : measure α} (f : simple_func α E μ) (g : simple_func α E μ) : edist f g = edist ↑f ↑g :=
rfl
@[simp] theorem dist_eq {α : Type u_1} {E : Type u_2} [measurable_space α] [normed_group E]
[topological_space.second_countable_topology E] [measurable_space E] [borel_space E]
{μ : measure α} (f : simple_func α E μ) (g : simple_func α E μ) : dist f g = dist ↑f ↑g :=
rfl
/-- The norm on `α →₁ₛ[μ] E` is inherited from L1 space. That is, `∥f∥ = ∫⁻ a, edist (f a) 0`.
Not declared as an instance as `α →₁ₛ[μ] E` will only be useful in the construction of the Bochner
integral. -/
protected def has_norm {α : Type u_1} {E : Type u_2} [measurable_space α] [normed_group E]
[topological_space.second_countable_topology E] [measurable_space E] [borel_space E]
{μ : measure α} : has_norm (simple_func α E μ) :=
has_norm.mk fun (f : simple_func α E μ) => norm ↑f
theorem norm_eq {α : Type u_1} {E : Type u_2} [measurable_space α] [normed_group E]
[topological_space.second_countable_topology E] [measurable_space E] [borel_space E]
{μ : measure α} (f : simple_func α E μ) : norm f = norm ↑f :=
rfl
theorem norm_eq' {α : Type u_1} {E : Type u_2} [measurable_space α] [normed_group E]
[topological_space.second_countable_topology E] [measurable_space E] [borel_space E]
{μ : measure α} (f : simple_func α E μ) : norm f = ennreal.to_real (edist (↑f) 0) :=
rfl
/-- Not declared as an instance as `α →₁ₛ[μ] E` will only be useful in the construction of the
Bochner integral. -/
protected def normed_group {α : Type u_1} {E : Type u_2} [measurable_space α] [normed_group E]
[topological_space.second_countable_topology E] [measurable_space E] [borel_space E]
{μ : measure α} : normed_group (simple_func α E μ) :=
normed_group.of_add_dist sorry sorry
/-- Not declared as an instance as `α →₁ₛ[μ] E` will only be useful in the construction of the
Bochner integral. -/
protected def has_scalar {α : Type u_1} {E : Type u_2} [measurable_space α] [normed_group E]
[topological_space.second_countable_topology E] [measurable_space E] [borel_space E]
{μ : measure α} {𝕜 : Type u_4} [normed_field 𝕜] [normed_space 𝕜 E] :
has_scalar 𝕜 (simple_func α E μ) :=
has_scalar.mk fun (k : 𝕜) (f : simple_func α E μ) => { val := k • ↑f, property := sorry }
@[simp] theorem coe_smul {α : Type u_1} {E : Type u_2} [measurable_space α] [normed_group E]
[topological_space.second_countable_topology E] [measurable_space E] [borel_space E]
{μ : measure α} {𝕜 : Type u_4} [normed_field 𝕜] [normed_space 𝕜 E] (c : 𝕜)
(f : simple_func α E μ) : ↑(c • f) = c • ↑f :=
rfl
/-- Not declared as an instance as `α →₁ₛ[μ] E` will only be useful in the construction of the
Bochner integral. -/
protected def semimodule {α : Type u_1} {E : Type u_2} [measurable_space α] [normed_group E]
[topological_space.second_countable_topology E] [measurable_space E] [borel_space E]
{μ : measure α} {𝕜 : Type u_4} [normed_field 𝕜] [normed_space 𝕜 E] :
semimodule 𝕜 (simple_func α E μ) :=
semimodule.mk sorry sorry
/-- Not declared as an instance as `α →₁ₛ[μ] E` will only be useful in the construction of the
Bochner integral. -/
protected def normed_space {α : Type u_1} {E : Type u_2} [measurable_space α] [normed_group E]
[topological_space.second_countable_topology E] [measurable_space E] [borel_space E]
{μ : measure α} {𝕜 : Type u_4} [normed_field 𝕜] [normed_space 𝕜 E] :
normed_space 𝕜 (simple_func α E μ) :=
normed_space.mk sorry
/-- Construct the equivalence class `[f]` of an integrable simple function `f`. -/
def of_simple_func {α : Type u_1} {E : Type u_2} [measurable_space α] [normed_group E]
[topological_space.second_countable_topology E] [measurable_space E] [borel_space E]
{μ : measure α} (f : simple_func α E) (hf : integrable ⇑f) : simple_func α E μ :=
{ val := of_fun (⇑f) hf, property := sorry }
theorem of_simple_func_eq_of_fun {α : Type u_1} {E : Type u_2} [measurable_space α] [normed_group E]
[topological_space.second_countable_topology E] [measurable_space E] [borel_space E]
{μ : measure α} (f : simple_func α E) (hf : integrable ⇑f) :
↑(of_simple_func f hf) = of_fun (⇑f) hf :=
rfl
theorem of_simple_func_eq_mk {α : Type u_1} {E : Type u_2} [measurable_space α] [normed_group E]
[topological_space.second_countable_topology E] [measurable_space E] [borel_space E]
{μ : measure α} (f : simple_func α E) (hf : integrable ⇑f) :
↑(of_simple_func f hf) = ae_eq_fun.mk (⇑f) (simple_func.ae_measurable f) :=
rfl
theorem of_simple_func_zero {α : Type u_1} {E : Type u_2} [measurable_space α] [normed_group E]
[topological_space.second_countable_topology E] [measurable_space E] [borel_space E]
{μ : measure α} : of_simple_func 0 (integrable_zero α E μ) = 0 :=
rfl
theorem of_simple_func_add {α : Type u_1} {E : Type u_2} [measurable_space α] [normed_group E]
[topological_space.second_countable_topology E] [measurable_space E] [borel_space E]
{μ : measure α} (f : simple_func α E) (g : simple_func α E) (hf : integrable ⇑f)
(hg : integrable ⇑g) :
of_simple_func (f + g) (integrable.add hf hg) = of_simple_func f hf + of_simple_func g hg :=
rfl
theorem of_simple_func_neg {α : Type u_1} {E : Type u_2} [measurable_space α] [normed_group E]
[topological_space.second_countable_topology E] [measurable_space E] [borel_space E]
{μ : measure α} (f : simple_func α E) (hf : integrable ⇑f) :
of_simple_func (-f) (integrable.neg hf) = -of_simple_func f hf :=
rfl
theorem of_simple_func_sub {α : Type u_1} {E : Type u_2} [measurable_space α] [normed_group E]
[topological_space.second_countable_topology E] [measurable_space E] [borel_space E]
{μ : measure α} (f : simple_func α E) (g : simple_func α E) (hf : integrable ⇑f)
(hg : integrable ⇑g) :
of_simple_func (f - g) (integrable.sub hf hg) = of_simple_func f hf - of_simple_func g hg :=
sorry
theorem of_simple_func_smul {α : Type u_1} {E : Type u_2} [measurable_space α] [normed_group E]
[topological_space.second_countable_topology E] [measurable_space E] [borel_space E]
{μ : measure α} {𝕜 : Type u_4} [normed_field 𝕜] [normed_space 𝕜 E] (f : simple_func α E)
(hf : integrable ⇑f) (c : 𝕜) :
of_simple_func (c • f) (integrable.smul c hf) = c • of_simple_func f hf :=
rfl
theorem norm_of_simple_func {α : Type u_1} {E : Type u_2} [measurable_space α] [normed_group E]
[topological_space.second_countable_topology E] [measurable_space E] [borel_space E]
{μ : measure α} (f : simple_func α E) (hf : integrable ⇑f) :
norm (of_simple_func f hf) =
ennreal.to_real (lintegral μ fun (a : α) => edist (coe_fn f a) 0) :=
rfl
/-- Find a representative of a `l1.simple_func`. -/
def to_simple_func {α : Type u_1} {E : Type u_2} [measurable_space α] [normed_group E]
[topological_space.second_countable_topology E] [measurable_space E] [borel_space E]
{μ : measure α} (f : simple_func α E μ) : simple_func α E :=
classical.some sorry
/-- `f.to_simple_func` is measurable. -/
protected theorem measurable {α : Type u_1} {E : Type u_2} [measurable_space α] [normed_group E]
[topological_space.second_countable_topology E] [measurable_space E] [borel_space E]
{μ : measure α} (f : simple_func α E μ) : measurable ⇑(to_simple_func f) :=
simple_func.measurable (to_simple_func f)
protected theorem ae_measurable {α : Type u_1} {E : Type u_2} [measurable_space α] [normed_group E]
[topological_space.second_countable_topology E] [measurable_space E] [borel_space E]
{μ : measure α} (f : simple_func α E μ) : ae_measurable ⇑(to_simple_func f) :=
measurable.ae_measurable (simple_func.measurable f)
/-- `f.to_simple_func` is integrable. -/
protected theorem integrable {α : Type u_1} {E : Type u_2} [measurable_space α] [normed_group E]
[topological_space.second_countable_topology E] [measurable_space E] [borel_space E]
{μ : measure α} (f : simple_func α E μ) : integrable ⇑(to_simple_func f) :=
sorry
theorem of_simple_func_to_simple_func {α : Type u_1} {E : Type u_2} [measurable_space α]
[normed_group E] [topological_space.second_countable_topology E] [measurable_space E]
[borel_space E] {μ : measure α} (f : simple_func α E μ) :
of_simple_func (to_simple_func f) (simple_func.integrable f) = f :=
sorry
theorem to_simple_func_of_simple_func {α : Type u_1} {E : Type u_2} [measurable_space α]
[normed_group E] [topological_space.second_countable_topology E] [measurable_space E]
[borel_space E] {μ : measure α} (f : simple_func α E) (hfi : integrable ⇑f) :
filter.eventually_eq (measure.ae μ) ⇑(to_simple_func (of_simple_func f hfi)) ⇑f :=
sorry
theorem to_simple_func_eq_to_fun {α : Type u_1} {E : Type u_2} [measurable_space α] [normed_group E]
[topological_space.second_countable_topology E] [measurable_space E] [borel_space E]
{μ : measure α} (f : simple_func α E μ) :
filter.eventually_eq (measure.ae μ) ⇑(to_simple_func f) ⇑f :=
sorry
theorem zero_to_simple_func (α : Type u_1) (E : Type u_2) [measurable_space α] [normed_group E]
[topological_space.second_countable_topology E] [measurable_space E] [borel_space E]
{μ : measure α} : filter.eventually_eq (measure.ae μ) (⇑(to_simple_func 0)) 0 :=
sorry
theorem add_to_simple_func {α : Type u_1} {E : Type u_2} [measurable_space α] [normed_group E]
[topological_space.second_countable_topology E] [measurable_space E] [borel_space E]
{μ : measure α} (f : simple_func α E μ) (g : simple_func α E μ) :
filter.eventually_eq (measure.ae μ) (⇑(to_simple_func (f + g)))
(⇑(to_simple_func f) + ⇑(to_simple_func g)) :=
sorry
theorem neg_to_simple_func {α : Type u_1} {E : Type u_2} [measurable_space α] [normed_group E]
[topological_space.second_countable_topology E] [measurable_space E] [borel_space E]
{μ : measure α} (f : simple_func α E μ) :
filter.eventually_eq (measure.ae μ) (⇑(to_simple_func (-f))) (-⇑(to_simple_func f)) :=
sorry
theorem sub_to_simple_func {α : Type u_1} {E : Type u_2} [measurable_space α] [normed_group E]
[topological_space.second_countable_topology E] [measurable_space E] [borel_space E]
{μ : measure α} (f : simple_func α E μ) (g : simple_func α E μ) :
filter.eventually_eq (measure.ae μ) (⇑(to_simple_func (f - g)))
(⇑(to_simple_func f) - ⇑(to_simple_func g)) :=
sorry
theorem smul_to_simple_func {α : Type u_1} {E : Type u_2} [measurable_space α] [normed_group E]
[topological_space.second_countable_topology E] [measurable_space E] [borel_space E]
{μ : measure α} {𝕜 : Type u_4} [normed_field 𝕜] [normed_space 𝕜 E] (k : 𝕜)
(f : simple_func α E μ) :
filter.eventually_eq (measure.ae μ) (⇑(to_simple_func (k • f))) (k • ⇑(to_simple_func f)) :=
sorry
theorem lintegral_edist_to_simple_func_lt_top {α : Type u_1} {E : Type u_2} [measurable_space α]
[normed_group E] [topological_space.second_countable_topology E] [measurable_space E]
[borel_space E] {μ : measure α} (f : simple_func α E μ) (g : simple_func α E μ) :
(lintegral μ fun (x : α) => edist (coe_fn (to_simple_func f) x) (coe_fn (to_simple_func g) x)) <
⊤ :=
sorry
theorem dist_to_simple_func {α : Type u_1} {E : Type u_2} [measurable_space α] [normed_group E]
[topological_space.second_countable_topology E] [measurable_space E] [borel_space E]
{μ : measure α} (f : simple_func α E μ) (g : simple_func α E μ) :
dist f g =
ennreal.to_real
(lintegral μ
fun (x : α) => edist (coe_fn (to_simple_func f) x) (coe_fn (to_simple_func g) x)) :=
sorry
theorem norm_to_simple_func {α : Type u_1} {E : Type u_2} [measurable_space α] [normed_group E]
[topological_space.second_countable_topology E] [measurable_space E] [borel_space E]
{μ : measure α} (f : simple_func α E μ) :
norm f = ennreal.to_real (lintegral μ fun (a : α) => ↑(nnnorm (coe_fn (to_simple_func f) a))) :=
sorry
-- calc ∥f∥ = ennreal.to_real (∫⁻ (x : α), (coe ∘ nnnorm) (f.to_simple_func x) ∂μ) :
theorem norm_eq_integral {α : Type u_1} {E : Type u_2} [measurable_space α] [normed_group E]
[topological_space.second_countable_topology E] [measurable_space E] [borel_space E]
{μ : measure α} (f : simple_func α E μ) :
norm f = simple_func.integral μ (simple_func.map norm (to_simple_func f)) :=
sorry
-- by { rw norm_to_simple_func }
-- ... = (f.to_simple_func.map norm).integral μ :
protected theorem uniform_continuous {α : Type u_1} {E : Type u_2} [measurable_space α]
[normed_group E] [topological_space.second_countable_topology E] [measurable_space E]
[borel_space E] {μ : measure α} : uniform_continuous coe :=
uniform_continuous_comap
protected theorem uniform_embedding {α : Type u_1} {E : Type u_2} [measurable_space α]
[normed_group E] [topological_space.second_countable_topology E] [measurable_space E]
[borel_space E] {μ : measure α} : uniform_embedding coe :=
uniform_embedding_comap subtype.val_injective
protected theorem uniform_inducing {α : Type u_1} {E : Type u_2} [measurable_space α]
[normed_group E] [topological_space.second_countable_topology E] [measurable_space E]
[borel_space E] {μ : measure α} : uniform_inducing coe :=
uniform_embedding.to_uniform_inducing simple_func.uniform_embedding
protected theorem dense_embedding {α : Type u_1} {E : Type u_2} [measurable_space α]
[normed_group E] [topological_space.second_countable_topology E] [measurable_space E]
[borel_space E] {μ : measure α} : dense_embedding coe :=
sorry
protected theorem dense_inducing {α : Type u_1} {E : Type u_2} [measurable_space α] [normed_group E]
[topological_space.second_countable_topology E] [measurable_space E] [borel_space E]
{μ : measure α} : dense_inducing coe :=
dense_embedding.to_dense_inducing simple_func.dense_embedding
protected theorem dense_range {α : Type u_1} {E : Type u_2} [measurable_space α] [normed_group E]
[topological_space.second_countable_topology E] [measurable_space E] [borel_space E]
{μ : measure α} : dense_range coe :=
dense_inducing.dense simple_func.dense_inducing
/-- The uniform and dense embedding of L1 simple functions into L1 functions. -/
def coe_to_l1 (α : Type u_1) (E : Type u_2) [measurable_space α] [normed_group E]
[topological_space.second_countable_topology E] [measurable_space E] [borel_space E]
{μ : measure α} (𝕜 : Type u_4) [normed_field 𝕜] [normed_space 𝕜 E] :
continuous_linear_map 𝕜 (simple_func α E μ) (l1 α E μ) :=
continuous_linear_map.mk (linear_map.mk coe sorry sorry)
/-- Positive part of a simple function in L1 space. -/
def pos_part {α : Type u_1} [measurable_space α] {μ : measure α} (f : simple_func α ℝ μ) :
simple_func α ℝ μ :=
{ val := pos_part ↑f, property := sorry }
/-- Negative part of a simple function in L1 space. -/
def neg_part {α : Type u_1} [measurable_space α] {μ : measure α} (f : simple_func α ℝ μ) :
simple_func α ℝ μ :=
pos_part (-f)
theorem coe_pos_part {α : Type u_1} [measurable_space α] {μ : measure α} (f : simple_func α ℝ μ) :
↑(pos_part f) = pos_part ↑f :=
rfl
theorem coe_neg_part {α : Type u_1} [measurable_space α] {μ : measure α} (f : simple_func α ℝ μ) :
↑(neg_part f) = neg_part ↑f :=
rfl
/-! Define the Bochner integral on `α →₁ₛ[μ] E` and prove basic properties of this integral. -/
/-- The Bochner integral over simple functions in l1 space. -/
def integral {α : Type u_1} {E : Type u_2} [measurable_space α] [normed_group E]
[topological_space.second_countable_topology E] [measurable_space E] [borel_space E]
{μ : measure α} [normed_space ℝ E] (f : simple_func α E μ) : E :=
simple_func.integral μ (to_simple_func f)
theorem integral_eq_integral {α : Type u_1} {E : Type u_2} [measurable_space α] [normed_group E]
[topological_space.second_countable_topology E] [measurable_space E] [borel_space E]
{μ : measure α} [normed_space ℝ E] (f : simple_func α E μ) :
integral f = simple_func.integral μ (to_simple_func f) :=
rfl
theorem integral_eq_lintegral {α : Type u_1} [measurable_space α] {μ : measure α}
{f : simple_func α ℝ μ} (h_pos : filter.eventually_le (measure.ae μ) 0 ⇑(to_simple_func f)) :
integral f =
ennreal.to_real
(lintegral μ fun (a : α) => ennreal.of_real (coe_fn (to_simple_func f) a)) :=
sorry
theorem integral_congr {α : Type u_1} {E : Type u_2} [measurable_space α] [normed_group E]
[topological_space.second_countable_topology E] [measurable_space E] [borel_space E]
{μ : measure α} [normed_space ℝ E] {f : simple_func α E μ} {g : simple_func α E μ}
(h : filter.eventually_eq (measure.ae μ) ⇑(to_simple_func f) ⇑(to_simple_func g)) :
integral f = integral g :=
simple_func.integral_congr (simple_func.integrable f) h
theorem integral_add {α : Type u_1} {E : Type u_2} [measurable_space α] [normed_group E]
[topological_space.second_countable_topology E] [measurable_space E] [borel_space E]
{μ : measure α} [normed_space ℝ E] (f : simple_func α E μ) (g : simple_func α E μ) :
integral (f + g) = integral f + integral g :=
sorry
theorem integral_smul {α : Type u_1} {E : Type u_2} [measurable_space α] [normed_group E]
[topological_space.second_countable_topology E] [measurable_space E] [borel_space E]
{μ : measure α} [normed_space ℝ E] (r : ℝ) (f : simple_func α E μ) :
integral (r • f) = r • integral f :=
sorry
theorem norm_integral_le_norm {α : Type u_1} {E : Type u_2} [measurable_space α] [normed_group E]
[topological_space.second_countable_topology E] [measurable_space E] [borel_space E]
{μ : measure α} [normed_space ℝ E] (f : simple_func α E μ) : norm (integral f) ≤ norm f :=
eq.mpr (id (Eq._oldrec (Eq.refl (norm (integral f) ≤ norm f)) (integral.equations._eqn_1 f)))
(eq.mpr
(id
(Eq._oldrec (Eq.refl (norm (simple_func.integral μ (to_simple_func f)) ≤ norm f))
(norm_eq_integral f)))
(simple_func.norm_integral_le_integral_norm (to_simple_func f) (simple_func.integrable f)))
/-- The Bochner integral over simple functions in l1 space as a continuous linear map. -/
def integral_clm {α : Type u_1} {E : Type u_2} [measurable_space α] [normed_group E]
[topological_space.second_countable_topology E] [measurable_space E] [borel_space E]
{μ : measure α} [normed_space ℝ E] : continuous_linear_map ℝ (simple_func α E μ) E :=
linear_map.mk_continuous (linear_map.mk integral integral_add integral_smul) 1 sorry
theorem norm_Integral_le_one {α : Type u_1} {E : Type u_2} [measurable_space α] [normed_group E]
[topological_space.second_countable_topology E] [measurable_space E] [borel_space E]
{μ : measure α} [normed_space ℝ E] : norm integral_clm ≤ 1 :=
linear_map.mk_continuous_norm_le (linear_map.mk integral integral_add integral_smul) zero_le_one
integral_clm._proof_1
theorem pos_part_to_simple_func {α : Type u_1} [measurable_space α] {μ : measure α}
(f : simple_func α ℝ μ) :
filter.eventually_eq (measure.ae μ) ⇑(to_simple_func (pos_part f))
⇑(simple_func.pos_part (to_simple_func f)) :=
sorry
theorem neg_part_to_simple_func {α : Type u_1} [measurable_space α] {μ : measure α}
(f : simple_func α ℝ μ) :
filter.eventually_eq (measure.ae μ) ⇑(to_simple_func (neg_part f))
⇑(simple_func.neg_part (to_simple_func f)) :=
sorry
theorem integral_eq_norm_pos_part_sub {α : Type u_1} [measurable_space α] {μ : measure α}
(f : simple_func α ℝ μ) : integral f = norm (pos_part f) - norm (neg_part f) :=
sorry
end simple_func
/-- The Bochner integral in l1 space as a continuous linear map. -/
def integral_clm {α : Type u_1} {E : Type u_2} [measurable_space α] [normed_group E]
[topological_space.second_countable_topology E] [measurable_space E] [borel_space E]
{μ : measure α} [normed_space ℝ E] [complete_space E] : continuous_linear_map ℝ (l1 α E μ) E :=
continuous_linear_map.extend simple_func.integral_clm (simple_func.coe_to_l1 α E ℝ)
simple_func.dense_range simple_func.uniform_inducing
/-- The Bochner integral in l1 space -/
def integral {α : Type u_1} {E : Type u_2} [measurable_space α] [normed_group E]
[topological_space.second_countable_topology E] [measurable_space E] [borel_space E]
{μ : measure α} [normed_space ℝ E] [complete_space E] (f : l1 α E μ) : E :=
coe_fn integral_clm f
theorem integral_eq {α : Type u_1} {E : Type u_2} [measurable_space α] [normed_group E]
[topological_space.second_countable_topology E] [measurable_space E] [borel_space E]
{μ : measure α} [normed_space ℝ E] [complete_space E] (f : l1 α E μ) :
integral f = coe_fn integral_clm f :=
rfl
theorem simple_func.integral_l1_eq_integral {α : Type u_1} {E : Type u_2} [measurable_space α]
[normed_group E] [topological_space.second_countable_topology E] [measurable_space E]
[borel_space E] {μ : measure α} [normed_space ℝ E] [complete_space E] (f : simple_func α E μ) :
integral ↑f = simple_func.integral f :=
uniformly_extend_of_ind simple_func.uniform_inducing simple_func.dense_range
(continuous_linear_map.uniform_continuous simple_func.integral_clm) f
@[simp] theorem integral_zero (α : Type u_1) (E : Type u_2) [measurable_space α] [normed_group E]
[topological_space.second_countable_topology E] [measurable_space E] [borel_space E]
{μ : measure α} [normed_space ℝ E] [complete_space E] : integral 0 = 0 :=
continuous_linear_map.map_zero integral_clm
theorem integral_add {α : Type u_1} {E : Type u_2} [measurable_space α] [normed_group E]
[topological_space.second_countable_topology E] [measurable_space E] [borel_space E]
{μ : measure α} [normed_space ℝ E] [complete_space E] (f : l1 α E μ) (g : l1 α E μ) :
integral (f + g) = integral f + integral g :=
continuous_linear_map.map_add integral_clm f g
theorem integral_neg {α : Type u_1} {E : Type u_2} [measurable_space α] [normed_group E]
[topological_space.second_countable_topology E] [measurable_space E] [borel_space E]
{μ : measure α} [normed_space ℝ E] [complete_space E] (f : l1 α E μ) :
integral (-f) = -integral f :=
continuous_linear_map.map_neg integral_clm f
theorem integral_sub {α : Type u_1} {E : Type u_2} [measurable_space α] [normed_group E]
[topological_space.second_countable_topology E] [measurable_space E] [borel_space E]
{μ : measure α} [normed_space ℝ E] [complete_space E] (f : l1 α E μ) (g : l1 α E μ) :
integral (f - g) = integral f - integral g :=
continuous_linear_map.map_sub integral_clm f g
theorem integral_smul {α : Type u_1} {E : Type u_2} [measurable_space α] [normed_group E]
[topological_space.second_countable_topology E] [measurable_space E] [borel_space E]
{μ : measure α} [normed_space ℝ E] [complete_space E] (r : ℝ) (f : l1 α E μ) :
integral (r • f) = r • integral f :=
continuous_linear_map.map_smul r integral_clm f
theorem norm_Integral_le_one {α : Type u_1} {E : Type u_2} [measurable_space α] [normed_group E]
[topological_space.second_countable_topology E] [measurable_space E] [borel_space E]
{μ : measure α} [normed_space ℝ E] [complete_space E] : norm integral_clm ≤ 1 :=
sorry
theorem norm_integral_le {α : Type u_1} {E : Type u_2} [measurable_space α] [normed_group E]
[topological_space.second_countable_topology E] [measurable_space E] [borel_space E]
{μ : measure α} [normed_space ℝ E] [complete_space E] (f : l1 α E μ) :
norm (integral f) ≤ norm f :=
sorry
theorem continuous_integral {α : Type u_1} {E : Type u_2} [measurable_space α] [normed_group E]
[topological_space.second_countable_topology E] [measurable_space E] [borel_space E]
{μ : measure α} [normed_space ℝ E] [complete_space E] :
continuous fun (f : l1 α E μ) => integral f :=
sorry
theorem integral_eq_norm_pos_part_sub {α : Type u_1} [measurable_space α] {μ : measure α}
(f : l1 α ℝ μ) : integral f = norm (pos_part f) - norm (neg_part f) :=
sorry
end l1
/-- The Bochner integral -/
def integral {α : Type u_1} {E : Type u_2} [measurable_space α] [normed_group E]
[topological_space.second_countable_topology E] [normed_space ℝ E] [complete_space E]
[measurable_space E] [borel_space E] (μ : measure α) (f : α → E) : E :=
dite (integrable f) (fun (hf : integrable f) => l1.integral (l1.of_fun f hf))
fun (hf : ¬integrable f) => 0
/-! In the notation for integrals, an expression like `∫ x, g ∥x∥ ∂μ` will not be parsed correctly,
and needs parentheses. We do not set the binding power of `r` to `0`, because then
`∫ x, f x = 0` will be parsed incorrectly. -/
theorem integral_eq {α : Type u_1} {E : Type u_2} [measurable_space α] [normed_group E]
[topological_space.second_countable_topology E] [normed_space ℝ E] [complete_space E]
[measurable_space E] [borel_space E] {μ : measure α} (f : α → E) (hf : integrable f) :
(integral μ fun (a : α) => f a) = l1.integral (l1.of_fun f hf) :=
dif_pos hf
theorem l1.integral_eq_integral {α : Type u_1} {E : Type u_2} [measurable_space α] [normed_group E]
[topological_space.second_countable_topology E] [normed_space ℝ E] [complete_space E]
[measurable_space E] [borel_space E] {μ : measure α} (f : l1 α E μ) :
l1.integral f = integral μ fun (a : α) => coe_fn f a :=
sorry
theorem integral_undef {α : Type u_1} {E : Type u_2} [measurable_space α] [normed_group E]
[topological_space.second_countable_topology E] [normed_space ℝ E] [complete_space E]
[measurable_space E] [borel_space E] {f : α → E} {μ : measure α} (h : ¬integrable f) :
(integral μ fun (a : α) => f a) = 0 :=
dif_neg h
theorem integral_non_ae_measurable {α : Type u_1} {E : Type u_2} [measurable_space α]
[normed_group E] [topological_space.second_countable_topology E] [normed_space ℝ E]
[complete_space E] [measurable_space E] [borel_space E] {f : α → E} {μ : measure α}
(h : ¬ae_measurable f) : (integral μ fun (a : α) => f a) = 0 :=
integral_undef (not_and_of_not_left (has_finite_integral fun (a : α) => f a) h)
theorem integral_zero (α : Type u_1) (E : Type u_2) [measurable_space α] [normed_group E]
[topological_space.second_countable_topology E] [normed_space ℝ E] [complete_space E]
[measurable_space E] [borel_space E] {μ : measure α} : (integral μ fun (a : α) => 0) = 0 :=
sorry
@[simp] theorem integral_zero' (α : Type u_1) (E : Type u_2) [measurable_space α] [normed_group E]
[topological_space.second_countable_topology E] [normed_space ℝ E] [complete_space E]
[measurable_space E] [borel_space E] {μ : measure α} : integral μ 0 = 0 :=
integral_zero α E
theorem integral_add {α : Type u_1} {E : Type u_2} [measurable_space α] [normed_group E]
[topological_space.second_countable_topology E] [normed_space ℝ E] [complete_space E]
[measurable_space E] [borel_space E] {f : α → E} {g : α → E} {μ : measure α} (hf : integrable f)
(hg : integrable g) :
(integral μ fun (a : α) => f a + g a) =
(integral μ fun (a : α) => f a) + integral μ fun (a : α) => g a :=
sorry
theorem integral_add' {α : Type u_1} {E : Type u_2} [measurable_space α] [normed_group E]
[topological_space.second_countable_topology E] [normed_space ℝ E] [complete_space E]
[measurable_space E] [borel_space E] {f : α → E} {g : α → E} {μ : measure α} (hf : integrable f)
(hg : integrable g) :
(integral μ fun (a : α) => Add.add f g a) =
(integral μ fun (a : α) => f a) + integral μ fun (a : α) => g a :=
integral_add hf hg
theorem integral_neg {α : Type u_1} {E : Type u_2} [measurable_space α] [normed_group E]
[topological_space.second_countable_topology E] [normed_space ℝ E] [complete_space E]
[measurable_space E] [borel_space E] {μ : measure α} (f : α → E) :
(integral μ fun (a : α) => -f a) = -integral μ fun (a : α) => f a :=
sorry
theorem integral_neg' {α : Type u_1} {E : Type u_2} [measurable_space α] [normed_group E]
[topological_space.second_countable_topology E] [normed_space ℝ E] [complete_space E]
[measurable_space E] [borel_space E] {μ : measure α} (f : α → E) :
(integral μ fun (a : α) => Neg.neg f a) = -integral μ fun (a : α) => f a :=
integral_neg f
theorem integral_sub {α : Type u_1} {E : Type u_2} [measurable_space α] [normed_group E]
[topological_space.second_countable_topology E] [normed_space ℝ E] [complete_space E]
[measurable_space E] [borel_space E] {f : α → E} {g : α → E} {μ : measure α} (hf : integrable f)
(hg : integrable g) :
(integral μ fun (a : α) => f a - g a) =
(integral μ fun (a : α) => f a) - integral μ fun (a : α) => g a :=
sorry
theorem integral_sub' {α : Type u_1} {E : Type u_2} [measurable_space α] [normed_group E]
[topological_space.second_countable_topology E] [normed_space ℝ E] [complete_space E]
[measurable_space E] [borel_space E] {f : α → E} {g : α → E} {μ : measure α} (hf : integrable f)
(hg : integrable g) :
(integral μ fun (a : α) => Sub.sub f g a) =
(integral μ fun (a : α) => f a) - integral μ fun (a : α) => g a :=
integral_sub hf hg
theorem integral_smul {α : Type u_1} {E : Type u_2} [measurable_space α] [normed_group E]
[topological_space.second_countable_topology E] [normed_space ℝ E] [complete_space E]
[measurable_space E] [borel_space E] {μ : measure α} (r : ℝ) (f : α → E) :
(integral μ fun (a : α) => r • f a) = r • integral μ fun (a : α) => f a :=
sorry
theorem integral_mul_left {α : Type u_1} [measurable_space α] {μ : measure α} (r : ℝ) (f : α → ℝ) :
(integral μ fun (a : α) => r * f a) = r * integral μ fun (a : α) => f a :=
integral_smul r f
theorem integral_mul_right {α : Type u_1} [measurable_space α] {μ : measure α} (r : ℝ) (f : α → ℝ) :
(integral μ fun (a : α) => f a * r) = (integral μ fun (a : α) => f a) * r :=
sorry
theorem integral_div {α : Type u_1} [measurable_space α] {μ : measure α} (r : ℝ) (f : α → ℝ) :
(integral μ fun (a : α) => f a / r) = (integral μ fun (a : α) => f a) / r :=
integral_mul_right (r⁻¹) f
theorem integral_congr_ae {α : Type u_1} {E : Type u_2} [measurable_space α] [normed_group E]
[topological_space.second_countable_topology E] [normed_space ℝ E] [complete_space E]
[measurable_space E] [borel_space E] {f : α → E} {g : α → E} {μ : measure α}
(h : filter.eventually_eq (measure.ae μ) f g) :
(integral μ fun (a : α) => f a) = integral μ fun (a : α) => g a :=
sorry
@[simp] theorem l1.integral_of_fun_eq_integral {α : Type u_1} {E : Type u_2} [measurable_space α]
[normed_group E] [topological_space.second_countable_topology E] [normed_space ℝ E]
[complete_space E] [measurable_space E] [borel_space E] {μ : measure α} {f : α → E}
(hf : integrable f) :
(integral μ fun (a : α) => coe_fn (l1.of_fun f hf) a) = integral μ fun (a : α) => f a :=
integral_congr_ae (l1.to_fun_of_fun f hf)
theorem continuous_integral {α : Type u_1} {E : Type u_2} [measurable_space α] [normed_group E]
[topological_space.second_countable_topology E] [normed_space ℝ E] [complete_space E]
[measurable_space E] [borel_space E] {μ : measure α} :
continuous fun (f : l1 α E μ) => integral μ fun (a : α) => coe_fn f a :=
sorry
theorem norm_integral_le_lintegral_norm {α : Type u_1} {E : Type u_2} [measurable_space α]
[normed_group E] [topological_space.second_countable_topology E] [normed_space ℝ E]
[complete_space E] [measurable_space E] [borel_space E] {μ : measure α} (f : α → E) :
norm (integral μ fun (a : α) => f a) ≤
ennreal.to_real (lintegral μ fun (a : α) => ennreal.of_real (norm (f a))) :=
sorry
theorem ennnorm_integral_le_lintegral_ennnorm {α : Type u_1} {E : Type u_2} [measurable_space α]
[normed_group E] [topological_space.second_countable_topology E] [normed_space ℝ E]
[complete_space E] [measurable_space E] [borel_space E] {μ : measure α} (f : α → E) :
↑(nnnorm (integral μ fun (a : α) => f a)) ≤ lintegral μ fun (a : α) => ↑(nnnorm (f a)) :=
sorry
theorem integral_eq_zero_of_ae {α : Type u_1} {E : Type u_2} [measurable_space α] [normed_group E]
[topological_space.second_countable_topology E] [normed_space ℝ E] [complete_space E]
[measurable_space E] [borel_space E] {μ : measure α} {f : α → E}
(hf : filter.eventually_eq (measure.ae μ) f 0) : (integral μ fun (a : α) => f a) = 0 :=
sorry
/-- If `f` has finite integral, then `∫ x in s, f x ∂μ` is absolutely continuous in `s`: it tends
to zero as `μ s` tends to zero. -/
theorem has_finite_integral.tendsto_set_integral_nhds_zero {α : Type u_1} {E : Type u_2}
[measurable_space α] [normed_group E] [topological_space.second_countable_topology E]
[normed_space ℝ E] [complete_space E] [measurable_space E] [borel_space E] {μ : measure α}
{ι : Type u_3} {f : α → E} (hf : has_finite_integral f) {l : filter ι} {s : ι → set α}
(hs : filter.tendsto (⇑μ ∘ s) l (nhds 0)) :
filter.tendsto (fun (i : ι) => integral (measure.restrict μ (s i)) fun (x : α) => f x) l
(nhds 0) :=
sorry
/-- If `f` is integrable, then `∫ x in s, f x ∂μ` is absolutely continuous in `s`: it tends
to zero as `μ s` tends to zero. -/
theorem integrable.tendsto_set_integral_nhds_zero {α : Type u_1} {E : Type u_2} [measurable_space α]
[normed_group E] [topological_space.second_countable_topology E] [normed_space ℝ E]
[complete_space E] [measurable_space E] [borel_space E] {μ : measure α} {ι : Type u_3}
{f : α → E} (hf : integrable f) {l : filter ι} {s : ι → set α}
(hs : filter.tendsto (⇑μ ∘ s) l (nhds 0)) :
filter.tendsto (fun (i : ι) => integral (measure.restrict μ (s i)) fun (x : α) => f x) l
(nhds 0) :=
has_finite_integral.tendsto_set_integral_nhds_zero (and.right hf) hs
/-- If `F i → f` in `L1`, then `∫ x, F i x ∂μ → ∫ x, f x∂μ`. -/
theorem tendsto_integral_of_l1 {α : Type u_1} {E : Type u_2} [measurable_space α] [normed_group E]
[topological_space.second_countable_topology E] [normed_space ℝ E] [complete_space E]
[measurable_space E] [borel_space E] {μ : measure α} {ι : Type u_3} (f : α → E)
(hfi : integrable f) {F : ι → α → E} {l : filter ι}
(hFi : filter.eventually (fun (i : ι) => integrable (F i)) l)
(hF :
filter.tendsto (fun (i : ι) => lintegral μ fun (x : α) => edist (F i x) (f x)) l (nhds 0)) :
filter.tendsto (fun (i : ι) => integral μ fun (x : α) => F i x) l
(nhds (integral μ fun (x : α) => f x)) :=
sorry
/-- Lebesgue dominated convergence theorem provides sufficient conditions under which almost
everywhere convergence of a sequence of functions implies the convergence of their integrals. -/
theorem tendsto_integral_of_dominated_convergence {α : Type u_1} {E : Type u_2} [measurable_space α]
[normed_group E] [topological_space.second_countable_topology E] [normed_space ℝ E]
[complete_space E] [measurable_space E] [borel_space E] {μ : measure α} {F : ℕ → α → E}
{f : α → E} (bound : α → ℝ) (F_measurable : ∀ (n : ℕ), ae_measurable (F n))
(f_measurable : ae_measurable f) (bound_integrable : integrable bound)
(h_bound : ∀ (n : ℕ), filter.eventually (fun (a : α) => norm (F n a) ≤ bound a) (measure.ae μ))
(h_lim :
filter.eventually
(fun (a : α) => filter.tendsto (fun (n : ℕ) => F n a) filter.at_top (nhds (f a)))
(measure.ae μ)) :
filter.tendsto (fun (n : ℕ) => integral μ fun (a : α) => F n a) filter.at_top
(nhds (integral μ fun (a : α) => f a)) :=
sorry
/-- Lebesgue dominated convergence theorem for filters with a countable basis -/
theorem tendsto_integral_filter_of_dominated_convergence {α : Type u_1} {E : Type u_2}
[measurable_space α] [normed_group E] [topological_space.second_countable_topology E]
[normed_space ℝ E] [complete_space E] [measurable_space E] [borel_space E] {μ : measure α}
{ι : Type u_3} {l : filter ι} {F : ι → α → E} {f : α → E} (bound : α → ℝ)
(hl_cb : filter.is_countably_generated l)
(hF_meas : filter.eventually (fun (n : ι) => ae_measurable (F n)) l)
(f_measurable : ae_measurable f)
(h_bound :
filter.eventually
(fun (n : ι) => filter.eventually (fun (a : α) => norm (F n a) ≤ bound a) (measure.ae μ)) l)
(bound_integrable : integrable bound)
(h_lim :
filter.eventually (fun (a : α) => filter.tendsto (fun (n : ι) => F n a) l (nhds (f a)))
(measure.ae μ)) :
filter.tendsto (fun (n : ι) => integral μ fun (a : α) => F n a) l
(nhds (integral μ fun (a : α) => f a)) :=
sorry
/-- The Bochner integral of a real-valued function `f : α → ℝ` is the difference between the
integral of the positive part of `f` and the integral of the negative part of `f`. -/
theorem integral_eq_lintegral_max_sub_lintegral_min {α : Type u_1} [measurable_space α]
{μ : measure α} {f : α → ℝ} (hf : integrable f) :
(integral μ fun (a : α) => f a) =
ennreal.to_real (lintegral μ fun (a : α) => ennreal.of_real (max (f a) 0)) -
ennreal.to_real (lintegral μ fun (a : α) => ennreal.of_real (-min (f a) 0)) :=
sorry
-- Go to the `L¹` space
-- Go to the `L¹` space
theorem integral_eq_lintegral_of_nonneg_ae {α : Type u_1} [measurable_space α] {μ : measure α}
{f : α → ℝ} (hf : filter.eventually_le (measure.ae μ) 0 f) (hfm : ae_measurable f) :
(integral μ fun (a : α) => f a) =
ennreal.to_real (lintegral μ fun (a : α) => ennreal.of_real (f a)) :=
sorry
theorem integral_nonneg_of_ae {α : Type u_1} [measurable_space α] {μ : measure α} {f : α → ℝ}
(hf : filter.eventually_le (measure.ae μ) 0 f) : 0 ≤ integral μ fun (a : α) => f a :=
sorry
theorem lintegral_coe_eq_integral {α : Type u_1} [measurable_space α] {μ : measure α}
(f : α → nnreal) (hfi : integrable fun (x : α) => ↑(f x)) :
(lintegral μ fun (a : α) => ↑(f a)) = ennreal.of_real (integral μ fun (x : α) => ↑(f x)) :=
sorry
theorem integral_to_real {α : Type u_1} [measurable_space α] {μ : measure α} {f : α → ennreal}
(hfm : ae_measurable f) (hf : filter.eventually (fun (x : α) => f x < ⊤) (measure.ae μ)) :
(integral μ fun (a : α) => ennreal.to_real (f a)) =
ennreal.to_real (lintegral μ fun (a : α) => f a) :=
sorry
theorem integral_nonneg {α : Type u_1} [measurable_space α] {μ : measure α} {f : α → ℝ}
(hf : 0 ≤ f) : 0 ≤ integral μ fun (a : α) => f a :=
integral_nonneg_of_ae (filter.eventually_of_forall hf)
theorem integral_nonpos_of_ae {α : Type u_1} [measurable_space α] {μ : measure α} {f : α → ℝ}
(hf : filter.eventually_le (measure.ae μ) f 0) : (integral μ fun (a : α) => f a) ≤ 0 :=
sorry
theorem integral_nonpos {α : Type u_1} [measurable_space α] {μ : measure α} {f : α → ℝ}
(hf : f ≤ 0) : (integral μ fun (a : α) => f a) ≤ 0 :=
integral_nonpos_of_ae (filter.eventually_of_forall hf)
theorem integral_eq_zero_iff_of_nonneg_ae {α : Type u_1} [measurable_space α] {μ : measure α}
{f : α → ℝ} (hf : filter.eventually_le (measure.ae μ) 0 f) (hfi : integrable f) :
(integral μ fun (x : α) => f x) = 0 ↔ filter.eventually_eq (measure.ae μ) f 0 :=
sorry
theorem integral_eq_zero_iff_of_nonneg {α : Type u_1} [measurable_space α] {μ : measure α}
{f : α → ℝ} (hf : 0 ≤ f) (hfi : integrable f) :
(integral μ fun (x : α) => f x) = 0 ↔ filter.eventually_eq (measure.ae μ) f 0 :=
integral_eq_zero_iff_of_nonneg_ae (filter.eventually_of_forall hf) hfi
theorem integral_pos_iff_support_of_nonneg_ae {α : Type u_1} [measurable_space α] {μ : measure α}
{f : α → ℝ} (hf : filter.eventually_le (measure.ae μ) 0 f) (hfi : integrable f) :
(0 < integral μ fun (x : α) => f x) ↔ 0 < coe_fn μ (function.support f) :=
sorry
theorem integral_pos_iff_support_of_nonneg {α : Type u_1} [measurable_space α] {μ : measure α}
{f : α → ℝ} (hf : 0 ≤ f) (hfi : integrable f) :
(0 < integral μ fun (x : α) => f x) ↔ 0 < coe_fn μ (function.support f) :=
integral_pos_iff_support_of_nonneg_ae (filter.eventually_of_forall hf) hfi
theorem l1.norm_eq_integral_norm {α : Type u_1} [measurable_space α] {μ : measure α} {H : Type u_4}
[normed_group H] [topological_space.second_countable_topology H] [measurable_space H]
[borel_space H] (f : l1 α H μ) : norm f = integral μ fun (a : α) => norm (coe_fn f a) :=
sorry
theorem l1.norm_of_fun_eq_integral_norm {α : Type u_1} [measurable_space α] {μ : measure α}
{H : Type u_4} [normed_group H] [topological_space.second_countable_topology H]
[measurable_space H] [borel_space H] {f : α → H} (hf : integrable f) :
norm (l1.of_fun f hf) = integral μ fun (a : α) => norm (f a) :=
sorry
theorem integral_mono_ae {α : Type u_1} [measurable_space α] {μ : measure α} {f : α → ℝ} {g : α → ℝ}
(hf : integrable f) (hg : integrable g) (h : filter.eventually_le (measure.ae μ) f g) :
(integral μ fun (a : α) => f a) ≤ integral μ fun (a : α) => g a :=
le_of_sub_nonneg
(Eq.subst (integral_sub hg hf) integral_nonneg_of_ae
(filter.eventually.mono h fun (a : α) => sub_nonneg_of_le))
theorem integral_mono {α : Type u_1} [measurable_space α] {μ : measure α} {f : α → ℝ} {g : α → ℝ}
(hf : integrable f) (hg : integrable g) (h : f ≤ g) :
(integral μ fun (a : α) => f a) ≤ integral μ fun (a : α) => g a :=
integral_mono_ae hf hg (filter.eventually_of_forall h)
theorem integral_mono_of_nonneg {α : Type u_1} [measurable_space α] {μ : measure α} {f : α → ℝ}
{g : α → ℝ} (hf : filter.eventually_le (measure.ae μ) 0 f) (hgi : integrable g)
(h : filter.eventually_le (measure.ae μ) f g) :
(integral μ fun (a : α) => f a) ≤ integral μ fun (a : α) => g a :=
sorry
theorem norm_integral_le_integral_norm {α : Type u_1} {E : Type u_2} [measurable_space α]
[normed_group E] [topological_space.second_countable_topology E] [normed_space ℝ E]
[complete_space E] [measurable_space E] [borel_space E] {μ : measure α} (f : α → E) :
norm (integral μ fun (a : α) => f a) ≤ integral μ fun (a : α) => norm (f a) :=
sorry
theorem norm_integral_le_of_norm_le {α : Type u_1} {E : Type u_2} [measurable_space α]
[normed_group E] [topological_space.second_countable_topology E] [normed_space ℝ E]
[complete_space E] [measurable_space E] [borel_space E] {μ : measure α} {f : α → E} {g : α → ℝ}
(hg : integrable g) (h : filter.eventually (fun (x : α) => norm (f x) ≤ g x) (measure.ae μ)) :
norm (integral μ fun (x : α) => f x) ≤ integral μ fun (x : α) => g x :=
le_trans (norm_integral_le_integral_norm f)
(integral_mono_of_nonneg (filter.eventually_of_forall fun (x : α) => norm_nonneg (f x)) hg h)
theorem integral_finset_sum {α : Type u_1} {E : Type u_2} [measurable_space α] [normed_group E]
[topological_space.second_countable_topology E] [normed_space ℝ E] [complete_space E]
[measurable_space E] [borel_space E] {μ : measure α} {ι : Type u_3} (s : finset ι)
{f : ι → α → E} (hf : ∀ (i : ι), integrable (f i)) :
(integral μ fun (a : α) => finset.sum s fun (i : ι) => f i a) =
finset.sum s fun (i : ι) => integral μ fun (a : α) => f i a :=
sorry
theorem simple_func.integral_eq_integral {α : Type u_1} {E : Type u_2} [measurable_space α]
[normed_group E] [topological_space.second_countable_topology E] [normed_space ℝ E]
[complete_space E] [measurable_space E] [borel_space E] {μ : measure α} (f : simple_func α E)
(hfi : integrable ⇑f) : simple_func.integral μ f = integral μ fun (x : α) => coe_fn f x :=
sorry
@[simp] theorem integral_const {α : Type u_1} {E : Type u_2} [measurable_space α] [normed_group E]
[topological_space.second_countable_topology E] [normed_space ℝ E] [complete_space E]
[measurable_space E] [borel_space E] {μ : measure α} (c : E) :
(integral μ fun (x : α) => c) = ennreal.to_real (coe_fn μ set.univ) • c :=
sorry
theorem norm_integral_le_of_norm_le_const {α : Type u_1} {E : Type u_2} [measurable_space α]
[normed_group E] [topological_space.second_countable_topology E] [normed_space ℝ E]
[complete_space E] [measurable_space E] [borel_space E] {μ : measure α} [finite_measure μ]
{f : α → E} {C : ℝ} (h : filter.eventually (fun (x : α) => norm (f x) ≤ C) (measure.ae μ)) :
norm (integral μ fun (x : α) => f x) ≤ C * ennreal.to_real (coe_fn μ set.univ) :=
sorry
theorem tendsto_integral_approx_on_univ_of_measurable {α : Type u_1} {E : Type u_2}
[measurable_space α] [normed_group E] [topological_space.second_countable_topology E]
[normed_space ℝ E] [complete_space E] [measurable_space E] [borel_space E] {μ : measure α}
{f : α → E} (fmeas : measurable f) (hf : integrable f) :
filter.tendsto
(fun (n : ℕ) => simple_func.integral μ (simple_func.approx_on f fmeas set.univ 0 trivial n))
filter.at_top (nhds (integral μ fun (x : α) => f x)) :=
sorry
theorem integral_add_measure {α : Type u_1} {E : Type u_2} [measurable_space α] [normed_group E]
[topological_space.second_countable_topology E] [normed_space ℝ E] [complete_space E]
[measurable_space E] [borel_space E] {μ : measure α} {ν : measure α} {f : α → E}
(hμ : integrable f) (hν : integrable f) :
(integral (μ + ν) fun (x : α) => f x) =
(integral μ fun (x : α) => f x) + integral ν fun (x : α) => f x :=
sorry
@[simp] theorem integral_zero_measure {α : Type u_1} {E : Type u_2} [measurable_space α]
[normed_group E] [topological_space.second_countable_topology E] [normed_space ℝ E]
[complete_space E] [measurable_space E] [borel_space E] (f : α → E) :
(integral 0 fun (x : α) => f x) = 0 :=
sorry
@[simp] theorem integral_smul_measure {α : Type u_1} {E : Type u_2} [measurable_space α]
[normed_group E] [topological_space.second_countable_topology E] [normed_space ℝ E]
[complete_space E] [measurable_space E] [borel_space E] {μ : measure α} (f : α → E)
(c : ennreal) :
(integral (c • μ) fun (x : α) => f x) = ennreal.to_real c • integral μ fun (x : α) => f x :=
sorry
theorem integral_map_of_measurable {α : Type u_1} {E : Type u_2} [measurable_space α]
[normed_group E] [topological_space.second_countable_topology E] [normed_space ℝ E]
[complete_space E] [measurable_space E] [borel_space E] {μ : measure α} {β : Type u_3}
[measurable_space β] {φ : α → β} (hφ : measurable φ) {f : β → E} (hfm : measurable f) :
(integral (coe_fn (measure.map φ) μ) fun (y : β) => f y) = integral μ fun (x : α) => f (φ x) :=
sorry
theorem integral_map {α : Type u_1} {E : Type u_2} [measurable_space α] [normed_group E]
[topological_space.second_countable_topology E] [normed_space ℝ E] [complete_space E]
[measurable_space E] [borel_space E] {μ : measure α} {β : Type u_3} [measurable_space β]
{φ : α → β} (hφ : measurable φ) {f : β → E} (hfm : ae_measurable f) :
(integral (coe_fn (measure.map φ) μ) fun (y : β) => f y) = integral μ fun (x : α) => f (φ x) :=
sorry
theorem integral_dirac' {α : Type u_1} {E : Type u_2} [measurable_space α] [normed_group E]
[topological_space.second_countable_topology E] [normed_space ℝ E] [complete_space E]
[measurable_space E] [borel_space E] (f : α → E) (a : α) (hfm : measurable f) :
(integral (measure.dirac a) fun (x : α) => f x) = f a :=
sorry
theorem integral_dirac {α : Type u_1} {E : Type u_2} [measurable_space α] [normed_group E]
[topological_space.second_countable_topology E] [normed_space ℝ E] [complete_space E]
[measurable_space E] [borel_space E] [measurable_singleton_class α] (f : α → E) (a : α) :
(integral (measure.dirac a) fun (x : α) => f x) = f a :=
sorry
end Mathlib |
1668c034eed8fab260ccb39b366154dedcedbf76 | 56762daf61566a2baf390b5d77988c29c75187e3 | /src/cty.lean | 46492c32d252d4e7c3817f629712f28e355e7369 | [] | no_license | Nicknamen/lie_group | de173ce5f1ffccb945ba05dca23ff27daef0e3b4 | e0d5c4f859654e3dea092702f1320c3c72a49983 | refs/heads/master | 1,674,937,428,196 | 1,607,213,423,000 | 1,607,213,423,000 | 275,196,635 | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 150 | lean | import geometry.manifold.smooth_manifold_with_corners
example : times_cont_diff ℝ ⊤ (λ x : ℝ × ℝ, x.1 * x.2) :=
begin
library_search,
end |
77ecfef45715ebd3720dbab73df952b0d0a6c7d3 | b7f22e51856f4989b970961f794f1c435f9b8f78 | /hott/types/fiber.hlean | f0eee0ee2986ee6a347c9666879c473f98a2dc06 | [
"Apache-2.0"
] | permissive | soonhokong/lean | cb8aa01055ffe2af0fb99a16b4cda8463b882cd1 | 38607e3eb57f57f77c0ac114ad169e9e4262e24f | refs/heads/master | 1,611,187,284,081 | 1,450,766,737,000 | 1,476,122,547,000 | 11,513,992 | 2 | 0 | null | 1,401,763,102,000 | 1,374,182,235,000 | C++ | UTF-8 | Lean | false | false | 7,036 | hlean | /-
Copyright (c) 2015 Floris van Doorn. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Author: Floris van Doorn
Ported from Coq HoTT
Theorems about fibers
-/
import .sigma .eq .pi cubical.squareover
open equiv sigma sigma.ops eq pi
structure fiber {A B : Type} (f : A → B) (b : B) :=
(point : A)
(point_eq : f point = b)
namespace fiber
variables {A B : Type} {f : A → B} {b : B}
protected definition sigma_char [constructor]
(f : A → B) (b : B) : fiber f b ≃ (Σ(a : A), f a = b) :=
begin
fapply equiv.MK,
{intro x, exact ⟨point x, point_eq x⟩},
{intro x, exact (fiber.mk x.1 x.2)},
{intro x, exact abstract begin cases x, apply idp end end},
{intro x, exact abstract begin cases x, apply idp end end},
end
definition fiber_eq_equiv (x y : fiber f b)
: (x = y) ≃ (Σ(p : point x = point y), point_eq x = ap f p ⬝ point_eq y) :=
begin
apply equiv.trans,
apply eq_equiv_fn_eq_of_equiv, apply fiber.sigma_char,
apply equiv.trans,
apply sigma_eq_equiv,
apply sigma_equiv_sigma_right,
intro p,
apply pathover_eq_equiv_Fl,
end
definition fiber_eq {x y : fiber f b} (p : point x = point y)
(q : point_eq x = ap f p ⬝ point_eq y) : x = y :=
to_inv !fiber_eq_equiv ⟨p, q⟩
definition fiber_pathover {X : Type} {A B : X → Type} {x₁ x₂ : X} {p : x₁ = x₂}
{f : Πx, A x → B x} {b : Πx, B x} {v₁ : fiber (f x₁) (b x₁)} {v₂ : fiber (f x₂) (b x₂)}
(q : point v₁ =[p] point v₂)
(r : squareover B hrfl (pathover_idp_of_eq (point_eq v₁)) (pathover_idp_of_eq (point_eq v₂))
(apo f q) (apd b p))
: v₁ =[p] v₂ :=
begin
apply pathover_of_fn_pathover_fn (λa, !fiber.sigma_char), esimp,
fapply sigma_pathover: esimp,
{ exact q},
{ induction v₁ with a₁ p₁, induction v₂ with a₂ p₂, esimp at *, induction q, esimp at *,
apply pathover_idp_of_eq, apply eq_of_vdeg_square, apply square_of_squareover_ids r}
end
open is_trunc
definition fiber_pr1 (B : A → Type) (a : A) : fiber (pr1 : (Σa, B a) → A) a ≃ B a :=
calc
fiber pr1 a ≃ Σu, u.1 = a : fiber.sigma_char
... ≃ Σa' (b : B a'), a' = a : sigma_assoc_equiv
... ≃ Σa' (p : a' = a), B a' : sigma_equiv_sigma_right (λa', !comm_equiv_nondep)
... ≃ Σu, B u.1 : sigma_assoc_equiv
... ≃ B a : !sigma_equiv_of_is_contr_left
definition sigma_fiber_equiv (f : A → B) : (Σb, fiber f b) ≃ A :=
calc
(Σb, fiber f b) ≃ Σb a, f a = b : sigma_equiv_sigma_right (λb, !fiber.sigma_char)
... ≃ Σa b, f a = b : sigma_comm_equiv
... ≃ A : sigma_equiv_of_is_contr_right
definition is_pointed_fiber [instance] [constructor] (f : A → B) (a : A)
: pointed (fiber f (f a)) :=
pointed.mk (fiber.mk a idp)
definition pointed_fiber [constructor] (f : A → B) (a : A) : Type* :=
pointed.Mk (fiber.mk a (idpath (f a)))
definition is_trunc_fun [reducible] (n : ℕ₋₂) (f : A → B) :=
Π(b : B), is_trunc n (fiber f b)
definition is_contr_fun [reducible] (f : A → B) := is_trunc_fun -2 f
-- pre and post composition with equivalences
open function
variable (f)
protected definition equiv_postcompose [constructor] {B' : Type} (g : B ≃ B') --[H : is_equiv g]
(b : B) : fiber (g ∘ f) (g b) ≃ fiber f b :=
calc
fiber (g ∘ f) (g b) ≃ Σa : A, g (f a) = g b : fiber.sigma_char
... ≃ Σa : A, f a = b : begin
apply sigma_equiv_sigma_right, intro a,
apply equiv.symm, apply eq_equiv_fn_eq
end
... ≃ fiber f b : fiber.sigma_char
protected definition equiv_precompose [constructor] {A' : Type} (g : A' ≃ A) --[H : is_equiv g]
(b : B) : fiber (f ∘ g) b ≃ fiber f b :=
calc
fiber (f ∘ g) b ≃ Σa' : A', f (g a') = b : fiber.sigma_char
... ≃ Σa : A, f a = b : begin
apply sigma_equiv_sigma g,
intro a', apply erfl
end
... ≃ fiber f b : fiber.sigma_char
end fiber
open unit is_trunc pointed
namespace fiber
definition fiber_star_equiv [constructor] (A : Type) : fiber (λx : A, star) star ≃ A :=
begin
fapply equiv.MK,
{ intro f, cases f with a H, exact a },
{ intro a, apply fiber.mk a, reflexivity },
{ intro a, reflexivity },
{ intro f, cases f with a H, change fiber.mk a (refl star) = fiber.mk a H,
rewrite [is_set.elim H (refl star)] }
end
definition fiber_const_equiv [constructor] (A : Type) (a₀ : A) (a : A)
: fiber (λz : unit, a₀) a ≃ a₀ = a :=
calc
fiber (λz : unit, a₀) a
≃ Σz : unit, a₀ = a : fiber.sigma_char
... ≃ a₀ = a : sigma_unit_left
-- the pointed fiber of a pointed map, which is the fiber over the basepoint
definition pfiber [constructor] {X Y : Type*} (f : X →* Y) : Type* :=
pointed.MK (fiber f pt) (fiber.mk pt !respect_pt)
definition ppoint [constructor] {X Y : Type*} (f : X →* Y) : pfiber f →* X :=
pmap.mk point idp
end fiber
open function is_equiv
namespace fiber
/- Theorem 4.7.6 -/
variables {A : Type} {P Q : A → Type}
variable (f : Πa, P a → Q a)
definition fiber_total_equiv [constructor] {a : A} (q : Q a)
: fiber (total f) ⟨a , q⟩ ≃ fiber (f a) q :=
calc
fiber (total f) ⟨a , q⟩
≃ Σ(w : Σx, P x), ⟨w.1 , f w.1 w.2 ⟩ = ⟨a , q⟩
: fiber.sigma_char
... ≃ Σ(x : A), Σ(p : P x), ⟨x , f x p⟩ = ⟨a , q⟩
: sigma_assoc_equiv
... ≃ Σ(x : A), Σ(p : P x), Σ(H : x = a), f x p =[H] q
:
begin
apply sigma_equiv_sigma_right, intro x,
apply sigma_equiv_sigma_right, intro p,
apply sigma_eq_equiv
end
... ≃ Σ(x : A), Σ(H : x = a), Σ(p : P x), f x p =[H] q
:
begin
apply sigma_equiv_sigma_right, intro x,
apply sigma_comm_equiv
end
... ≃ Σ(w : Σx, x = a), Σ(p : P w.1), f w.1 p =[w.2] q
: sigma_assoc_equiv
... ≃ Σ(p : P (center (Σx, x=a)).1), f (center (Σx, x=a)).1 p =[(center (Σx, x=a)).2] q
: sigma_equiv_of_is_contr_left
... ≃ Σ(p : P a), f a p =[idpath a] q
: equiv_of_eq idp
... ≃ Σ(p : P a), f a p = q
:
begin
apply sigma_equiv_sigma_right, intro p,
apply pathover_idp
end
... ≃ fiber (f a) q
: fiber.sigma_char
end fiber
|
5e6aaa251ef645ac83d931a6093822a58621a43a | 9dc8cecdf3c4634764a18254e94d43da07142918 | /src/data/dfinsupp/interval.lean | 2516db9bbc19a3e0cb1f715305c7274fe15a3f1e | [
"Apache-2.0"
] | permissive | jcommelin/mathlib | d8456447c36c176e14d96d9e76f39841f69d2d9b | ee8279351a2e434c2852345c51b728d22af5a156 | refs/heads/master | 1,664,782,136,488 | 1,663,638,983,000 | 1,663,638,983,000 | 132,563,656 | 0 | 0 | Apache-2.0 | 1,663,599,929,000 | 1,525,760,539,000 | Lean | UTF-8 | Lean | false | false | 6,057 | lean | /-
Copyright (c) 2021 Yaël Dillies. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yaël Dillies
-/
import data.finset.locally_finite
import data.finset.pointwise
import data.fintype.card
import data.dfinsupp.order
/-!
# Finite intervals of finitely supported functions
This file provides the `locally_finite_order` instance for `Π₀ i, α i` when `α` itself is locally
finite and calculates the cardinality of its finite intervals.
-/
open dfinsupp finset
open_locale big_operators pointwise
variables {ι : Type*} {α : ι → Type*}
namespace finset
variables [decidable_eq ι] [Π i, has_zero (α i)] {s : finset ι} {f : Π₀ i, α i}
{t : Π i, finset (α i)}
/-- Finitely supported product of finsets. -/
def dfinsupp (s : finset ι) (t : Π i, finset (α i)) : finset (Π₀ i, α i) :=
(s.pi t).map ⟨λ f, dfinsupp.mk s $ λ i, f i i.2, begin
refine (mk_injective _).comp (λ f g h, _),
ext i hi,
convert congr_fun h ⟨i, hi⟩,
end⟩
@[simp] lemma card_dfinsupp (s : finset ι) (t : Π i, finset (α i)) :
(s.dfinsupp t).card = ∏ i in s, (t i).card :=
(card_map _).trans $ card_pi _ _
variables [Π i, decidable_eq (α i)]
lemma mem_dfinsupp_iff : f ∈ s.dfinsupp t ↔ f.support ⊆ s ∧ ∀ i ∈ s, f i ∈ t i :=
begin
refine mem_map.trans ⟨_, _⟩,
{ rintro ⟨f, hf, rfl⟩,
refine ⟨support_mk_subset, λ i hi, _⟩,
convert mem_pi.1 hf i hi,
exact mk_of_mem hi },
{ refine λ h, ⟨λ i _, f i, mem_pi.2 h.2, _⟩,
ext i,
dsimp,
exact ite_eq_left_iff.2 (λ hi, (not_mem_support_iff.1 $ λ H, hi $ h.1 H).symm) }
end
/-- When `t` is supported on `s`, `f ∈ s.dfinsupp t` precisely means that `f` is pointwise in `t`.
-/
@[simp] lemma mem_dfinsupp_iff_of_support_subset {t : Π₀ i, finset (α i)} (ht : t.support ⊆ s) :
f ∈ s.dfinsupp t ↔ ∀ i, f i ∈ t i :=
begin
refine mem_dfinsupp_iff.trans (forall_and_distrib.symm.trans $ forall_congr $ λ i, ⟨λ h, _,
λ h, ⟨λ hi, ht $ mem_support_iff.2 $ λ H, mem_support_iff.1 hi _, λ _, h⟩⟩),
{ by_cases hi : i ∈ s,
{ exact h.2 hi },
{ rw [not_mem_support_iff.1 (mt h.1 hi), not_mem_support_iff.1 (not_mem_mono ht hi)],
exact zero_mem_zero } },
{ rwa [H, mem_zero] at h }
end
end finset
open finset
namespace dfinsupp
section bundled_singleton
variables [Π i, has_zero (α i)] {f : Π₀ i, α i} {i : ι} {a : α i}
/-- Pointwise `finset.singleton` bundled as a `dfinsupp`. -/
def singleton (f : Π₀ i, α i) : Π₀ i, finset (α i) :=
{ to_fun := λ i, {f i},
support' := f.support'.map $ λ s, ⟨s, λ i, (s.prop i).imp id (congr_arg _) ⟩ }
lemma mem_singleton_apply_iff : a ∈ f.singleton i ↔ a = f i := mem_singleton
end bundled_singleton
section bundled_Icc
variables [Π i, has_zero (α i)] [Π i, partial_order (α i)] [Π i, locally_finite_order (α i)]
{f g : Π₀ i, α i} {i : ι} {a : α i}
/-- Pointwise `finset.Icc` bundled as a `dfinsupp`. -/
def range_Icc (f g : Π₀ i, α i) : Π₀ i, finset (α i) :=
{ to_fun := λ i, Icc (f i) (g i),
support' := f.support'.bind $ λ fs, g.support'.map $ λ gs,
⟨fs + gs, λ i, or_iff_not_imp_left.2 $ λ h, begin
have hf : f i = 0 := (fs.prop i).resolve_left
(multiset.not_mem_mono (multiset.le.subset $ multiset.le_add_right _ _) h),
have hg : g i = 0 := (gs.prop i).resolve_left
(multiset.not_mem_mono (multiset.le.subset $ multiset.le_add_left _ _) h),
rw [hf, hg],
exact Icc_self _,
end⟩ }
@[simp] lemma range_Icc_apply (f g : Π₀ i, α i) (i : ι) : f.range_Icc g i = Icc (f i) (g i) := rfl
lemma mem_range_Icc_apply_iff : a ∈ f.range_Icc g i ↔ f i ≤ a ∧ a ≤ g i := mem_Icc
lemma support_range_Icc_subset [decidable_eq ι] [Π i, decidable_eq (α i)] :
(f.range_Icc g).support ⊆ f.support ∪ g.support :=
begin
refine λ x hx, _,
by_contra,
refine not_mem_support_iff.2 _ hx,
rw [range_Icc_apply,
not_mem_support_iff.1 (not_mem_mono (subset_union_left _ _) h),
not_mem_support_iff.1 (not_mem_mono (subset_union_right _ _) h)],
exact Icc_self _,
end
end bundled_Icc
section pi
variables [Π i, has_zero (α i)] [decidable_eq ι] [Π i, decidable_eq (α i)]
/-- Given a finitely supported function `f : Π₀ i, finset (α i)`, one can define the finset
`f.pi` of all finitely supported functions whose value at `i` is in `f i` for all `i`. -/
def pi (f : Π₀ i, finset (α i)) : finset (Π₀ i, α i) := f.support.dfinsupp f
@[simp] lemma mem_pi {f : Π₀ i, finset (α i)} {g : Π₀ i, α i} : g ∈ f.pi ↔ ∀ i, g i ∈ f i :=
mem_dfinsupp_iff_of_support_subset $ subset.refl _
@[simp] lemma card_pi (f : Π₀ i, finset (α i)) : f.pi.card = f.prod (λ i, (f i).card) :=
begin
rw [pi, card_dfinsupp],
exact finset.prod_congr rfl (λ i _, by simp only [pi.nat_apply, nat.cast_id]),
end
end pi
section locally_finite
variables [decidable_eq ι] [Π i, decidable_eq (α i)]
variables [Π i, partial_order (α i)] [Π i, has_zero (α i)] [Π i, locally_finite_order (α i)]
instance : locally_finite_order (Π₀ i, α i) :=
locally_finite_order.of_Icc (Π₀ i, α i)
(λ f g, (f.support ∪ g.support).dfinsupp $ f.range_Icc g)
(λ f g x, begin
refine (mem_dfinsupp_iff_of_support_subset $ support_range_Icc_subset).trans _,
simp_rw [mem_range_Icc_apply_iff, forall_and_distrib],
refl,
end)
variables (f g : Π₀ i, α i)
lemma card_Icc : (Icc f g).card = ∏ i in f.support ∪ g.support, (Icc (f i) (g i)).card :=
card_dfinsupp _ _
lemma card_Ico : (Ico f g).card = ∏ i in f.support ∪ g.support, (Icc (f i) (g i)).card - 1 :=
by rw [card_Ico_eq_card_Icc_sub_one, card_Icc]
lemma card_Ioc : (Ioc f g).card = ∏ i in f.support ∪ g.support, (Icc (f i) (g i)).card - 1 :=
by rw [card_Ioc_eq_card_Icc_sub_one, card_Icc]
lemma card_Ioo : (Ioo f g).card = ∏ i in f.support ∪ g.support, (Icc (f i) (g i)).card - 2 :=
by rw [card_Ioo_eq_card_Icc_sub_two, card_Icc]
end locally_finite
end dfinsupp
|
85b31f58e74a2f242812a3bba3b6daa34e0dd735 | 6432ea7a083ff6ba21ea17af9ee47b9c371760f7 | /tests/pkg/user_attr_app/UserAttr/Tst.lean | f80db320f8829ecc77baf8af2620ab5063614121 | [
"Apache-2.0",
"LLVM-exception",
"NCSA",
"LGPL-3.0-only",
"LicenseRef-scancode-inner-net-2.0",
"BSD-3-Clause",
"LGPL-2.0-or-later",
"Spencer-94",
"LGPL-2.1-or-later",
"HPND",
"LicenseRef-scancode-pcre",
"ISC",
"LGPL-2.1-only",
"LicenseRef-scancode-other-permissive",
"SunPro",
"CMU-Mach"... | permissive | leanprover/lean4 | 4bdf9790294964627eb9be79f5e8f6157780b4cc | f1f9dc0f2f531af3312398999d8b8303fa5f096b | refs/heads/master | 1,693,360,665,786 | 1,693,350,868,000 | 1,693,350,868,000 | 129,571,436 | 2,827 | 311 | Apache-2.0 | 1,694,716,156,000 | 1,523,760,560,000 | Lean | UTF-8 | Lean | false | false | 89 | lean | import UserAttr.BlaAttr
@[bla] def f (x : Nat) := x + 2
@[bla] def g (x : Nat) := x + 1
|
d9cca151419ee08cf4d8c205f185ecdde4ae8749 | 6432ea7a083ff6ba21ea17af9ee47b9c371760f7 | /tests/lean/run/instanceWhere.lean | aef59baac89dd48d73e79b027840865f465788df | [
"Apache-2.0",
"LLVM-exception",
"NCSA",
"LGPL-3.0-only",
"LicenseRef-scancode-inner-net-2.0",
"BSD-3-Clause",
"LGPL-2.0-or-later",
"Spencer-94",
"LGPL-2.1-or-later",
"HPND",
"LicenseRef-scancode-pcre",
"ISC",
"LGPL-2.1-only",
"LicenseRef-scancode-other-permissive",
"SunPro",
"CMU-Mach"... | permissive | leanprover/lean4 | 4bdf9790294964627eb9be79f5e8f6157780b4cc | f1f9dc0f2f531af3312398999d8b8303fa5f096b | refs/heads/master | 1,693,360,665,786 | 1,693,350,868,000 | 1,693,350,868,000 | 129,571,436 | 2,827 | 311 | Apache-2.0 | 1,694,716,156,000 | 1,523,760,560,000 | Lean | UTF-8 | Lean | false | false | 533 | lean | namespace Exp
universe u v w
def StateT' (σ : Type u) (m : Type u → Type v) (α : Type u) : Type (max u v) :=
σ → m (α × σ)
instance [Monad m] : Monad (StateT' σ m) where
pure a := fun s => pure (a, s)
bind x f := fun s => do
let (a, s) ← x s
f a s
map f x := fun s => do
let (a, s) ← x s
pure (f a, s)
instance [ToString α] [ToString β] : ToString (Sum α β) where
toString : Sum α β → String
| Sum.inr a => "inl" ++ toString a
| Sum.inl b => "inr" ++ toString b
end Exp
|
8f28c4450c1d4e10c0dba80b5749d1598e0fb1ae | ba4794a0deca1d2aaa68914cd285d77880907b5c | /src/game/world8/level10.lean | c0eaf89cab62497c56f59adb7021c394e818a521 | [
"Apache-2.0"
] | permissive | ChrisHughes24/natural_number_game | c7c00aa1f6a95004286fd456ed13cf6e113159ce | 9d09925424da9f6275e6cfe427c8bcf12bb0944f | refs/heads/master | 1,600,715,773,528 | 1,573,910,462,000 | 1,573,910,462,000 | null | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 1,987 | lean | import game.world8.level9 -- hide
namespace mynat -- hide
/-
# Advanced Addition World
## Level 10: `add_left_eq_zero`
## Important: the definition of `≠`
In Lean, `a ≠ b` is *defined to mean* `(a = b) → false`.
This means that if you see `a ≠ b` you can *literally treat
it as saying* `(a = b) → false`. Computer scientists would
say that these two terms are *definitionally equal*.
The following lemma, $a+b=0\implies b=0$, will be useful in inequality world.
Let me go through the proof, because it introduces several new
concepts:
* `cases b` with `b : mynat`
* `exfalso`
* `apply succ_ne_zero`
We're going to prove $a+b=0\implies b=0$. Here is the
strategy. Each natural number is either `0` or `succ(d)` for
some other natural number `d`. So we can start the proof
with
`cases b with d,`
and then we have two goals, the case `b = 0` (which you can solve easily)
and the case `b = succ(d)`, which looks like this:
```
a d : mynat,
H : a + succ d = 0
⊢ succ d = 0
```
Our goal is impossible to prove. However our hypothesis `H`
is also impossible, meaning that we still have a chance!
First let's see why `H` is impossible. We can
`rw add_succ at H,`
to turn `H` into `H : succ (a + d) = 0`. Because
`succ_ne_zero (a + d)` is a proof that `succ (a + d) ≠ 0`,
it is also a proof of the implication `succ (a + d) = 0 → false`.
Hence `succ_ne_zero (a + d) H` is a proof of `false`!
Unfortunately our goal is not `false`, it's a generic
false statement.
Recall however that the `exfalso` command turns any goal into `false`
(it's logically OK because `false` implies every proposition, true or false).
You can probably take it from here.
-/
/- Lemma
If $a$ and $b$ are natural numbers such that
$$ a + b = 0, $$
then $b = 0$.
-/
lemma add_left_eq_zero {a b : mynat} (H : a + b = 0) : b = 0 :=
begin [less_leaky]
cases b with d,
{ refl},
{ rw add_succ at H,
exfalso,
apply succ_ne_zero (a + d),
exact H,
},
end
end mynat -- hide
|
40620510f7d2f1854ceb87275416fa41dc126763 | d9d511f37a523cd7659d6f573f990e2a0af93c6f | /src/order/basic.lean | 881a1c4f10b6bc4623d66fe16997e206eb715bc3 | [
"Apache-2.0"
] | permissive | hikari0108/mathlib | b7ea2b7350497ab1a0b87a09d093ecc025a50dfa | a9e7d333b0cfd45f13a20f7b96b7d52e19fa2901 | refs/heads/master | 1,690,483,608,260 | 1,631,541,580,000 | 1,631,541,580,000 | null | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 25,313 | lean | /-
Copyright (c) 2014 Jeremy Avigad. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jeremy Avigad, Mario Carneiro
-/
import data.subtype
import data.prod
/-!
# Basic definitions about `≤` and `<`
## Definitions
### Predicates on functions
- `monotone f`: A function between two types equipped with `≤` is monotone if `a ≤ b` implies
`f a ≤ f b`.
- `strict_mono f` : A function between two types equipped with `<` is strictly monotone if
`a < b` implies `f a < f b`.
- `order_dual α` : A type tag reversing the meaning of all inequalities.
### Transfering orders
- `order.preimage`, `preorder.lift`: Transfers a (pre)order on `β` to an order on `α`
using a function `f : α → β`.
- `partial_order.lift`, `linear_order.lift`: Transfers a partial (resp., linear) order on `β` to a
partial (resp., linear) order on `α` using an injective function `f`.
### Extra classes
- `no_top_order`, `no_bot_order`: An order without a maximal/minimal element.
- `densely_ordered`: An order with no gap, i.e. for any two elements `a < b` there exists `c` such
that `a < c < b`.
## Main theorems
- `monotone_nat_of_le_succ`: If `f : ℕ → α` and `f n ≤ f (n + 1)` for all `n`, then `f` is
monotone.
- `strict_mono_nat_of_lt_succ`: If `f : ℕ → α` and `f n < f (n + 1)` for all `n`, then `f` is
strictly monotone.
## TODO
- expand module docs
- automatic construction of dual definitions / theorems
## See also
- `algebra.order` for basic lemmas about orders, and projection notation for orders
## Tags
preorder, order, partial order, linear order, monotone, strictly monotone
-/
open function
universes u v w
variables {α : Type u} {β : Type v} {γ : Type w} {r : α → α → Prop}
attribute [simp] le_refl
@[simp] lemma lt_self_iff_false [preorder α] (a : α) : a < a ↔ false :=
by simp [lt_irrefl a]
attribute [ext] has_le
@[ext]
lemma preorder.to_has_le_injective {α : Type*} :
function.injective (@preorder.to_has_le α) :=
λ A B h, begin
cases A, cases B,
injection h with h_le,
have : A_lt = B_lt,
{ funext a b,
dsimp [(≤)] at A_lt_iff_le_not_le B_lt_iff_le_not_le h_le,
simp [A_lt_iff_le_not_le, B_lt_iff_le_not_le, h_le], },
congr',
end
@[ext]
lemma partial_order.to_preorder_injective {α : Type*} :
function.injective (@partial_order.to_preorder α) :=
λ A B h, by { cases A, cases B, injection h, congr' }
@[ext]
lemma linear_order.to_partial_order_injective {α : Type*} :
function.injective (@linear_order.to_partial_order α) :=
λ A B h, by { cases A, cases B, injection h, congr' }
theorem preorder.ext {α} {A B : preorder α}
(H : ∀ x y : α, (by haveI := A; exact x ≤ y) ↔ x ≤ y) : A = B :=
by { ext x y, exact H x y }
theorem partial_order.ext {α} {A B : partial_order α}
(H : ∀ x y : α, (by haveI := A; exact x ≤ y) ↔ x ≤ y) : A = B :=
by { ext x y, exact H x y }
theorem linear_order.ext {α} {A B : linear_order α}
(H : ∀ x y : α, (by haveI := A; exact x ≤ y) ↔ x ≤ y) : A = B :=
by { ext x y, exact H x y }
/-- Given a relation `R` on `β` and a function `f : α → β`, the preimage relation on `α` is defined
by `x ≤ y ↔ f x ≤ f y`. It is the unique relation on `α` making `f` a `rel_embedding` (assuming `f`
is injective). -/
@[simp] def order.preimage {α β} (f : α → β) (s : β → β → Prop) (x y : α) : Prop := s (f x) (f y)
infix ` ⁻¹'o `:80 := order.preimage
/-- The preimage of a decidable order is decidable. -/
instance order.preimage.decidable {α β} (f : α → β) (s : β → β → Prop) [H : decidable_rel s] :
decidable_rel (f ⁻¹'o s) :=
λ x y, H _ _
section monotone
variables [preorder α] [preorder β] [preorder γ]
/-- A function between preorders is monotone if `a ≤ b` implies `f a ≤ f b`. -/
def monotone (f : α → β) : Prop := ∀ ⦃a b⦄, a ≤ b → f a ≤ f b
theorem monotone_id : @monotone α α _ _ id := λ x y h, h
theorem monotone_const {b : β} : monotone (λ (a : α), b) := λ x y h, le_refl b
protected theorem monotone.comp {g : β → γ} {f : α → β} (m_g : monotone g) (m_f : monotone f) :
monotone (g ∘ f) :=
λ a b h, m_g (m_f h)
protected theorem monotone.iterate {f : α → α} (hf : monotone f) (n : ℕ) : monotone (f^[n]) :=
nat.rec_on n monotone_id (λ n ihn, ihn.comp hf)
lemma monotone_nat_of_le_succ {f : ℕ → α} (hf : ∀ n, f n ≤ f (n + 1)) :
monotone f | n m h :=
begin
induction h,
{ refl },
{ transitivity, assumption, exact hf _ }
end
lemma monotone.reflect_lt {α β} [linear_order α] [preorder β] {f : α → β} (hf : monotone f)
{x x' : α} (h : f x < f x') : x < x' :=
by { rw [← not_le], intro h', apply not_le_of_lt h, exact hf h' }
/-- If `f` is a monotone function from `ℕ` to a preorder such that `y` lies between `f x` and
`f (x + 1)`, then `y` doesn't lie in the range of `f`. -/
lemma monotone.ne_of_lt_of_lt_nat {α} [preorder α] {f : ℕ → α} (hf : monotone f)
(x x' : ℕ) {y : α} (h1 : f x < y) (h2 : y < f (x + 1)) : f x' ≠ y :=
by { rintro rfl, apply (hf.reflect_lt h1).not_le, exact nat.le_of_lt_succ (hf.reflect_lt h2) }
/-- If `f` is a monotone function from `ℤ` to a preorder such that `y` lies between `f x` and
`f (x + 1)`, then `y` doesn't lie in the range of `f`. -/
lemma monotone.ne_of_lt_of_lt_int {α} [preorder α] {f : ℤ → α} (hf : monotone f)
(x x' : ℤ) {y : α} (h1 : f x < y) (h2 : y < f (x + 1)) : f x' ≠ y :=
by { rintro rfl, apply (hf.reflect_lt h1).not_le, exact int.le_of_lt_add_one (hf.reflect_lt h2) }
end monotone
/-- A function `f` is strictly monotone if `a < b` implies `f a < f b`. -/
def strict_mono [has_lt α] [has_lt β] (f : α → β) : Prop :=
∀ ⦃a b⦄, a < b → f a < f b
lemma strict_mono_id [has_lt α] : strict_mono (id : α → α) := λ a b, id
/-- A function `f` is strictly monotone increasing on `t` if `x < y` for `x,y ∈ t` implies
`f x < f y`. -/
def strict_mono_incr_on [has_lt α] [has_lt β] (f : α → β) (t : set α) : Prop :=
∀ ⦃x⦄ (hx : x ∈ t) ⦃y⦄ (hy : y ∈ t), x < y → f x < f y
/-- A function `f` is strictly monotone decreasing on `t` if `x < y` for `x,y ∈ t` implies
`f y < f x`. -/
def strict_mono_decr_on [has_lt α] [has_lt β] (f : α → β) (t : set α) : Prop :=
∀ ⦃x⦄ (hx : x ∈ t) ⦃y⦄ (hy : y ∈ t), x < y → f y < f x
/-- Type tag for a set with dual order: `≤` means `≥` and `<` means `>`. -/
def order_dual (α : Type*) : Type* := α
namespace order_dual
instance (α : Type*) [h : nonempty α] : nonempty (order_dual α) := h
instance (α : Type*) [h : subsingleton α] : subsingleton (order_dual α) := h
instance (α : Type*) [has_le α] : has_le (order_dual α) := ⟨λ x y : α, y ≤ x⟩
instance (α : Type*) [has_lt α] : has_lt (order_dual α) := ⟨λ x y : α, y < x⟩
instance (α : Type*) [has_zero α] : has_zero (order_dual α) := ⟨(0 : α)⟩
-- `dual_le` and `dual_lt` should not be simp lemmas:
-- they cause a loop since `α` and `order_dual α` are definitionally equal
lemma dual_le [has_le α] {a b : α} :
@has_le.le (order_dual α) _ a b ↔ @has_le.le α _ b a := iff.rfl
lemma dual_lt [has_lt α] {a b : α} :
@has_lt.lt (order_dual α) _ a b ↔ @has_lt.lt α _ b a := iff.rfl
lemma dual_compares [has_lt α] {a b : α} {o : ordering} :
@ordering.compares (order_dual α) _ o a b ↔ @ordering.compares α _ o b a :=
by { cases o, exacts [iff.rfl, eq_comm, iff.rfl] }
instance (α : Type*) [preorder α] : preorder (order_dual α) :=
{ le_refl := le_refl,
le_trans := λ a b c hab hbc, hbc.trans hab,
lt_iff_le_not_le := λ _ _, lt_iff_le_not_le,
.. order_dual.has_le α,
.. order_dual.has_lt α }
instance (α : Type*) [partial_order α] : partial_order (order_dual α) :=
{ le_antisymm := λ a b hab hba, @le_antisymm α _ a b hba hab, .. order_dual.preorder α }
instance (α : Type*) [linear_order α] : linear_order (order_dual α) :=
{ le_total := λ a b : α, le_total b a,
decidable_le := show decidable_rel (λ a b : α, b ≤ a), by apply_instance,
decidable_lt := show decidable_rel (λ a b : α, b < a), by apply_instance,
.. order_dual.partial_order α }
instance : Π [inhabited α], inhabited (order_dual α) := id
theorem preorder.dual_dual (α : Type*) [H : preorder α] :
order_dual.preorder (order_dual α) = H :=
preorder.ext $ λ _ _, iff.rfl
theorem partial_order.dual_dual (α : Type*) [H : partial_order α] :
order_dual.partial_order (order_dual α) = H :=
partial_order.ext $ λ _ _, iff.rfl
theorem linear_order.dual_dual (α : Type*) [H : linear_order α] :
order_dual.linear_order (order_dual α) = H :=
linear_order.ext $ λ _ _, iff.rfl
theorem cmp_le_flip {α} [has_le α] [@decidable_rel α (≤)] (x y : α) :
@cmp_le (order_dual α) _ _ x y = cmp_le y x := rfl
end order_dual
namespace strict_mono_incr_on
section dual
variables [preorder α] [preorder β] {f : α → β} {s : set α}
protected lemma dual (H : strict_mono_incr_on f s) :
@strict_mono_incr_on (order_dual α) (order_dual β) _ _ f s :=
λ x hx y hy, H hy hx
protected lemma dual_right (H : strict_mono_incr_on f s) :
@strict_mono_decr_on α (order_dual β) _ _ f s :=
H
end dual
variables [linear_order α] [preorder β] {f : α → β} {s : set α} {x y : α}
lemma le_iff_le (H : strict_mono_incr_on f s) (hx : x ∈ s) (hy : y ∈ s) :
f x ≤ f y ↔ x ≤ y :=
⟨λ h, le_of_not_gt $ λ h', not_le_of_lt (H hy hx h') h,
λ h, h.lt_or_eq_dec.elim (λ h', le_of_lt (H hx hy h')) (λ h', h' ▸ le_refl _)⟩
lemma lt_iff_lt (H : strict_mono_incr_on f s) (hx : x ∈ s) (hy : y ∈ s) :
f x < f y ↔ x < y :=
by simp only [H.le_iff_le, hx, hy, lt_iff_le_not_le]
protected theorem compares (H : strict_mono_incr_on f s) (hx : x ∈ s) (hy : y ∈ s) :
∀ {o}, ordering.compares o (f x) (f y) ↔ ordering.compares o x y
| ordering.lt := H.lt_iff_lt hx hy
| ordering.eq := ⟨λ h, ((H.le_iff_le hx hy).1 h.le).antisymm ((H.le_iff_le hy hx).1 h.symm.le),
congr_arg _⟩
| ordering.gt := H.lt_iff_lt hy hx
end strict_mono_incr_on
namespace strict_mono_decr_on
section dual
variables [preorder α] [preorder β] {f : α → β} {s : set α}
protected lemma dual (H : strict_mono_decr_on f s) :
@strict_mono_decr_on (order_dual α) (order_dual β) _ _ f s :=
λ x hx y hy, H hy hx
protected lemma dual_right (H : strict_mono_decr_on f s) :
@strict_mono_incr_on α (order_dual β) _ _ f s :=
H
end dual
variables [linear_order α] [preorder β] {f : α → β} {s : set α} {x y : α}
lemma le_iff_le (H : strict_mono_decr_on f s) (hx : x ∈ s) (hy : y ∈ s) :
f x ≤ f y ↔ y ≤ x :=
H.dual_right.le_iff_le hy hx
lemma lt_iff_lt (H : strict_mono_decr_on f s) (hx : x ∈ s) (hy : y ∈ s) :
f x < f y ↔ y < x :=
H.dual_right.lt_iff_lt hy hx
protected theorem compares (H : strict_mono_decr_on f s) (hx : x ∈ s) (hy : y ∈ s) {o : ordering} :
ordering.compares o (f x) (f y) ↔ ordering.compares o y x :=
order_dual.dual_compares.trans $ H.dual_right.compares hy hx
end strict_mono_decr_on
namespace strict_mono
open ordering function
protected lemma strict_mono_incr_on [has_lt α] [has_lt β] {f : α → β} (hf : strict_mono f)
(s : set α) :
strict_mono_incr_on f s :=
λ x hx y hy hxy, hf hxy
lemma comp [has_lt α] [has_lt β] [has_lt γ] {g : β → γ} {f : α → β}
(hg : strict_mono g) (hf : strict_mono f) :
strict_mono (g ∘ f) :=
λ a b h, hg (hf h)
protected theorem iterate [has_lt α] {f : α → α} (hf : strict_mono f) (n : ℕ) :
strict_mono (f^[n]) :=
nat.rec_on n strict_mono_id (λ n ihn, ihn.comp hf)
lemma id_le {φ : ℕ → ℕ} (h : strict_mono φ) : ∀ n, n ≤ φ n :=
λ n, nat.rec_on n (nat.zero_le _)
(λ n hn, nat.succ_le_of_lt (lt_of_le_of_lt hn $ h $ nat.lt_succ_self n))
protected lemma ite' [preorder α] [has_lt β] {f g : α → β} (hf : strict_mono f) (hg : strict_mono g)
{p : α → Prop} [decidable_pred p] (hp : ∀ ⦃x y⦄, x < y → p y → p x)
(hfg : ∀ ⦃x y⦄, p x → ¬p y → x < y → f x < g y) :
strict_mono (λ x, if p x then f x else g x) :=
begin
intros x y h,
by_cases hy : p y,
{ have hx : p x := hp h hy,
simpa [hx, hy] using hf h },
{ by_cases hx : p x,
{ simpa [hx, hy] using hfg hx hy h },
{ simpa [hx, hy] using hg h} }
end
protected lemma ite [preorder α] [preorder β] {f g : α → β} (hf : strict_mono f)
(hg : strict_mono g) {p : α → Prop} [decidable_pred p] (hp : ∀ ⦃x y⦄, x < y → p y → p x)
(hfg : ∀ x, f x ≤ g x) :
strict_mono (λ x, if p x then f x else g x) :=
hf.ite' hg hp $ λ x y hx hy h, (hf h).trans_le (hfg y)
section
variables [linear_order α] [preorder β] {f : α → β}
lemma lt_iff_lt (H : strict_mono f) {a b} : f a < f b ↔ a < b :=
(H.strict_mono_incr_on set.univ).lt_iff_lt trivial trivial
protected theorem compares (H : strict_mono f) {a b} {o} :
compares o (f a) (f b) ↔ compares o a b :=
(H.strict_mono_incr_on set.univ).compares trivial trivial
lemma injective (H : strict_mono f) : injective f :=
λ x y h, show compares eq x y, from H.compares.1 h
lemma le_iff_le (H : strict_mono f) {a b} : f a ≤ f b ↔ a ≤ b :=
(H.strict_mono_incr_on set.univ).le_iff_le trivial trivial
lemma top_preimage_top (H : strict_mono f) {a} (h_top : ∀ p, p ≤ f a) (x : α) : x ≤ a :=
H.le_iff_le.mp (h_top (f x))
lemma bot_preimage_bot (H : strict_mono f) {a} (h_bot : ∀ p, f a ≤ p) (x : α) : a ≤ x :=
H.le_iff_le.mp (h_bot (f x))
end
-- `preorder α` isn't strong enough: if the preorder on α is an equivalence relation,
-- then `strict_mono f` is vacuously true.
lemma monotone [partial_order α] [preorder β] {f : α → β} (H : strict_mono f) : monotone f :=
λ a b h, (lt_or_eq_of_le h).rec (le_of_lt ∘ (@H _ _)) (by rintro rfl; refl)
end strict_mono
lemma strict_mono_nat_of_lt_succ {β} [preorder β] {f : ℕ → β} (h : ∀ n, f n < f (n + 1)) :
strict_mono f :=
by { intros n m hnm, induction hnm with m' hnm' ih, apply h, exact ih.trans (h _) }
section
open function
lemma injective_of_lt_imp_ne [linear_order α] {f : α → β} (h : ∀ x y, x < y → f x ≠ f y) :
injective f :=
begin
intros x y k,
contrapose k,
rw [←ne.def, ne_iff_lt_or_gt] at k,
cases k,
{ apply h _ _ k },
{ rw eq_comm,
apply h _ _ k }
end
lemma injective_of_le_imp_le [partial_order α] [preorder β] (f : α → β)
(h : ∀ {x y}, f x ≤ f y → x ≤ y) : injective f :=
λ x y hxy, (h hxy.le).antisymm (h hxy.ge)
lemma strict_mono_of_monotone_of_injective [partial_order α] [partial_order β] {f : α → β}
(h₁ : monotone f) (h₂ : injective f) : strict_mono f :=
λ a b h,
begin
rw lt_iff_le_and_ne at ⊢ h,
exact ⟨h₁ h.1, λ e, h.2 (h₂ e)⟩
end
lemma monotone.strict_mono_iff_injective [linear_order α] [partial_order β] {f : α → β}
(h : monotone f) : strict_mono f ↔ injective f :=
⟨λ h, h.injective, strict_mono_of_monotone_of_injective h⟩
lemma strict_mono_of_le_iff_le [preorder α] [preorder β] {f : α → β}
(h : ∀ x y, x ≤ y ↔ f x ≤ f y) : strict_mono f :=
λ a b, by simp [lt_iff_le_not_le, h] {contextual := tt}
end
/-! ### Order instances on the function space -/
instance pi.preorder {ι : Type u} {α : ι → Type v} [∀ i, preorder (α i)] : preorder (Πi, α i) :=
{ le := λ x y, ∀ i, x i ≤ y i,
le_refl := λ a i, le_refl (a i),
le_trans := λ a b c h₁ h₂ i, le_trans (h₁ i) (h₂ i) }
lemma function.monotone_eval {ι : Type u} {α : ι → Type v} [∀ i, preorder (α i)] (i : ι) :
monotone (function.eval i : (Π i, α i) → α i) :=
λ f g H, H i
lemma pi.le_def {ι : Type u} {α : ι → Type v} [∀ i, preorder (α i)] {x y : Π i, α i} :
x ≤ y ↔ ∀ i, x i ≤ y i :=
iff.rfl
lemma pi.lt_def {ι : Type u} {α : ι → Type v} [∀ i, preorder (α i)] {x y : Π i, α i} :
x < y ↔ x ≤ y ∧ ∃ i, x i < y i :=
by simp [lt_iff_le_not_le, pi.le_def] {contextual := tt}
lemma le_update_iff {ι : Type u} {α : ι → Type v} [∀ i, preorder (α i)] [decidable_eq ι]
{x y : Π i, α i} {i : ι} {a : α i} :
x ≤ function.update y i a ↔ x i ≤ a ∧ ∀ j ≠ i, x j ≤ y j :=
function.forall_update_iff _ (λ j z, x j ≤ z)
lemma update_le_iff {ι : Type u} {α : ι → Type v} [∀ i, preorder (α i)] [decidable_eq ι]
{x y : Π i, α i} {i : ι} {a : α i} :
function.update x i a ≤ y ↔ a ≤ y i ∧ ∀ j ≠ i, x j ≤ y j :=
function.forall_update_iff _ (λ j z, z ≤ y j)
lemma update_le_update_iff {ι : Type u} {α : ι → Type v} [∀ i, preorder (α i)] [decidable_eq ι]
{x y : Π i, α i} {i : ι} {a b : α i} :
function.update x i a ≤ function.update y i b ↔ a ≤ b ∧ ∀ j ≠ i, x j ≤ y j :=
by simp [update_le_iff] {contextual := tt}
instance pi.partial_order {ι : Type u} {α : ι → Type v} [∀ i, partial_order (α i)] :
partial_order (Πi, α i) :=
{ le_antisymm := λ f g h1 h2, funext (λ b, (h1 b).antisymm (h2 b)),
..pi.preorder }
theorem comp_le_comp_left_of_monotone [preorder α] [preorder β]
{f : β → α} {g h : γ → β} (m_f : monotone f) (le_gh : g ≤ h) :
has_le.le.{max w u} (f ∘ g) (f ∘ h) :=
λ x, m_f (le_gh x)
section monotone
variables [preorder α] [preorder γ]
protected theorem monotone.order_dual {f : α → γ} (hf : monotone f) :
@monotone (order_dual α) (order_dual γ) _ _ f :=
λ x y hxy, hf hxy
theorem monotone_lam {f : α → β → γ} (m : ∀ b, monotone (λ a, f a b)) : monotone f :=
λ a a' h b, m b h
theorem monotone_app (f : β → α → γ) (b : β) (m : monotone (λ a b, f b a)) : monotone (f b) :=
λ a a' h, m h b
end monotone
theorem strict_mono.order_dual [has_lt α] [has_lt β] {f : α → β} (hf : strict_mono f) :
@strict_mono (order_dual α) (order_dual β) _ _ f :=
λ x y hxy, hf hxy
/-- Transfer a `preorder` on `β` to a `preorder` on `α` using a function `f : α → β`.
See note [reducible non-instances]. -/
@[reducible] def preorder.lift {α β} [preorder β] (f : α → β) : preorder α :=
{ le := λ x y, f x ≤ f y,
le_refl := λ a, le_refl _,
le_trans := λ a b c, le_trans,
lt := λ x y, f x < f y,
lt_iff_le_not_le := λ a b, lt_iff_le_not_le }
/-- Transfer a `partial_order` on `β` to a `partial_order` on `α` using an injective
function `f : α → β`. See note [reducible non-instances]. -/
@[reducible] def partial_order.lift {α β} [partial_order β] (f : α → β) (inj : injective f) :
partial_order α :=
{ le_antisymm := λ a b h₁ h₂, inj (h₁.antisymm h₂), .. preorder.lift f }
/-- Transfer a `linear_order` on `β` to a `linear_order` on `α` using an injective
function `f : α → β`. See note [reducible non-instances]. -/
@[reducible] def linear_order.lift {α β} [linear_order β] (f : α → β) (inj : injective f) :
linear_order α :=
{ le_total := λ x y, le_total (f x) (f y),
decidable_le := λ x y, (infer_instance : decidable (f x ≤ f y)),
decidable_lt := λ x y, (infer_instance : decidable (f x < f y)),
decidable_eq := λ x y, decidable_of_iff _ inj.eq_iff,
.. partial_order.lift f inj }
instance subtype.preorder {α} [preorder α] (p : α → Prop) : preorder (subtype p) :=
preorder.lift subtype.val
@[simp] lemma subtype.mk_le_mk {α} [preorder α] {p : α → Prop} {x y : α} {hx : p x} {hy : p y} :
(⟨x, hx⟩ : subtype p) ≤ ⟨y, hy⟩ ↔ x ≤ y :=
iff.rfl
@[simp] lemma subtype.mk_lt_mk {α} [preorder α] {p : α → Prop} {x y : α} {hx : p x} {hy : p y} :
(⟨x, hx⟩ : subtype p) < ⟨y, hy⟩ ↔ x < y :=
iff.rfl
@[simp, norm_cast] lemma subtype.coe_le_coe {α} [preorder α] {p : α → Prop} {x y : subtype p} :
(x : α) ≤ y ↔ x ≤ y :=
iff.rfl
@[simp, norm_cast] lemma subtype.coe_lt_coe {α} [preorder α] {p : α → Prop} {x y : subtype p} :
(x : α) < y ↔ x < y :=
iff.rfl
instance subtype.partial_order {α} [partial_order α] (p : α → Prop) :
partial_order (subtype p) :=
partial_order.lift subtype.val subtype.val_injective
instance subtype.linear_order {α} [linear_order α] (p : α → Prop) : linear_order (subtype p) :=
linear_order.lift subtype.val subtype.val_injective
lemma subtype.mono_coe [preorder α] (t : set α) : monotone (coe : (subtype t) → α) :=
λ x y, id
lemma subtype.strict_mono_coe [preorder α] (t : set α) : strict_mono (coe : (subtype t) → α) :=
λ x y, id
instance prod.has_le (α : Type u) (β : Type v) [has_le α] [has_le β] : has_le (α × β) :=
⟨λ p q, p.1 ≤ q.1 ∧ p.2 ≤ q.2⟩
instance prod.preorder (α : Type u) (β : Type v) [preorder α] [preorder β] : preorder (α × β) :=
{ le_refl := λ ⟨a, b⟩, ⟨le_refl a, le_refl b⟩,
le_trans := λ ⟨a, b⟩ ⟨c, d⟩ ⟨e, f⟩ ⟨hac, hbd⟩ ⟨hce, hdf⟩,
⟨le_trans hac hce, le_trans hbd hdf⟩,
.. prod.has_le α β }
/-- The pointwise partial order on a product.
(The lexicographic ordering is defined in order/lexicographic.lean, and the instances are
available via the type synonym `lex α β = α × β`.) -/
instance prod.partial_order (α : Type u) (β : Type v) [partial_order α] [partial_order β] :
partial_order (α × β) :=
{ le_antisymm := λ ⟨a, b⟩ ⟨c, d⟩ ⟨hac, hbd⟩ ⟨hca, hdb⟩,
prod.ext (hac.antisymm hca) (hbd.antisymm hdb),
.. prod.preorder α β }
lemma monotone_fst {α β : Type*} [preorder α] [preorder β] : monotone (@prod.fst α β) :=
λ x y h, h.1
lemma monotone_snd {α β : Type*} [preorder α] [preorder β] : monotone (@prod.snd α β) :=
λ x y h, h.2
/-!
### Additional order classes
-/
/-- order without a top element; sometimes called cofinal -/
class no_top_order (α : Type u) [preorder α] : Prop :=
(no_top : ∀ a : α, ∃ a', a < a')
lemma no_top [preorder α] [no_top_order α] : ∀ a : α, ∃ a', a < a' :=
no_top_order.no_top
instance nonempty_gt {α : Type u} [preorder α] [no_top_order α] (a : α) :
nonempty {x // a < x} :=
nonempty_subtype.2 (no_top a)
/-- order without a bottom element; somtimes called coinitial or dense -/
class no_bot_order (α : Type u) [preorder α] : Prop :=
(no_bot : ∀ a : α, ∃ a', a' < a)
lemma no_bot [preorder α] [no_bot_order α] : ∀ a : α, ∃ a', a' < a :=
no_bot_order.no_bot
instance order_dual.no_top_order (α : Type u) [preorder α] [no_bot_order α] :
no_top_order (order_dual α) :=
⟨λ a, @no_bot α _ _ a⟩
instance order_dual.no_bot_order (α : Type u) [preorder α] [no_top_order α] :
no_bot_order (order_dual α) :=
⟨λ a, @no_top α _ _ a⟩
instance nonempty_lt {α : Type u} [preorder α] [no_bot_order α] (a : α) :
nonempty {x // x < a} :=
nonempty_subtype.2 (no_bot a)
/-- An order is dense if there is an element between any pair of distinct elements. -/
class densely_ordered (α : Type u) [preorder α] : Prop :=
(dense : ∀ a₁ a₂ : α, a₁ < a₂ → ∃ a, a₁ < a ∧ a < a₂)
lemma exists_between [preorder α] [densely_ordered α] :
∀ {a₁ a₂ : α}, a₁ < a₂ → ∃ a, a₁ < a ∧ a < a₂ :=
densely_ordered.dense
instance order_dual.densely_ordered (α : Type u) [preorder α] [densely_ordered α] :
densely_ordered (order_dual α) :=
⟨λ a₁ a₂ ha, (@exists_between α _ _ _ _ ha).imp $ λ a, and.symm⟩
lemma le_of_forall_le_of_dense [linear_order α] [densely_ordered α] {a₁ a₂ : α}
(h : ∀ a, a₂ < a → a₁ ≤ a) :
a₁ ≤ a₂ :=
le_of_not_gt $ λ ha,
let ⟨a, ha₁, ha₂⟩ := exists_between ha in
lt_irrefl a $ lt_of_lt_of_le ‹a < a₁› (h _ ‹a₂ < a›)
lemma eq_of_le_of_forall_le_of_dense [linear_order α] [densely_ordered α] {a₁ a₂ : α}
(h₁ : a₂ ≤ a₁) (h₂ : ∀ a, a₂ < a → a₁ ≤ a) : a₁ = a₂ :=
le_antisymm (le_of_forall_le_of_dense h₂) h₁
lemma le_of_forall_ge_of_dense [linear_order α] [densely_ordered α] {a₁ a₂ : α}
(h : ∀ a₃ < a₁, a₃ ≤ a₂) :
a₁ ≤ a₂ :=
le_of_not_gt $ λ ha,
let ⟨a, ha₁, ha₂⟩ := exists_between ha in
lt_irrefl a $ lt_of_le_of_lt (h _ ‹a < a₁›) ‹a₂ < a›
lemma eq_of_le_of_forall_ge_of_dense [linear_order α] [densely_ordered α] {a₁ a₂ : α}
(h₁ : a₂ ≤ a₁) (h₂ : ∀ a₃ < a₁, a₃ ≤ a₂) : a₁ = a₂ :=
(le_of_forall_ge_of_dense h₂).antisymm h₁
lemma dense_or_discrete [linear_order α] (a₁ a₂ : α) :
(∃ a, a₁ < a ∧ a < a₂) ∨ ((∀ a, a₁ < a → a₂ ≤ a) ∧ (∀ a < a₂, a ≤ a₁)) :=
or_iff_not_imp_left.2 $ λ h,
⟨λ a ha₁, le_of_not_gt $ λ ha₂, h ⟨a, ha₁, ha₂⟩,
λ a ha₂, le_of_not_gt $ λ ha₁, h ⟨a, ha₁, ha₂⟩⟩
variables {s : β → β → Prop} {t : γ → γ → Prop}
/-- Type synonym to create an instance of `linear_order` from a `partial_order` and
`is_total α (≤)` -/
def as_linear_order (α : Type u) := α
instance {α} [inhabited α] : inhabited (as_linear_order α) :=
⟨ (default α : α) ⟩
noncomputable instance as_linear_order.linear_order {α} [partial_order α] [is_total α (≤)] :
linear_order (as_linear_order α) :=
{ le_total := @total_of α (≤) _,
decidable_le := classical.dec_rel _,
.. (_ : partial_order α) }
|
9d1b5945093619f7f0882e8e464799b8639296f9 | a9d0fb7b0e4f802bd3857b803e6c5c23d87fef91 | /tests/lean/ppbug.lean | c768e8dffd932f853c93237812e74d52a6eddc02 | [
"Apache-2.0"
] | permissive | soonhokong/lean-osx | 4a954262c780e404c1369d6c06516161d07fcb40 | 3670278342d2f4faa49d95b46d86642d7875b47c | refs/heads/master | 1,611,410,334,552 | 1,474,425,686,000 | 1,474,425,686,000 | 12,043,103 | 5 | 1 | null | null | null | null | UTF-8 | Lean | false | false | 18 | lean | check list.rec_on
|
dd0be5763ff5b92f54e68e6c0cb6201d50fdc6e6 | e94d3f31e48d06d252ee7307fe71efe1d500f274 | /hott/homotopy/join.hlean | b6025afcb01810069f53abcef2a11eb864cc416c | [
"Apache-2.0"
] | permissive | GallagherCommaJack/lean | e4471240a069d82f97cb361d2bf1a029de3f4256 | 226f8bafeb9baaa5a2ac58000c83d6beb29991e2 | refs/heads/master | 1,610,725,100,482 | 1,459,194,829,000 | 1,459,195,377,000 | 55,377,224 | 0 | 0 | null | 1,459,731,701,000 | 1,459,731,700,000 | null | UTF-8 | Lean | false | false | 22,708 | hlean | /-
Copyright (c) 2015 Jakob von Raumer. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jakob von Raumer, Ulrik Buchholtz
Declaration of a join as a special case of a pushout
-/
import hit.pushout .sphere cubical.cube
open eq function prod equiv is_trunc bool sigma.ops
definition join (A B : Type) : Type := @pushout.pushout (A × B) A B pr1 pr2
namespace join
section
variables {A B : Type}
definition inl (a : A) : join A B := @pushout.inl (A × B) A B pr1 pr2 a
definition inr (b : B) : join A B := @pushout.inr (A × B) A B pr1 pr2 b
definition glue (a : A) (b : B) : inl a = inr b :=
@pushout.glue (A × B) A B pr1 pr2 (a, b)
protected definition rec {P : join A B → Type}
(Pinl : Π(x : A), P (inl x))
(Pinr : Π(y : B), P (inr y))
(Pglue : Π(x : A)(y : B), Pinl x =[glue x y] Pinr y)
(z : join A B) : P z :=
pushout.rec Pinl Pinr (prod.rec Pglue) z
protected definition rec_glue {P : join A B → Type}
(Pinl : Π(x : A), P (inl x))
(Pinr : Π(y : B), P (inr y))
(Pglue : Π(x : A)(y : B), Pinl x =[glue x y] Pinr y)
(x : A) (y : B)
: apdo (join.rec Pinl Pinr Pglue) (glue x y) = Pglue x y :=
!quotient.rec_eq_of_rel
protected definition elim {P : Type} (Pinl : A → P) (Pinr : B → P)
(Pglue : Π(x : A)(y : B), Pinl x = Pinr y) (z : join A B) : P :=
join.rec Pinl Pinr (λx y, pathover_of_eq (Pglue x y)) z
protected definition elim_glue {P : Type} (Pinl : A → P) (Pinr : B → P)
(Pglue : Π(x : A)(y : B), Pinl x = Pinr y) (x : A) (y : B)
: ap (join.elim Pinl Pinr Pglue) (glue x y) = Pglue x y :=
begin
apply equiv.eq_of_fn_eq_fn_inv !(pathover_constant (glue x y)),
rewrite [▸*,-apdo_eq_pathover_of_eq_ap,↑join.elim],
apply join.rec_glue
end
protected definition elim_ap_inl {P : Type} (Pinl : A → P) (Pinr : B → P)
(Pglue : Π(x : A)(y : B), Pinl x = Pinr y) {a a' : A} (p : a = a')
: ap (join.elim Pinl Pinr Pglue) (ap inl p) = ap Pinl p :=
by cases p; reflexivity
protected definition hsquare {a a' : A} {b b' : B} (p : a = a') (q : b = b') :
square (ap inl p) (ap inr q) (glue a b) (glue a' b') :=
eq.rec_on p (eq.rec_on q hrfl)
protected definition vsquare {a a' : A} {b b' : B} (p : a = a') (q : b = b') :
square (glue a b) (glue a' b') (ap inl p) (ap inr q) :=
eq.rec_on p (eq.rec_on q vrfl)
end
end join
attribute join.inl join.inr [constructor]
attribute join.rec [recursor]
attribute join.elim [recursor 7]
attribute join.rec join.elim [unfold 7]
/- Diamonds in joins -/
namespace join
variables {A B : Type}
protected definition diamond (a a' : A) (b b' : B) :=
square (glue a b) (glue a' b')⁻¹ (glue a b') (glue a' b)⁻¹
protected definition hdiamond {a a' : A} (b b' : B) (p : a = a')
: join.diamond a a' b b' :=
begin
cases p, unfold join.diamond,
assert H : (glue a b' ⬝ (glue a b')⁻¹ ⬝ (glue a b)⁻¹⁻¹) = glue a b,
{ rewrite [con.right_inv,inv_inv,idp_con] },
exact H ▸ top_deg_square (glue a b') (glue a b')⁻¹ (glue a b)⁻¹,
end
protected definition vdiamond (a a' : A) {b b' : B} (q : b = b')
: join.diamond a a' b b' :=
begin
cases q, unfold join.diamond,
assert H : (glue a b ⬝ (glue a' b)⁻¹ ⬝ (glue a' b)⁻¹⁻¹) = glue a b,
{ rewrite [con.assoc,con.right_inv] },
exact H ▸ top_deg_square (glue a b) (glue a' b)⁻¹ (glue a' b)⁻¹
end
protected definition symm_diamond (a : A) (b : B)
: join.vdiamond a a idp = join.hdiamond b b idp :=
begin
unfold join.hdiamond, unfold join.vdiamond,
assert H : Π{X : Type} ⦃x y : X⦄ (p : x = y),
eq.rec (eq.rec (refl p) (symm (con.right_inv p⁻¹)))
(symm (con.assoc p p⁻¹ p⁻¹⁻¹)) ▸ top_deg_square p p⁻¹ p⁻¹
= eq.rec (eq.rec (eq.rec (refl p) (symm (idp_con p))) (symm (inv_inv p)))
(symm (con.right_inv p)) ▸ top_deg_square p p⁻¹ p⁻¹
:> square p p⁻¹ p p⁻¹,
{ intros X x y p, cases p, reflexivity },
apply H (glue a b)
end
end join
namespace join
variables {A₁ A₂ B₁ B₂ : Type}
protected definition functor [reducible]
(f : A₁ → A₂) (g : B₁ → B₂) : join A₁ B₁ → join A₂ B₂ :=
begin
intro x, induction x with a b a b,
{ exact inl (f a) }, { exact inr (g b) }, { apply glue }
end
protected definition ap_diamond (f : A₁ → A₂) (g : B₁ → B₂)
{a a' : A₁} {b b' : B₁}
: join.diamond a a' b b' → join.diamond (f a) (f a') (g b) (g b') :=
begin
unfold join.diamond, intro s,
note s' := aps (join.functor f g) s,
do 2 rewrite eq.ap_inv at s',
do 4 rewrite join.elim_glue at s', exact s'
end
protected definition equiv_closed
: A₁ ≃ A₂ → B₁ ≃ B₂ → join A₁ B₁ ≃ join A₂ B₂ :=
begin
intros H K,
fapply equiv.MK,
{ intro x, induction x with a b a b,
{ exact inl (to_fun H a) }, { exact inr (to_fun K b) },
{ apply glue } },
{ intro y, induction y with a b a b,
{ exact inl (to_inv H a) }, { exact inr (to_inv K b) },
{ apply glue } },
{ intro y, induction y with a b a b,
{ apply ap inl, apply to_right_inv },
{ apply ap inr, apply to_right_inv },
{ apply eq_pathover, rewrite ap_id,
rewrite (ap_compose' (join.elim _ _ _)),
do 2 krewrite join.elim_glue, apply join.hsquare } },
{ intro x, induction x with a b a b,
{ apply ap inl, apply to_left_inv },
{ apply ap inr, apply to_left_inv },
{ apply eq_pathover, rewrite ap_id,
rewrite (ap_compose' (join.elim _ _ _)),
do 2 krewrite join.elim_glue, apply join.hsquare } }
end
protected definition twist_diamond {A : Type} {a a' : A} (p : a = a')
: pathover (λx, join.diamond a' x a x)
(join.vdiamond a' a idp) p
(join.hdiamond a a' idp) :=
begin
cases p, apply pathover_idp_of_eq, apply join.symm_diamond
end
protected definition empty (A : Type) : join empty A ≃ A :=
begin
fapply equiv.MK,
{ intro x, induction x with z a z a,
{ induction z },
{ exact a },
{ induction z } },
{ intro a, exact inr a },
{ intro a, reflexivity },
{ intro x, induction x with z a z a,
{ induction z },
{ reflexivity },
{ induction z } }
end
protected definition bool (A : Type) : join bool A ≃ susp A :=
begin
fapply equiv.MK,
{ intro ba, induction ba with [b, a, b, a],
{ induction b, exact susp.south, exact susp.north },
{ exact susp.north },
{ induction b, esimp,
{ apply inverse, apply susp.merid, exact a },
{ reflexivity } } },
{ intro s, induction s with a,
{ exact inl tt },
{ exact inl ff },
{ exact (glue tt a) ⬝ (glue ff a)⁻¹ } },
{ intro s, induction s with a,
{ reflexivity },
{ reflexivity },
{ esimp, apply eq_pathover, rewrite ap_id,
rewrite (ap_compose' (join.elim _ _ _)),
rewrite [susp.elim_merid,ap_con,ap_inv],
krewrite [join.elim_glue,join.elim_glue],
esimp, rewrite [inv_inv,idp_con],
apply hdeg_square, reflexivity } },
{ intro ba, induction ba with [b, a, b, a], esimp,
{ induction b, do 2 reflexivity },
{ apply glue },
{ induction b,
{ esimp, apply eq_pathover, rewrite ap_id,
rewrite (ap_compose' (susp.elim _ _ _)),
krewrite join.elim_glue, rewrite ap_inv,
krewrite susp.elim_merid,
apply square_of_eq_top, apply inverse,
rewrite con.assoc, apply con.left_inv },
{ esimp, apply eq_pathover, rewrite ap_id,
rewrite (ap_compose' (susp.elim _ _ _)),
krewrite join.elim_glue, esimp,
apply square_of_eq_top,
rewrite [idp_con,con.right_inv] } } }
end
end join
namespace join
variables (A B C : Type)
protected definition is_contr [HA : is_contr A] :
is_contr (join A B) :=
begin
fapply is_contr.mk, exact inl (center A),
intro x, induction x with a b a b, apply ap inl, apply center_eq,
apply glue, apply pathover_of_tr_eq,
apply concat, apply transport_eq_Fr, esimp, rewrite ap_id,
generalize center_eq a, intro p, cases p, apply idp_con,
end
protected definition swap : join A B → join B A :=
begin
intro x, induction x with a b a b, exact inr a, exact inl b,
apply !glue⁻¹
end
protected definition swap_involutive (x : join A B) :
join.swap B A (join.swap A B x) = x :=
begin
induction x with a b a b, do 2 reflexivity,
apply eq_pathover, rewrite ap_id,
apply hdeg_square, esimp[join.swap],
apply concat, apply ap_compose' (join.elim _ _ _),
krewrite [join.elim_glue, ap_inv, join.elim_glue], apply inv_inv,
end
protected definition symm : join A B ≃ join B A :=
by fapply equiv.MK; do 2 apply join.swap; do 2 apply join.swap_involutive
end join
/- This proves that the join operator is associative.
The proof is more or less ported from Evan Cavallo's agda version:
https://github.com/HoTT/HoTT-Agda/blob/master/homotopy/JoinAssocCubical.agda -/
namespace join
section join_switch
private definition massage_sq' {A : Type} {a₀₀ a₂₀ a₀₂ a₂₂ : A}
{p₁₀ : a₀₀ = a₂₀} {p₁₂ : a₀₂ = a₂₂} {p₀₁ : a₀₀ = a₀₂} {p₂₁ : a₂₀ = a₂₂}
(sq : square p₁₀ p₁₂ p₀₁ p₂₁) : square p₁₀⁻¹ p₀₁⁻¹ (p₂₁ ⬝ p₁₂⁻¹) idp :=
by induction sq; exact ids
private definition massage_sq {A : Type} {a₀₀ a₂₀ a₀₂ : A}
{p₁₀ : a₀₀ = a₂₀} {p₁₂ : a₀₂ = a₂₀} {p₀₁ : a₀₀ = a₀₂}
(sq : square p₁₀ p₁₂ p₀₁ idp) : square p₁₀⁻¹ p₀₁⁻¹ p₁₂⁻¹ idp :=
!idp_con⁻¹ ⬝ph (massage_sq' sq)
private definition ap_square_massage {A B : Type} (f : A → B) {a₀₀ a₀₂ a₂₀ : A}
{p₀₁ : a₀₀ = a₀₂} {p₁₀ : a₀₀ = a₂₀} {p₁₁ : a₂₀ = a₀₂} (sq : square p₀₁ p₁₁ p₁₀ idp) :
cube (hdeg_square (ap_inv f p₁₁)) ids
(aps f (massage_sq sq)) (massage_sq (aps f sq))
(hdeg_square !ap_inv) (hdeg_square !ap_inv) :=
by apply rec_on_r sq; apply idc
private definition massage_cube' {A : Type} {a₀₀₀ a₂₀₀ a₀₂₀ a₂₂₀ a₀₀₂ a₂₀₂ a₀₂₂ a₂₂₂ : A}
{p₁₀₀ : a₀₀₀ = a₂₀₀} {p₀₁₀ : a₀₀₀ = a₀₂₀} {p₀₀₁ : a₀₀₀ = a₀₀₂} {p₁₂₀ : a₀₂₀ = a₂₂₀}
{p₂₁₀ : a₂₀₀ = a₂₂₀} {p₂₀₁ : a₂₀₀ = a₂₀₂} {p₁₀₂ : a₀₀₂ = a₂₀₂} {p₀₁₂ : a₀₀₂ = a₀₂₂}
{p₀₂₁ : a₀₂₀ = a₀₂₂} {p₁₂₂ : a₀₂₂ = a₂₂₂} {p₂₁₂ : a₂₀₂ = a₂₂₂} {p₂₂₁ : a₂₂₀ = a₂₂₂}
{s₁₁₀ : square p₀₁₀ p₂₁₀ p₁₀₀ p₁₂₀} {s₁₁₂ : square p₀₁₂ p₂₁₂ p₁₀₂ p₁₂₂}
{s₀₁₁ : square p₀₁₀ p₀₁₂ p₀₀₁ p₀₂₁} {s₂₁₁ : square p₂₁₀ p₂₁₂ p₂₀₁ p₂₂₁}
{s₁₀₁ : square p₁₀₀ p₁₀₂ p₀₀₁ p₂₀₁} {s₁₂₁ : square p₁₂₀ p₁₂₂ p₀₂₁ p₂₂₁}
(c : cube s₀₁₁ s₂₁₁ s₁₀₁ s₁₂₁ s₁₁₀ s₁₁₂) :
cube (s₂₁₁ ⬝v s₁₁₂⁻¹ᵛ) vrfl (massage_sq' s₁₀₁) (massage_sq' s₁₂₁) s₁₁₀⁻¹ᵛ s₀₁₁⁻¹ᵛ :=
by cases c; apply idc
private definition massage_cube {A : Type} {a₀₀₀ a₂₀₀ a₀₂₀ a₂₂₀ a₀₀₂ a₀₂₂ : A}
{p₁₀₀ : a₀₀₀ = a₂₀₀} {p₀₁₀ : a₀₀₀ = a₀₂₀} {p₀₀₁ : a₀₀₀ = a₀₀₂} {p₁₂₀ : a₀₂₀ = a₂₂₀}
{p₂₁₀ : a₂₀₀ = a₂₂₀} {p₁₀₂ : a₀₀₂ = a₂₀₀} {p₀₁₂ : a₀₀₂ = a₀₂₂}
{p₀₂₁ : a₀₂₀ = a₀₂₂} {p₁₂₂ : a₀₂₂ = a₂₂₀}
{s₁₁₀ : square p₀₁₀ _ _ _} {s₁₁₂ : square p₀₁₂ p₂₁₀ p₁₀₂ p₁₂₂}
{s₀₁₁ : square p₀₁₀ p₀₁₂ p₀₀₁ p₀₂₁} --{s₂₁₁ : square p₂₁₀ p₂₁₀ idp idp}
{s₁₀₁ : square p₁₀₀ p₁₀₂ p₀₀₁ idp} {s₁₂₁ : square p₁₂₀ p₁₂₂ p₀₂₁ idp}
(c : cube s₀₁₁ vrfl s₁₀₁ s₁₂₁ s₁₁₀ s₁₁₂) :
cube s₁₁₂⁻¹ᵛ vrfl (massage_sq s₁₀₁) (massage_sq s₁₂₁) s₁₁₀⁻¹ᵛ s₀₁₁⁻¹ᵛ :=
begin
cases p₁₀₀, cases p₁₀₂, cases p₁₂₂, note c' := massage_cube' c, esimp[massage_sq],
krewrite vdeg_v_eq_ph_pv_hp at c', exact c',
end
private definition massage_massage {A : Type} {a₀₀ a₀₂ a₂₀ : A}
{p₀₁ : a₀₀ = a₀₂} {p₁₀ : a₀₀ = a₂₀} {p₁₁ : a₂₀ = a₀₂} (sq : square p₀₁ p₁₁ p₁₀ idp) :
cube (hdeg_square !inv_inv) ids (massage_sq (massage_sq sq))
sq (hdeg_square !inv_inv) (hdeg_square !inv_inv) :=
by apply rec_on_r sq; apply idc
private definition square_Flr_ap_idp_cube {A B : Type} {b : B} {f : A → B}
{p₁ p₂ : Π a, f a = b} (α : Π a, p₁ a = p₂ a) {a₁ a₂ : A} (q : a₁ = a₂) :
cube hrfl hrfl (square_Flr_ap_idp p₁ q) (square_Flr_ap_idp p₂ q)
(hdeg_square (α _)) (hdeg_square (α _)) :=
by cases q; esimp[square_Flr_ap_idp]; apply deg3_cube; esimp
variables {A B C : Type}
definition switch_left [reducible] : join A B → join (join C B) A :=
begin
intro x, induction x with a b a b, exact inr a, exact inl (inr b), apply !glue⁻¹,
end
private definition switch_coh_fill_square (a : A) (b : B) (c : C) :=
square (glue (inl c) a)⁻¹ (ap inl (glue c b))⁻¹ (ap switch_left (glue a b)) idp
private definition switch_coh_fill_cube (a : A) (b : B) (c : C)
(sq : switch_coh_fill_square a b c) :=
cube (hdeg_square !join.elim_glue) ids
sq (massage_sq !square_Flr_ap_idp)
hrfl hrfl
private definition switch_coh_fill_type (a : A) (b : B) (c : C) :=
Σ sq : switch_coh_fill_square a b c, switch_coh_fill_cube a b c sq
private definition switch_coh_fill (a : A) (b : B) (c : C)
: switch_coh_fill_type a b c :=
by esimp; apply cube_fill101
private definition switch_coh (ab : join A B) (c : C) : switch_left ab = inl (inl c) :=
begin
induction ab with a b a b, apply !glue⁻¹, apply (ap inl !glue)⁻¹,
apply eq_pathover, refine _ ⬝hp !ap_constant⁻¹,
apply !switch_coh_fill.1,
end
protected definition switch [reducible] : join (join A B) C → join (join C B) A :=
begin
intro x, induction x with ab c ab c, exact switch_left ab, exact inl (inl c),
exact switch_coh ab c,
end
private definition switch_inv_left_square (a : A) (b : B) :
square idp idp (ap (!(@join.switch C) ∘ switch_left) (glue a b)) (ap inl (glue a b)) :=
begin
refine hdeg_square !ap_compose ⬝h _,
refine aps join.switch (hdeg_square !join.elim_glue) ⬝h _, esimp,
refine hdeg_square !(ap_inv join.switch) ⬝h _,
refine hrfl⁻¹ʰ⁻¹ᵛ ⬝h _, esimp[join.switch,switch_left,switch_coh],
refine (hdeg_square !join.elim_glue)⁻¹ᵛ ⬝h _, esimp,
refine hrfl⁻¹ᵛ ⬝h _, apply hdeg_square !inv_inv,
end
private definition switch_inv_coh_left (c : C) (a : A) :
square idp idp (ap !(@join.switch C B) (switch_coh (inl a) c)) (glue (inl a) c) :=
begin
refine hrfl ⬝h _,
refine aps join.switch hrfl ⬝h _, esimp[switch_coh],
refine hdeg_square !ap_inv ⬝h _,
refine hrfl⁻¹ʰ⁻¹ᵛ ⬝h _, esimp[join.switch,switch_left],
refine (hdeg_square !join.elim_glue)⁻¹ᵛ ⬝h _,
refine hrfl⁻¹ᵛ ⬝h _, apply hdeg_square !inv_inv,
end
private definition switch_inv_coh_right (c : C) (b : B) :
square idp idp (ap !(@join.switch _ _ A) (switch_coh (inr b) c)) (glue (inr b) c) :=
begin
refine hrfl ⬝h _,
refine aps join.switch hrfl ⬝h _, esimp[switch_coh],
refine hdeg_square !ap_inv ⬝h _,
refine (hdeg_square !ap_compose)⁻¹ʰ⁻¹ᵛ ⬝h _,
refine hrfl⁻¹ᵛ ⬝h _, esimp[join.switch,switch_left],
refine (hdeg_square !join.elim_glue)⁻¹ᵛ ⬝h _, apply hdeg_square !inv_inv,
end
private definition switch_inv_left (ab : join A B) :
!(@join.switch C) (join.switch (inl ab)) = inl ab :=
begin
induction ab with a b a b, do 2 reflexivity,
apply eq_pathover, exact !switch_inv_left_square,
end
section
variables (a : A) (b : B) (c : C)
private definition switch_inv_cube_aux1 {A B C : Type} {b : B} {f : A → B} (h : B → C)
(g : Π a, f a = b) {x y : A} (p : x = y) :
cube (hdeg_square (ap_compose h f p)) ids (square_Flr_ap_idp (λ a, ap h (g a)) p)
(aps h (square_Flr_ap_idp _ _)) hrfl hrfl :=
by cases p; esimp[square_Flr_ap_idp]; apply deg2_cube; cases (g x); esimp
private definition switch_inv_cube_aux2 {A B : Type} {b : B} {f : A → B}
(g : Π a, f a = b) {x y : A} (p : x = y) {sq : square (g x) (g y) (ap f p) idp}
(q : apdo g p = eq_pathover (sq ⬝hp !ap_constant⁻¹)) : square_Flr_ap_idp _ _ = sq :=
begin
cases p, esimp at *, apply concat, apply inverse, apply vdeg_square_idp,
apply concat, apply ap vdeg_square, exact ap eq_of_pathover_idp q,
krewrite (is_equiv.right_inv (equiv.to_fun !pathover_idp)),
exact is_equiv.left_inv (equiv.to_fun (vdeg_square_equiv _ _)) sq,
end
private definition switch_inv_cube (a : A) (b : B) (c : C) :
cube (switch_inv_left_square a b) ids (square_Flr_ap_idp _ _)
(square_Flr_ap_idp _ _) (switch_inv_coh_left c a) (switch_inv_coh_right c b) :=
begin
esimp [switch_inv_coh_left, switch_inv_coh_right, switch_inv_left_square],
apply cube_concat2, apply switch_inv_cube_aux1,
apply cube_concat2, apply cube_transport101, apply inverse,
apply ap (λ x, aps join.switch x), apply switch_inv_cube_aux2, apply join.rec_glue,
apply apc, apply (switch_coh_fill a b c).2,
apply cube_concat2, esimp, apply ap_square_massage,
apply cube_concat2, apply massage_cube, apply cube_inverse2, apply switch_inv_cube_aux1,
apply cube_concat2, apply massage_cube, apply square_Flr_ap_idp_cube,
apply cube_concat2, apply massage_cube, apply cube_transport101,
apply inverse, apply switch_inv_cube_aux2,
esimp[switch_coh], apply join.rec_glue, apply (switch_coh_fill c b a).2,
apply massage_massage,
end
end
private definition pathover_of_triangle_cube {A B : Type} {b₀ b₁ : A → B}
{b : B} {p₀₁ : Π a, b₀ a = b₁ a} {p₀ : Π a, b₀ a = b} {p₁ : Π a, b₁ a = b}
{x y : A} {q : x = y} {sqx : square (p₀₁ x) idp (p₀ x) (p₁ x)}
{sqy : square (p₀₁ y) idp (p₀ y) (p₁ y)}
(c : cube (natural_square_tr _ _) ids (square_Flr_ap_idp p₀ q) (square_Flr_ap_idp p₁ q)
sqx sqy) :
sqx =[q] sqy :=
by cases q; apply pathover_of_eq_tr; apply eq_of_deg12_cube; exact c
private definition pathover_of_ap_ap_square {A : Type} {x y : A} {p : x = y}
(g : B → A) (f : A → B) {u : g (f x) = x} {v : g (f y) = y}
(sq : square (ap g (ap f p)) p u v) : u =[p] v :=
by cases p; apply eq_pathover; apply transpose; exact sq
private definition natural_square_tr_beta {A B : Type} {f₁ f₂ : A → B}
(p : Π a, f₁ a = f₂ a) {x y : A} (q : x = y) {sq : square (p x) (p y) (ap f₁ q) (ap f₂ q)}
(e : apdo p q = eq_pathover sq) :
natural_square_tr p q = sq :=
begin
cases q, esimp at *, apply concat, apply inverse, apply vdeg_square_idp,
apply concat, apply ap vdeg_square, apply ap eq_of_pathover_idp e,
krewrite (is_equiv.right_inv (equiv.to_fun !pathover_idp)),
exact is_equiv.left_inv (equiv.to_fun (vdeg_square_equiv _ _)) sq,
end
private definition switch_inv_coh (c : C) (k : join A B) :
square (switch_inv_left k) idp (ap join.switch (switch_coh k c)) (glue k c) :=
begin
induction k with a b a b, apply switch_inv_coh_left, apply switch_inv_coh_right,
refine pathover_of_triangle_cube _,
esimp, apply cube_transport011,
apply inverse, rotate 1, apply switch_inv_cube,
apply natural_square_tr_beta, apply join.rec_glue,
end
protected definition switch_involutive (x : join (join A B) C) :
join.switch (join.switch x) = x :=
begin
induction x with ab c ab c, apply switch_inv_left, reflexivity,
apply pathover_of_ap_ap_square join.switch join.switch,
krewrite join.elim_glue, esimp,
apply transpose, exact !switch_inv_coh,
end
end join_switch
protected definition switch_equiv (A B C : Type) : join (join A B) C ≃ join (join C B) A :=
by apply equiv.MK; do 2 apply join.switch_involutive
protected definition assoc (A B C : Type) : join (join A B) C ≃ join A (join B C) :=
calc join (join A B) C ≃ join (join C B) A : join.switch_equiv
... ≃ join A (join C B) : join.symm
... ≃ join A (join B C) : join.equiv_closed erfl (join.symm C B)
protected definition ap_assoc_inv_glue_inl {A B : Type} (C : Type) (a : A) (b : B)
: ap (to_inv (join.assoc A B C)) (glue a (inl b)) = ap inl (glue a b) :=
begin
unfold join.assoc, unfold equiv.trans, rewrite ap_compose, krewrite join.elim_glue,
rewrite ap_compose, krewrite join.elim_glue, rewrite ap_inv, krewrite join.elim_glue,
unfold switch_coh, unfold join.symm, unfold join.swap, esimp, rewrite eq.inv_inv
end
protected definition ap_assoc_inv_glue_inr {A C : Type} (B : Type) (a : A) (c : C)
: ap (to_inv (join.assoc A B C)) (glue a (inr c)) = glue (inl a) c :=
begin
unfold join.assoc, unfold equiv.trans, rewrite ap_compose, krewrite join.elim_glue,
rewrite ap_compose, krewrite join.elim_glue, rewrite ap_inv, krewrite join.elim_glue,
unfold switch_coh, unfold join.symm, unfold join.swap, esimp, rewrite eq.inv_inv
end
end join
namespace join
open sphere sphere_index sphere.ops
protected definition spheres (n m : ℕ₋₁) : join (S n) (S m) ≃ S (n+1+m) :=
begin
apply equiv.trans (join.symm (S n) (S m)),
induction m with m IH,
{ exact join.empty (S n) },
{ calc join (S m.+1) (S n)
≃ join (join bool (S m)) (S n)
: join.equiv_closed (equiv.symm (join.bool (S m))) erfl
... ≃ join bool (join (S m) (S n))
: join.assoc
... ≃ join bool (S (n+1+m))
: join.equiv_closed erfl IH
... ≃ sphere (n+1+m.+1)
: join.bool (S (n+1+m)) }
end
end join
|
a207f5dd5408b37e73da3957b5cdc402c2e123e0 | 64874bd1010548c7f5a6e3e8902efa63baaff785 | /tests/lean/hott/bug_struct_level.hlean | 32e9af505fecde631dfcd9f772369abcd933a787 | [
"Apache-2.0"
] | permissive | tjiaqi/lean | 4634d729795c164664d10d093f3545287c76628f | d0ce4cf62f4246b0600c07e074d86e51f2195e30 | refs/heads/master | 1,622,323,796,480 | 1,422,643,069,000 | 1,422,643,069,000 | null | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 1,196 | hlean | import algebra.precategory.basic
open precategory
context
parameter {D₀ : Type}
parameter (C : precategory D₀)
parameter (D₂ : Π ⦃a b c d : D₀⦄ (f : hom a b) (g : hom c d) (h : hom a c) (i : hom b d), Type)
attribute compose [reducible]
definition comp₁_type [reducible] : Type :=
Π ⦃a b c₁ d₁ c₂ d₂ : D₀⦄
⦃f₁ : hom a b⦄ ⦃g₁ : hom c₁ d₁⦄ ⦃h₁ : hom a c₁⦄ ⦃i₁ : hom b d₁⦄
⦃g₂ : hom c₂ d₂⦄ ⦃h₂ : hom c₁ c₂⦄ ⦃i₂ : hom d₁ d₂⦄,
(D₂ g₁ g₂ h₂ i₂) → (D₂ f₁ g₁ h₁ i₁) → (@D₂ a b c₂ d₂ f₁ g₂ (h₂ ∘ h₁) (i₂ ∘ i₁))
definition ID₁_type [reducible] : Type :=
Π ⦃a b : D₀⦄ (f : hom a b), D₂ f f (ID a) (ID b)
structure worm_precat [class] : Type :=
(comp₁ : comp₁_type)
(ID₁ : ID₁_type)
end
context
parameter {D₀ : Type}
parameter [C : precategory D₀]
parameter {D₂ : Π ⦃a b c d : D₀⦄ (f : hom a b) (g : hom c d) (h : hom a c) (i : hom b d), Type}
parameter [D : worm_precat C D₂]
include D
structure two_cell_ob : Type :=
(vo1 : D₀) (vo2 : D₀) (vo3 : hom vo1 vo2)
end
|
ae0697fa10e3ee6ee6101f36798d4ea3635482ce | 874a8d2247ab9a4516052498f80da2e32d0e3a48 | /root2final.lean | 5dd5db9b9eae532c76f6b837626bc36b237c9e60 | [] | no_license | AlexKontorovich/Spring2020Math492 | 378b36c643ee029f5ab91c1677889baa591f5e85 | 659108c5d864ff5c75b9b3b13b847aa5cff4348a | refs/heads/master | 1,610,780,595,457 | 1,588,174,859,000 | 1,588,174,859,000 | 243,017,788 | 0 | 1 | null | null | null | null | UTF-8 | Lean | false | false | 1,068 | lean | import tactic
import data.nat.prime
open nat
theorem simproot2 {x y : ℕ} (coprime : gcd x y = 1) : x^2 ≠ 2 * y^2 :=
-- For Contradiction, will show false
assume contr : x^2 = 2 * y^2,
have twodivxsquare : 2 ∣ x^2,
by exact dvd.intro (y ^ 2) (eq.symm contr),
have twodivx: 2 ∣ x,
from prime.dvd_of_dvd_pow prime_two twodivxsquare,
exists.elim twodivx $
assume (z : nat) (introz : x = 2 * z),
have subst : 2 * (2 * z^2) = 2 * y^2,
by
begin
rw introz at contr,
simp[eq.symm contr, nat.pow],
simp [nat.pow_succ, mul_comm, mul_assoc, mul_left_comm],
end,
have subst2 : 2 * z^2 = y^2,
from eq_of_mul_eq_mul_left dec_trivial subst,
have revsubst : y^2 = 2 * z^2,
by rw ←subst2,
have twodivysquare : 2 ∣ y^2,
by exact dvd.intro (z ^ 2) (eq.symm revsubst),
have twodivy: 2 ∣ y,
from prime.dvd_of_dvd_pow prime_two twodivysquare,
have fin : 2 ∣ gcd x y,
from dvd_gcd twodivx twodivy,
have last : 2 ∣ 1,
from
begin
rw coprime at fin,
use fin,
end,
show false,
from absurd last dec_trivial
|
8f6a86a73aab4b682da80412170524b0a3623e7d | b7f22e51856f4989b970961f794f1c435f9b8f78 | /tests/lean/run/blast_grind1.lean | 54fe83b08f7094ff266b5d68278ad77bbeb26148 | [
"Apache-2.0"
] | permissive | soonhokong/lean | cb8aa01055ffe2af0fb99a16b4cda8463b882cd1 | 38607e3eb57f57f77c0ac114ad169e9e4262e24f | refs/heads/master | 1,611,187,284,081 | 1,450,766,737,000 | 1,476,122,547,000 | 11,513,992 | 2 | 0 | null | 1,401,763,102,000 | 1,374,182,235,000 | C++ | UTF-8 | Lean | false | false | 911 | lean | set_option blast.strategy "core_grind"
example (a b c : nat) : a = b ∨ a = c → b = c → b = a :=
by blast
example (f : nat → nat) (a b c : nat) : f a = f b ∨ f a = f c → f b = f c → f b = f a :=
by blast
definition ex1 (a : nat) : a = 0 → (λ x, x + a) = (λ x, x + 0) :=
by blast
print ex1
attribute Exists.intro [intro!] -- core_grind only process [intro!] declarations
example (p q : nat → Prop) : (∃ x, p x ∧ q x) → (∃ x, q x) ∧ (∃ x, p x) :=
by blast
set_option blast.strategy "core_grind"
example (a b c : nat) : a = b ∨ a = c → b = c → b = a :=
by blast
example (f : nat → nat) (a b c : nat) : f a = f b ∨ f a = f c → f b = f c → f b = f a :=
by blast
example (a : nat) : a = 0 → (λ x, x + a) = (λ x, x + 0) :=
by blast
set_option trace.blast true
example (p q : nat → Prop) : (∃ x, p x ∧ q x) → (∃ x, q x) ∧ (∃ x, p x) :=
by blast
|
e553d660f680ae1258932b8eae54d4aa3d038626 | 4727251e0cd73359b15b664c3170e5d754078599 | /src/tactic/group.lean | d1ea8f30697df63b31b3f8d17a0696ffdad88475 | [
"Apache-2.0"
] | permissive | Vierkantor/mathlib | 0ea59ac32a3a43c93c44d70f441c4ee810ccceca | 83bc3b9ce9b13910b57bda6b56222495ebd31c2f | refs/heads/master | 1,658,323,012,449 | 1,652,256,003,000 | 1,652,256,003,000 | 209,296,341 | 0 | 1 | Apache-2.0 | 1,568,807,655,000 | 1,568,807,655,000 | null | UTF-8 | Lean | false | false | 3,785 | lean | /-
Copyright (c) 2020. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Patrick Massot
-/
import tactic.ring
import tactic.doc_commands
/-!
# `group`
Normalizes expressions in the language of groups. The basic idea is to use the simplifier
to put everything into a product of group powers (`zpow` which takes a group element and an
integer), then simplify the exponents using the `ring` tactic. The process needs to be repeated
since `ring` can normalize an exponent to zero, leading to a factor that can be removed
before collecting exponents again. The simplifier step also uses some extra lemmas to avoid
some `ring` invocations.
## Tags
group_theory
-/
-- The next four lemmas are not general purpose lemmas, they are intended for use only by
-- the `group` tactic.
@[to_additive]
lemma tactic.group.zpow_trick {G : Type*} [group G] (a b : G) (n m : ℤ) : a*b^n*b^m = a*b^(n+m) :=
by rw [mul_assoc, ← zpow_add]
@[to_additive]
lemma tactic.group.zpow_trick_one {G : Type*} [group G] (a b : G) (m : ℤ) : a*b*b^m = a*b^(m+1) :=
by rw [mul_assoc, mul_self_zpow]
@[to_additive]
lemma tactic.group.zpow_trick_one' {G : Type*} [group G] (a b : G) (n : ℤ) : a*b^n*b = a*b^(n+1) :=
by rw [mul_assoc, mul_zpow_self]
@[to_additive]
lemma tactic.group.zpow_trick_sub {G : Type*} [group G] (a b : G) (n m : ℤ) :
a*b^n*b^(-m) = a*b^(n-m) :=
by rw [mul_assoc, ← zpow_add] ; refl
namespace tactic
setup_tactic_parser
open tactic.simp_arg_type interactive tactic.group
/-- Auxiliary tactic for the `group` tactic. Calls the simplifier only. -/
meta def aux_group₁ (locat : loc) : tactic unit :=
simp_core {} skip tt [
expr ``(commutator_element_def),
expr ``(mul_one),
expr ``(one_mul),
expr ``(one_pow),
expr ``(one_zpow),
expr ``(sub_self),
expr ``(add_neg_self),
expr ``(neg_add_self),
expr ``(neg_neg),
expr ``(tsub_self),
expr ``(int.coe_nat_add),
expr ``(int.coe_nat_mul),
expr ``(int.coe_nat_zero),
expr ``(int.coe_nat_one),
expr ``(int.coe_nat_bit0),
expr ``(int.coe_nat_bit1),
expr ``(int.mul_neg_eq_neg_mul_symm),
expr ``(int.neg_mul_eq_neg_mul_symm),
symm_expr ``(zpow_coe_nat),
symm_expr ``(zpow_neg_one),
symm_expr ``(zpow_mul),
symm_expr ``(zpow_add_one),
symm_expr ``(zpow_one_add),
symm_expr ``(zpow_add),
expr ``(mul_zpow_neg_one),
expr ``(zpow_zero),
expr ``(mul_zpow),
symm_expr ``(mul_assoc),
expr ``(zpow_trick),
expr ``(zpow_trick_one),
expr ``(zpow_trick_one'),
expr ``(zpow_trick_sub),
expr ``(tactic.ring.horner)]
[] locat >> skip
/-- Auxiliary tactic for the `group` tactic. Calls `ring_nf` to normalize exponents. -/
meta def aux_group₂ (locat : loc) : tactic unit :=
ring_nf none tactic.ring.normalize_mode.raw locat
end tactic
namespace tactic.interactive
setup_tactic_parser
open tactic
/--
Tactic for normalizing expressions in multiplicative groups, without assuming
commutativity, using only the group axioms without any information about which group
is manipulated.
(For additive commutative groups, use the `abel` tactic instead.)
Example:
```lean
example {G : Type} [group G] (a b c d : G) (h : c = (a*b^2)*((b*b)⁻¹*a⁻¹)*d) : a*c*d⁻¹ = a :=
begin
group at h, -- normalizes `h` which becomes `h : c = d`
rw h, -- the goal is now `a*d*d⁻¹ = a`
group, -- which then normalized and closed
end
```
-/
meta def group (locat : parse location) : tactic unit :=
do when locat.include_goal `[rw ← mul_inv_eq_one],
try (aux_group₁ locat),
repeat (aux_group₂ locat ; aux_group₁ locat)
end tactic.interactive
add_tactic_doc
{ name := "group",
category := doc_category.tactic,
decl_names := [`tactic.interactive.group],
tags := ["decision procedure", "simplification"] }
|
ec1c46fcee835945b0581fc2f36244b7ad0beaf8 | 80746c6dba6a866de5431094bf9f8f841b043d77 | /src/linear_algebra/dimension.lean | 28a7030a7990e4495613847e4cb5b76d76f537c3 | [
"Apache-2.0"
] | permissive | leanprover-fork/mathlib-backup | 8b5c95c535b148fca858f7e8db75a76252e32987 | 0eb9db6a1a8a605f0cf9e33873d0450f9f0ae9b0 | refs/heads/master | 1,585,156,056,139 | 1,548,864,430,000 | 1,548,864,438,000 | 143,964,213 | 0 | 0 | Apache-2.0 | 1,550,795,966,000 | 1,533,705,322,000 | Lean | UTF-8 | Lean | false | false | 8,649 | lean | /-
Copyright (c) 2018 Mario Carneiro. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Author: Mario Carneiro, Johannes Hölzl, Sander Dahmen
Dimension of modules and vector spaces.
-/
import linear_algebra.basis
import set_theory.ordinal
noncomputable theory
local attribute [instance, priority 0] classical.prop_decidable
universes u v w
variables {α : Type u} {β γ δ : Type v}
section vector_space
variables [discrete_field α] [add_comm_group β] [vector_space α β]
include α
open submodule lattice function set
variables (α β)
def vector_space.dim : cardinal :=
cardinal.min
(nonempty_subtype.2 (exists_is_basis α β))
(λ b, cardinal.mk b.1)
variables {α β}
open vector_space
theorem is_basis.le_span {I J : set β} (hI : is_basis α I) (hJ : span α J = ⊤) : cardinal.mk I ≤ cardinal.mk J :=
begin
cases le_or_lt cardinal.omega (cardinal.mk J) with oJ oJ,
{ refine le_of_not_lt (λ IJ, _),
let S : J → set β := λ j, ↑(hI.repr j).support,
have hs : I ⊆ ⋃ j, S j,
{ intros i hi,
have : span α J ≤ comap hI.repr (lc.supported α (⋃ j, S j)) :=
span_le.2 (λ j hj x hx, ⟨_, ⟨⟨j, hj⟩, rfl⟩, hx⟩),
rw hJ at this, replace : hI.repr i ∈ _ := this trivial,
rw hI.repr_eq_single hi at this,
apply this, simp },
suffices : cardinal.mk (⋃ j, S j) < cardinal.mk I,
from not_le_of_lt this ⟨set.embedding_of_subset hs⟩,
refine lt_of_le_of_lt (le_trans cardinal.mk_Union_le_sum_mk
(cardinal.sum_le_sum _ (λ _, cardinal.omega) _)) _,
{ exact λ j, le_of_lt (cardinal.lt_omega_iff_finite.2 $ finset.finite_to_set _) },
{ rwa [cardinal.sum_const, cardinal.mul_eq_max oJ (le_refl _), max_eq_left oJ] } },
{ rcases exists_finite_card_le_of_finite_of_linear_independent_of_span
(cardinal.lt_omega_iff_finite.1 oJ) hI.1 _ with ⟨fI, hi⟩,
{ rwa [← cardinal.nat_cast_le, cardinal.finset_card, finset.coe_to_finset,
cardinal.finset_card, finset.coe_to_finset] at hi },
{ rw hJ, apply set.subset_univ } },
end
/-- dimension theorem -/
theorem mk_eq_mk_of_basis {I J : set β} (hI : is_basis α I) (hJ : is_basis α J) : cardinal.mk I = cardinal.mk J :=
le_antisymm (hI.le_span hJ.2) (hJ.le_span hI.2)
theorem is_basis.mk_eq_dim {b : set β} (h : is_basis α b) : cardinal.mk b = dim α β :=
let ⟨b', e⟩ := show ∃ b', dim α β = _, from cardinal.min_eq _ _ in
mk_eq_mk_of_basis h (subtype.property _)
variables [add_comm_group γ] [vector_space α γ]
theorem linear_equiv.dim_eq (f : β ≃ₗ[α] γ) : dim α β = dim α γ :=
let ⟨b, hb⟩ := exists_is_basis α β in
hb.mk_eq_dim.symm.trans $
(cardinal.mk_eq_of_injective f.to_equiv.bijective.1).symm.trans $
(f.is_basis hb).mk_eq_dim
lemma dim_bot : dim α (⊥ : submodule α β) = 0 :=
begin
rw [← (@is_basis_empty_bot α β _ _ _).mk_eq_dim],
exact cardinal.mk_emptyc (⊥ : submodule α β)
end
set_option class.instance_max_depth 37
lemma dim_span {s : set β} (hs : linear_independent α s) : dim α ↥(span α s) = cardinal.mk s :=
have (span α s).subtype '' ((span α s).subtype ⁻¹' s) = s :=
image_preimage_eq_of_subset $ by rw [← linear_map.range_coe, range_subtype]; exact subset_span,
begin
rw [← (is_basis_span hs).mk_eq_dim],
calc cardinal.mk ↥(⇑(submodule.subtype (span α s)) ⁻¹' s) =
cardinal.mk ↥((submodule.subtype (span α s)) '' ((submodule.subtype (span α s)) ⁻¹' s)) :
(cardinal.mk_eq_of_injective subtype.val_injective).symm
... = cardinal.mk ↥s : by rw this
end
set_option class.instance_max_depth 32
theorem dim_prod : dim α (β × γ) = dim α β + dim α γ :=
begin
rcases exists_is_basis α β with ⟨b, hb⟩,
rcases exists_is_basis α γ with ⟨c, hc⟩,
rw [← @is_basis.mk_eq_dim α (β × γ) _ _ _ _ (is_basis_inl_union_inr hb hc),
← hb.mk_eq_dim, ← hc.mk_eq_dim, cardinal.mk_union_of_disjoint,
cardinal.mk_eq_of_injective, cardinal.mk_eq_of_injective],
{ exact prod.injective_inr },
{ exact prod.injective_inl },
{ rintro _ ⟨⟨x, hx, rfl⟩, ⟨y, hy, ⟨⟩⟩⟩,
exact zero_not_mem_of_linear_independent (@zero_ne_one α _) hb.1 hx }
end
theorem dim_quotient (p : submodule α β) : dim α p.quotient + dim α p = dim α β :=
let ⟨f⟩ := quotient_prod_linear_equiv p in dim_prod.symm.trans f.dim_eq
/-- rank-nullity theorem -/
theorem dim_range_add_dim_ker (f : β →ₗ[α] γ) : dim α f.range + dim α f.ker = dim α β :=
by rw [← f.quot_ker_equiv_range.dim_eq, dim_quotient]
lemma dim_range_le (f : β →ₗ[α] γ) : dim α f.range ≤ dim α β :=
by rw ← dim_range_add_dim_ker f; exact le_add_right (le_refl _)
lemma dim_map_le (f : β →ₗ γ) (p : submodule α β): dim α (p.map f) ≤ dim α p :=
begin
have h := dim_range_le (f.comp (submodule.subtype p)),
rwa [linear_map.range_comp, range_subtype] at h,
end
lemma dim_range_of_surjective (f : β →ₗ[α] γ) (h : surjective f) :
dim α f.range = dim α γ :=
begin
refine linear_equiv.dim_eq (linear_equiv.of_bijective (submodule.subtype _) _ _),
exact linear_map.ker_eq_bot.2 subtype.val_injective,
rwa [range_subtype, linear_map.range_eq_top]
end
lemma dim_eq_surjective (f : β →ₗ[α] γ) (h : surjective f) : dim α β = dim α γ + dim α f.ker :=
by rw [← dim_range_add_dim_ker f, ← dim_range_of_surjective f h]
lemma dim_le_surjective (f : β →ₗ[α] γ) (h : surjective f) : dim α γ ≤ dim α β :=
by rw [dim_eq_surjective f h]; refine le_add_right (le_refl _)
lemma dim_eq_injective (f : β →ₗ[α] γ) (h : injective f) : dim α β = dim α f.range :=
by rw [← dim_range_add_dim_ker f, linear_map.ker_eq_bot.2 h]; simp [dim_bot]
set_option class.instance_max_depth 37
lemma dim_submodule_le (s : submodule α β) : dim α s ≤ dim α β :=
begin
rcases exists_is_basis α s with ⟨bs, hbs⟩,
have : linear_independent α (submodule.subtype s '' bs) :=
hbs.1.image (linear_map.disjoint_ker'.2 $ assume x y _ _ eq, subtype.val_injective eq),
have : linear_independent α ((coe : s → β) '' bs) := this,
rcases exists_subset_is_basis this with ⟨b, hbs_b, hb⟩,
rw [← is_basis.mk_eq_dim hbs, ← is_basis.mk_eq_dim hb],
calc cardinal.mk ↥bs = cardinal.mk ((coe : s → β) '' bs) :
(cardinal.mk_eq_of_injective $ subtype.val_injective).symm
... ≤ cardinal.mk ↥b :
nonempty.intro (embedding_of_subset hbs_b)
end
set_option class.instance_max_depth 32
lemma dim_le_injective (f : β →ₗ[α] γ) (h : injective f) : dim α β ≤ dim α γ :=
by rw [dim_eq_injective f h]; exact dim_submodule_le _
lemma dim_le_of_submodule (s t : submodule α β) (h : s ≤ t) : dim α s ≤ dim α t :=
dim_le_injective (of_le h) $ assume ⟨x, hx⟩ ⟨y, hy⟩ eq,
subtype.eq $ show x = y, from subtype.ext.1 eq
set_option class.instance_max_depth 37
lemma dim_add_le_dim_add_dim (s t : submodule α β) :
dim α (s ⊔ t : submodule α β) ≤ dim α s + dim α t :=
calc dim α (s ⊔ t : submodule α β) ≤ dim α (s × t) :
dim_le_surjective
(linear_map.copair (of_le $ le_sup_left) (of_le $ le_sup_right))
(assume ⟨b, (hb : b ∈ (s ⊔ t : submodule α β))⟩,
let ⟨x, hx, y, hy, eq⟩ := mem_sup.1 hb in
⟨⟨⟨x, hx⟩, ⟨y, hy⟩⟩, subtype.eq $ by simp [eq.symm]; refl⟩)
... = dim α s + dim α t : dim_prod
def rank (f : β →ₗ[α] γ) : cardinal := dim α f.range
lemma rank_le_domain (f : β →ₗ[α] γ) : rank f ≤ dim α β :=
by rw [← dim_range_add_dim_ker f]; exact le_add_right (le_refl _)
lemma rank_le_range (f : β →ₗ[α] γ) : rank f ≤ dim α γ :=
dim_submodule_le _
lemma rank_add_le (f g : β →ₗ[α] γ) : rank (f + g) ≤ rank f + rank g :=
calc rank (f + g) ≤ dim α (f.range ⊔ g.range : submodule α γ) :
begin
refine dim_le_of_submodule _ _ _,
exact (linear_map.range_le_iff_comap.2 $ eq_top_iff'.2 $
assume x, show f x + g x ∈ (f.range ⊔ g.range : submodule α γ), from
mem_sup.2 ⟨_, mem_image_of_mem _ (mem_univ _), _, mem_image_of_mem _ (mem_univ _), rfl⟩)
end
... ≤ rank f + rank g : dim_add_le_dim_add_dim _ _
variables [add_comm_group δ] [vector_space α δ]
lemma rank_comp_le1 (g : β →ₗ[α] γ) (f : γ →ₗ[α] δ) : rank (f.comp g) ≤ rank f :=
begin
refine dim_le_of_submodule _ _ _,
rw [linear_map.range_comp],
exact image_subset _ (subset_univ _)
end
lemma rank_comp_le2 (g : β →ₗ[α] γ) (f : γ →ₗ δ) : rank (f.comp g) ≤ rank g :=
by rw [rank, rank, linear_map.range_comp]; exact dim_map_le _ _
end vector_space
|
8a4fa034c38c3a76b72a3e01a0387fce3a470811 | 5749d8999a76f3a8fddceca1f6941981e33aaa96 | /src/analysis/calculus/mean_value.lean | 1c33de1006f5decc85e6d3a1551fe2180152fb8d | [
"Apache-2.0"
] | permissive | jdsalchow/mathlib | 13ab43ef0d0515a17e550b16d09bd14b76125276 | 497e692b946d93906900bb33a51fd243e7649406 | refs/heads/master | 1,585,819,143,348 | 1,580,072,892,000 | 1,580,072,892,000 | 154,287,128 | 0 | 0 | Apache-2.0 | 1,540,281,610,000 | 1,540,281,609,000 | null | UTF-8 | Lean | false | false | 38,676 | lean | /-
Copyright (c) 2019 Sébastien Gouëzel. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Sébastien Gouëzel, Yury Kudryashov
-/
import analysis.calculus.local_extr
/-!
# The mean value inequality and equalities
In this file we prove the following facts:
* `convex.norm_image_sub_le_of_norm_deriv_le` : if `f` is differentaible on a convex set `s`
and the norm of its derivative is bounded by `C`, then `f` is Lipschitz continuous on `s` with
constant `C`.
* `image_le_of*`, `image_norm_le_of_*` : several similar lemmas deducing `f x ≤ B x` or
`∥f x∥ ≤ B x` from upper estimates on `f'` or `∥f'∥`, respectively. These lemmas differ by
their assumptions:
* `of_liminf_*` lemmas assume that limit inferior of some ratio is less than `B' x`;
* `of_deriv_right_*`, `of_norm_deriv_right_*` lemmas assume that the right derivative
or its norm is less than `B' x`;
* `of_*_lt_*` lemmas assume a strict inequality whenever `f x = B x` or `∥f x∥ = B x`;
* `of_*_le_*` lemmas assume a non-strict inequality everywhere on `[a, b)`;
* name of a lemma ends with `'` if (1) it assumes that `B` is continuous on `[a, b]`
and has a right derivative at every point of `[a, b)`, and (2) the lemma has
a counterpart assuming that `B` is differentiable everywhere on `ℝ`
* `norm_image_sub_le_*_segment` : if derivative of `f` on `[a, b]` is bounded above
by a constant `C`, then `∥f x - f a∥ ≤ C * ∥x - a∥`; several versions deal with
right derivative and derivative within `[a, b]` (`has_deriv_within_at` or `deriv_within`).
* `convex.is_const_of_fderiv_within_eq_zero` : if a function has derivative `0` on a convex set `s`,
then it is a constant on `s`.
* `exists_ratio_has_deriv_at_eq_ratio_slope` and `exists_ratio_deriv_eq_ratio_slope` :
Cauchy's Mean Value Theorem.
* `exists_has_deriv_at_eq_slope` and `exists_deriv_eq_slope` : Lagrange's Mean Value Theorem.
* `convex.image_sub_lt_mul_sub_of_deriv_lt`, `convex.mul_sub_lt_image_sub_of_lt_deriv`,
`convex.image_sub_le_mul_sub_of_deriv_le`, `convex.mul_sub_le_image_sub_of_le_deriv`,
if `∀ x, C (</≤/>/≥) (f' x)`, then `C * (y - x) (</≤/>/≥) (f y - f x)` whenever `x < y`.
* `convex.mono_of_deriv_nonneg`, `convex.antimono_of_deriv_nonpos`,
`convex.strict_mono_of_deriv_pos`, `convex.strict_antimono_of_deriv_neg` :
if the derivative of a function is non-negative/non-positive/positive/negative, then
the function is monotone/monotonically decreasing/strictly monotone/strictly monotonically
decreasing.
* `convex_on_of_deriv_mono`, `convex_on_of_deriv2_nonneg` : if the derivative of a function
is increasing or its second derivative is nonnegative, then the original function is convex.
-/
set_option class.instance_max_depth 120
variables {E : Type*} [normed_group E] [normed_space ℝ E]
{F : Type*} [normed_group F] [normed_space ℝ F]
open metric set lattice asymptotics continuous_linear_map filter
open_locale classical topological_space
/-! ### One-dimensional fencing inequalities -/
/-- General fencing theorem for continuous functions with an estimate on the derivative.
Let `f` and `B` be continuous functions on `[a, b]` such that
* `f a ≤ B a`;
* `B` has right derivative `B'` at every point of `[a, b)`;
* for each `x ∈ [a, b)` the right-side limit inferior of `(f z - f x) / (z - x)`
is bounded above by a function `f'`;
* we have `f' x < B' x` whenever `f x = B x`.
Then `f x ≤ B x` everywhere on `[a, b]`. -/
lemma image_le_of_liminf_slope_right_lt_deriv_boundary' {f f' : ℝ → ℝ} {a b : ℝ}
(hf : continuous_on f (Icc a b))
-- `hf'` actually says `liminf (z - x)⁻¹ * (f z - f x) ≤ f' x`
(hf' : ∀ x ∈ Ico a b, ∀ r, f' x < r →
∃ᶠ z in nhds_within x (Ioi x), (z - x)⁻¹ * (f z - f x) < r)
{B B' : ℝ → ℝ} (ha : f a ≤ B a) (hB : continuous_on B (Icc a b))
(hB' : ∀ x ∈ Ico a b, has_deriv_within_at B (B' x) (Ioi x) x)
(bound : ∀ x ∈ Ico a b, f x = B x → f' x < B' x) :
∀ ⦃x⦄, x ∈ Icc a b → f x ≤ B x :=
begin
change Icc a b ⊆ {x | f x ≤ B x},
set s := {x | f x ≤ B x} ∩ Icc a b,
have A : continuous_on (λ x, (f x, B x)) (Icc a b), from hf.prod hB,
have : is_closed s,
{ simp only [s, inter_comm],
exact A.preimage_closed_of_closed is_closed_Icc (order_closed_topology.is_closed_le' _) },
apply this.Icc_subset_of_forall_exists_gt ha,
rintros x ⟨hxB, xab⟩ y hy,
change f x ≤ B x at hxB,
cases lt_or_eq_of_le hxB with hxB hxB,
{ -- If `f x < B x`, then all we need is continuity of both sides
apply inhabited_of_mem_sets (nhds_within_Ioi_self_ne_bot x),
refine inter_mem_sets _ (Ioc_mem_nhds_within_Ioi ⟨le_refl x, hy⟩),
have : {x | f x < B x} ∈ nhds_within x (Icc a b),
from A x (Ico_subset_Icc_self xab)
(mem_nhds_sets (is_open_lt continuous_fst continuous_snd) hxB),
have : {x | f x < B x} ∈ nhds_within x (Ioi x),
from nhds_within_le_of_mem (Icc_mem_nhds_within_Ioi xab) this,
refine mem_sets_of_superset this (set_of_subset_set_of.2 $ λ y, le_of_lt) },
{ rcases dense (bound x xab hxB) with ⟨r, hfr, hrB⟩,
specialize hf' x xab r hfr,
have HB : ∀ᶠ z in nhds_within x (Ioi x), r < (z - x)⁻¹ * (B z - B x),
from (has_deriv_within_at_iff_tendsto_slope' $ lt_irrefl x).1 (hB' x xab)
(mem_nhds_sets is_open_Ioi hrB),
obtain ⟨z, ⟨hfz, hzB⟩, hz⟩ :
∃ z, ((z - x)⁻¹ * (f z - f x) < r ∧ r < (z - x)⁻¹ * (B z - B x)) ∧ z ∈ Ioc x y,
from ((hf'.and_eventually HB).and_eventually
(Ioc_mem_nhds_within_Ioi ⟨le_refl _, hy⟩)).exists,
have := le_of_lt (lt_trans hfz hzB),
refine ⟨z, _, hz⟩,
rw [mul_le_mul_left (inv_pos $ sub_pos.2 hz.1), hxB, sub_le_sub_iff_right] at this,
exact this }
end
/-- General fencing theorem for continuous functions with an estimate on the derivative.
Let `f` and `B` be continuous functions on `[a, b]` such that
* `f a ≤ B a`;
* `B` has derivative `B'` everywhere on `ℝ`;
* for each `x ∈ [a, b)` the right-side limit inferior of `(f z - f x) / (z - x)`
is bounded above by a function `f'`;
* we have `f' x < B' x` whenever `f x = B x`.
Then `f x ≤ B x` everywhere on `[a, b]`. -/
lemma image_le_of_liminf_slope_right_lt_deriv_boundary {f f' : ℝ → ℝ} {a b : ℝ}
(hf : continuous_on f (Icc a b))
-- `hf'` actually says `liminf (z - x)⁻¹ * (f z - f x) ≤ f' x`
(hf' : ∀ x ∈ Ico a b, ∀ r, f' x < r →
∃ᶠ z in nhds_within x (Ioi x), (z - x)⁻¹ * (f z - f x) < r)
{B B' : ℝ → ℝ} (ha : f a ≤ B a) (hB : ∀ x, has_deriv_at B (B' x) x)
(bound : ∀ x ∈ Ico a b, f x = B x → f' x < B' x) :
∀ ⦃x⦄, x ∈ Icc a b → f x ≤ B x :=
image_le_of_liminf_slope_right_lt_deriv_boundary' hf hf' ha
(λ x hx, (hB x).continuous_at.continuous_within_at)
(λ x hx, (hB x).has_deriv_within_at) bound
/-- General fencing theorem for continuous functions with an estimate on the derivative.
Let `f` and `B` be continuous functions on `[a, b]` such that
* `f a ≤ B a`;
* `B` has right derivative `B'` at every point of `[a, b)`;
* for each `x ∈ [a, b)` the right-side limit inferior of `(f z - f x) / (z - x)`
is bounded above by `B'`.
Then `f x ≤ B x` everywhere on `[a, b]`. -/
lemma image_le_of_liminf_slope_right_le_deriv_boundary {f : ℝ → ℝ} {a b : ℝ}
(hf : continuous_on f (Icc a b))
{B B' : ℝ → ℝ} (ha : f a ≤ B a) (hB : continuous_on B (Icc a b))
(hB' : ∀ x ∈ Ico a b, has_deriv_within_at B (B' x) (Ioi x) x)
-- `bound` actually says `liminf (z - x)⁻¹ * (f z - f x) ≤ B' x`
(bound : ∀ x ∈ Ico a b, ∀ r, B' x < r →
∃ᶠ z in nhds_within x (Ioi x), (z - x)⁻¹ * (f z - f x) < r) :
∀ ⦃x⦄, x ∈ Icc a b → f x ≤ B x :=
begin
have Hr : ∀ x ∈ Icc a b, ∀ r ∈ Ioi (0:ℝ), f x ≤ B x + r * (x - a),
{ intros x hx r hr,
apply image_le_of_liminf_slope_right_lt_deriv_boundary' hf bound,
{ rwa [sub_self, mul_zero, add_zero] },
{ exact hB.add (continuous_on_const.mul
(continuous_id.continuous_on.sub continuous_on_const)) },
{ assume x hx,
exact (hB' x hx).add (((has_deriv_within_at_id x (Ioi x)).sub_const a).const_mul r) },
{ assume x hx _,
rw [mul_one],
exact (lt_add_iff_pos_right _).2 hr },
exact hx },
assume x hx,
have : continuous_within_at (λ r, B x + r * (x - a)) (Ioi 0) 0,
from continuous_within_at_const.add (continuous_within_at_id.mul continuous_within_at_const),
convert continuous_within_at_const.closure_le _ this (Hr x hx); simp [closure_Ioi]
end
/-- General fencing theorem for continuous functions with an estimate on the derivative.
Let `f` and `B` be continuous functions on `[a, b]` such that
* `f a ≤ B a`;
* `B` has right derivative `B'` at every point of `[a, b)`;
* `f` has right derivative `f'` at every point of `[a, b)`;
* we have `f' x < B' x` whenever `f x = B x`.
Then `f x ≤ B x` everywhere on `[a, b]`. -/
lemma image_le_of_deriv_right_lt_deriv_boundary' {f f' : ℝ → ℝ} {a b : ℝ}
(hf : continuous_on f (Icc a b))
(hf' : ∀ x ∈ Ico a b, has_deriv_within_at f (f' x) (Ioi x) x)
{B B' : ℝ → ℝ} (ha : f a ≤ B a) (hB : continuous_on B (Icc a b))
(hB' : ∀ x ∈ Ico a b, has_deriv_within_at B (B' x) (Ioi x) x)
(bound : ∀ x ∈ Ico a b, f x = B x → f' x < B' x) :
∀ ⦃x⦄, x ∈ Icc a b → f x ≤ B x :=
image_le_of_liminf_slope_right_lt_deriv_boundary' hf
(λ x hx r hr, (hf' x hx).liminf_right_slope_le hr) ha hB hB' bound
/-- General fencing theorem for continuous functions with an estimate on the derivative.
Let `f` and `B` be continuous functions on `[a, b]` such that
* `f a ≤ B a`;
* `B` has derivative `B'` everywhere on `ℝ`;
* `f` has right derivative `f'` at every point of `[a, b)`;
* we have `f' x < B' x` whenever `f x = B x`.
Then `f x ≤ B x` everywhere on `[a, b]`. -/
lemma image_le_of_deriv_right_lt_deriv_boundary {f f' : ℝ → ℝ} {a b : ℝ}
(hf : continuous_on f (Icc a b))
(hf' : ∀ x ∈ Ico a b, has_deriv_within_at f (f' x) (Ioi x) x)
{B B' : ℝ → ℝ} (ha : f a ≤ B a) (hB : ∀ x, has_deriv_at B (B' x) x)
(bound : ∀ x ∈ Ico a b, f x = B x → f' x < B' x) :
∀ ⦃x⦄, x ∈ Icc a b → f x ≤ B x :=
image_le_of_deriv_right_lt_deriv_boundary' hf hf' ha
(λ x hx, (hB x).continuous_at.continuous_within_at)
(λ x hx, (hB x).has_deriv_within_at) bound
/-- General fencing theorem for continuous functions with an estimate on the derivative.
Let `f` and `B` be continuous functions on `[a, b]` such that
* `f a ≤ B a`;
* `B` has derivative `B'` everywhere on `ℝ`;
* `f` has right derivative `f'` at every point of `[a, b)`;
* we have `f' x ≤ B' x` on `[a, b)`.
Then `f x ≤ B x` everywhere on `[a, b]`. -/
lemma image_le_of_deriv_right_le_deriv_boundary {f f' : ℝ → ℝ} {a b : ℝ}
(hf : continuous_on f (Icc a b))
(hf' : ∀ x ∈ Ico a b, has_deriv_within_at f (f' x) (Ioi x) x)
{B B' : ℝ → ℝ} (ha : f a ≤ B a) (hB : continuous_on B (Icc a b))
(hB' : ∀ x ∈ Ico a b, has_deriv_within_at B (B' x) (Ioi x) x)
(bound : ∀ x ∈ Ico a b, f' x ≤ B' x) :
∀ ⦃x⦄, x ∈ Icc a b → f x ≤ B x :=
image_le_of_liminf_slope_right_le_deriv_boundary hf ha hB hB' $
assume x hx r hr, (hf' x hx).liminf_right_slope_le (lt_of_le_of_lt (bound x hx) hr)
/-! ### Vector-valued functions `f : ℝ → E` -/
section
variables {f : ℝ → E} {a b : ℝ}
/-- General fencing theorem for continuous functions with an estimate on the derivative.
Let `f` and `B` be continuous functions on `[a, b]` such that
* `∥f a∥ ≤ B a`;
* `B` has right derivative at every point of `[a, b)`;
* for each `x ∈ [a, b)` the right-side limit inferior of `(∥f z∥ - ∥f x∥) / (z - x)`
is bounded above by a function `f'`;
* we have `f' x < B' x` whenever `∥f x∥ = B x`.
Then `∥f x∥ ≤ B x` everywhere on `[a, b]`. -/
lemma image_norm_le_of_liminf_right_slope_norm_lt_deriv_boundary {E : Type*} [normed_group E]
{f : ℝ → E} {f' : ℝ → ℝ} (hf : continuous_on f (Icc a b))
-- `hf'` actually says `liminf ∥z - x∥⁻¹ * (∥f z∥ - ∥f x∥) ≤ f' x`
(hf' : ∀ x ∈ Ico a b, ∀ r, f' x < r →
∃ᶠ z in nhds_within x (Ioi x), (z - x)⁻¹ * (∥f z∥ - ∥f x∥) < r)
{B B' : ℝ → ℝ} (ha : ∥f a∥ ≤ B a) (hB : continuous_on B (Icc a b))
(hB' : ∀ x ∈ Ico a b, has_deriv_within_at B (B' x) (Ioi x) x)
(bound : ∀ x ∈ Ico a b, ∥f x∥ = B x → f' x < B' x) :
∀ ⦃x⦄, x ∈ Icc a b → ∥f x∥ ≤ B x :=
image_le_of_liminf_slope_right_lt_deriv_boundary' (continuous_norm.comp_continuous_on hf) hf'
ha hB hB' bound
/-- General fencing theorem for continuous functions with an estimate on the norm of the derivative.
Let `f` and `B` be continuous functions on `[a, b]` such that
* `∥f a∥ ≤ B a`;
* `f` and `B` have right derivatives `f'` and `B'` respectively at every point of `[a, b)`;
* the norm of `f'` is strictly less than `B'` whenever `∥f x∥ = B x`.
Then `∥f x∥ ≤ B x` everywhere on `[a, b]`. We use one-sided derivatives in the assumptions
to make this theorem work for piecewise differentiable functions.
-/
lemma image_norm_le_of_norm_deriv_right_lt_deriv_boundary' {f' : ℝ → E}
(hf : continuous_on f (Icc a b))
(hf' : ∀ x ∈ Ico a b, has_deriv_within_at f (f' x) (Ioi x) x)
{B B' : ℝ → ℝ} (ha : ∥f a∥ ≤ B a) (hB : continuous_on B (Icc a b))
(hB' : ∀ x ∈ Ico a b, has_deriv_within_at B (B' x) (Ioi x) x)
(bound : ∀ x ∈ Ico a b, ∥f x∥ = B x → ∥f' x∥ < B' x) :
∀ ⦃x⦄, x ∈ Icc a b → ∥f x∥ ≤ B x :=
image_norm_le_of_liminf_right_slope_norm_lt_deriv_boundary hf
(λ x hx r hr, (hf' x hx).liminf_right_slope_norm_le hr) ha hB hB' bound
/-- General fencing theorem for continuous functions with an estimate on the norm of the derivative.
Let `f` and `B` be continuous functions on `[a, b]` such that
* `∥f a∥ ≤ B a`;
* `f` has right derivative `f'` at every point of `[a, b)`;
* `B` has derivative `B'` everywhere on `ℝ`;
* the norm of `f'` is strictly less than `B'` whenever `∥f x∥ = B x`.
Then `∥f x∥ ≤ B x` everywhere on `[a, b]`. We use one-sided derivatives in the assumptions
to make this theorem work for piecewise differentiable functions.
-/
lemma image_norm_le_of_norm_deriv_right_lt_deriv_boundary {f' : ℝ → E}
(hf : continuous_on f (Icc a b))
(hf' : ∀ x ∈ Ico a b, has_deriv_within_at f (f' x) (Ioi x) x)
{B B' : ℝ → ℝ} (ha : ∥f a∥ ≤ B a) (hB : ∀ x, has_deriv_at B (B' x) x)
(bound : ∀ x ∈ Ico a b, ∥f x∥ = B x → ∥f' x∥ < B' x) :
∀ ⦃x⦄, x ∈ Icc a b → ∥f x∥ ≤ B x :=
image_norm_le_of_norm_deriv_right_lt_deriv_boundary' hf hf' ha
(λ x hx, (hB x).continuous_at.continuous_within_at)
(λ x hx, (hB x).has_deriv_within_at) bound
/-- General fencing theorem for continuous functions with an estimate on the norm of the derivative.
Let `f` and `B` be continuous functions on `[a, b]` such that
* `∥f a∥ ≤ B a`;
* `f` and `B` have right derivatives `f'` and `B'` respectively at every point of `[a, b)`;
* we have `∥f' x∥ ≤ B x` everywhere on `[a, b)`.
Then `∥f x∥ ≤ B x` everywhere on `[a, b]`. We use one-sided derivatives in the assumptions
to make this theorem work for piecewise differentiable functions.
-/
lemma image_norm_le_of_norm_deriv_right_le_deriv_boundary' {f' : ℝ → E}
(hf : continuous_on f (Icc a b))
(hf' : ∀ x ∈ Ico a b, has_deriv_within_at f (f' x) (Ioi x) x)
{B B' : ℝ → ℝ} (ha : ∥f a∥ ≤ B a) (hB : continuous_on B (Icc a b))
(hB' : ∀ x ∈ Ico a b, has_deriv_within_at B (B' x) (Ioi x) x)
(bound : ∀ x ∈ Ico a b, ∥f' x∥ ≤ B' x) :
∀ ⦃x⦄, x ∈ Icc a b → ∥f x∥ ≤ B x :=
image_le_of_liminf_slope_right_le_deriv_boundary (continuous_norm.comp_continuous_on hf) ha hB hB' $
(λ x hx r hr, (hf' x hx).liminf_right_slope_norm_le (lt_of_le_of_lt (bound x hx) hr))
/-- General fencing theorem for continuous functions with an estimate on the norm of the derivative.
Let `f` and `B` be continuous functions on `[a, b]` such that
* `∥f a∥ ≤ B a`;
* `f` has right derivative `f'` at every point of `[a, b)`;
* `B` has derivative `B'` everywhere on `ℝ`;
* we have `∥f' x∥ ≤ B x` everywhere on `[a, b)`.
Then `∥f x∥ ≤ B x` everywhere on `[a, b]`. We use one-sided derivatives in the assumptions
to make this theorem work for piecewise differentiable functions.
-/
lemma image_norm_le_of_norm_deriv_right_le_deriv_boundary {f' : ℝ → E}
(hf : continuous_on f (Icc a b))
(hf' : ∀ x ∈ Ico a b, has_deriv_within_at f (f' x) (Ioi x) x)
{B B' : ℝ → ℝ} (ha : ∥f a∥ ≤ B a) (hB : ∀ x, has_deriv_at B (B' x) x)
(bound : ∀ x ∈ Ico a b, ∥f' x∥ ≤ B' x) :
∀ ⦃x⦄, x ∈ Icc a b → ∥f x∥ ≤ B x :=
image_norm_le_of_norm_deriv_right_le_deriv_boundary' hf hf' ha
(λ x hx, (hB x).continuous_at.continuous_within_at)
(λ x hx, (hB x).has_deriv_within_at) bound
/-- A function on `[a, b]` with the norm of the right derivative bounded by `C`
satisfies `∥f x - f a∥ ≤ C * (x - a)`. -/
theorem norm_image_sub_le_of_norm_deriv_right_le_segment {f' : ℝ → E} {C : ℝ}
(hf : continuous_on f (Icc a b))
(hf' : ∀ x ∈ Ico a b, has_deriv_within_at f (f' x) (Ioi x) x)
(bound : ∀x ∈ Ico a b, ∥f' x∥ ≤ C) :
∀ x ∈ Icc a b, ∥f x - f a∥ ≤ C * (x - a) :=
begin
let g := λ x, f x - f a,
have hg : continuous_on g (Icc a b), from hf.sub continuous_on_const,
have hg' : ∀ x ∈ Ico a b, has_deriv_within_at g (f' x) (Ioi x) x,
{ assume x hx,
simpa using (hf' x hx).sub (has_deriv_within_at_const _ _ _) },
let B := λ x, C * (x - a),
have hB : ∀ x, has_deriv_at B C x,
{ assume x,
simpa using (has_deriv_at_const x C).mul ((has_deriv_at_id x).sub (has_deriv_at_const x a)) },
convert image_norm_le_of_norm_deriv_right_le_deriv_boundary hg hg' _ hB bound,
{ simp only [g, B] },
{ simp only [g, B], rw [sub_self, _root_.norm_zero, sub_self, mul_zero] }
end
/-- A function on `[a, b]` with the norm of the derivative within `[a, b]`
bounded by `C` satisfies `∥f x - f a∥ ≤ C * (x - a)`, `has_deriv_within_at`
version. -/
theorem norm_image_sub_le_of_norm_deriv_le_segment' {f' : ℝ → E} {C : ℝ}
(hf : ∀ x ∈ Icc a b, has_deriv_within_at f (f' x) (Icc a b) x)
(bound : ∀x ∈ Ico a b, ∥f' x∥ ≤ C) :
∀ x ∈ Icc a b, ∥f x - f a∥ ≤ C * (x - a) :=
begin
refine norm_image_sub_le_of_norm_deriv_right_le_segment
(λ x hx, (hf x hx).continuous_within_at) (λ x hx, _) bound,
apply (hf x $ Ico_subset_Icc_self hx).nhds_within,
exact Icc_mem_nhds_within_Ioi hx
end
/-- A function on `[a, b]` with the norm of the derivative within `[a, b]`
bounded by `C` satisfies `∥f x - f a∥ ≤ C * (x - a)`, `deriv_within`
version. -/
theorem norm_image_sub_le_of_norm_deriv_le_segment {C : ℝ} (hf : differentiable_on ℝ f (Icc a b))
(bound : ∀x ∈ Ico a b, ∥deriv_within f (Icc a b) x∥ ≤ C) :
∀ x ∈ Icc a b, ∥f x - f a∥ ≤ C * (x - a) :=
begin
refine norm_image_sub_le_of_norm_deriv_le_segment' _ bound,
exact λ x hx, (hf x hx).has_deriv_within_at
end
/-- A function on `[0, 1]` with the norm of the derivative within `[0, 1]`
bounded by `C` satisfies `∥f 1 - f 0∥ ≤ C`, `has_deriv_within_at`
version. -/
theorem norm_image_sub_le_of_norm_deriv_le_segment_01' {f' : ℝ → E} {C : ℝ}
(hf : ∀ x ∈ Icc (0:ℝ) 1, has_deriv_within_at f (f' x) (Icc (0:ℝ) 1) x)
(bound : ∀x ∈ Ico (0:ℝ) 1, ∥f' x∥ ≤ C) :
∥f 1 - f 0∥ ≤ C :=
by simpa only [sub_zero, mul_one]
using norm_image_sub_le_of_norm_deriv_le_segment' hf bound 1 (right_mem_Icc.2 zero_le_one)
/-- A function on `[0, 1]` with the norm of the derivative within `[0, 1]`
bounded by `C` satisfies `∥f 1 - f 0∥ ≤ C`, `deriv_within` version. -/
theorem norm_image_sub_le_of_norm_deriv_le_segment_01 {C : ℝ}
(hf : differentiable_on ℝ f (Icc (0:ℝ) 1))
(bound : ∀x ∈ Ico (0:ℝ) 1, ∥deriv_within f (Icc (0:ℝ) 1) x∥ ≤ C) :
∥f 1 - f 0∥ ≤ C :=
by simpa only [sub_zero, mul_one]
using norm_image_sub_le_of_norm_deriv_le_segment hf bound 1 (right_mem_Icc.2 zero_le_one)
end
/-! ### Vector-valued functions `f : E → F` -/
/-- The mean value theorem on a convex set: if the derivative of a function is bounded by C, then
the function is C-Lipschitz -/
theorem convex.norm_image_sub_le_of_norm_deriv_le {f : E → F} {C : ℝ} {s : set E} {x y : E}
(hf : differentiable_on ℝ f s) (bound : ∀x∈s, ∥fderiv_within ℝ f s x∥ ≤ C)
(hs : convex s) (xs : x ∈ s) (ys : y ∈ s) : ∥f y - f x∥ ≤ C * ∥y - x∥ :=
begin
/- By composition with t ↦ x + t • (y-x), we reduce to a statement for functions defined
on [0,1], for which it is proved in `norm_image_sub_le_of_norm_deriv_le_segment`.
We just have to check the differentiability of the composition and bounds on its derivative,
which is straightforward but tedious for lack of automation. -/
have C0 : 0 ≤ C := le_trans (norm_nonneg _) (bound x xs),
set g : ℝ → E := λ t, x + t • (y - x),
have Dg : ∀ t, has_deriv_at g (y-x) t,
{ assume t,
simpa only [one_smul] using ((has_deriv_at_id t).smul_const (y - x)).const_add x },
have segm : Icc 0 1 ⊆ g ⁻¹' s,
{ rw [← image_subset_iff, ← segment_eq_image_Icc_zero_one],
apply convex_segment_iff.1 hs x y xs ys },
have : f x = f (g 0), by { simp only [g], rw [zero_smul, add_zero] },
rw this,
have : f y = f (g 1), by { simp only [g], rw [one_smul, add_sub_cancel'_right] },
rw this,
have D2: ∀ t ∈ Icc (0:ℝ) 1, has_deriv_within_at (f ∘ g)
((fderiv_within ℝ f s (g t) : E → F) (y-x)) (Icc (0:ℝ) 1) t,
{ intros t ht,
exact (hf (g t) $ segm ht).has_fderiv_within_at.comp_has_deriv_within_at _
(Dg t).has_deriv_within_at segm },
apply norm_image_sub_le_of_norm_deriv_le_segment_01' D2,
assume t ht,
refine le_trans (le_op_norm _ _) (mul_le_mul_of_nonneg_right _ (norm_nonneg _)),
exact bound (g t) (segm $ Ico_subset_Icc_self ht)
end
/-- If a function has zero Fréchet derivative at every point of a convex set,
then it is a constant on this set. -/
theorem convex.is_const_of_fderiv_within_eq_zero {s : set E} (hs : convex s)
{f : E → F} (hf : differentiable_on ℝ f s) (hf' : ∀ x ∈ s, fderiv_within ℝ f s x = 0)
{x y : E} (hx : x ∈ s) (hy : y ∈ s) :
f x = f y :=
have bound : ∀ x ∈ s, ∥fderiv_within ℝ f s x∥ ≤ 0,
from λ x hx, by simp only [hf' x hx, _root_.norm_zero],
by simpa only [(dist_eq_norm _ _).symm, zero_mul, dist_le_zero, eq_comm]
using hs.norm_image_sub_le_of_norm_deriv_le hf bound hx hy
theorem is_const_of_fderiv_eq_zero {f : E → F} (hf : differentiable ℝ f)
(hf' : ∀ x, fderiv ℝ f x = 0) (x y : E) :
f x = f y :=
convex_univ.is_const_of_fderiv_within_eq_zero hf.differentiable_on
(λ x _, by rw fderiv_within_univ; exact hf' x) trivial trivial
/-! ### Functions `[a, b] → ℝ`. -/
section interval
-- Declare all variables here to make sure they come in a correct order
variables (f f' : ℝ → ℝ) {a b : ℝ} (hab : a < b) (hfc : continuous_on f (Icc a b))
(hff' : ∀ x ∈ Ioo a b, has_deriv_at f (f' x) x) (hfd : differentiable_on ℝ f (Ioo a b))
(g g' : ℝ → ℝ) (hgc : continuous_on g (Icc a b)) (hgg' : ∀ x ∈ Ioo a b, has_deriv_at g (g' x) x)
(hgd : differentiable_on ℝ g (Ioo a b))
include hab hfc hff' hgc hgg'
/-- Cauchy's Mean Value Theorem, `has_deriv_at` version. -/
lemma exists_ratio_has_deriv_at_eq_ratio_slope :
∃ c ∈ Ioo a b, (g b - g a) * f' c = (f b - f a) * g' c :=
begin
let h := λ x, (g b - g a) * f x - (f b - f a) * g x,
have hI : h a = h b,
{ simp only [h], ring },
let h' := λ x, (g b - g a) * f' x - (f b - f a) * g' x,
have hhh' : ∀ x ∈ Ioo a b, has_deriv_at h (h' x) x,
from λ x hx, ((hff' x hx).const_mul (g b - g a)).sub ((hgg' x hx).const_mul (f b - f a)),
have hhc : continuous_on h (Icc a b),
from (continuous_on_const.mul hfc).sub (continuous_on_const.mul hgc),
rcases exists_has_deriv_at_eq_zero h h' hab hhc hI hhh' with ⟨c, cmem, hc⟩,
exact ⟨c, cmem, sub_eq_zero.1 hc⟩
end
omit hgc hgg'
/-- Lagrange's Mean Value Theorem, `has_deriv_at` version -/
lemma exists_has_deriv_at_eq_slope : ∃ c ∈ Ioo a b, f' c = (f b - f a) / (b - a) :=
begin
rcases exists_ratio_has_deriv_at_eq_ratio_slope f f' hab hfc hff'
id 1 continuous_id.continuous_on (λ x hx, has_deriv_at_id x) with ⟨c, cmem, hc⟩,
use [c, cmem],
simp only [_root_.id, pi.one_apply, mul_one] at hc,
rw [← hc, mul_div_cancel_left],
exact ne_of_gt (sub_pos.2 hab)
end
omit hff'
/-- Cauchy's Mean Value Theorem, `deriv` version. -/
lemma exists_ratio_deriv_eq_ratio_slope :
∃ c ∈ Ioo a b, (g b - g a) * (deriv f c) = (f b - f a) * (deriv g c) :=
exists_ratio_has_deriv_at_eq_ratio_slope f (deriv f) hab hfc
(λ x hx, ((hfd x hx).differentiable_at $ mem_nhds_sets is_open_Ioo hx).has_deriv_at)
g (deriv g) hgc (λ x hx, ((hgd x hx).differentiable_at $ mem_nhds_sets is_open_Ioo hx).has_deriv_at)
/-- Lagrange's Mean Value Theorem, `deriv` version. -/
lemma exists_deriv_eq_slope : ∃ c ∈ Ioo a b, deriv f c = (f b - f a) / (b - a) :=
exists_has_deriv_at_eq_slope f (deriv f) hab hfc
(λ x hx, ((hfd x hx).differentiable_at $ mem_nhds_sets is_open_Ioo hx).has_deriv_at)
end interval
/-- Let `f` be a function continuous on a convex (or, equivalently, connected) subset `D`
of the real line. If `f` is differentiable on the interior of `D` and `C < f'`, then
`f` grows faster than `C * x` on `D`, i.e., `C * (y - x) < f y - f x` whenever `x, y ∈ D`,
`x < y`. -/
theorem convex.mul_sub_lt_image_sub_of_lt_deriv {D : set ℝ} (hD : convex D) {f : ℝ → ℝ}
(hf : continuous_on f D) (hf' : differentiable_on ℝ f (interior D))
{C} (hf'_gt : ∀ x ∈ interior D, C < deriv f x) :
∀ x y ∈ D, x < y → C * (y - x) < f y - f x :=
begin
assume x y hx hy hxy,
have hxyD : Icc x y ⊆ D, from convex_real_iff.1 hD hx hy,
have hxyD' : Ioo x y ⊆ interior D,
from subset_sUnion_of_mem ⟨is_open_Ioo, subset.trans Ioo_subset_Icc_self hxyD⟩,
obtain ⟨a, a_mem, ha⟩ : ∃ a ∈ Ioo x y, deriv f a = (f y - f x) / (y - x),
from exists_deriv_eq_slope f hxy (hf.mono hxyD) (hf'.mono hxyD'),
have : C < (f y - f x) / (y - x), by { rw [← ha], exact hf'_gt _ (hxyD' a_mem) },
exact (lt_div_iff (sub_pos.2 hxy)).1 this
end
/-- Let `f : ℝ → ℝ` be a differentiable function. If `C < f'`, then `f` grows faster than
`C * x`, i.e., `C * (y - x) < f y - f x` whenever `x < y`. -/
theorem mul_sub_lt_image_sub_of_lt_deriv {f : ℝ → ℝ} (hf : differentiable ℝ f)
{C} (hf'_gt : ∀ x, C < deriv f x) ⦃x y⦄ (hxy : x < y) :
C * (y - x) < f y - f x :=
convex_univ.mul_sub_lt_image_sub_of_lt_deriv hf.continuous.continuous_on hf.differentiable_on
(λ x _, hf'_gt x) x y trivial trivial hxy
/-- Let `f` be a function continuous on a convex (or, equivalently, connected) subset `D`
of the real line. If `f` is differentiable on the interior of `D` and `C ≤ f'`, then
`f` grows at least as fast as `C * x` on `D`, i.e., `C * (y - x) ≤ f y - f x` whenever `x, y ∈ D`,
`x ≤ y`. -/
theorem convex.mul_sub_le_image_sub_of_le_deriv {D : set ℝ} (hD : convex D) {f : ℝ → ℝ}
(hf : continuous_on f D) (hf' : differentiable_on ℝ f (interior D))
{C} (hf'_ge : ∀ x ∈ interior D, C ≤ deriv f x) :
∀ x y ∈ D, x ≤ y → C * (y - x) ≤ f y - f x :=
begin
assume x y hx hy hxy,
cases eq_or_lt_of_le hxy with hxy' hxy', by rw [hxy', sub_self, sub_self, mul_zero],
have hxyD : Icc x y ⊆ D, from convex_real_iff.1 hD hx hy,
have hxyD' : Ioo x y ⊆ interior D,
from subset_sUnion_of_mem ⟨is_open_Ioo, subset.trans Ioo_subset_Icc_self hxyD⟩,
obtain ⟨a, a_mem, ha⟩ : ∃ a ∈ Ioo x y, deriv f a = (f y - f x) / (y - x),
from exists_deriv_eq_slope f hxy' (hf.mono hxyD) (hf'.mono hxyD'),
have : C ≤ (f y - f x) / (y - x), by { rw [← ha], exact hf'_ge _ (hxyD' a_mem) },
exact (le_div_iff (sub_pos.2 hxy')).1 this
end
/-- Let `f : ℝ → ℝ` be a differentiable function. If `C ≤ f'`, then `f` grows at least as fast
as `C * x`, i.e., `C * (y - x) ≤ f y - f x` whenever `x ≤ y`. -/
theorem mul_sub_le_image_sub_of_le_deriv {f : ℝ → ℝ} (hf : differentiable ℝ f)
{C} (hf'_ge : ∀ x, C ≤ deriv f x) ⦃x y⦄ (hxy : x ≤ y) :
C * (y - x) ≤ f y - f x :=
convex_univ.mul_sub_le_image_sub_of_le_deriv hf.continuous.continuous_on hf.differentiable_on
(λ x _, hf'_ge x) x y trivial trivial hxy
/-- Let `f` be a function continuous on a convex (or, equivalently, connected) subset `D`
of the real line. If `f` is differentiable on the interior of `D` and `f' < C`, then
`f` grows slower than `C * x` on `D`, i.e., `f y - f x < C * (y - x)` whenever `x, y ∈ D`,
`x < y`. -/
theorem convex.image_sub_lt_mul_sub_of_deriv_lt {D : set ℝ} (hD : convex D) {f : ℝ → ℝ}
(hf : continuous_on f D) (hf' : differentiable_on ℝ f (interior D))
{C} (lt_hf' : ∀ x ∈ interior D, deriv f x < C) :
∀ x y ∈ D, x < y → f y - f x < C * (y - x) :=
begin
assume x y hx hy hxy,
have hf'_gt : ∀ x ∈ interior D, -C < deriv (λ y, -f y) x,
{ assume x hx,
rw [deriv_neg, neg_lt_neg_iff],
exact lt_hf' x hx },
simpa [-neg_lt_neg_iff]
using neg_lt_neg (hD.mul_sub_lt_image_sub_of_lt_deriv hf.neg hf'.neg hf'_gt x y hx hy hxy)
end
/-- Let `f : ℝ → ℝ` be a differentiable function. If `f' < C`, then `f` grows slower than
`C * x` on `D`, i.e., `f y - f x < C * (y - x)` whenever `x < y`. -/
theorem image_sub_lt_mul_sub_of_deriv_lt {f : ℝ → ℝ} (hf : differentiable ℝ f)
{C} (lt_hf' : ∀ x, deriv f x < C) ⦃x y⦄ (hxy : x < y) :
f y - f x < C * (y - x) :=
convex_univ.image_sub_lt_mul_sub_of_deriv_lt hf.continuous.continuous_on hf.differentiable_on
(λ x _, lt_hf' x) x y trivial trivial hxy
/-- Let `f` be a function continuous on a convex (or, equivalently, connected) subset `D`
of the real line. If `f` is differentiable on the interior of `D` and `f' ≤ C`, then
`f` grows at most as fast as `C * x` on `D`, i.e., `f y - f x ≤ C * (y - x)` whenever `x, y ∈ D`,
`x ≤ y`. -/
theorem convex.image_sub_le_mul_sub_of_deriv_le {D : set ℝ} (hD : convex D) {f : ℝ → ℝ}
(hf : continuous_on f D) (hf' : differentiable_on ℝ f (interior D))
{C} (le_hf' : ∀ x ∈ interior D, deriv f x ≤ C) :
∀ x y ∈ D, x ≤ y → f y - f x ≤ C * (y - x) :=
begin
assume x y hx hy hxy,
have hf'_ge : ∀ x ∈ interior D, -C ≤ deriv (λ y, -f y) x,
{ assume x hx,
rw [deriv_neg, neg_le_neg_iff],
exact le_hf' x hx },
simpa [-neg_le_neg_iff]
using neg_le_neg (hD.mul_sub_le_image_sub_of_le_deriv hf.neg hf'.neg hf'_ge x y hx hy hxy)
end
/-- Let `f : ℝ → ℝ` be a differentiable function. If `f' ≤ C`, then `f` grows at most as fast
as `C * x`, i.e., `f y - f x ≤ C * (y - x)` whenever `x ≤ y`. -/
theorem image_sub_le_mul_sub_of_deriv_le {f : ℝ → ℝ} (hf : differentiable ℝ f)
{C} (le_hf' : ∀ x, deriv f x ≤ C) ⦃x y⦄ (hxy : x ≤ y) :
f y - f x ≤ C * (y - x) :=
convex_univ.image_sub_le_mul_sub_of_deriv_le hf.continuous.continuous_on hf.differentiable_on
(λ x _, le_hf' x) x y trivial trivial hxy
/-- Let `f` be a function continuous on a convex (or, equivalently, connected) subset `D`
of the real line. If `f` is differentiable on the interior of `D` and `f'` is positive, then
`f` is a strictly monotonically increasing function on `D`. -/
theorem convex.strict_mono_of_deriv_pos {D : set ℝ} (hD : convex D) {f : ℝ → ℝ}
(hf : continuous_on f D) (hf' : differentiable_on ℝ f (interior D))
(hf'_pos : ∀ x ∈ interior D, 0 < deriv f x) :
∀ x y ∈ D, x < y → f x < f y :=
by simpa only [zero_mul, sub_pos] using hD.mul_sub_lt_image_sub_of_lt_deriv hf hf' hf'_pos
/-- Let `f : ℝ → ℝ` be a differentiable function. If `f'` is positive, then
`f` is a strictly monotonically increasing function. -/
theorem strict_mono_of_deriv_pos {f : ℝ → ℝ} (hf : differentiable ℝ f)
(hf'_pos : ∀ x, 0 < deriv f x) :
strict_mono f :=
λ x y hxy, convex_univ.strict_mono_of_deriv_pos hf.continuous.continuous_on hf.differentiable_on
(λ x _, hf'_pos x) x y trivial trivial hxy
/-- Let `f` be a function continuous on a convex (or, equivalently, connected) subset `D`
of the real line. If `f` is differentiable on the interior of `D` and `f'` is nonnegative, then
`f` is a monotonically increasing function on `D`. -/
theorem convex.mono_of_deriv_nonneg {D : set ℝ} (hD : convex D) {f : ℝ → ℝ}
(hf : continuous_on f D) (hf' : differentiable_on ℝ f (interior D))
(hf'_nonneg : ∀ x ∈ interior D, 0 ≤ deriv f x) :
∀ x y ∈ D, x ≤ y → f x ≤ f y :=
by simpa only [zero_mul, sub_nonneg] using hD.mul_sub_le_image_sub_of_le_deriv hf hf' hf'_nonneg
/-- Let `f : ℝ → ℝ` be a differentiable function. If `f'` is nonnegative, then
`f` is a monotonically increasing function. -/
theorem mono_of_deriv_nonneg {f : ℝ → ℝ} (hf : differentiable ℝ f) (hf' : ∀ x, 0 ≤ deriv f x) :
monotone f :=
λ x y hxy, convex_univ.mono_of_deriv_nonneg hf.continuous.continuous_on hf.differentiable_on
(λ x _, hf' x) x y trivial trivial hxy
/-- Let `f` be a function continuous on a convex (or, equivalently, connected) subset `D`
of the real line. If `f` is differentiable on the interior of `D` and `f'` is negative, then
`f` is a strictly monotonically decreasing function on `D`. -/
theorem convex.strict_antimono_of_deriv_neg {D : set ℝ} (hD : convex D) {f : ℝ → ℝ}
(hf : continuous_on f D) (hf' : differentiable_on ℝ f (interior D))
(hf'_neg : ∀ x ∈ interior D, deriv f x < 0) :
∀ x y ∈ D, x < y → f y < f x :=
by simpa only [zero_mul, sub_lt_zero] using hD.image_sub_lt_mul_sub_of_deriv_lt hf hf' hf'_neg
/-- Let `f : ℝ → ℝ` be a differentiable function. If `f'` is negative, then
`f` is a strictly monotonically decreasing function. -/
theorem strict_antimono_of_deriv_neg {f : ℝ → ℝ} (hf : differentiable ℝ f)
(hf' : ∀ x, deriv f x < 0) :
∀ ⦃x y⦄, x < y → f y < f x :=
λ x y hxy, convex_univ.strict_antimono_of_deriv_neg hf.continuous.continuous_on hf.differentiable_on
(λ x _, hf' x) x y trivial trivial hxy
/-- Let `f` be a function continuous on a convex (or, equivalently, connected) subset `D`
of the real line. If `f` is differentiable on the interior of `D` and `f'` is nonpositive, then
`f` is a monotonically decreasing function on `D`. -/
theorem convex.antimono_of_deriv_nonpos {D : set ℝ} (hD : convex D) {f : ℝ → ℝ}
(hf : continuous_on f D) (hf' : differentiable_on ℝ f (interior D))
(hf'_nonpos : ∀ x ∈ interior D, deriv f x ≤ 0) :
∀ x y ∈ D, x ≤ y → f y ≤ f x :=
by simpa only [zero_mul, sub_nonpos] using hD.image_sub_le_mul_sub_of_deriv_le hf hf' hf'_nonpos
/-- Let `f : ℝ → ℝ` be a differentiable function. If `f'` is nonpositive, then
`f` is a monotonically decreasing function. -/
theorem antimono_of_deriv_nonpos {f : ℝ → ℝ} (hf : differentiable ℝ f) (hf' : ∀ x, deriv f x ≤ 0) :
∀ ⦃x y⦄, x ≤ y → f y ≤ f x :=
λ x y hxy, convex_univ.antimono_of_deriv_nonpos hf.continuous.continuous_on hf.differentiable_on
(λ x _, hf' x) x y trivial trivial hxy
/-- If a function `f` is continuous on a convex set `D ⊆ ℝ`, is differentiable on its interior,
and `f'` is monotone on the interior, then `f` is convex on `D`. -/
theorem convex_on_of_deriv_mono {D : set ℝ} (hD : convex D) {f : ℝ → ℝ}
(hf : continuous_on f D) (hf' : differentiable_on ℝ f (interior D))
(hf'_mono : ∀ x y ∈ interior D, x ≤ y → deriv f x ≤ deriv f y) :
convex_on D f :=
convex_on_real_of_slope_mono_adjacent hD
begin
intros x y z hx hz hxy hyz,
-- First we prove some trivial inclusions
have hxzD : Icc x z ⊆ D, from convex_real_iff.1 hD hx hz,
have hxyD : Icc x y ⊆ D, from subset.trans (Icc_subset_Icc_right $ le_of_lt hyz) hxzD,
have hxyD' : Ioo x y ⊆ interior D,
from subset_sUnion_of_mem ⟨is_open_Ioo, subset.trans Ioo_subset_Icc_self hxyD⟩,
have hyzD : Icc y z ⊆ D, from subset.trans (Icc_subset_Icc_left $ le_of_lt hxy) hxzD,
have hyzD' : Ioo y z ⊆ interior D,
from subset_sUnion_of_mem ⟨is_open_Ioo, subset.trans Ioo_subset_Icc_self hyzD⟩,
-- Then we apply MVT to both `[x, y]` and `[y, z]`
obtain ⟨a, ⟨hxa, hay⟩, ha⟩ : ∃ a ∈ Ioo x y, deriv f a = (f y - f x) / (y - x),
from exists_deriv_eq_slope f hxy (hf.mono hxyD) (hf'.mono hxyD'),
obtain ⟨b, ⟨hyb, hbz⟩, hb⟩ : ∃ b ∈ Ioo y z, deriv f b = (f z - f y) / (z - y),
from exists_deriv_eq_slope f hyz (hf.mono hyzD) (hf'.mono hyzD'),
rw [← ha, ← hb],
exact hf'_mono a b (hxyD' ⟨hxa, hay⟩) (hyzD' ⟨hyb, hbz⟩) (le_of_lt $ lt_trans hay hyb)
end
/-- If a function `f` is continuous on a convex set `D ⊆ ℝ`, is differentiable on its interior,
and `f'` is monotone on the interior, then `f` is convex on `ℝ`. -/
theorem convex_on_univ_of_deriv_mono {f : ℝ → ℝ} (hf : differentiable ℝ f)
(hf'_mono : monotone (deriv f)) : convex_on univ f :=
convex_on_of_deriv_mono convex_univ hf.continuous.continuous_on hf.differentiable_on
(λ x y _ _ h, hf'_mono h)
/-- If a function `f` is continuous on a convex set `D ⊆ ℝ`, is twice differentiable on its interior,
and `f''` is nonnegative on the interior, then `f` is convex on `D`. -/
theorem convex_on_of_deriv2_nonneg {D : set ℝ} (hD : convex D) {f : ℝ → ℝ}
(hf : continuous_on f D) (hf' : differentiable_on ℝ f (interior D))
(hf'' : differentiable_on ℝ (deriv f) (interior D))
(hf''_nonneg : ∀ x ∈ interior D, 0 ≤ (deriv^[2] f x)) :
convex_on D f :=
convex_on_of_deriv_mono hD hf hf' $
assume x y hx hy hxy,
hD.interior.mono_of_deriv_nonneg hf''.continuous_on (by rwa [interior_interior])
(by rwa [interior_interior]) _ _ hx hy hxy
/-- If a function `f` is twice differentiable on `ℝ`, and `f''` is nonnegative on `ℝ`,
then `f` is convex on `ℝ`. -/
theorem convex_on_univ_of_deriv2_nonneg {f : ℝ → ℝ} (hf' : differentiable ℝ f)
(hf'' : differentiable ℝ (deriv f)) (hf''_nonneg : ∀ x, 0 ≤ (deriv^[2] f x)) :
convex_on univ f :=
convex_on_of_deriv2_nonneg convex_univ hf'.continuous.continuous_on hf'.differentiable_on
hf''.differentiable_on (λ x _, hf''_nonneg x)
|
669da56f1a84c46935f1f7d85a69feb74a8e8fc4 | ad3e8f15221a986da27c99f371922c0b3f5792b6 | /src/week04/solutions/e01_groups.lean | 4c56db19b1e96e94d17de35639f42239d662c9eb | [] | no_license | VArtem/lean-itmo | a0e1424c8cc4c2de2ac85ab6fd4a12d80e9b85f1 | dc44cd06f9f5b984d051831b3aaa7364e64c2dc4 | refs/heads/main | 1,683,761,214,467 | 1,622,821,295,000 | 1,622,821,295,000 | 357,236,048 | 12 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 9,594 | lean | import tactic
-- Этот файл переведен и адаптирован из второй недели курса Formalising Mathematics: https://github.com/ImperialCollegeLondon/formalising-mathematics/tree/master/src/week_2
-- Там же есть продолжение про подгруппы, скачайте репозиторий с помощью
-- `leanproject get ImperialCollegeLondon/formalising-mathematics`
-- И самостоятельно пройдите то, что там есть
namespace itmo.lean
/-
Определим группу как тайпкласс (подробнее: https://leanprover.github.io/theorem_proving_in_lean/type_classes.html), расширяющий `has_mul`, `has_one` и `has_inv`.
`has_mul G` означает, что на `G` определено умножение `* : G → G → G`
`has_one G` означает, что в `G` есть единица `1 : G`
`has_inv G` означает, что есть функция, выдающая обратный для элемента `G`: `⁻¹ : G → G`
Все эти определения - просто нотация, свойства и взаимодействие этих функций надо будет добавить. Определим класс `group` с аксиомами групп:
-/
class group (G : Type) extends has_mul G, has_one G, has_inv G :=
(mul_assoc : ∀ (a b c : G), a * b * c = a * (b * c))
(one_mul : ∀ (a : G), 1 * a = a)
(mul_left_inv : ∀ (a : G), a⁻¹ * a = 1)
/-
Формально, `group G` это структура, в которой есть умножение, 1, обратный элемент, и доказательства аксиом групп. Поскольку `group G` это тайпкласс, то добавить в сигнатуру функции "пусть `G` - группа" нужно, как `(G : Type) [group G]`. Квадратные скобки используются для тайпклассов и автоматически (насколько получится) находятся соответствующие инстансы для `G`.
Обратите внимание, что набор использованных аксиом минимален, например, нет аксиом
`mul_one : ∀ (a : G), a * 1 = a` и
`mul_right_inv : ∀ (a : G), a * a⁻¹ = 1`.
На самом деле, эти аксиомы следуют из основных, и мы это докажем.
-/
namespace group
variables {G : Type} [group G]
lemma mul_left_cancel (a b c : G) (Habac : a * b = a * c) : b = c :=
begin
rw ← one_mul b,
rw ← one_mul c,
rw ← mul_left_inv a,
rw mul_assoc,
rw mul_assoc,
rw Habac,
end
-- Доказательства из длинных цепочек равенств или неравенств часто можно заменить на `calc` (справка по `calc`: https://leanprover-community.github.io/extras/calc.html)
-- Пример решения задачи с IMO 2020 с использованием `calc`: https://github.com/leanprover-community/mathlib/blob/master/archive/imo/imo2020_q2.lean
example (a b c : G) (Habac : a * b = a * c) : b = c :=
begin
calc b = 1 * b : by rw one_mul
... = (a⁻¹ * a) * b : by rw ← mul_left_inv a
... = a⁻¹ * (a * b) : by rw ← mul_assoc
... = a⁻¹ * (a * c) : by rw Habac
... = (a⁻¹ * a) * c : by rw ← mul_assoc
... = 1 * c : by rw mul_left_inv a
... = c : by rw one_mul,
end
lemma mul_eq_of_eq_inv_mul {a x y : G} (h : x = a⁻¹ * y) : a * x = y :=
begin
apply mul_left_cancel,
rwa [← mul_assoc, mul_left_inv, one_mul],
end
variables (a b c x y : G)
/-
Попробуйте начать доказательство с `apply mul_eq_of_eq_inv_mul`.
-/
@[simp] theorem mul_one : a * 1 = a :=
begin
exact mul_eq_of_eq_inv_mul (mul_left_inv _).symm,
end
@[simp] theorem mul_right_inv : a * a⁻¹ = 1 :=
begin
exact mul_eq_of_eq_inv_mul (mul_one _).symm,
end
/-
Хорошей идеей было бы научить `simp` работать с леммами вида `A = B` или `A ↔ B`, которые мы описали выше. Для этого мы написали атрибут `@[simp]` перед леммой. В идеале, хочется, чтобы равенства в группах решались автоматически:
`example : (a * b) * 1⁻¹⁻¹ * b⁻¹ * (a⁻¹ * a⁻¹⁻¹⁻¹) * a = 1`
Тактика `simp` будет пытаться "упростить" цель как можно больше, в идеале закрыть цель с помощью известных ей лемм. `simp` работает переписываниями, только используя переписывания слева направо (если хочется изменить направление, можно дать дополнительный аргумент `simp [← h] at ...`). Поэтому, в тождествах, помеченных `simp`, правая часть должна быть "проще", чем левая. В частности, `add_comm (a b : ℕ) : a + b = b + a` - плохая лемма для `simp`. Обратите внимание, что во всех леммах выше, например,
`@[simp] theorem mul_one (a : G) : a * 1 = a`
`@[simp] theorem mul_right_inv (a : G) : a * a⁻¹ = 1`
правая часть проще левой. Помечать равенство `a = a * 1` тегом `@[simp]` - плохая идея.
Уже определенным функциям (или определенным в другом файле) можно ретроспективно проставить атрибуты вручную.
-/
attribute [simp] one_mul mul_left_inv mul_assoc
/-
Научим `simp` использовать следующие пять лемм:
`inv_mul_cancel_left : a⁻¹ * (a * b) = b`
`mul_inv_cancel_left : a * (a⁻¹ * b) = b`
`inv_mul : (a * b)⁻¹ = b⁻¹ * a⁻¹`
`one_inv : (1 : G)⁻¹ = 1`
`inv_inv : (a⁻¹)⁻¹ = a`
Обратите внимание, что везде правая часть "проще" левой.
-/
@[simp] lemma inv_mul_cancel_left : a⁻¹ * (a * b) = b :=
begin
rw ← mul_assoc,
-- Здесь уже `simp` сможет переписать `a⁻¹ * a = 1` и `1 * b = b`
simp,
end
@[simp] lemma mul_inv_cancel_left : a * (a⁻¹ * b) = b :=
begin
rw [← mul_assoc],
simp,
end
@[simp] lemma inv_mul : (a * b)⁻¹ = b⁻¹ * a⁻¹ :=
begin
apply mul_left_cancel (a * b),
rw mul_right_inv,
simp,
end
@[simp] lemma one_inv : (1 : G)⁻¹ = 1 :=
begin
apply mul_left_cancel (1 : G),
rw mul_right_inv,
simp,
end
@[simp] lemma inv_inv : a ⁻¹ ⁻¹ = a :=
begin
apply mul_left_cancel a⁻¹,
simp,
end
/-
Эти 5 лемм выбраны неспроста: это вывод алгоритма Кнута-Бендикса для переписываний в группе:
https://en.wikipedia.org/wiki/Word_problem_(mathematics)#Example:_A_term_rewriting_system_to_decide_the_word_problem_in_the_free_group
-/
-- Сложный пример теперь решается автоматически
example : (a * b) * 1⁻¹⁻¹ * b⁻¹ * (a⁻¹ * a⁻¹⁻¹⁻¹) * a = 1 := by simp
lemma eq_mul_inv_of_mul_eq {a b c : G} (h : a * c = b) : a = b * c⁻¹ :=
begin
rw ← h,
simp,
end
lemma eq_inv_mul_of_mul_eq {a b c : G} (h : b * a = c) : a = b⁻¹ * c :=
begin
rw ← h,
simp,
end
lemma mul_left_eq_self {a b : G} : a * b = b ↔ a = 1 :=
begin
split, {
intro h,
replace h := congr_arg (λ x, x * b⁻¹) h,
simpa using h,
}, {
intro h,
simp [h],
}
end
lemma mul_right_eq_self {a b : G} : a * b = a ↔ b = 1 :=
begin
split, {
intro h,
replace h := congr_arg (λ x, a⁻¹ * x) h,
simp at h,
exact h,
}, {
intro h,
simp [h],
}
end
lemma eq_inv_of_mul_eq_one {a b : G} (h : a * b = 1) : a = b⁻¹ :=
calc a = a * 1 : by rw mul_one
... = a * (b * b⁻¹) : by rw mul_right_inv
... = (a * b) * b⁻¹ : by rw mul_assoc
... = 1 * b⁻¹ : by rw h
... = b⁻¹ : one_mul _
lemma inv_eq_of_mul_eq_one {a b : G} (h : a * b = 1) : a⁻¹ = b :=
begin
replace h := eq_inv_of_mul_eq_one h,
simp [h],
end
lemma unique_left_id {e : G} (h : ∀ x : G, e * x = x) : e = 1 :=
begin
have h1 := h 1,
simpa using h1,
end
lemma unique_right_inv {a b : G} (h : a * b = 1) : b = a⁻¹ :=
begin
apply mul_left_cancel a,
simp [h],
end
lemma mul_left_cancel_iff (a x y : G) : a * x = a * y ↔ x = y :=
begin
split,
{ apply mul_left_cancel },
{ intro hxy,
rwa hxy }
end
-- В режим `calc` можно войти даже вне блока begin-end
lemma mul_right_cancel (a x y : G) (Habac : x * a = y * a) : x = y :=
calc x = x * 1 : by rw mul_one
... = x * (a * a⁻¹) : by rw ← mul_right_inv
... = (x * a) * a⁻¹ : by rw ← mul_assoc
... = (y * a) * a⁻¹ : by rw Habac
... = y * (a * a⁻¹) : by rw mul_assoc
... = y * 1 : by rw mul_right_inv
... = y : by rw mul_one
@[simp] theorem inv_inj_iff {a b : G}: a⁻¹ = b⁻¹ ↔ a = b :=
begin
split, {
intro h,
rw [← inv_inv a, h, inv_inv],
}, {
rintro rfl,
refl,
}
end
theorem inv_eq {a b : G}: a⁻¹ = b ↔ b⁻¹ = a :=
begin
split,
all_goals {
rintro rfl,
simp only [inv_inv],
},
end
end group
end itmo.lean
|
a0d30160eee76058c83ee5372c13de9bab88027a | 57c233acf9386e610d99ed20ef139c5f97504ba3 | /src/algebra/module/basic.lean | f878a1d99c62df535b01b0dfd0c53cf0a097f688 | [
"Apache-2.0"
] | permissive | robertylewis/mathlib | 3d16e3e6daf5ddde182473e03a1b601d2810952c | 1d13f5b932f5e40a8308e3840f96fc882fae01f0 | refs/heads/master | 1,651,379,945,369 | 1,644,276,960,000 | 1,644,276,960,000 | 98,875,504 | 0 | 0 | Apache-2.0 | 1,644,253,514,000 | 1,501,495,700,000 | Lean | UTF-8 | Lean | false | false | 24,679 | lean | /-
Copyright (c) 2015 Nathaniel Thomas. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Nathaniel Thomas, Jeremy Avigad, Johannes Hölzl, Mario Carneiro
-/
import algebra.big_operators.basic
import algebra.smul_with_zero
import group_theory.group_action.group
import tactic.norm_num
/-!
# Modules over a ring
In this file we define
* `module R M` : an additive commutative monoid `M` is a `module` over a
`semiring R` if for `r : R` and `x : M` their "scalar multiplication `r • x : M` is defined, and
the operation `•` satisfies some natural associativity and distributivity axioms similar to those
on a ring.
## Implementation notes
In typical mathematical usage, our definition of `module` corresponds to "semimodule", and the
word "module" is reserved for `module R M` where `R` is a `ring` and `M` an `add_comm_group`.
If `R` is a `field` and `M` an `add_comm_group`, `M` would be called an `R`-vector space.
Since those assumptions can be made by changing the typeclasses applied to `R` and `M`,
without changing the axioms in `module`, mathlib calls everything a `module`.
In older versions of mathlib, we had separate `semimodule` and `vector_space` abbreviations.
This caused inference issues in some cases, while not providing any real advantages, so we decided
to use a canonical `module` typeclass throughout.
## Tags
semimodule, module, vector space
-/
open function
open_locale big_operators
universes u u' v w x y z
variables {R : Type u} {k : Type u'} {S : Type v} {M : Type w} {M₂ : Type x} {M₃ : Type y}
{ι : Type z}
/-- A module is a generalization of vector spaces to a scalar semiring.
It consists of a scalar semiring `R` and an additive monoid of "vectors" `M`,
connected by a "scalar multiplication" operation `r • x : M`
(where `r : R` and `x : M`) with some natural associativity and
distributivity axioms similar to those on a ring. -/
@[protect_proj] class module (R : Type u) (M : Type v) [semiring R]
[add_comm_monoid M] extends distrib_mul_action R M :=
(add_smul : ∀(r s : R) (x : M), (r + s) • x = r • x + s • x)
(zero_smul : ∀x : M, (0 : R) • x = 0)
section add_comm_monoid
variables [semiring R] [add_comm_monoid M] [module R M] (r s : R) (x y : M)
/-- A module over a semiring automatically inherits a `mul_action_with_zero` structure. -/
@[priority 100] -- see Note [lower instance priority]
instance module.to_mul_action_with_zero :
mul_action_with_zero R M :=
{ smul_zero := smul_zero,
zero_smul := module.zero_smul,
..(infer_instance : mul_action R M) }
instance add_comm_monoid.nat_module : module ℕ M :=
{ one_smul := one_nsmul,
mul_smul := λ m n a, mul_nsmul a m n,
smul_add := λ n a b, nsmul_add a b n,
smul_zero := nsmul_zero,
zero_smul := zero_nsmul,
add_smul := λ r s x, add_nsmul x r s }
theorem add_smul : (r + s) • x = r • x + s • x := module.add_smul r s x
variables (R)
theorem two_smul : (2 : R) • x = x + x := by rw [bit0, add_smul, one_smul]
theorem two_smul' : (2 : R) • x = bit0 x := two_smul R x
/-- Pullback a `module` structure along an injective additive monoid homomorphism.
See note [reducible non-instances]. -/
@[reducible]
protected def function.injective.module [add_comm_monoid M₂] [has_scalar R M₂] (f : M₂ →+ M)
(hf : injective f) (smul : ∀ (c : R) x, f (c • x) = c • f x) :
module R M₂ :=
{ smul := (•),
add_smul := λ c₁ c₂ x, hf $ by simp only [smul, f.map_add, add_smul],
zero_smul := λ x, hf $ by simp only [smul, zero_smul, f.map_zero],
.. hf.distrib_mul_action f smul }
/-- Pushforward a `module` structure along a surjective additive monoid homomorphism. -/
protected def function.surjective.module [add_comm_monoid M₂] [has_scalar R M₂] (f : M →+ M₂)
(hf : surjective f) (smul : ∀ (c : R) x, f (c • x) = c • f x) :
module R M₂ :=
{ smul := (•),
add_smul := λ c₁ c₂ x, by { rcases hf x with ⟨x, rfl⟩,
simp only [add_smul, ← smul, ← f.map_add] },
zero_smul := λ x, by { rcases hf x with ⟨x, rfl⟩, simp only [← f.map_zero, ← smul, zero_smul] },
.. hf.distrib_mul_action f smul }
/-- Push forward the action of `R` on `M` along a compatible surjective map `f : R →+* S`.
See also `function.surjective.mul_action_left` and `function.surjective.distrib_mul_action_left`.
-/
@[reducible]
def function.surjective.module_left {R S M : Type*} [semiring R] [add_comm_monoid M]
[module R M] [semiring S] [has_scalar S M]
(f : R →+* S) (hf : function.surjective f) (hsmul : ∀ c (x : M), f c • x = c • x) :
module S M :=
{ smul := (•),
zero_smul := λ x, by rw [← f.map_zero, hsmul, zero_smul],
add_smul := hf.forall₂.mpr (λ a b x, by simp only [← f.map_add, hsmul, add_smul]),
.. hf.distrib_mul_action_left f.to_monoid_hom hsmul }
variables {R} (M)
/-- Compose a `module` with a `ring_hom`, with action `f s • m`.
See note [reducible non-instances]. -/
@[reducible] def module.comp_hom [semiring S] (f : S →+* R) :
module S M :=
{ smul := has_scalar.comp.smul f,
add_smul := λ r s x, by simp [add_smul],
.. mul_action_with_zero.comp_hom M f.to_monoid_with_zero_hom,
.. distrib_mul_action.comp_hom M (f : S →* R) }
variables (R) (M)
/-- `(•)` as an `add_monoid_hom`.
This is a stronger version of `distrib_mul_action.to_add_monoid_End` -/
@[simps apply_apply]
def module.to_add_monoid_End : R →+* add_monoid.End M :=
{ map_zero' := add_monoid_hom.ext $ λ r, by simp,
map_add' := λ x y, add_monoid_hom.ext $ λ r, by simp [add_smul],
..distrib_mul_action.to_add_monoid_End R M }
/-- A convenience alias for `module.to_add_monoid_End` as an `add_monoid_hom`, usually to allow the
use of `add_monoid_hom.flip`. -/
def smul_add_hom : R →+ M →+ M :=
(module.to_add_monoid_End R M).to_add_monoid_hom
variables {R M}
@[simp] lemma smul_add_hom_apply (r : R) (x : M) :
smul_add_hom R M r x = r • x := rfl
lemma module.eq_zero_of_zero_eq_one (zero_eq_one : (0 : R) = 1) : x = 0 :=
by rw [←one_smul R x, ←zero_eq_one, zero_smul]
lemma list.sum_smul {l : list R} {x : M} : l.sum • x = (l.map (λ r, r • x)).sum :=
((smul_add_hom R M).flip x).map_list_sum l
lemma multiset.sum_smul {l : multiset R} {x : M} : l.sum • x = (l.map (λ r, r • x)).sum :=
((smul_add_hom R M).flip x).map_multiset_sum l
lemma finset.sum_smul {f : ι → R} {s : finset ι} {x : M} :
(∑ i in s, f i) • x = (∑ i in s, (f i) • x) :=
((smul_add_hom R M).flip x).map_sum f s
end add_comm_monoid
variables (R)
/-- An `add_comm_monoid` that is a `module` over a `ring` carries a natural `add_comm_group`
structure.
See note [reducible non-instances]. -/
@[reducible]
def module.add_comm_monoid_to_add_comm_group [ring R] [add_comm_monoid M] [module R M] :
add_comm_group M :=
{ neg := λ a, (-1 : R) • a,
add_left_neg := λ a, show (-1 : R) • a + a = 0, by
{ nth_rewrite 1 ← one_smul _ a,
rw [← add_smul, add_left_neg, zero_smul] },
..(infer_instance : add_comm_monoid M), }
variables {R}
section add_comm_group
variables (R M) [semiring R] [add_comm_group M]
instance add_comm_group.int_module : module ℤ M :=
{ one_smul := one_zsmul,
mul_smul := λ m n a, mul_zsmul a m n,
smul_add := λ n a b, zsmul_add a b n,
smul_zero := zsmul_zero,
zero_smul := zero_zsmul,
add_smul := λ r s x, add_zsmul x r s }
/-- A structure containing most informations as in a module, except the fields `zero_smul`
and `smul_zero`. As these fields can be deduced from the other ones when `M` is an `add_comm_group`,
this provides a way to construct a module structure by checking less properties, in
`module.of_core`. -/
@[nolint has_inhabited_instance]
structure module.core extends has_scalar R M :=
(smul_add : ∀(r : R) (x y : M), r • (x + y) = r • x + r • y)
(add_smul : ∀(r s : R) (x : M), (r + s) • x = r • x + s • x)
(mul_smul : ∀(r s : R) (x : M), (r * s) • x = r • s • x)
(one_smul : ∀x : M, (1 : R) • x = x)
variables {R M}
/-- Define `module` without proving `zero_smul` and `smul_zero` by using an auxiliary
structure `module.core`, when the underlying space is an `add_comm_group`. -/
def module.of_core (H : module.core R M) : module R M :=
by letI := H.to_has_scalar; exact
{ zero_smul := λ x, (add_monoid_hom.mk' (λ r : R, r • x) (λ r s, H.add_smul r s x)).map_zero,
smul_zero := λ r, (add_monoid_hom.mk' ((•) r) (H.smul_add r)).map_zero,
..H }
end add_comm_group
/--
To prove two module structures on a fixed `add_comm_monoid` agree,
it suffices to check the scalar multiplications agree.
-/
-- We'll later use this to show `module ℕ M` and `module ℤ M` are subsingletons.
@[ext]
lemma module_ext {R : Type*} [semiring R] {M : Type*} [add_comm_monoid M] (P Q : module R M)
(w : ∀ (r : R) (m : M), by { haveI := P, exact r • m } = by { haveI := Q, exact r • m }) :
P = Q :=
begin
unfreezingI { rcases P with ⟨⟨⟨⟨P⟩⟩⟩⟩, rcases Q with ⟨⟨⟨⟨Q⟩⟩⟩⟩ },
obtain rfl : P = Q, by { funext r m, exact w r m },
congr
end
section module
variables [ring R] [add_comm_group M] [module R M] (r s : R) (x y : M)
@[simp] theorem neg_smul : -r • x = - (r • x) :=
eq_neg_of_add_eq_zero (by rw [← add_smul, add_left_neg, zero_smul])
@[simp] lemma neg_smul_neg : -r • -x = r • x :=
by rw [neg_smul, smul_neg, neg_neg]
@[simp] theorem units.neg_smul (u : Rˣ) (x : M) : -u • x = - (u • x) :=
by rw [units.smul_def, units.coe_neg, neg_smul, units.smul_def]
variables (R)
theorem neg_one_smul (x : M) : (-1 : R) • x = -x := by simp
variables {R}
theorem sub_smul (r s : R) (y : M) : (r - s) • y = r • y - s • y :=
by simp [add_smul, sub_eq_add_neg]
end module
/-- A module over a `subsingleton` semiring is a `subsingleton`. We cannot register this
as an instance because Lean has no way to guess `R`. -/
protected
theorem module.subsingleton (R M : Type*) [semiring R] [subsingleton R] [add_comm_monoid M]
[module R M] :
subsingleton M :=
⟨λ x y, by rw [← one_smul R x, ← one_smul R y, subsingleton.elim (1:R) 0, zero_smul, zero_smul]⟩
@[priority 910] -- see Note [lower instance priority]
instance semiring.to_module [semiring R] : module R R :=
{ smul_add := mul_add,
add_smul := add_mul,
zero_smul := zero_mul,
smul_zero := mul_zero }
/-- Like `semiring.to_module`, but multiplies on the right. -/
@[priority 910] -- see Note [lower instance priority]
instance semiring.to_opposite_module [semiring R] : module Rᵐᵒᵖ R :=
{ smul_add := λ r x y, add_mul _ _ _,
add_smul := λ r x y, mul_add _ _ _,
..monoid_with_zero.to_opposite_mul_action_with_zero R}
/-- A ring homomorphism `f : R →+* M` defines a module structure by `r • x = f r * x`. -/
def ring_hom.to_module [semiring R] [semiring S] (f : R →+* S) : module R S :=
module.comp_hom S f
/-- The tautological action by `R →+* R` on `R`.
This generalizes `function.End.apply_mul_action`. -/
instance ring_hom.apply_distrib_mul_action [semiring R] : distrib_mul_action (R →+* R) R :=
{ smul := ($),
smul_zero := ring_hom.map_zero,
smul_add := ring_hom.map_add,
one_smul := λ _, rfl,
mul_smul := λ _ _ _, rfl }
@[simp] protected lemma ring_hom.smul_def [semiring R] (f : R →+* R) (a : R) :
f • a = f a := rfl
/-- `ring_hom.apply_distrib_mul_action` is faithful. -/
instance ring_hom.apply_has_faithful_scalar [semiring R] : has_faithful_scalar (R →+* R) R :=
⟨ring_hom.ext⟩
section add_comm_monoid
variables [semiring R] [add_comm_monoid M] [module R M]
section
variables (R)
/-- `nsmul` is equal to any other module structure via a cast. -/
lemma nsmul_eq_smul_cast (n : ℕ) (b : M) :
n • b = (n : R) • b :=
begin
induction n with n ih,
{ rw [nat.cast_zero, zero_smul, zero_smul] },
{ rw [nat.succ_eq_add_one, nat.cast_succ, add_smul, add_smul, one_smul, ih, one_smul], }
end
end
/-- Convert back any exotic `ℕ`-smul to the canonical instance. This should not be needed since in
mathlib all `add_comm_monoid`s should normally have exactly one `ℕ`-module structure by design.
-/
lemma nat_smul_eq_nsmul (h : module ℕ M) (n : ℕ) (x : M) :
@has_scalar.smul ℕ M h.to_has_scalar n x = n • x :=
by rw [nsmul_eq_smul_cast ℕ n x, nat.cast_id]
/-- All `ℕ`-module structures are equal. Not an instance since in mathlib all `add_comm_monoid`
should normally have exactly one `ℕ`-module structure by design. -/
def add_comm_monoid.nat_module.unique : unique (module ℕ M) :=
{ default := by apply_instance,
uniq := λ P, module_ext P _ $ λ n, nat_smul_eq_nsmul P n }
instance add_comm_monoid.nat_is_scalar_tower :
is_scalar_tower ℕ R M :=
{ smul_assoc := λ n x y, nat.rec_on n
(by simp only [zero_smul])
(λ n ih, by simp only [nat.succ_eq_add_one, add_smul, one_smul, ih]) }
instance add_comm_monoid.nat_smul_comm_class : smul_comm_class ℕ R M :=
{ smul_comm := λ n r m, nat.rec_on n
(by simp only [zero_smul, smul_zero])
(λ n ih, by simp only [nat.succ_eq_add_one, add_smul, one_smul, ←ih, smul_add]) }
-- `smul_comm_class.symm` is not registered as an instance, as it would cause a loop
instance add_comm_monoid.nat_smul_comm_class' : smul_comm_class R ℕ M :=
smul_comm_class.symm _ _ _
end add_comm_monoid
section add_comm_group
variables [semiring S] [ring R] [add_comm_group M] [module S M] [module R M]
section
variables (R)
/-- `zsmul` is equal to any other module structure via a cast. -/
lemma zsmul_eq_smul_cast (n : ℤ) (b : M) : n • b = (n : R) • b :=
have (smul_add_hom ℤ M).flip b = ((smul_add_hom R M).flip b).comp (int.cast_add_hom R),
by { ext, simp },
add_monoid_hom.congr_fun this n
end
/-- Convert back any exotic `ℤ`-smul to the canonical instance. This should not be needed since in
mathlib all `add_comm_group`s should normally have exactly one `ℤ`-module structure by design. -/
lemma int_smul_eq_zsmul (h : module ℤ M) (n : ℤ) (x : M) :
@has_scalar.smul ℤ M h.to_has_scalar n x = n • x :=
by rw [zsmul_eq_smul_cast ℤ n x, int.cast_id]
/-- All `ℤ`-module structures are equal. Not an instance since in mathlib all `add_comm_group`
should normally have exactly one `ℤ`-module structure by design. -/
def add_comm_group.int_module.unique : unique (module ℤ M) :=
{ default := by apply_instance,
uniq := λ P, module_ext P _ $ λ n, int_smul_eq_zsmul P n }
end add_comm_group
namespace add_monoid_hom
lemma map_nat_module_smul [add_comm_monoid M] [add_comm_monoid M₂]
(f : M →+ M₂) (x : ℕ) (a : M) : f (x • a) = x • f a :=
f.map_nsmul a x
lemma map_int_module_smul [add_comm_group M] [add_comm_group M₂]
(f : M →+ M₂) (x : ℤ) (a : M) : f (x • a) = x • f a :=
f.map_zsmul a x
lemma map_int_cast_smul [add_comm_group M] [add_comm_group M₂]
(f : M →+ M₂) (R S : Type*) [ring R] [ring S] [module R M] [module S M₂]
(x : ℤ) (a : M) : f ((x : R) • a) = (x : S) • f a :=
by simp only [←zsmul_eq_smul_cast, f.map_zsmul]
lemma map_nat_cast_smul [add_comm_monoid M] [add_comm_monoid M₂] (f : M →+ M₂)
(R S : Type*) [semiring R] [semiring S] [module R M] [module S M₂] (x : ℕ) (a : M) :
f ((x : R) • a) = (x : S) • f a :=
by simp only [←nsmul_eq_smul_cast, f.map_nsmul]
lemma map_inv_int_cast_smul {E F : Type*} [add_comm_group E] [add_comm_group F] (f : E →+ F)
(R S : Type*) [division_ring R] [division_ring S] [module R E] [module S F]
(n : ℤ) (x : E) :
f ((n⁻¹ : R) • x) = (n⁻¹ : S) • f x :=
begin
by_cases hR : (n : R) = 0; by_cases hS : (n : S) = 0,
{ simp [hR, hS] },
{ suffices : ∀ y, f y = 0, by simp [this], clear x, intro x,
rw [← inv_smul_smul₀ hS (f x), ← map_int_cast_smul f R S], simp [hR] },
{ suffices : ∀ y, f y = 0, by simp [this], clear x, intro x,
rw [← smul_inv_smul₀ hR x, map_int_cast_smul f R S, hS, zero_smul] },
{ rw [← inv_smul_smul₀ hS (f _), ← map_int_cast_smul f R S, smul_inv_smul₀ hR] }
end
lemma map_inv_nat_cast_smul {E F : Type*} [add_comm_group E] [add_comm_group F] (f : E →+ F)
(R S : Type*) [division_ring R] [division_ring S] [module R E] [module S F]
(n : ℕ) (x : E) :
f ((n⁻¹ : R) • x) = (n⁻¹ : S) • f x :=
f.map_inv_int_cast_smul R S n x
lemma map_rat_cast_smul {E F : Type*} [add_comm_group E] [add_comm_group F] (f : E →+ F)
(R S : Type*) [division_ring R] [division_ring S] [module R E] [module S F]
(c : ℚ) (x : E) :
f ((c : R) • x) = (c : S) • f x :=
by rw [rat.cast_def, rat.cast_def, div_eq_mul_inv, div_eq_mul_inv, mul_smul, mul_smul,
map_int_cast_smul f R S, map_inv_nat_cast_smul f R S]
lemma map_rat_module_smul {E : Type*} [add_comm_group E] [module ℚ E]
{F : Type*} [add_comm_group F] [module ℚ F] (f : E →+ F) (c : ℚ) (x : E) :
f (c • x) = c • f x :=
rat.cast_id c ▸ f.map_rat_cast_smul ℚ ℚ c x
end add_monoid_hom
/-- There can be at most one `module ℚ E` structure on an additive commutative group. This is not
an instance because `simp` becomes very slow if we have many `subsingleton` instances,
see [gh-6025]. -/
lemma subsingleton_rat_module (E : Type*) [add_comm_group E] : subsingleton (module ℚ E) :=
⟨λ P Q, module_ext P Q $ λ r x,
@add_monoid_hom.map_rat_module_smul E ‹_› P E ‹_› Q (add_monoid_hom.id _) r x⟩
/-- If `E` is a vector space over two division rings `R` and `S`, then scalar multiplications
agree on inverses of integer numbers in `R` and `S`. -/
lemma inv_int_cast_smul_eq {E : Type*} (R S : Type*) [add_comm_group E] [division_ring R]
[division_ring S] [module R E] [module S E] (n : ℤ) (x : E) :
(n⁻¹ : R) • x = (n⁻¹ : S) • x :=
(add_monoid_hom.id E).map_inv_int_cast_smul R S n x
/-- If `E` is a vector space over two division rings `R` and `S`, then scalar multiplications
agree on inverses of natural numbers in `R` and `S`. -/
lemma inv_nat_cast_smul_eq {E : Type*} (R S : Type*) [add_comm_group E] [division_ring R]
[division_ring S] [module R E] [module S E] (n : ℕ) (x : E) :
(n⁻¹ : R) • x = (n⁻¹ : S) • x :=
(add_monoid_hom.id E).map_inv_nat_cast_smul R S n x
/-- If `E` is a vector space over two division rings `R` and `S`, then scalar multiplications
agree on rational numbers in `R` and `S`. -/
lemma rat_cast_smul_eq {E : Type*} (R S : Type*) [add_comm_group E] [division_ring R]
[division_ring S] [module R E] [module S E] (r : ℚ) (x : E) :
(r : R) • x = (r : S) • x :=
(add_monoid_hom.id E).map_rat_cast_smul R S r x
instance add_comm_group.int_is_scalar_tower {R : Type u} {M : Type v} [ring R] [add_comm_group M]
[module R M]: is_scalar_tower ℤ R M :=
{ smul_assoc := λ n x y, ((smul_add_hom R M).flip y).map_int_module_smul n x }
instance add_comm_group.int_smul_comm_class {S : Type u} {M : Type v} [semiring S]
[add_comm_group M] [module S M] :
smul_comm_class ℤ S M :=
{ smul_comm := λ n x y, ((smul_add_hom S M x).map_zsmul y n).symm }
-- `smul_comm_class.symm` is not registered as an instance, as it would cause a loop
instance add_comm_group.int_smul_comm_class' {S : Type u} {M : Type v} [semiring S]
[add_comm_group M] [module S M] : smul_comm_class S ℤ M :=
smul_comm_class.symm _ _ _
instance is_scalar_tower.rat {R : Type u} {M : Type v} [ring R] [add_comm_group M]
[module R M] [module ℚ R] [module ℚ M] : is_scalar_tower ℚ R M :=
{ smul_assoc := λ r x y, ((smul_add_hom R M).flip y).map_rat_module_smul r x }
instance smul_comm_class.rat {R : Type u} {M : Type v} [semiring R] [add_comm_group M]
[module R M] [module ℚ M] : smul_comm_class ℚ R M :=
{ smul_comm := λ r x y, ((smul_add_hom R M x).map_rat_module_smul r y).symm }
instance smul_comm_class.rat' {R : Type u} {M : Type v} [semiring R] [add_comm_group M]
[module R M] [module ℚ M] : smul_comm_class R ℚ M :=
smul_comm_class.symm _ _ _
section no_zero_smul_divisors
/-! ### `no_zero_smul_divisors`
This section defines the `no_zero_smul_divisors` class, and includes some tests
for the vanishing of elements (especially in modules over division rings).
-/
/-- `no_zero_smul_divisors R M` states that a scalar multiple is `0` only if either argument is `0`.
This a version of saying that `M` is torsion free, without assuming `R` is zero-divisor free.
The main application of `no_zero_smul_divisors R M`, when `M` is a module,
is the result `smul_eq_zero`: a scalar multiple is `0` iff either argument is `0`.
It is a generalization of the `no_zero_divisors` class to heterogeneous multiplication.
-/
class no_zero_smul_divisors (R M : Type*) [has_zero R] [has_zero M] [has_scalar R M] : Prop :=
(eq_zero_or_eq_zero_of_smul_eq_zero : ∀ {c : R} {x : M}, c • x = 0 → c = 0 ∨ x = 0)
export no_zero_smul_divisors (eq_zero_or_eq_zero_of_smul_eq_zero)
/-- Pullback a `no_zero_smul_divisors` instance along an injective function. -/
lemma function.injective.no_zero_smul_divisors {R M N : Type*} [has_zero R] [has_zero M]
[has_zero N] [has_scalar R M] [has_scalar R N] [no_zero_smul_divisors R N] (f : M → N)
(hf : function.injective f) (h0 : f 0 = 0) (hs : ∀ (c : R) (x : M), f (c • x) = c • f x) :
no_zero_smul_divisors R M :=
⟨λ c m h,
or.imp_right (@hf _ _) $ h0.symm ▸ eq_zero_or_eq_zero_of_smul_eq_zero (by rw [←hs, h, h0])⟩
section module
variables [semiring R] [add_comm_monoid M] [module R M]
instance no_zero_smul_divisors.of_no_zero_divisors [no_zero_divisors R] :
no_zero_smul_divisors R R :=
⟨λ c x, no_zero_divisors.eq_zero_or_eq_zero_of_mul_eq_zero⟩
@[simp]
theorem smul_eq_zero [no_zero_smul_divisors R M] {c : R} {x : M} :
c • x = 0 ↔ c = 0 ∨ x = 0 :=
⟨eq_zero_or_eq_zero_of_smul_eq_zero,
λ h, h.elim (λ h, h.symm ▸ zero_smul R x) (λ h, h.symm ▸ smul_zero c)⟩
theorem smul_ne_zero [no_zero_smul_divisors R M] {c : R} {x : M} :
c • x ≠ 0 ↔ c ≠ 0 ∧ x ≠ 0 :=
by simp only [ne.def, smul_eq_zero, not_or_distrib]
section nat
variables (R) (M) [no_zero_smul_divisors R M] [char_zero R]
include R
lemma nat.no_zero_smul_divisors : no_zero_smul_divisors ℕ M :=
⟨by { intros c x, rw [nsmul_eq_smul_cast R, smul_eq_zero], simp }⟩
variables {M}
lemma eq_zero_of_two_nsmul_eq_zero {v : M} (hv : 2 • v = 0) : v = 0 :=
by haveI := nat.no_zero_smul_divisors R M;
exact (smul_eq_zero.mp hv).resolve_left (by norm_num)
end nat
variables (R M)
/-- If `M` is an `R`-module with one and `M` has characteristic zero, then `R` has characteristic
zero as well. Usually `M` is an `R`-algebra. -/
lemma char_zero.of_module [has_one M] [char_zero M] : char_zero R :=
begin
refine ⟨λ m n h, @nat.cast_injective M _ _ _ _ _ _⟩,
rw [← nsmul_one, ← nsmul_one, nsmul_eq_smul_cast R m (1 : M), nsmul_eq_smul_cast R n (1 : M), h]
end
end module
section add_comm_group -- `R` can still be a semiring here
variables [semiring R] [add_comm_group M] [module R M]
section smul_injective
variables (M)
lemma smul_right_injective [no_zero_smul_divisors R M] {c : R} (hc : c ≠ 0) :
function.injective (λ (x : M), c • x) :=
λ x y h, sub_eq_zero.mp ((smul_eq_zero.mp
(calc c • (x - y) = c • x - c • y : smul_sub c x y
... = 0 : sub_eq_zero.mpr h)).resolve_left hc)
end smul_injective
section nat
variables (R) [no_zero_smul_divisors R M] [char_zero R]
include R
lemma eq_zero_of_eq_neg {v : M} (hv : v = - v) : v = 0 :=
begin
refine eq_zero_of_two_nsmul_eq_zero R _,
rw two_smul,
exact add_eq_zero_iff_eq_neg.mpr hv
end
end nat
end add_comm_group
section module
variables [ring R] [add_comm_group M] [module R M] [no_zero_smul_divisors R M]
section smul_injective
variables (R)
lemma smul_left_injective {x : M} (hx : x ≠ 0) :
function.injective (λ (c : R), c • x) :=
λ c d h, sub_eq_zero.mp ((smul_eq_zero.mp
(calc (c - d) • x = c • x - d • x : sub_smul c d x
... = 0 : sub_eq_zero.mpr h)).resolve_right hx)
end smul_injective
section nat
variables [char_zero R]
lemma ne_neg_of_ne_zero [no_zero_divisors R] {v : R} (hv : v ≠ 0) : v ≠ -v :=
λ h, hv (eq_zero_of_eq_neg R h)
end nat
end module
section division_ring
variables [division_ring R] [add_comm_group M] [module R M]
@[priority 100] -- see note [lower instance priority]
instance no_zero_smul_divisors.of_division_ring : no_zero_smul_divisors R M :=
⟨λ c x h, or_iff_not_imp_left.2 $ λ hc, (smul_eq_zero_iff_eq' hc).1 h⟩
end division_ring
end no_zero_smul_divisors
@[simp] lemma nat.smul_one_eq_coe {R : Type*} [semiring R] (m : ℕ) :
m • (1 : R) = ↑m :=
by rw [nsmul_eq_mul, mul_one]
@[simp] lemma int.smul_one_eq_coe {R : Type*} [ring R] (m : ℤ) :
m • (1 : R) = ↑m :=
by rw [zsmul_eq_mul, mul_one]
|
467e32acf4a417c0cd158e5d1b5be87198af3505 | 8cae430f0a71442d02dbb1cbb14073b31048e4b0 | /src/group_theory/subgroup/pointwise.lean | 8b31a7d37c61dd58c548768a4a8f2303c74211c6 | [
"Apache-2.0"
] | permissive | leanprover-community/mathlib | 56a2cadd17ac88caf4ece0a775932fa26327ba0e | 442a83d738cb208d3600056c489be16900ba701d | refs/heads/master | 1,693,584,102,358 | 1,693,471,902,000 | 1,693,471,902,000 | 97,922,418 | 1,595 | 352 | Apache-2.0 | 1,694,693,445,000 | 1,500,624,130,000 | Lean | UTF-8 | Lean | false | false | 20,027 | lean | /-
Copyright (c) 2021 Eric Wieser. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Eric Wieser
-/
import group_theory.subgroup.mul_opposite
import group_theory.submonoid.pointwise
import group_theory.group_action.conj_act
/-! # Pointwise instances on `subgroup` and `add_subgroup`s
> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.
> Any changes to this file require a corresponding PR to mathlib4.
This file provides the actions
* `subgroup.pointwise_mul_action`
* `add_subgroup.pointwise_mul_action`
which matches the action of `mul_action_set`.
These actions are available in the `pointwise` locale.
## Implementation notes
The pointwise section of this file is almost identical to `group_theory/submonoid/pointwise.lean`.
Where possible, try to keep them in sync.
-/
open set
open_locale pointwise
variables {α G A S : Type*}
@[simp, to_additive]
lemma inv_coe_set [has_involutive_inv G] [set_like S G] [inv_mem_class S G] {H : S} :
(H : set G)⁻¹ = H :=
set.ext $ λ _, inv_mem_iff
variables [group G] [add_group A] {s : set G}
namespace subgroup
@[simp, to_additive] lemma inv_subset_closure (S : set G) : S⁻¹ ⊆ closure S :=
λ s hs, by { rw [set_like.mem_coe, ←subgroup.inv_mem_iff], exact subset_closure (mem_inv.mp hs) }
@[to_additive]
lemma closure_to_submonoid (S : set G) : (closure S).to_submonoid = submonoid.closure (S ∪ S⁻¹) :=
begin
refine le_antisymm (λ x hx, _) (submonoid.closure_le.2 _),
{ refine closure_induction hx (λ x hx, submonoid.closure_mono (subset_union_left S S⁻¹)
(submonoid.subset_closure hx)) (submonoid.one_mem _) (λ x y hx hy, submonoid.mul_mem _ hx hy)
(λ x hx, _),
rwa [←submonoid.mem_closure_inv, set.union_inv, inv_inv, set.union_comm] },
{ simp only [true_and, coe_to_submonoid, union_subset_iff, subset_closure, inv_subset_closure] }
end
/-- For subgroups generated by a single element, see the simpler `zpow_induction_left`. -/
@[to_additive "For additive subgroups generated by a single element, see the simpler
`zsmul_induction_left`."]
lemma closure_induction_left {p : G → Prop} {x : G} (h : x ∈ closure s) (H1 : p 1)
(Hmul : ∀ (x ∈ s) y, p y → p (x * y)) (Hinv : ∀ (x ∈ s) y, p y → p (x⁻¹ * y)) : p x :=
let key := (closure_to_submonoid s).le in submonoid.closure_induction_left (key h) H1 $
λ x hx, hx.elim (Hmul x) $ λ hx y hy, (congr_arg _ $ inv_inv x).mp $ Hinv x⁻¹ hx y hy
/-- For subgroups generated by a single element, see the simpler `zpow_induction_right`. -/
@[to_additive "For additive subgroups generated by a single element, see the simpler
`zsmul_induction_right`."]
lemma closure_induction_right {p : G → Prop} {x : G} (h : x ∈ closure s) (H1 : p 1)
(Hmul : ∀ x (y ∈ s), p x → p (x * y)) (Hinv : ∀ x (y ∈ s), p x → p (x * y⁻¹)) : p x :=
let key := (closure_to_submonoid s).le in submonoid.closure_induction_right (key h) H1 $
λ x y hy, hy.elim (Hmul x y) $ λ hy hx, (congr_arg _ $ inv_inv y).mp $ Hinv x y⁻¹ hy hx
@[simp, to_additive] lemma closure_inv (s : set G) : closure s⁻¹ = closure s :=
by simp only [← to_submonoid_eq, closure_to_submonoid, inv_inv, union_comm]
/-- An induction principle for closure membership. If `p` holds for `1` and all elements of
`k` and their inverse, and is preserved under multiplication, then `p` holds for all elements of
the closure of `k`. -/
@[to_additive "An induction principle for additive closure membership. If `p` holds for `0` and all
elements of `k` and their negation, and is preserved under addition, then `p` holds for all
elements of the additive closure of `k`."]
lemma closure_induction'' {p : G → Prop} {x} (h : x ∈ closure s) (Hk : ∀ x ∈ s, p x)
(Hk_inv : ∀ x ∈ s, p x⁻¹) (H1 : p 1) (Hmul : ∀ x y, p x → p y → p (x * y)) : p x :=
closure_induction_left h H1 (λ x hx y hy, Hmul x y (Hk x hx) hy) $ λ x hx y,
Hmul x⁻¹ y $ Hk_inv x hx
/-- An induction principle for elements of `⨆ i, S i`.
If `C` holds for `1` and all elements of `S i` for all `i`, and is preserved under multiplication,
then it holds for all elements of the supremum of `S`. -/
@[elab_as_eliminator, to_additive /-" An induction principle for elements of `⨆ i, S i`.
If `C` holds for `0` and all elements of `S i` for all `i`, and is preserved under addition,
then it holds for all elements of the supremum of `S`. "-/]
lemma supr_induction {ι : Sort*} (S : ι → subgroup G) {C : G → Prop} {x : G} (hx : x ∈ ⨆ i, S i)
(hp : ∀ i (x ∈ S i), C x)
(h1 : C 1)
(hmul : ∀ x y, C x → C y → C (x * y)) : C x :=
begin
rw supr_eq_closure at hx,
refine closure_induction'' hx (λ x hx, _) (λ x hx, _) h1 hmul,
{ obtain ⟨i, hi⟩ := set.mem_Union.mp hx,
exact hp _ _ hi, },
{ obtain ⟨i, hi⟩ := set.mem_Union.mp hx,
exact hp _ _ (inv_mem hi), },
end
/-- A dependent version of `subgroup.supr_induction`. -/
@[elab_as_eliminator, to_additive /-"A dependent version of `add_subgroup.supr_induction`. "-/]
lemma supr_induction' {ι : Sort*} (S : ι → subgroup G) {C : Π x, (x ∈ ⨆ i, S i) → Prop}
(hp : ∀ i (x ∈ S i), C x (mem_supr_of_mem i ‹_›))
(h1 : C 1 (one_mem _))
(hmul : ∀ x y hx hy, C x hx → C y hy → C (x * y) (mul_mem ‹_› ‹_›))
{x : G} (hx : x ∈ ⨆ i, S i) : C x hx :=
begin
refine exists.elim _ (λ (hx : x ∈ ⨆ i, S i) (hc : C x hx), hc),
refine supr_induction S hx (λ i x hx, _) _ (λ x y, _),
{ exact ⟨_, hp _ _ hx⟩ },
{ exact ⟨_, h1⟩ },
{ rintro ⟨_, Cx⟩ ⟨_, Cy⟩,
refine ⟨_, hmul _ _ _ _ Cx Cy⟩ },
end
@[to_additive]
lemma closure_mul_le (S T : set G) : closure (S * T) ≤ closure S ⊔ closure T :=
Inf_le $ λ x ⟨s, t, hs, ht, hx⟩, hx ▸ (closure S ⊔ closure T).mul_mem
(set_like.le_def.mp le_sup_left $ subset_closure hs)
(set_like.le_def.mp le_sup_right $ subset_closure ht)
@[to_additive]
lemma sup_eq_closure (H K : subgroup G) : H ⊔ K = closure (H * K) :=
le_antisymm
(sup_le
(λ h hh, subset_closure ⟨h, 1, hh, K.one_mem, mul_one h⟩)
(λ k hk, subset_closure ⟨1, k, H.one_mem, hk, one_mul k⟩))
(by conv_rhs { rw [← closure_eq H, ← closure_eq K] }; apply closure_mul_le)
@[to_additive]
private def mul_normal_aux (H N : subgroup G) [hN : N.normal] : subgroup G :=
{ carrier := (H : set G) * N,
one_mem' := ⟨1, 1, H.one_mem, N.one_mem, by rw mul_one⟩,
mul_mem' := λ a b ⟨h, n, hh, hn, ha⟩ ⟨h', n', hh', hn', hb⟩,
⟨h * h', h'⁻¹ * n * h' * n',
H.mul_mem hh hh', N.mul_mem (by simpa using hN.conj_mem _ hn h'⁻¹) hn',
by simp [← ha, ← hb, mul_assoc]⟩,
inv_mem' := λ x ⟨h, n, hh, hn, hx⟩,
⟨h⁻¹, h * n⁻¹ * h⁻¹, H.inv_mem hh, hN.conj_mem _ (N.inv_mem hn) h,
by rw [mul_assoc h, inv_mul_cancel_left, ← hx, mul_inv_rev]⟩ }
/-- The carrier of `H ⊔ N` is just `↑H * ↑N` (pointwise set product) when `N` is normal. -/
@[to_additive "The carrier of `H ⊔ N` is just `↑H + ↑N` (pointwise set addition)
when `N` is normal."]
lemma mul_normal (H N : subgroup G) [N.normal] : (↑(H ⊔ N) : set G) = H * N :=
set.subset.antisymm
(show H ⊔ N ≤ mul_normal_aux H N,
by { rw sup_eq_closure, apply Inf_le _, dsimp, refl })
((sup_eq_closure H N).symm ▸ subset_closure)
@[to_additive]
private def normal_mul_aux (N H : subgroup G) [hN : N.normal] : subgroup G :=
{ carrier := (N : set G) * H,
one_mem' := ⟨1, 1, N.one_mem, H.one_mem, by rw mul_one⟩,
mul_mem' := λ a b ⟨n, h, hn, hh, ha⟩ ⟨n', h', hn', hh', hb⟩,
⟨n * (h * n' * h⁻¹), h * h',
N.mul_mem hn (hN.conj_mem _ hn' _), H.mul_mem hh hh',
by simp [← ha, ← hb, mul_assoc]⟩,
inv_mem' := λ x ⟨n, h, hn, hh, hx⟩,
⟨h⁻¹ * n⁻¹ * h, h⁻¹,
by simpa using hN.conj_mem _ (N.inv_mem hn) h⁻¹, H.inv_mem hh,
by rw [mul_inv_cancel_right, ← mul_inv_rev, hx]⟩ }
/-- The carrier of `N ⊔ H` is just `↑N * ↑H` (pointwise set product) when `N` is normal. -/
@[to_additive "The carrier of `N ⊔ H` is just `↑N + ↑H` (pointwise set addition)
when `N` is normal."]
lemma normal_mul (N H : subgroup G) [N.normal] : (↑(N ⊔ H) : set G) = N * H :=
set.subset.antisymm
(show N ⊔ H ≤ normal_mul_aux N H,
by { rw sup_eq_closure, apply Inf_le _, dsimp, refl })
((sup_eq_closure N H).symm ▸ subset_closure)
@[to_additive] lemma mul_inf_assoc (A B C : subgroup G) (h : A ≤ C) :
(A : set G) * ↑(B ⊓ C) = (A * B) ⊓ C :=
begin
ext,
simp only [coe_inf, set.inf_eq_inter, set.mem_mul, set.mem_inter_iff],
split,
{ rintros ⟨y, z, hy, ⟨hzB, hzC⟩, rfl⟩,
refine ⟨_, mul_mem (h hy) hzC⟩,
exact ⟨y, z, hy, hzB, rfl⟩ },
rintros ⟨⟨y, z, hy, hz, rfl⟩, hyz⟩,
refine ⟨y, z, hy, ⟨hz, _⟩, rfl⟩,
suffices : y⁻¹ * (y * z) ∈ C, { simpa },
exact mul_mem (inv_mem (h hy)) hyz
end
@[to_additive] lemma inf_mul_assoc (A B C : subgroup G) (h : C ≤ A) :
((A ⊓ B : subgroup G) : set G) * C = A ⊓ (B * C) :=
begin
ext,
simp only [coe_inf, set.inf_eq_inter, set.mem_mul, set.mem_inter_iff],
split,
{ rintros ⟨y, z, ⟨hyA, hyB⟩, hz, rfl⟩,
refine ⟨A.mul_mem hyA (h hz), _⟩,
exact ⟨y, z, hyB, hz, rfl⟩ },
rintros ⟨hyz, y, z, hy, hz, rfl⟩,
refine ⟨y, z, ⟨_, hy⟩, hz, rfl⟩,
suffices : (y * z) * z⁻¹ ∈ A, { simpa },
exact mul_mem hyz (inv_mem (h hz))
end
instance sup_normal (H K : subgroup G) [hH : H.normal] [hK : K.normal] : (H ⊔ K).normal :=
{ conj_mem := λ n hmem g,
begin
change n ∈ ↑(H ⊔ K) at hmem,
change g * n * g⁻¹ ∈ ↑(H ⊔ K),
rw [normal_mul, set.mem_mul] at *,
rcases hmem with ⟨h, k, hh, hk, rfl⟩,
refine ⟨g * h * g⁻¹, g * k * g⁻¹, hH.conj_mem h hh g, hK.conj_mem k hk g, _⟩,
simp
end }
@[to_additive] lemma smul_opposite_image_mul_preimage {H : subgroup G} (g : G) (h : H.opposite)
(s : set G) : (λ y, h • y) '' (has_mul.mul g ⁻¹' s) = has_mul.mul g ⁻¹' ((λ y, h • y) '' s) :=
by { ext x, cases h, simp [(•), mul_assoc] }
/-! ### Pointwise action -/
section monoid
variables [monoid α] [mul_distrib_mul_action α G]
/-- The action on a subgroup corresponding to applying the action to every element.
This is available as an instance in the `pointwise` locale. -/
protected def pointwise_mul_action : mul_action α (subgroup G) :=
{ smul := λ a S, S.map (mul_distrib_mul_action.to_monoid_End _ _ a),
one_smul := λ S, (congr_arg (λ f, S.map f) (monoid_hom.map_one _)).trans S.map_id,
mul_smul := λ a₁ a₂ S,
(congr_arg (λ f, S.map f) (monoid_hom.map_mul _ _ _)).trans (S.map_map _ _).symm,}
localized "attribute [instance] subgroup.pointwise_mul_action" in pointwise
open_locale pointwise
lemma pointwise_smul_def {a : α} (S : subgroup G) :
a • S = S.map (mul_distrib_mul_action.to_monoid_End _ _ a) := rfl
@[simp] lemma coe_pointwise_smul (a : α) (S : subgroup G) : ↑(a • S) = a • (S : set G) := rfl
@[simp] lemma pointwise_smul_to_submonoid (a : α) (S : subgroup G) :
(a • S).to_submonoid = a • S.to_submonoid := rfl
lemma smul_mem_pointwise_smul (m : G) (a : α) (S : subgroup G) : m ∈ S → a • m ∈ a • S :=
(set.smul_mem_smul_set : _ → _ ∈ a • (S : set G))
lemma mem_smul_pointwise_iff_exists (m : G) (a : α) (S : subgroup G) :
m ∈ a • S ↔ ∃ (s : G), s ∈ S ∧ a • s = m :=
(set.mem_smul_set : m ∈ a • (S : set G) ↔ _)
@[simp] lemma smul_bot (a : α) : a • (⊥ : subgroup G) = ⊥ := map_bot _
lemma smul_sup (a : α) (S T : subgroup G) : a • (S ⊔ T) = a • S ⊔ a • T := map_sup _ _ _
lemma smul_closure (a : α) (s : set G) : a • closure s = closure (a • s) :=
monoid_hom.map_closure _ _
instance pointwise_central_scalar [mul_distrib_mul_action αᵐᵒᵖ G] [is_central_scalar α G] :
is_central_scalar α (subgroup G) :=
⟨λ a S, congr_arg (λ f, S.map f) $ monoid_hom.ext $ by exact op_smul_eq_smul _⟩
lemma conj_smul_le_of_le {P H : subgroup G} (hP : P ≤ H) (h : H) :
mul_aut.conj (h : G) • P ≤ H :=
begin
rintro - ⟨g, hg, rfl⟩,
exact H.mul_mem (H.mul_mem h.2 (hP hg)) (H.inv_mem h.2),
end
lemma conj_smul_subgroup_of {P H : subgroup G} (hP : P ≤ H) (h : H) :
mul_aut.conj h • P.subgroup_of H = (mul_aut.conj (h : G) • P).subgroup_of H :=
begin
refine le_antisymm _ _,
{ rintro - ⟨g, hg, rfl⟩,
exact ⟨g, hg, rfl⟩ },
{ rintro p ⟨g, hg, hp⟩,
exact ⟨⟨g, hP hg⟩, hg, subtype.ext hp⟩ },
end
end monoid
section group
variables [group α] [mul_distrib_mul_action α G]
open_locale pointwise
@[simp] lemma smul_mem_pointwise_smul_iff {a : α} {S : subgroup G} {x : G} :
a • x ∈ a • S ↔ x ∈ S :=
smul_mem_smul_set_iff
lemma mem_pointwise_smul_iff_inv_smul_mem {a : α} {S : subgroup G} {x : G} :
x ∈ a • S ↔ a⁻¹ • x ∈ S :=
mem_smul_set_iff_inv_smul_mem
lemma mem_inv_pointwise_smul_iff {a : α} {S : subgroup G} {x : G} : x ∈ a⁻¹ • S ↔ a • x ∈ S :=
mem_inv_smul_set_iff
@[simp] lemma pointwise_smul_le_pointwise_smul_iff {a : α} {S T : subgroup G} :
a • S ≤ a • T ↔ S ≤ T :=
set_smul_subset_set_smul_iff
lemma pointwise_smul_subset_iff {a : α} {S T : subgroup G} : a • S ≤ T ↔ S ≤ a⁻¹ • T :=
set_smul_subset_iff
lemma subset_pointwise_smul_iff {a : α} {S T : subgroup G} : S ≤ a • T ↔ a⁻¹ • S ≤ T :=
subset_set_smul_iff
@[simp] lemma smul_inf (a : α) (S T : subgroup G) : a • (S ⊓ T) = a • S ⊓ a • T :=
by simp [set_like.ext_iff, mem_pointwise_smul_iff_inv_smul_mem]
/-- Applying a `mul_distrib_mul_action` results in an isomorphic subgroup -/
@[simps] def equiv_smul (a : α) (H : subgroup G) : H ≃* (a • H : subgroup G) :=
(mul_distrib_mul_action.to_mul_equiv G a).subgroup_map H
lemma subgroup_mul_singleton {H : subgroup G} {h : G} (hh : h ∈ H) :
(H : set G) * {h} = H :=
begin
refine le_antisymm _ (λ h' hh',
⟨h' * h⁻¹, h, H.mul_mem hh' (H.inv_mem hh), rfl, inv_mul_cancel_right h' h⟩),
rintros _ ⟨h', h, hh', rfl : _ = _, rfl⟩,
exact H.mul_mem hh' hh,
end
lemma singleton_mul_subgroup {H : subgroup G} {h : G} (hh : h ∈ H) :
{h} * (H : set G) = H :=
begin
refine le_antisymm _ (λ h' hh', ⟨h, h⁻¹ * h', rfl, H.mul_mem (H.inv_mem hh) hh',
mul_inv_cancel_left h h'⟩),
rintros _ ⟨h, h', rfl : _ = _, hh', rfl⟩,
exact H.mul_mem hh hh',
end
lemma normal.conj_act {G : Type*} [group G] {H : subgroup G} (hH : H.normal ) (g : conj_act G) :
g • H = H :=
begin
ext,
split,
{ intro h,
have := hH.conj_mem (g⁻¹ • x) _ (conj_act.of_conj_act g),
rw subgroup.mem_pointwise_smul_iff_inv_smul_mem at h,
dsimp at *,
rw conj_act.smul_def at *,
simp only [conj_act.of_conj_act_inv, conj_act.of_conj_act_to_conj_act, inv_inv] at *,
convert this,
simp only [←mul_assoc, mul_right_inv, one_mul, mul_inv_cancel_right],
rw subgroup.mem_pointwise_smul_iff_inv_smul_mem at h,
exact h},
{ intro h,
rw [subgroup.mem_pointwise_smul_iff_inv_smul_mem, conj_act.smul_def],
apply hH.conj_mem,
exact h}
end
@[simp] lemma smul_normal (g : G) (H : subgroup G) [h : normal H] : mul_aut.conj g • H = H :=
h.conj_act g
end group
section group_with_zero
variables [group_with_zero α] [mul_distrib_mul_action α G]
open_locale pointwise
@[simp] lemma smul_mem_pointwise_smul_iff₀ {a : α} (ha : a ≠ 0) (S : subgroup G)
(x : G) : a • x ∈ a • S ↔ x ∈ S :=
smul_mem_smul_set_iff₀ ha (S : set G) x
lemma mem_pointwise_smul_iff_inv_smul_mem₀ {a : α} (ha : a ≠ 0) (S : subgroup G) (x : G) :
x ∈ a • S ↔ a⁻¹ • x ∈ S :=
mem_smul_set_iff_inv_smul_mem₀ ha (S : set G) x
lemma mem_inv_pointwise_smul_iff₀ {a : α} (ha : a ≠ 0) (S : subgroup G) (x : G) :
x ∈ a⁻¹ • S ↔ a • x ∈ S :=
mem_inv_smul_set_iff₀ ha (S : set G) x
@[simp] lemma pointwise_smul_le_pointwise_smul_iff₀ {a : α} (ha : a ≠ 0) {S T : subgroup G} :
a • S ≤ a • T ↔ S ≤ T :=
set_smul_subset_set_smul_iff₀ ha
lemma pointwise_smul_le_iff₀ {a : α} (ha : a ≠ 0) {S T : subgroup G} : a • S ≤ T ↔ S ≤ a⁻¹ • T :=
set_smul_subset_iff₀ ha
lemma le_pointwise_smul_iff₀ {a : α} (ha : a ≠ 0) {S T : subgroup G} : S ≤ a • T ↔ a⁻¹ • S ≤ T :=
subset_set_smul_iff₀ ha
end group_with_zero
end subgroup
namespace add_subgroup
section monoid
variables [monoid α] [distrib_mul_action α A]
/-- The action on an additive subgroup corresponding to applying the action to every element.
This is available as an instance in the `pointwise` locale. -/
protected def pointwise_mul_action : mul_action α (add_subgroup A) :=
{ smul := λ a S, S.map (distrib_mul_action.to_add_monoid_End _ _ a),
one_smul := λ S, (congr_arg (λ f, S.map f) (monoid_hom.map_one _)).trans S.map_id,
mul_smul := λ a₁ a₂ S,
(congr_arg (λ f, S.map f) (monoid_hom.map_mul _ _ _)).trans (S.map_map _ _).symm,}
localized "attribute [instance] add_subgroup.pointwise_mul_action" in pointwise
open_locale pointwise
@[simp] lemma coe_pointwise_smul (a : α) (S : add_subgroup A) : ↑(a • S) = a • (S : set A) := rfl
@[simp] lemma pointwise_smul_to_add_submonoid (a : α) (S : add_subgroup A) :
(a • S).to_add_submonoid = a • S.to_add_submonoid := rfl
lemma smul_mem_pointwise_smul (m : A) (a : α) (S : add_subgroup A) : m ∈ S → a • m ∈ a • S :=
(set.smul_mem_smul_set : _ → _ ∈ a • (S : set A))
lemma mem_smul_pointwise_iff_exists (m : A) (a : α) (S : add_subgroup A) :
m ∈ a • S ↔ ∃ (s : A), s ∈ S ∧ a • s = m :=
(set.mem_smul_set : m ∈ a • (S : set A) ↔ _)
instance pointwise_central_scalar [distrib_mul_action αᵐᵒᵖ A] [is_central_scalar α A] :
is_central_scalar α (add_subgroup A) :=
⟨λ a S, congr_arg (λ f, S.map f) $ add_monoid_hom.ext $ by exact op_smul_eq_smul _⟩
end monoid
section group
variables [group α] [distrib_mul_action α A]
open_locale pointwise
@[simp] lemma smul_mem_pointwise_smul_iff {a : α} {S : add_subgroup A} {x : A} :
a • x ∈ a • S ↔ x ∈ S :=
smul_mem_smul_set_iff
lemma mem_pointwise_smul_iff_inv_smul_mem {a : α} {S : add_subgroup A} {x : A} :
x ∈ a • S ↔ a⁻¹ • x ∈ S :=
mem_smul_set_iff_inv_smul_mem
lemma mem_inv_pointwise_smul_iff {a : α} {S : add_subgroup A} {x : A} : x ∈ a⁻¹ • S ↔ a • x ∈ S :=
mem_inv_smul_set_iff
@[simp] lemma pointwise_smul_le_pointwise_smul_iff {a : α} {S T : add_subgroup A} :
a • S ≤ a • T ↔ S ≤ T :=
set_smul_subset_set_smul_iff
lemma pointwise_smul_le_iff {a : α} {S T : add_subgroup A} : a • S ≤ T ↔ S ≤ a⁻¹ • T :=
set_smul_subset_iff
lemma le_pointwise_smul_iff {a : α} {S T : add_subgroup A} : S ≤ a • T ↔ a⁻¹ • S ≤ T :=
subset_set_smul_iff
end group
section group_with_zero
variables [group_with_zero α] [distrib_mul_action α A]
open_locale pointwise
@[simp] lemma smul_mem_pointwise_smul_iff₀ {a : α} (ha : a ≠ 0) (S : add_subgroup A)
(x : A) : a • x ∈ a • S ↔ x ∈ S :=
smul_mem_smul_set_iff₀ ha (S : set A) x
lemma mem_pointwise_smul_iff_inv_smul_mem₀ {a : α} (ha : a ≠ 0) (S : add_subgroup A) (x : A) :
x ∈ a • S ↔ a⁻¹ • x ∈ S :=
mem_smul_set_iff_inv_smul_mem₀ ha (S : set A) x
lemma mem_inv_pointwise_smul_iff₀ {a : α} (ha : a ≠ 0) (S : add_subgroup A) (x : A) :
x ∈ a⁻¹ • S ↔ a • x ∈ S :=
mem_inv_smul_set_iff₀ ha (S : set A) x
@[simp] lemma pointwise_smul_le_pointwise_smul_iff₀ {a : α} (ha : a ≠ 0) {S T : add_subgroup A} :
a • S ≤ a • T ↔ S ≤ T :=
set_smul_subset_set_smul_iff₀ ha
lemma pointwise_smul_le_iff₀ {a : α} (ha : a ≠ 0) {S T : add_subgroup A} :
a • S ≤ T ↔ S ≤ a⁻¹ • T :=
set_smul_subset_iff₀ ha
lemma le_pointwise_smul_iff₀ {a : α} (ha : a ≠ 0) {S T : add_subgroup A} :
S ≤ a • T ↔ a⁻¹ • S ≤ T :=
subset_set_smul_iff₀ ha
end group_with_zero
end add_subgroup
|
01ec6dc840df0cd8496703140cf5ac3c1e9b3e04 | 4bcaca5dc83d49803f72b7b5920b75b6e7d9de2d | /src/Lean/Meta.lean | b45a98a1a6d224e234e8a208ac497a8d0f9c224b | [
"Apache-2.0"
] | permissive | subfish-zhou/leanprover-zh_CN.github.io | 30b9fba9bd790720bd95764e61ae796697d2f603 | 8b2985d4a3d458ceda9361ac454c28168d920d3f | refs/heads/master | 1,689,709,967,820 | 1,632,503,056,000 | 1,632,503,056,000 | 409,962,097 | 1 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 1,163 | lean | /-
Copyright (c) 2019 Microsoft Corporation. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Leonardo de Moura
-/
import Lean.Meta.Basic
import Lean.Meta.LevelDefEq
import Lean.Meta.WHNF
import Lean.Meta.InferType
import Lean.Meta.FunInfo
import Lean.Meta.ExprDefEq
import Lean.Meta.DiscrTree
import Lean.Meta.Reduce
import Lean.Meta.Instances
import Lean.Meta.AbstractMVars
import Lean.Meta.SynthInstance
import Lean.Meta.AppBuilder
import Lean.Meta.Tactic
import Lean.Meta.KAbstract
import Lean.Meta.RecursorInfo
import Lean.Meta.GeneralizeTelescope
import Lean.Meta.Match
import Lean.Meta.ReduceEval
import Lean.Meta.Closure
import Lean.Meta.AbstractNestedProofs
import Lean.Meta.ForEachExpr
import Lean.Meta.Transform
import Lean.Meta.PPGoal
import Lean.Meta.UnificationHint
import Lean.Meta.Inductive
import Lean.Meta.SizeOf
import Lean.Meta.IndPredBelow
import Lean.Meta.Coe
import Lean.Meta.SortLocalDecls
import Lean.Meta.CollectFVars
import Lean.Meta.GeneralizeVars
import Lean.Meta.Injective
import Lean.Meta.Structure
import Lean.Meta.Constructions
import Lean.Meta.CongrTheorems
import Lean.Meta.Eqns
|
959c13ec33a6238c8931cf4be847f56ae8a5b326 | e5169dbb8b1bea3ec2a32737442bc91a4a94b46a | /hott/cubical/cubeover.hlean | 56193a61c103a60a06f6634087a4aaf526bdf65c | [
"Apache-2.0"
] | permissive | pazthor/lean | 733b775e3123f6bbd2c4f7ccb5b560b467b76800 | c923120db54276a22a75b12c69765765608a8e76 | refs/heads/master | 1,610,703,744,289 | 1,448,419,395,000 | 1,448,419,703,000 | null | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 4,216 | hlean | /-
Copyright (c) 2015 Floris van Doorn. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Author: Floris van Doorn
Cubeovers
-/
import .squareover .cube
open equiv is_equiv
namespace eq
-- we need to specify B explicitly, also in pathovers
inductive cubeover {A : Type} (B : A → Type) {a₀₀₀ : A} {b₀₀₀ : B a₀₀₀}
: Π{a₂₀₀ a₀₂₀ a₂₂₀ a₀₀₂ a₂₀₂ a₀₂₂ a₂₂₂ : A}
{p₁₀₀ : a₀₀₀ = a₂₀₀} {p₀₁₀ : a₀₀₀ = a₀₂₀} {p₀₀₁ : a₀₀₀ = a₀₀₂}
{p₁₂₀ : a₀₂₀ = a₂₂₀} {p₂₁₀ : a₂₀₀ = a₂₂₀} {p₂₀₁ : a₂₀₀ = a₂₀₂}
{p₁₀₂ : a₀₀₂ = a₂₀₂} {p₀₁₂ : a₀₀₂ = a₀₂₂} {p₀₂₁ : a₀₂₀ = a₀₂₂}
{p₁₂₂ : a₀₂₂ = a₂₂₂} {p₂₁₂ : a₂₀₂ = a₂₂₂} {p₂₂₁ : a₂₂₀ = a₂₂₂}
{s₁₁₀ : square p₀₁₀ p₂₁₀ p₁₀₀ p₁₂₀}
{s₁₁₂ : square p₀₁₂ p₂₁₂ p₁₀₂ p₁₂₂}
{s₀₁₁ : square p₀₁₀ p₀₁₂ p₀₀₁ p₀₂₁}
{s₂₁₁ : square p₂₁₀ p₂₁₂ p₂₀₁ p₂₂₁}
{s₁₀₁ : square p₁₀₀ p₁₀₂ p₀₀₁ p₂₀₁}
{s₁₂₁ : square p₁₂₀ p₁₂₂ p₀₂₁ p₂₂₁}
(c : cube s₁₁₀ s₁₁₂ s₀₁₁ s₂₁₁ s₁₀₁ s₁₂₁)
{b₀₂₀ : B a₀₂₀} {b₂₀₀ : B a₂₀₀} {b₂₂₀ : B a₂₂₀}
{b₀₀₂ : B a₀₀₂} {b₀₂₂ : B a₀₂₂} {b₂₀₂ : B a₂₀₂} {b₂₂₂ : B a₂₂₂}
{q₁₀₀ : pathover B b₀₀₀ p₁₀₀ b₂₀₀} {q₀₁₀ : pathover B b₀₀₀ p₀₁₀ b₀₂₀}
{q₀₀₁ : pathover B b₀₀₀ p₀₀₁ b₀₀₂} {q₁₂₀ : pathover B b₀₂₀ p₁₂₀ b₂₂₀}
{q₂₁₀ : pathover B b₂₀₀ p₂₁₀ b₂₂₀} {q₂₀₁ : pathover B b₂₀₀ p₂₀₁ b₂₀₂}
{q₁₀₂ : pathover B b₀₀₂ p₁₀₂ b₂₀₂} {q₀₁₂ : pathover B b₀₀₂ p₀₁₂ b₀₂₂}
{q₀₂₁ : pathover B b₀₂₀ p₀₂₁ b₀₂₂} {q₁₂₂ : pathover B b₀₂₂ p₁₂₂ b₂₂₂}
{q₂₁₂ : pathover B b₂₀₂ p₂₁₂ b₂₂₂} {q₂₂₁ : pathover B b₂₂₀ p₂₂₁ b₂₂₂}
(t₁₁₀ : squareover B s₁₁₀ q₀₁₀ q₂₁₀ q₁₀₀ q₁₂₀)
(t₁₁₂ : squareover B s₁₁₂ q₀₁₂ q₂₁₂ q₁₀₂ q₁₂₂)
(t₀₁₁ : squareover B s₀₁₁ q₀₁₀ q₀₁₂ q₀₀₁ q₀₂₁)
(t₂₁₁ : squareover B s₂₁₁ q₂₁₀ q₂₁₂ q₂₀₁ q₂₂₁)
(t₁₀₁ : squareover B s₁₀₁ q₁₀₀ q₁₀₂ q₀₀₁ q₂₀₁)
(t₁₂₁ : squareover B s₁₂₁ q₁₂₀ q₁₂₂ q₀₂₁ q₂₂₁), Type :=
idcubeo : cubeover B idc idso idso idso idso idso idso
-- variables {A : Type} {a₀₀₀ a₂₀₀ a₀₂₀ a₂₂₀ a₀₀₂ a₂₀₂ a₀₂₂ a₂₂₂ : A}
-- {p₁₀₀ : a₀₀₀ = a₂₀₀} {p₀₁₀ : a₀₀₀ = a₀₂₀} {p₀₀₁ : a₀₀₀ = a₀₀₂}
-- {p₁₂₀ : a₀₂₀ = a₂₂₀} {p₂₁₀ : a₂₀₀ = a₂₂₀} {p₂₀₁ : a₂₀₀ = a₂₀₂}
-- {p₁₀₂ : a₀₀₂ = a₂₀₂} {p₀₁₂ : a₀₀₂ = a₀₂₂} {p₀₂₁ : a₀₂₀ = a₀₂₂}
-- {p₁₂₂ : a₀₂₂ = a₂₂₂} {p₂₁₂ : a₂₀₂ = a₂₂₂} {p₂₂₁ : a₂₂₀ = a₂₂₂}
-- {s₁₁₀ : square p₀₁₀ p₂₁₀ p₁₀₀ p₁₂₀}
-- {s₁₁₂ : square p₀₁₂ p₂₁₂ p₁₀₂ p₁₂₂}
-- {s₁₀₁ : square p₁₀₀ p₁₀₂ p₀₀₁ p₂₀₁}
-- {s₁₂₁ : square p₁₂₀ p₁₂₂ p₀₂₁ p₂₂₁}
-- {s₀₁₁ : square p₀₁₀ p₀₁₂ p₀₀₁ p₀₂₁}
-- {s₂₁₁ : square p₂₁₀ p₂₁₂ p₂₀₁ p₂₂₁}
end eq
|
00135299aa9e94cda3d6d5822b6be934073e4223 | d406927ab5617694ec9ea7001f101b7c9e3d9702 | /src/algebra/polynomial/big_operators.lean | 87967ccbfdc9d2c99856afa73669649d265b1cd8 | [
"Apache-2.0"
] | permissive | alreadydone/mathlib | dc0be621c6c8208c581f5170a8216c5ba6721927 | c982179ec21091d3e102d8a5d9f5fe06c8fafb73 | refs/heads/master | 1,685,523,275,196 | 1,670,184,141,000 | 1,670,184,141,000 | 287,574,545 | 0 | 0 | Apache-2.0 | 1,670,290,714,000 | 1,597,421,623,000 | Lean | UTF-8 | Lean | false | false | 13,247 | lean | /-
Copyright (c) 2020 Aaron Anderson. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Aaron Anderson, Jalex Stark
-/
import algebra.order.with_zero
import data.polynomial.monic
/-!
# Lemmas for the interaction between polynomials and `∑` and `∏`.
Recall that `∑` and `∏` are notation for `finset.sum` and `finset.prod` respectively.
## Main results
- `polynomial.nat_degree_prod_of_monic` : the degree of a product of monic polynomials is the
product of degrees. We prove this only for `[comm_semiring R]`,
but it ought to be true for `[semiring R]` and `list.prod`.
- `polynomial.nat_degree_prod` : for polynomials over an integral domain,
the degree of the product is the sum of degrees.
- `polynomial.leading_coeff_prod` : for polynomials over an integral domain,
the leading coefficient is the product of leading coefficients.
- `polynomial.prod_X_sub_C_coeff_card_pred` carries most of the content for computing
the second coefficient of the characteristic polynomial.
-/
open finset
open multiset
open_locale big_operators polynomial
universes u w
variables {R : Type u} {ι : Type w}
namespace polynomial
variables (s : finset ι)
section semiring
variables {S : Type*} [semiring S]
lemma nat_degree_list_sum_le (l : list S[X]) :
nat_degree l.sum ≤ (l.map nat_degree).foldr max 0 :=
list.sum_le_foldr_max nat_degree (by simp) nat_degree_add_le _
lemma nat_degree_multiset_sum_le (l : multiset S[X]) :
nat_degree l.sum ≤ (l.map nat_degree).foldr max max_left_comm 0 :=
quotient.induction_on l (by simpa using nat_degree_list_sum_le)
lemma nat_degree_sum_le (f : ι → S[X]) :
nat_degree (∑ i in s, f i) ≤ s.fold max 0 (nat_degree ∘ f) :=
by simpa using nat_degree_multiset_sum_le (s.val.map f)
lemma degree_list_sum_le (l : list S[X]) :
degree l.sum ≤ (l.map nat_degree).maximum :=
begin
by_cases h : l.sum = 0,
{ simp [h] },
{ rw degree_eq_nat_degree h,
suffices : (l.map nat_degree).maximum = ((l.map nat_degree).foldr max 0 : ℕ),
{ rw this,
simpa [this] using nat_degree_list_sum_le l },
rw ← list.foldr_max_of_ne_nil,
{ congr },
contrapose! h,
rw [list.map_eq_nil] at h,
simp [h] }
end
lemma nat_degree_list_prod_le (l : list S[X]) :
nat_degree l.prod ≤ (l.map nat_degree).sum :=
begin
induction l with hd tl IH,
{ simp },
{ simpa using nat_degree_mul_le.trans (add_le_add_left IH _) }
end
lemma degree_list_prod_le (l : list S[X]) :
degree l.prod ≤ (l.map degree).sum :=
begin
induction l with hd tl IH,
{ simp },
{ simpa using (degree_mul_le _ _).trans (add_le_add_left IH _) }
end
lemma coeff_list_prod_of_nat_degree_le (l : list S[X]) (n : ℕ)
(hl : ∀ p ∈ l, nat_degree p ≤ n) :
coeff (list.prod l) (l.length * n) = (l.map (λ p, coeff p n)).prod :=
begin
induction l with hd tl IH,
{ simp },
{ have hl' : ∀ (p ∈ tl), nat_degree p ≤ n := λ p hp, hl p (list.mem_cons_of_mem _ hp),
simp only [list.prod_cons, list.map, list.length],
rw [add_mul, one_mul, add_comm, ←IH hl', mul_comm tl.length],
have h : nat_degree tl.prod ≤ n * tl.length,
{ refine (nat_degree_list_prod_le _).trans _,
rw [←tl.length_map nat_degree, mul_comm],
refine list.sum_le_card_nsmul _ _ _,
simpa using hl' },
have hdn : nat_degree hd ≤ n := hl _ (list.mem_cons_self _ _),
rcases hdn.eq_or_lt with rfl|hdn',
{ cases h.eq_or_lt with h' h',
{ rw [←h', coeff_mul_degree_add_degree, leading_coeff, leading_coeff] },
{ rw [coeff_eq_zero_of_nat_degree_lt, coeff_eq_zero_of_nat_degree_lt h', mul_zero],
exact nat_degree_mul_le.trans_lt (add_lt_add_left h' _) } },
{ rw [coeff_eq_zero_of_nat_degree_lt hdn', coeff_eq_zero_of_nat_degree_lt, zero_mul],
exact nat_degree_mul_le.trans_lt (add_lt_add_of_lt_of_le hdn' h) } }
end
end semiring
section comm_semiring
variables [comm_semiring R] (f : ι → R[X]) (t : multiset R[X])
lemma nat_degree_multiset_prod_le :
t.prod.nat_degree ≤ (t.map nat_degree).sum :=
quotient.induction_on t (by simpa using nat_degree_list_prod_le)
lemma nat_degree_prod_le : (∏ i in s, f i).nat_degree ≤ ∑ i in s, (f i).nat_degree :=
by simpa using nat_degree_multiset_prod_le (s.1.map f)
/--
The degree of a product of polynomials is at most the sum of the degrees,
where the degree of the zero polynomial is ⊥.
-/
lemma degree_multiset_prod_le :
t.prod.degree ≤ (t.map polynomial.degree).sum :=
quotient.induction_on t (by simpa using degree_list_prod_le)
lemma degree_prod_le : (∏ i in s, f i).degree ≤ ∑ i in s, (f i).degree :=
by simpa only [multiset.map_map] using degree_multiset_prod_le (s.1.map f)
/--
The leading coefficient of a product of polynomials is equal to
the product of the leading coefficients, provided that this product is nonzero.
See `polynomial.leading_coeff_multiset_prod` (without the `'`) for a version for integral domains,
where this condition is automatically satisfied.
-/
lemma leading_coeff_multiset_prod' (h : (t.map leading_coeff).prod ≠ 0) :
t.prod.leading_coeff = (t.map leading_coeff).prod :=
begin
induction t using multiset.induction_on with a t ih, { simp },
simp only [multiset.map_cons, multiset.prod_cons] at h ⊢,
rw polynomial.leading_coeff_mul'; { rwa ih, apply right_ne_zero_of_mul h }
end
/--
The leading coefficient of a product of polynomials is equal to
the product of the leading coefficients, provided that this product is nonzero.
See `polynomial.leading_coeff_prod` (without the `'`) for a version for integral domains,
where this condition is automatically satisfied.
-/
lemma leading_coeff_prod' (h : ∏ i in s, (f i).leading_coeff ≠ 0) :
(∏ i in s, f i).leading_coeff = ∏ i in s, (f i).leading_coeff :=
by simpa using leading_coeff_multiset_prod' (s.1.map f) (by simpa using h)
/--
The degree of a product of polynomials is equal to
the sum of the degrees, provided that the product of leading coefficients is nonzero.
See `polynomial.nat_degree_multiset_prod` (without the `'`) for a version for integral domains,
where this condition is automatically satisfied.
-/
lemma nat_degree_multiset_prod' (h : (t.map (λ f, leading_coeff f)).prod ≠ 0) :
t.prod.nat_degree = (t.map (λ f, nat_degree f)).sum :=
begin
revert h,
refine multiset.induction_on t _ (λ a t ih ht, _), { simp },
rw [multiset.map_cons, multiset.prod_cons] at ht ⊢,
rw [multiset.sum_cons, polynomial.nat_degree_mul', ih],
{ apply right_ne_zero_of_mul ht },
{ rwa polynomial.leading_coeff_multiset_prod', apply right_ne_zero_of_mul ht },
end
/--
The degree of a product of polynomials is equal to
the sum of the degrees, provided that the product of leading coefficients is nonzero.
See `polynomial.nat_degree_prod` (without the `'`) for a version for integral domains,
where this condition is automatically satisfied.
-/
lemma nat_degree_prod' (h : ∏ i in s, (f i).leading_coeff ≠ 0) :
(∏ i in s, f i).nat_degree = ∑ i in s, (f i).nat_degree :=
by simpa using nat_degree_multiset_prod' (s.1.map f) (by simpa using h)
lemma nat_degree_multiset_prod_of_monic (h : ∀ f ∈ t, monic f) :
t.prod.nat_degree = (t.map nat_degree).sum :=
begin
nontriviality R,
apply nat_degree_multiset_prod',
suffices : (t.map (λ f, leading_coeff f)).prod = 1, { rw this, simp },
convert prod_repeat (1 : R) t.card,
{ simp only [eq_repeat, multiset.card_map, eq_self_iff_true, true_and],
rintros i hi,
obtain ⟨i, hi, rfl⟩ := multiset.mem_map.mp hi,
apply h, assumption },
{ simp }
end
lemma nat_degree_prod_of_monic (h : ∀ i ∈ s, (f i).monic) :
(∏ i in s, f i).nat_degree = ∑ i in s, (f i).nat_degree :=
by simpa using nat_degree_multiset_prod_of_monic (s.1.map f) (by simpa using h)
lemma coeff_multiset_prod_of_nat_degree_le (n : ℕ)
(hl : ∀ p ∈ t, nat_degree p ≤ n) :
coeff t.prod (t.card * n) = (t.map (λ p, coeff p n)).prod :=
begin
induction t using quotient.induction_on,
simpa using coeff_list_prod_of_nat_degree_le _ _ hl
end
lemma coeff_prod_of_nat_degree_le (f : ι → R[X]) (n : ℕ)
(h : ∀ p ∈ s, nat_degree (f p) ≤ n) :
coeff (∏ i in s, f i) (s.card * n) = ∏ i in s, coeff (f i) n :=
begin
cases s with l hl,
convert coeff_multiset_prod_of_nat_degree_le (l.map f) _ _,
{ simp },
{ simp },
{ simpa using h }
end
lemma coeff_zero_multiset_prod :
t.prod.coeff 0 = (t.map (λ f, coeff f 0)).prod :=
begin
refine multiset.induction_on t _ (λ a t ht, _), { simp },
rw [multiset.prod_cons, multiset.map_cons, multiset.prod_cons, polynomial.mul_coeff_zero, ht]
end
lemma coeff_zero_prod :
(∏ i in s, f i).coeff 0 = ∏ i in s, (f i).coeff 0 :=
by simpa using coeff_zero_multiset_prod (s.1.map f)
end comm_semiring
section comm_ring
variables [comm_ring R]
open monic
-- Eventually this can be generalized with Vieta's formulas
-- plus the connection between roots and factorization.
lemma multiset_prod_X_sub_C_next_coeff (t : multiset R) :
next_coeff (t.map (λ x, X - C x)).prod = -t.sum :=
begin
rw next_coeff_multiset_prod,
{ simp only [next_coeff_X_sub_C],
exact t.sum_hom (-add_monoid_hom.id R) },
{ intros, apply monic_X_sub_C }
end
lemma prod_X_sub_C_next_coeff {s : finset ι} (f : ι → R) :
next_coeff ∏ i in s, (X - C (f i)) = -∑ i in s, f i :=
by simpa using multiset_prod_X_sub_C_next_coeff (s.1.map f)
lemma multiset_prod_X_sub_C_coeff_card_pred (t : multiset R) (ht : 0 < t.card) :
(t.map (λ x, (X - C x))).prod.coeff (t.card - 1) = -t.sum :=
begin
nontriviality R,
convert multiset_prod_X_sub_C_next_coeff (by assumption),
rw next_coeff, split_ifs,
{ rw nat_degree_multiset_prod_of_monic at h; simp only [multiset.mem_map] at *,
swap, { rintros _ ⟨_, _, rfl⟩, apply monic_X_sub_C },
simp_rw [multiset.sum_eq_zero_iff, multiset.mem_map] at h,
contrapose! h,
obtain ⟨x, hx⟩ := card_pos_iff_exists_mem.mp ht,
exact ⟨_, ⟨_, ⟨x, hx, rfl⟩, nat_degree_X_sub_C _⟩, one_ne_zero⟩ },
congr, rw nat_degree_multiset_prod_of_monic; { simp [nat_degree_X_sub_C, monic_X_sub_C] },
end
lemma prod_X_sub_C_coeff_card_pred (s : finset ι) (f : ι → R) (hs : 0 < s.card) :
(∏ i in s, (X - C (f i))).coeff (s.card - 1) = - ∑ i in s, f i :=
by simpa using multiset_prod_X_sub_C_coeff_card_pred (s.1.map f) (by simpa using hs)
end comm_ring
section no_zero_divisors
section semiring
variables [semiring R] [no_zero_divisors R]
/--
The degree of a product of polynomials is equal to
the sum of the degrees, where the degree of the zero polynomial is ⊥.
`[nontrivial R]` is needed, otherwise for `l = []` we have `⊥` in the LHS and `0` in the RHS.
-/
lemma degree_list_prod [nontrivial R] (l : list R[X]) :
l.prod.degree = (l.map degree).sum :=
map_list_prod (@degree_monoid_hom R _ _ _) l
end semiring
section comm_semiring
variables [comm_semiring R] [no_zero_divisors R] (f : ι → R[X]) (t : multiset R[X])
/--
The degree of a product of polynomials is equal to
the sum of the degrees.
See `polynomial.nat_degree_prod'` (with a `'`) for a version for commutative semirings,
where additionally, the product of the leading coefficients must be nonzero.
-/
lemma nat_degree_prod (h : ∀ i ∈ s, f i ≠ 0) :
(∏ i in s, f i).nat_degree = ∑ i in s, (f i).nat_degree :=
begin
nontriviality R,
apply nat_degree_prod',
rw prod_ne_zero_iff,
intros x hx, simp [h x hx]
end
lemma nat_degree_multiset_prod (h : (0 : R[X]) ∉ t) :
nat_degree t.prod = (t.map nat_degree).sum :=
begin
nontriviality R,
rw nat_degree_multiset_prod',
simp_rw [ne.def, multiset.prod_eq_zero_iff, multiset.mem_map, leading_coeff_eq_zero],
rintro ⟨_, h, rfl⟩,
contradiction
end
/--
The degree of a product of polynomials is equal to
the sum of the degrees, where the degree of the zero polynomial is ⊥.
-/
lemma degree_multiset_prod [nontrivial R] :
t.prod.degree = (t.map (λ f, degree f)).sum :=
map_multiset_prod (@degree_monoid_hom R _ _ _) _
/--
The degree of a product of polynomials is equal to
the sum of the degrees, where the degree of the zero polynomial is ⊥.
-/
lemma degree_prod [nontrivial R] : (∏ i in s, f i).degree = ∑ i in s, (f i).degree :=
map_prod (@degree_monoid_hom R _ _ _) _ _
/--
The leading coefficient of a product of polynomials is equal to
the product of the leading coefficients.
See `polynomial.leading_coeff_multiset_prod'` (with a `'`) for a version for commutative semirings,
where additionally, the product of the leading coefficients must be nonzero.
-/
lemma leading_coeff_multiset_prod :
t.prod.leading_coeff = (t.map (λ f, leading_coeff f)).prod :=
by { rw [← leading_coeff_hom_apply, monoid_hom.map_multiset_prod], refl }
/--
The leading coefficient of a product of polynomials is equal to
the product of the leading coefficients.
See `polynomial.leading_coeff_prod'` (with a `'`) for a version for commutative semirings,
where additionally, the product of the leading coefficients must be nonzero.
-/
lemma leading_coeff_prod :
(∏ i in s, f i).leading_coeff = ∏ i in s, (f i).leading_coeff :=
by simpa using leading_coeff_multiset_prod (s.1.map f)
end comm_semiring
end no_zero_divisors
end polynomial
|
be5ba12277e652ec96aabd8387a0b39104b9e548 | 12dabd587ce2621d9a4eff9f16e354d02e206c8e | /world09/level03.lean | e2dd3a8aba1091f6a6bf4bd3deb99da6c78ec861 | [] | no_license | abdelq/natural-number-game | a1b5b8f1d52625a7addcefc97c966d3f06a48263 | bbddadc6d2e78ece2e9acd40fa7702ecc2db75c2 | refs/heads/master | 1,668,606,478,691 | 1,594,175,058,000 | 1,594,175,058,000 | 278,673,209 | 0 | 1 | null | null | null | null | UTF-8 | Lean | false | false | 188 | lean | theorem mul_eq_zero_iff (a b : mynat): a * b = 0 ↔ a = 0 ∨ b = 0 :=
begin
split,
apply eq_zero_or_eq_zero_of_mul_eq_zero,
intro h,
cases h,
rw h,
rwa zero_mul,
rw h,
rwa mul_zero,
end
|
10d5e1785cc56be3894625d4a8895af28373a2d7 | 05f637fa14ac28031cb1ea92086a0f4eb23ff2b1 | /tests/lean/tst15.lean | b1116ed134cfe2c4e04228bde8efc58e818a7fdc | [
"Apache-2.0"
] | permissive | codyroux/lean0.1 | 1ce92751d664aacff0529e139083304a7bbc8a71 | 0dc6fb974aa85ed6f305a2f4b10a53a44ee5f0ef | refs/heads/master | 1,610,830,535,062 | 1,402,150,480,000 | 1,402,150,480,000 | 19,588,851 | 2 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 513 | lean | universe M >= 1
universe U >= M + 1
variable x : (Type max U+1+2 M+1 M+2 3)
check x
variable f : (Type U+10) -> Type
check f
check f x
check (Type 4)
check x
check (Type max U M)
print (Type U+3)
check (Type U+3)
check (Type U ⊔ M)
check (Type U ⊔ M ⊔ 3)
print (Type U+1 ⊔ M ⊔ 3)
check (Type U+1 ⊔ M ⊔ 3)
print (Type U) -> (Type 5)
check (Type U) -> (Type 5)
check (Type M ⊔ 3) -> (Type U+5)
print (Type M ⊔ 3) -> (Type U) -> (Type 5)
check (Type M ⊔ 3) -> (Type U) -> (Type 5)
print (Type U)
|
08f3477d19349fd12d6d42c81caa4a8fc2832d1c | e514e8b939af519a1d5e9b30a850769d058df4e9 | /src/tactic/rewrite_search/bundles/arithmetic.lean | ccd333922c0fa12394e52bd42a4f3e30b175d35f | [] | no_license | semorrison/lean-rewrite-search | dca317c5a52e170fb6ffc87c5ab767afb5e3e51a | e804b8f2753366b8957be839908230ee73f9e89f | refs/heads/master | 1,624,051,754,485 | 1,614,160,817,000 | 1,614,160,817,000 | 162,660,605 | 0 | 1 | null | null | null | null | UTF-8 | Lean | false | false | 335 | lean | import tactic.rewrite_search.discovery.bundle
namespace tactic.rewrite_search.discovery
@[bundle] meta def arithmetic : bundle := {}
attribute [search arithmetic] add_comm add_assoc
attribute [search arithmetic] mul_comm mul_assoc mul_one
attribute [search arithmetic] left_distrib right_distrib
end tactic.rewrite_search.discovery |
ca6cc1a49cc8860d1ea9868bb4e3d77ba9b30d31 | 74addaa0e41490cbaf2abd313a764c96df57b05d | /Mathlib/tactic/core_auto.lean | 8b8cf74c9babefbe9a6808efd781db4f21a29d94 | [] | no_license | AurelienSaue/Mathlib4_auto | f538cfd0980f65a6361eadea39e6fc639e9dae14 | 590df64109b08190abe22358fabc3eae000943f2 | refs/heads/master | 1,683,906,849,776 | 1,622,564,669,000 | 1,622,564,669,000 | 371,723,747 | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 39,488 | lean | /-
Copyright (c) 2018 Mario Carneiro. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro, Simon Hudon, Scott Morrison, Keeley Hoek
-/
import Mathlib.PrePort
import Mathlib.Lean3Lib.init.default
import Mathlib.data.dlist.basic
import Mathlib.logic.function.basic
import Mathlib.control.basic
import Mathlib.meta.expr
import Mathlib.meta.rb_map
import Mathlib.data.bool
import Mathlib.tactic.binder_matching
import Mathlib.tactic.lean_core_docs
import Mathlib.tactic.interactive_expr
import Mathlib.Lean3Lib.system.io
import Mathlib.PostPort
universes u_1 l_2 l_1
namespace Mathlib
protected instance pos.has_lt : HasLess pos :=
{ Less := fun (x y : pos) => (pos.line x, pos.column x) < (pos.line y, pos.column y) }
namespace expr
/-- Given an expr `α` representing a type with numeral structure,
`of_nat α n` creates the `α`-valued numeral expression corresponding to `n`. -/
/-- Given an expr `α` representing a type with numeral structure,
`of_int α n` creates the `α`-valued numeral expression corresponding to `n`.
The output is either a numeral or the negation of a numeral. -/
/-- Generates an expression of the form `∃(args), inner`. `args` is assumed to be a list of local
constants. When possible, `p ∧ q` is used instead of `∃(_ : p), q`. -/
/-- `traverse f e` applies the monadic function `f` to the direct descendants of `e`. -/
/-- `mfoldl f a e` folds the monadic function `f` over the subterms of the expression `e`,
with initial value `a`. -/
/-- `kreplace e old new` replaces all occurrences of the expression `old` in `e`
with `new`. The occurrences of `old` in `e` are determined using keyed matching
with transparency `md`; see `kabstract` for details. If `unify` is true,
we may assign metavariables in `e` as we match subterms of `e` against `old`. -/
end expr
namespace interaction_monad
/-- `get_state` returns the underlying state inside an interaction monad, from within that monad. -/
-- Note that this is a generalization of `tactic.read` in core.
/-- `set_state` sets the underlying state inside an interaction monad, from within that monad. -/
-- Note that this is a generalization of `tactic.write` in core.
/--
`run_with_state state tac` applies `tac` to the given state `state` and returns the result,
subsequently restoring the original state.
If `tac` fails, then `run_with_state` does too.
-/
end interaction_monad
namespace format
/-- `join' [a,b,c]` produces the format object `abc`.
It differs from `format.join` by using `format.nil` instead of `""` for the empty list. -/
/-- `intercalate x [a, b, c]` produces the format object `a.x.b.x.c`,
where `.` represents `format.join`. -/
/-- `soft_break` is similar to `line`. Whereas in `group (x ++ line ++ y ++ line ++ z)`
the result either fits on one line or in three, `x ++ soft_break ++ y ++ soft_break ++ z`
each line break is decided independently -/
/-- Format a list as a comma separated list, without any brackets. -/
end format
/-- format a `list` by separating elements with `soft_break` instead of `line` -/
namespace tactic
/-- Private work function for `add_local_consts_as_local_hyps`: given
`mappings : list (expr × expr)` corresponding to pairs `(var, hyp)` of variables and the local
hypothesis created as a result and `(var :: rest) : list expr` of more local variables we
examine `var` to see if it contains any other variables in `rest`. If it does, we put it to the
back of the queue and recurse. If it does not, then we perform replacements inside the type of
`var` using the `mappings`, create a new associate local hypothesis, add this to the list of
mappings, and recurse. We are done once all local hypotheses have been processed.
If the list of passed local constants have types which depend on one another (which can only
happen by hand-crafting the `expr`s manually), this function will loop forever. -/
/-- `add_local_consts_as_local_hyps vars` add the given list `vars` of `expr.local_const`s to the
tactic state. This is harder than it sounds, since the list of local constants which we have
been passed can have dependencies between their types.
For example, suppose we have two local constants `n : ℕ` and `h : n = 3`. Then we cannot blindly
add `h` as a local hypothesis, since we need the `n` to which it refers to be the `n` created as
a new local hypothesis, not the old local constant `n` with the same name. Of course, these
dependencies can be nested arbitrarily deep.
If the list of passed local constants have types which depend on one another (which can only
happen by hand-crafting the `expr`s manually), this function will loop forever. -/
/- The `list.reverse` below is a performance optimisation since the list of available variables
reported by the system is often mostly the reverse of the order in which they are dependent. -/
/-- Compute the arity of explicit arguments of `type`. -/
/-- Compute the arity of explicit arguments of `fn`'s type. -/
/--
For `e = f x₁ ... xₙ`, `get_app_fn_args_whnf e` returns `(f, [x₁, ..., xₙ])`. `e`
is normalised as necessary; for example:
```
get_app_fn_args_whnf `(let f := g x in f y) = (`(g), [`(x), `(y)])
```
The returned expression is in whnf, but the arguments are generally not.
-/
/--
`get_app_fn_whnf e md unfold_ginductive` is like `expr.get_app_fn e` but `e` is
normalised as necessary (with transparency `md`). `unfold_ginductive` controls
whether constructors of generalised inductive types are unfolded. The returned
expression is in whnf.
-/
/--
`get_app_fn_const_whnf e md unfold_ginductive` expects that `e = C x₁ ... xₙ`,
where `C` is a constant, after normalisation with transparency `md`. If so, the
name of `C` is returned. Otherwise the tactic fails. `unfold_ginductive`
controls whether constructors of generalised inductive types are unfolded.
-/
/--
`get_app_args_whnf e md unfold_ginductive` is like `expr.get_app_args e` but `e`
is normalised as necessary (with transparency `md`). `unfold_ginductive`
controls whether constructors of generalised inductive types are unfolded. The
returned expressions are not necessarily in whnf.
-/
/-- `pis loc_consts f` is used to create a pi expression whose body is `f`.
`loc_consts` should be a list of local constants. The function will abstract these local
constants from `f` and bind them with pi binders.
For example, if `a, b` are local constants with types `Ta, Tb`,
``pis [a, b] `(f a b)`` will return the expression
`Π (a : Ta) (b : Tb), f a b`. -/
/-- `lambdas loc_consts f` is used to create a lambda expression whose body is `f`.
`loc_consts` should be a list of local constants. The function will abstract these local
constants from `f` and bind them with lambda binders.
For example, if `a, b` are local constants with types `Ta, Tb`,
``lambdas [a, b] `(f a b)`` will return the expression
`λ (a : Ta) (b : Tb), f a b`. -/
-- TODO: move to `declaration` namespace in `meta/expr.lean`
/-- `mk_theorem n ls t e` creates a theorem declaration with name `n`, universe parameters named
`ls`, type `t`, and body `e`. -/
/-- `add_theorem_by n ls type tac` uses `tac` to synthesize a term with type `type`, and adds this
to the environment as a theorem with name `n` and universe parameters `ls`. -/
/-- `eval_expr' α e` attempts to evaluate the expression `e` in the type `α`.
This is a variant of `eval_expr` in core. Due to unexplained behavior in the VM, in rare
situations the latter will fail but the former will succeed. -/
/-- `mk_fresh_name` returns identifiers starting with underscores,
which are not legal when emitted by tactic programs. `mk_user_fresh_name`
turns the useful source of random names provided by `mk_fresh_name` into
names which are usable by tactic programs.
The returned name has four components which are all strings. -/
/-- `has_attribute' attr_name decl_name` checks
whether `decl_name` exists and has attribute `attr_name`. -/
/-- Checks whether the name is a simp lemma -/
/-- Checks whether the name is an instance. -/
/-- `local_decls` returns a dictionary mapping names to their corresponding declarations.
Covers all declarations from the current file. -/
/-- `get_decls_from` returns a dictionary mapping names to their
corresponding declarations. Covers all declarations the files listed
in `fs`, with the current file listed as `none`.
The path of the file names is expected to be relative to
the root of the project (i.e. the location of `leanpkg.toml` when it
is present); e.g. `"src/tactic/core.lean"`
Possible issue: `get_decls_from` uses `get_cwd`, the current working
directory, which may not always point at the root of the project.
It would work better if it searched for the root directory or,
better yet, if Lean exposed its path information.
-/
/-- If `{nm}_{n}` doesn't exist in the environment, returns that, otherwise tries `{nm}_{n+1}` -/
/-- Return a name which doesn't already exist in the environment. If `nm` doesn't exist, it
returns that, otherwise it tries `nm_2`, `nm_3`, ... -/
/--
Returns a pair `(e, t)`, where `e ← mk_const d.to_name`, and `t = d.type`
but with universe params updated to match the fresh universe metavariables in `e`.
This should have the same effect as just
```lean
do e ← mk_const d.to_name,
t ← infer_type e,
return (e, t)
```
but is hopefully faster.
-/
/--
Replace every universe metavariable in an expression with a universe parameter.
(This is useful when making new declarations.)
-/
/-- `mk_local n` creates a dummy local variable with name `n`.
The type of this local constant is a constant with name `n`, so it is very unlikely to be
a meaningful expression. -/
/-- `mk_psigma [x,y,z]`, with `[x,y,z]` list of local constants of types `x : tx`,
`y : ty x` and `z : tz x y`, creates an expression of sigma type:
`⟨x,y,z⟩ : Σ' (x : tx) (y : ty x), tz x y`.
-/
/--
Update the type of a local constant or metavariable. For local constants and
metavariables obtained via, for example, `tactic.get_local`, the type stored in
the expression is not necessarily the same as the type returned by `infer_type`.
This tactic, given a local constant or metavariable, updates the stored type to
match the output of `infer_type`. If the input is not a local constant or
metavariable, `update_type` does nothing.
-/
/-- `elim_gen_prod n e _ ns` with `e` an expression of type `psigma _`, applies `cases` on `e` `n`
times and uses `ns` to name the resulting variables. Returns a triple: list of new variables,
remaining term and unused variable names.
-/
/-- `elim_gen_sum n e` applies cases on `e` `n` times. `e` is assumed to be a local constant whose
type is a (nested) sum `⊕`. Returns the list of local constants representing the components of `e`.
-/
/-- Given `elab_def`, a tactic to solve the current goal,
`extract_def n trusted elab_def` will create an auxiliary definition named `n` and use it
to close the goal. If `trusted` is false, it will be a meta definition. -/
/-- Attempts to close the goal with `dec_trivial`. -/
/-- Runs a tactic for a result, reverting the state after completion. -/
/-- Runs a tactic for a result, reverting the state after completion or error. -/
/-- Repeat a tactic at least once, calling it recursively on all subgoals,
until it fails. This tactic fails if the first invocation fails. -/
/-- `iterate_range m n t`: Repeat the given tactic at least `m` times and
at most `n` times or until `t` fails. Fails if `t` does not run at least `m` times. -/
/--
Given a tactic `tac` that takes an expression
and returns a new expression and a proof of equality,
use that tactic to change the type of the hypotheses listed in `hs`,
as well as the goal if `tgt = tt`.
Returns `tt` if any types were successfully changed.
-/
/-- `revert_after e` reverts all local constants after local constant `e`. -/
/-- `revert_target_deps` reverts all local constants on which the target depends (recursively).
Returns the number of local constants that have been reverted. -/
/-- `generalize' e n` generalizes the target with respect to `e`. It creates a new local constant
with name `n` of the same type as `e` and replaces all occurrences of `e` by `n`.
`generalize'` is similar to `generalize` but also succeeds when `e` does not occur in the
goal, in which case it just calls `assert`.
In contrast to `generalize` it already introduces the generalized variable. -/
/--
`intron_no_renames n` calls `intro` `n` times, using the pretty-printing name
provided by the binder to name the new local constant.
Unlike `intron`, it does not rename introduced constants if the names shadow existing constants.
-/
/-!
### Various tactics related to local definitions (local constants of the form `x : α := t`)
We call `t` the value of `x`.
-/
/-- `local_def_value e` returns the value of the expression `e`, assuming that `e` has been defined
locally using a `let` expression. Otherwise it fails. -/
/-- `is_local_def e` succeeds when `e` is a local definition (a local constant of the form
`e : α := t`) and otherwise fails. -/
/-- like `split_on_p p xs`, `partition_local_deps_aux vs xs acc` searches for matches in `xs`
(using membership to `vs` instead of a predicate) and breaks `xs` when matches are found.
whereas `split_on_p p xs` removes the matches, `partition_local_deps_aux vs xs acc` includes
them in the following partition. Also, `partition_local_deps_aux vs xs acc` discards the partition
running up to the first match. -/
/-- `partition_local_deps vs`, with `vs` a list of local constants,
reorders `vs` in the order they appear in the local context together
with the variables that follow them. If local context is `[a,b,c,d,e,f]`,
and that we call `partition_local_deps [d,b]`, we get `[[d,e,f], [b,c]]`.
The head of each list is one of the variables given as a parameter. -/
/-- `clear_value [e₀, e₁, e₂, ...]` clears the body of the local definitions `e₀`, `e₁`, `e₂`, ...
changing them into regular hypotheses. A hypothesis `e : α := t` is changed to `e : α`. The order of
locals `e₀`, `e₁`, `e₂` does not matter as a permutation will be chosen so as to preserve type
correctness. This tactic is called `clearbody` in Coq. -/
/--
`context_has_local_def` is true iff there is at least one local definition in
the context.
-/
/--
`context_upto_hyp_has_local_def h` is true iff any of the hypotheses in the
context up to and including `h` is a local definition.
-/
/-- A variant of `simplify_bottom_up`. Given a tactic `post` for rewriting subexpressions,
`simp_bottom_up post e` tries to rewrite `e` starting at the leaf nodes. Returns the resulting
expression and a proof of equality. -/
/-- Caches unary type classes on a type `α : Type.{univ}`. -/
/-- Creates an `instance_cache` for the type `α`. -/
namespace instance_cache
/-- If `n` is the name of a type class with one parameter, `get c n` tries to find an instance of
`n c.α` by checking the cache `c`. If there is no entry in the cache, it tries to find the instance
via type class resolution, and updates the cache. -/
/-- If `e` is a `pi` expression that binds an instance-implicit variable of type `n`,
`append_typeclasses e c l` searches `c` for an instance `p` of type `n` and returns `p :: l`. -/
/-- Creates the application `n c.α p l`, where `p` is a type class instance found in the cache `c`.
-/
/-- `c.of_nat n` creates the `c.α`-valued numeral expression corresponding to `n`. -/
/-- `c.of_int n` creates the `c.α`-valued numeral expression corresponding to `n`.
The output is either a numeral or the negation of a numeral. -/
end instance_cache
/-- A variation on `assert` where a (possibly incomplete)
proof of the assertion is provided as a parameter.
``(h,gs) ← local_proof `h p tac`` creates a local `h : p` and
use `tac` to (partially) construct a proof for it. `gs` is the
list of remaining goals in the proof of `h`.
The benefits over assert are:
- unlike with ``h ← assert `h p, tac`` , `h` cannot be used by `tac`;
- when `tac` does not complete the proof of `h`, returning the list
of goals allows one to write a tactic using `h` and with the confidence
that a proof will not boil over to goals left over from the proof of `h`,
unlike what would be the case when using `tactic.swap`.
-/
/-- `var_names e` returns a list of the unique names of the initial pi bindings in `e`. -/
/-- When `struct_n` is the name of a structure type,
`subobject_names struct_n` returns two lists of names `(instances, fields)`.
The names in `instances` are the projections from `struct_n` to the structures that it extends
(assuming it was defined with `old_structure_cmd false`).
The names in `fields` are the standard fields of `struct_n`. -/
/-- `expanded_field_list struct_n` produces a list of the names of the fields of the structure
named `struct_n`. These are returned as pairs of names `(prefix, name)`, where the full name
of the projection is `prefix.name`.
`struct_n` cannot be a synonym for a `structure`, it must be itself a `structure` -/
/--
Return a list of all type classes which can be instantiated
for the given expression.
-/
/--
Finds an instance of an implication `cond → tgt`.
Returns a pair of a local constant `e` of type `cond`, and an instance of `tgt` that can mention
`e`. The local constant `e` is added as an hypothesis to the tactic state, but should not be used,
since it has been "proven" by a metavariable.
-/
/-- Create a list of `n` fresh metavariables. -/
/-- Returns the only goal, or fails if there isn't just one goal. -/
/-- `iterate_at_most_on_all_goals n t`: repeat the given tactic at most `n` times on all goals,
or until it fails. Always succeeds. -/
/-- `iterate_at_most_on_subgoals n t`: repeat the tactic `t` at most `n` times on the first
goal and on all subgoals thus produced, or until it fails. Fails iff `t` fails on
current goal. -/
/-- This makes sure that the execution of the tactic does not change the tactic state.
This can be helpful while using rewrite, apply, or expr munging.
Remember to instantiate your metavariables before you're done! -/
/--
`apply_list l`, for `l : list (tactic expr)`,
tries to apply the lemmas generated by the tactics in `l` on the first goal, and
fail if none succeeds.
-/
/--
Constructs a list of `tactic expr` given a list of p-expressions, as follows:
- if the p-expression is the name of a theorem, use `i_to_expr_for_apply` on it
- if the p-expression is a user attribute, add all the theorems with this attribute
to the list.
We need to return a list of `tactic expr`, rather than just `expr`, because these expressions
will be repeatedly applied against goals, and we need to ensure that metavariables don't get stuck.
-/
/--`apply_rules hs n`: apply the list of rules `hs` (given as pexpr) and `assumption` on the
first goal and the resulting subgoals, iteratively, at most `n` times.
Unlike `solve_by_elim`, `apply_rules` does not do any backtracking, and just greedily applies
a lemma from the list until it can't.
-/
/-- `replace h p` elaborates the pexpr `p`, clears the existing hypothesis named `h` from the local
context, and adds a new hypothesis named `h`. The type of this hypothesis is the type of `p`.
Fails if there is nothing named `h` in the local context. -/
/-- Auxiliary function for `iff_mp` and `iff_mpr`. Takes a name, which should be either `` `iff.mp``
or `` `iff.mpr``. If the passed expression is an iterated function type eventually producing an
`iff`, returns an expression with the `iff` converted to either the forwards or backwards
implication, as requested. -/
/-- `iff_mp_core e ty` assumes that `ty` is the type of `e`.
If `ty` has the shape `Π ..., A ↔ B`, returns an expression whose type is `Π ..., A → B`. -/
/-- `iff_mpr_core e ty` assumes that `ty` is the type of `e`.
If `ty` has the shape `Π ..., A ↔ B`, returns an expression whose type is `Π ..., B → A`. -/
/-- Given an expression whose type is (a possibly iterated function producing) an `iff`,
create the expression which is the forward implication. -/
/-- Given an expression whose type is (a possibly iterated function producing) an `iff`,
create the expression which is the reverse implication. -/
/--
Attempts to apply `e`, and if that fails, if `e` is an `iff`,
try applying both directions separately.
-/
/--
Configuration options for `apply_any`:
* `use_symmetry`: if `apply_any` fails to apply any lemma, call `symmetry` and try again.
* `use_exfalso`: if `apply_any` fails to apply any lemma, call `exfalso` and try again.
* `apply`: specify an alternative to `tactic.apply`; usually `apply := tactic.eapply`.
-/
/--
This is a version of `apply_any` that takes a list of `tactic expr`s instead of `expr`s,
and evaluates these as thunks before trying to apply them.
We need to do this to avoid metavariables getting stuck during subsequent rounds of `apply`.
-/
/--
`apply_any lemmas` tries to apply one of the list `lemmas` to the current goal.
`apply_any lemmas opt` allows control over how lemmas are applied.
`opt` has fields:
* `use_symmetry`: if no lemma applies, call `symmetry` and try again. (Defaults to `tt`.)
* `use_exfalso`: if no lemma applies, call `exfalso` and try again. (Defaults to `tt`.)
* `apply`: use a tactic other than `tactic.apply` (e.g. `tactic.fapply` or `tactic.eapply`).
`apply_any lemmas tac` calls the tactic `tac` after a successful application.
Defaults to `skip`. This is used, for example, by `solve_by_elim` to arrange
recursive invocations of `apply_any`.
-/
/-- Try to apply a hypothesis from the local context to the goal. -/
/-- `change_core e none` is equivalent to `change e`. It tries to change the goal to `e` and fails
if this is not a definitional equality.
`change_core e (some h)` assumes `h` is a local constant, and tries to change the type of `h` to `e`
by reverting `h`, changing the goal, and reintroducing hypotheses. -/
/--
`change_with_at olde newe hyp` replaces occurences of `olde` with `newe` at hypothesis `hyp`,
assuming `olde` and `newe` are defeq when elaborated.
-/
/-- Returns a list of all metavariables in the current partial proof. This can differ from
the list of goals, since the goals can be manually edited. -/
/--
`sorry_if_contains_sorry` will solve any goal already containing `sorry` in its type with `sorry`,
and fail otherwise.
-/
/-- Fail if the target contains a metavariable. -/
/-- Succeeds only if the current goal is a proposition. -/
/-- Succeeds only if we can construct an instance showing the
current goal is a subsingleton type. -/
/--
Succeeds only if the current goal is "terminal",
in the sense that no other goals depend on it
(except possibly through shared metavariables; see `independent_goal`).
-/
/--
Succeeds only if the current goal is "independent", in the sense
that no other goals depend on it, even through shared meta-variables.
-/
/-- `triv'` tries to close the first goal with the proof `trivial : true`. Unlike `triv`,
it only unfolds reducible definitions, so it sometimes fails faster. -/
/-- Apply a tactic as many times as possible, collecting the results in a list.
Fail if the tactic does not succeed at least once. -/
/-- Introduces one or more variables and returns the new local constants.
Fails if `intro` cannot be applied. -/
/-- Run a tactic "under binders", by running `intros` before, and `revert` afterwards. -/
namespace interactive
/-- Run a tactic "under binders", by running `intros` before, and `revert` afterwards. -/
end interactive
/-- `successes` invokes each tactic in turn, returning the list of successful results. -/
/--
Try all the tactics in a list, each time starting at the original `tactic_state`,
returning the list of successful results,
and reverting to the original `tactic_state`.
-/
-- Note this is not the same as `successes`, which keeps track of the evolving `tactic_state`.
/--
Try all the tactics in a list, each time starting at the original `tactic_state`,
returning the list of successful results sorted by
the value produced by a subsequent execution of the `sort_by` tactic,
and reverting to the original `tactic_state`.
-/
/-- Return target after instantiating metavars and whnf. -/
/--
Just like `split`, `fsplit` applies the constructor when the type of the target is
an inductive data type with one constructor.
However it does not reorder goals or invoke `auto_param` tactics.
-/
-- FIXME check if we can remove `auto_param := ff`
/-- Calls `injection` on each hypothesis, and then, for each hypothesis on which `injection`
succeeds, clears the old hypothesis. -/
/-- Calls `cases` on every local hypothesis, succeeding if
it succeeds on at least one hypothesis. -/
/--
`note_anon t v`, given a proof `v : t`,
adds `h : t` to the current context, where the name `h` is fresh.
`note_anon none v` will infer the type `t` from `v`.
-/
-- While `note` provides a default value for `t`, it doesn't seem this could ever be used.
/-- `find_local t` returns a local constant with type t, or fails if none exists. -/
/-- `dependent_pose_core l`: introduce dependent hypotheses, where the proofs depend on the values
of the previous local constants. `l` is a list of local constants and their values. -/
/--
Instantiates metavariables that appear in the current goal.
-/
/--
Instantiates metavariables in all goals.
-/
/-- Protect the declaration `n` -/
end tactic
namespace lean.parser
/-- `emit_command_here str` behaves as if the string `str` were placed as a user command at the
current line. -/
/-- Inner recursion for `emit_code_here`. -/
/-- `emit_code_here str` behaves as if the string `str` were placed at the current location in
source code. -/
/-- `run_parser p` is like `run_cmd` but for the parser monad. It executes parser `p` at the
top level, giving access to operations like `emit_code_here`. -/
/-- `get_current_namespace` returns the current namespace (it could be `name.anonymous`).
This function deserves a C++ implementation in core lean, and will fail if it is not called from
the body of a command (i.e. anywhere else that the `lean.parser` monad can be invoked). -/
/-- `get_variables` returns a list of existing variable names, along with their types and binder
info. -/
/-- `get_included_variables` returns those variables `v` returned by `get_variables` which have been
"included" by an `include v` statement and are not (yet) `omit`ed. -/
/-- From the `lean.parser` monad, synthesize a `tactic_state` which includes all of the local
variables referenced in `es : list pexpr`, and those variables which have been `include`ed in the
local context---precisely those variables which would be ambiently accessible if we were in a
tactic-mode block where the goals had types `es.mmap to_expr`, for example.
Returns a new `ts : tactic_state` with these local variables added, and
`mappings : list (expr × expr)`, for which pairs `(var, hyp)` correspond to an existing variable
`var` and the local hypothesis `hyp` which was added to the tactic state `ts` as a result. -/
end lean.parser
namespace tactic
/--
Hole command used to fill in a structure's field when specifying an instance.
In the following:
```lean
instance : monad id :=
{! !}
```
invoking the hole command "Instance Stub" ("Generate a skeleton for the structure under
construction.") produces:
```lean
instance : monad id :=
{ map := _,
map_const := _,
pure := _,
seq := _,
seq_left := _,
seq_right := _,
bind := _ }
```
-/
/-- Like `resolve_name` except when the list of goals is
empty. In that situation `resolve_name` fails whereas
`resolve_name'` simply proceeds on a dummy goal -/
/-- Strips unnecessary prefixes from a name, e.g. if a namespace is open. -/
/-- Used to format return strings for the hole commands `match_stub` and `eqn_stub`. -/
/--
Hole command used to generate a `match` expression.
In the following:
```lean
meta def foo (e : expr) : tactic unit :=
{! e !}
```
invoking hole command "Match Stub" ("Generate a list of equations for a `match` expression")
produces:
```lean
meta def foo (e : expr) : tactic unit :=
match e with
| (expr.var a) := _
| (expr.sort a) := _
| (expr.const a a_1) := _
| (expr.mvar a a_1 a_2) := _
| (expr.local_const a a_1 a_2 a_3) := _
| (expr.app a a_1) := _
| (expr.lam a a_1 a_2 a_3) := _
| (expr.pi a a_1 a_2 a_3) := _
| (expr.elet a a_1 a_2 a_3) := _
| (expr.macro a a_1) := _
end
```
-/
/--
Invoking hole command "Equations Stub" ("Generate a list of equations for a recursive definition")
in the following:
```lean
meta def foo : {! expr → tactic unit !} -- `:=` is omitted
```
produces:
```lean
meta def foo : expr → tactic unit
| (expr.var a) := _
| (expr.sort a) := _
| (expr.const a a_1) := _
| (expr.mvar a a_1 a_2) := _
| (expr.local_const a a_1 a_2 a_3) := _
| (expr.app a a_1) := _
| (expr.lam a a_1 a_2 a_3) := _
| (expr.pi a a_1 a_2 a_3) := _
| (expr.elet a a_1 a_2 a_3) := _
| (expr.macro a a_1) := _
```
A similar result can be obtained by invoking "Equations Stub" on the following:
```lean
meta def foo : expr → tactic unit := -- do not forget to write `:=`!!
{! !}
```
```lean
meta def foo : expr → tactic unit := -- don't forget to erase `:=`!!
| (expr.var a) := _
| (expr.sort a) := _
| (expr.const a a_1) := _
| (expr.mvar a a_1 a_2) := _
| (expr.local_const a a_1 a_2 a_3) := _
| (expr.app a a_1) := _
| (expr.lam a a_1 a_2 a_3) := _
| (expr.pi a a_1 a_2 a_3) := _
| (expr.elet a a_1 a_2 a_3) := _
| (expr.macro a a_1) := _
```
-/
/--
This command lists the constructors that can be used to satisfy the expected type.
Invoking "List Constructors" ("Show the list of constructors of the expected type")
in the following hole:
```lean
def foo : ℤ ⊕ ℕ :=
{! !}
```
produces:
```lean
def foo : ℤ ⊕ ℕ :=
{! sum.inl, sum.inr !}
```
and will display:
```lean
sum.inl : ℤ → ℤ ⊕ ℕ
sum.inr : ℕ → ℤ ⊕ ℕ
```
-/
/-- Makes the declaration `classical.prop_decidable` available to type class inference.
This asserts that all propositions are decidable, but does not have computational content. -/
/-- `mk_comp v e` checks whether `e` is a sequence of nested applications `f (g (h v))`, and if so,
returns the expression `f ∘ g ∘ h`. -/
/-- Given two expressions `e₀` and `e₁`, return the expression `` `(%%e₀ ↔ %%e₁)``. -/
/--
From a lemma of the shape `∀ x, f (g x) = h x`
derive an auxiliary lemma of the form `f ∘ g = h`
for reasoning about higher-order functions.
-/
/-- A user attribute that applies to lemmas of the shape `∀ x, f (g x) = h x`.
It derives an auxiliary lemma of the form `f ∘ g = h` for reasoning about higher-order functions.
-/
@[simp] theorem Mathlib.is_lawful_applicative.map_comp_pure {f : Type l_2 → Type l_1}
[Applicative f] [c : is_lawful_applicative f] {α : Type l_2} {β : Type l_2} (g : α → β) :
Functor.map g ∘ pure = pure ∘ g :=
funext fun (x : α) => map_pure g x
/--
Copies a definition into the `tactic.interactive` namespace to make it usable
in proof scripts. It allows one to write
```lean
@[interactive]
meta def my_tactic := ...
```
instead of
```lean
meta def my_tactic := ...
run_cmd add_interactive [``my_tactic]
```
-/
/--
Use `refine` to partially discharge the goal,
or call `fconstructor` and try again.
-/
/-- Similar to `existsi`, `use l` will use entries in `l` to instantiate existential obligations
at the beginning of a target. Unlike `existsi`, the pexprs in `l` are elaborated with respect to
the expected type.
```lean
example : ∃ x : ℤ, x = x :=
by tactic.use ``(42)
```
See the doc string for `tactic.interactive.use` for more information.
-/
/-- `clear_aux_decl_aux l` clears all expressions in `l` that represent aux decls from the
local context. -/
/-- `clear_aux_decl` clears all expressions from the local context that represent aux decls. -/
/-- `apply_at_aux e et [] h ht` (with `et` the type of `e` and `ht` the type of `h`)
finds a list of expressions `vs` and returns `(e.mk_args (vs ++ [h]), vs)`. -/
/-- `apply_at e h` applies implication `e` on hypothesis `h` and replaces `h` with the result. -/
/-- `symmetry_hyp h` applies `symmetry` on hypothesis `h`. -/
/-- `setup_tactic_parser` is a user command that opens the namespaces used in writing
interactive tactics, and declares the local postfix notation `?` for `optional` and `*` for `many`.
It does *not* use the `namespace` command, so it will typically be used after
`namespace tactic.interactive`.
-/
/-- `finally tac finalizer` runs `tac` first, then runs `finalizer` even if
`tac` fails. `finally tac finalizer` fails if either `tac` or `finalizer` fails. -/
/--
`on_exception handler tac` runs `tac` first, and then runs `handler` only if `tac` failed.
-/
/-- `decorate_error add_msg tac` prepends `add_msg` to an exception produced by `tac` -/
/-- Applies tactic `t`. If it succeeds, revert the state, and return the value. If it fails,
returns the error message. -/
/-- Applies tactic `t`. If it succeeds, return the value. If it fails, returns the error message. -/
/-- This tactic succeeds if `t` succeeds or fails with message `msg` such that `p msg` is `tt`.
-/
/-- `trace_error msg t` executes the tactic `t`. If `t` fails, traces `msg` and the failure message
of `t`. -/
/--
``trace_if_enabled `n msg`` traces the message `msg`
only if tracing is enabled for the name `n`.
Create new names registered for tracing with `declare_trace n`.
Then use `set_option trace.n true/false` to enable or disable tracing for `n`.
-/
/--
``trace_state_if_enabled `n msg`` prints the tactic state,
preceded by the optional string `msg`,
only if tracing is enabled for the name `n`.
-/
/--
This combinator is for testing purposes. It succeeds if `t` fails with message `msg`,
and fails otherwise.
-/
/--
Construct a `Try this: refine ...` or `Try this: exact ...` string which would construct `g`.
-/
/-- `with_local_goals gs tac` runs `tac` on the goals `gs` and then restores the
initial goals and returns the goals `tac` ended on. -/
/-- like `with_local_goals` but discards the resulting goals -/
/-- Representation of a proof goal that lends itself to comparison. The
following goal:
```lean
l₀ : T,
l₁ : T
⊢ ∀ v : T, foo
```
is represented as
```
(2, ∀ l₀ l₁ v : T, foo)
```
The number 2 indicates that first the two bound variables of the
`∀` are actually local constant. Comparing two such goals with `=`
rather than `=ₐ` or `is_def_eq` tells us that proof script should
not see the difference between the two.
-/
/-- proof state made of multiple `goal` meant for comparing
the result of running different tactics -/
/-- create a `packaged_goal` corresponding to the current goal -/
/-- `goal_of_mvar g`, with `g` a meta variable, creates a
`packaged_goal` corresponding to `g` interpretted as a proof goal -/
/-- `get_proof_state` lists the user visible goal for each goal
of the current state and for each goal, abstracts all of the
meta variables of the other gaols.
This produces a list of goals in the form of `ℕ × expr` where
the `expr` encodes the following proof state:
```lean
2 goals
l₁ : t₁,
l₂ : t₂,
l₃ : t₃
⊢ tgt₁
⊢ tgt₂
```
as
```lean
[ (3, ∀ (mv : tgt₁) (mv : tgt₂) (l₁ : t₁) (l₂ : t₂) (l₃ : t₃), tgt₁),
(0, ∀ (mv : tgt₁) (mv : tgt₂), tgt₂) ]
```
with 2 goals, the first 2 bound variables encode the meta variable
of all the goals, the next 3 (in the first goal) and 0 (in the second goal)
are the local constants.
This representation allows us to compare goals and proof states while
ignoring information like the unique name of local constants and
the equality or difference of meta variables that encode the same goal.
-/
/--
Run `tac` in a disposable proof state and return the state.
See `proof_state`, `goal` and `get_proof_state`.
-/
/-- A type alias for `tactic format`, standing for "pretty print format". -/
/-- `mk` lifts `fmt : format` to the tactic monad (`pformat`). -/
/-- an alias for `pp`. -/
/-- See `format!` in `init/meta/interactive_base.lean`.
The main differences are that `pp` is called instead of `to_fmt` and that we can use
arguments of type `tactic α` in the quotations.
Now, consider the following:
```lean
e ← to_expr ``(3 + 7),
trace format!"{e}" -- outputs `has_add.add.{0} nat nat.has_add
-- (bit1.{0} nat nat.has_one nat.has_add (has_one.one.{0} nat nat.has_one)) ...`
trace pformat!"{e}" -- outputs `3 + 7`
```
The difference is significant. And now, the following is expressible:
```lean
e ← to_expr ``(3 + 7),
trace pformat!"{e} : {infer_type e}" -- outputs `3 + 7 : ℕ`
```
See also: `trace!` and `fail!`
-/
/--
The combination of `pformat` and `fail`.
-/
/--
The combination of `pformat` and `trace`.
-/
/-- A hackish way to get the `src` directory of mathlib. -/
/-- Checks whether a declaration with the given name is declared in mathlib.
If you want to run this tactic many times, you should use `environment.is_prefix_of_file` instead,
since it is expensive to execute `get_mathlib_dir` many times. -/
/--
Runs a tactic by name.
If it is a `tactic string`, return whatever string it returns.
If it is a `tactic unit`, return the name.
(This is mostly used in invoking "self-reporting tactics", e.g. by `tidy` and `hint`.)
-/
/-- auxiliary function for `apply_under_n_pis` -/
/--
Assumes `pi_expr` is of the form `Π x1 ... xn xn+1..., _`.
Creates a pexpr of the form `Π x1 ... xn, func (arg x1 ... xn)`.
All arguments (implicit and explicit) to `arg` should be supplied. -/
/--
Assumes `pi_expr` is of the form `Π x1 ... xn, _`.
Creates a pexpr of the form `Π x1 ... xn, func (arg x1 ... xn)`.
All arguments (implicit and explicit) to `arg` should be supplied. -/
/--
If `func` is a `pexpr` representing a function that takes an argument `a`,
`get_pexpr_arg_arity_with_tgt func tgt` returns the arity of `a`.
When `tgt` is a `pi` expr, `func` is elaborated in a context
with the domain of `tgt`.
Examples:
* ```get_pexpr_arg_arity ``(ring) `(true)``` returns 0, since `ring` takes one non-function
argument.
* ```get_pexpr_arg_arity_with_tgt ``(monad) `(true)``` returns 1, since `monad` takes one argument
of type `α → α`.
* ```get_pexpr_arg_arity_with_tgt ``(module R) `(Π (R : Type), comm_ring R → true)``` returns 0
-/
/-- `find_private_decl n none` finds a private declaration named `n` in any of the imported files.
`find_private_decl n (some m)` finds a private declaration named `n` in the same file where a
declaration named `m` can be found. -/
/-- `import_private foo from bar` finds a private declaration `foo` in the same file as `bar`
and creates a local notation to refer to it.
`import_private foo` looks for `foo` in all imported files.
When possible, make `foo` non-private rather than using this feature.
-/
/--
The command `mk_simp_attribute simp_name "description"` creates a simp set with name `simp_name`.
Lemmas tagged with `@[simp_name]` will be included when `simp with simp_name` is called.
`mk_simp_attribute simp_name none` will use a default description.
Appending the command with `with attr1 attr2 ...` will include all declarations tagged with
`attr1`, `attr2`, ... in the new simp set.
This command is preferred to using ``run_cmd mk_simp_attr `simp_name`` since it adds a doc string
to the attribute that is defined. If you need to create a simp set in a file where this command is
not available, you should use
```lean
run_cmd mk_simp_attr `simp_name
run_cmd add_doc_string `simp_attr.simp_name "Description of the simp set here"
```
-/
end Mathlib |
d6ce85a8e3205ee9e730e979a79b7e1d2cd925b7 | 4727251e0cd73359b15b664c3170e5d754078599 | /src/data/nat/factorial/cast.lean | 27a4a241076adf874a944c88a82dd53bd1c607ec | [
"Apache-2.0"
] | permissive | Vierkantor/mathlib | 0ea59ac32a3a43c93c44d70f441c4ee810ccceca | 83bc3b9ce9b13910b57bda6b56222495ebd31c2f | refs/heads/master | 1,658,323,012,449 | 1,652,256,003,000 | 1,652,256,003,000 | 209,296,341 | 0 | 1 | Apache-2.0 | 1,568,807,655,000 | 1,568,807,655,000 | null | UTF-8 | Lean | false | false | 2,238 | lean | /-
Copyright (c) 2021 Yaël Dillies. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yaël Dillies
-/
import ring_theory.polynomial.pochhammer
/-!
# Cast of factorials
This file allows calculating factorials (including ascending and descending ones) as elements of a
semiring.
This is particularly crucial for `nat.desc_factorial` as substraction on `ℕ` does **not** correspond
to substraction on a general semiring. For example, we can't rely on existing cast lemmas to prove
`↑(a.desc_factorial 2) = ↑a * (↑a - 1)`. We must use the fact that, whenever `↑(a - 1)` is not equal
to `↑a - 1`, the other factor is `0` anyway.
-/
open_locale nat
variables (S : Type*)
namespace nat
section semiring
variables [semiring S] (a b : ℕ)
lemma cast_asc_factorial :
(a.asc_factorial b : S) = (pochhammer S b).eval (a + 1) :=
by rw [←pochhammer_nat_eq_asc_factorial, pochhammer_eval_cast, nat.cast_add, nat.cast_one]
lemma cast_desc_factorial :
(a.desc_factorial b : S) = (pochhammer S b).eval (a - (b - 1) : ℕ) :=
begin
rw [←pochhammer_eval_cast, pochhammer_nat_eq_desc_factorial],
cases b,
{ simp_rw desc_factorial_zero },
simp_rw [add_succ, succ_sub_one],
obtain h | h := le_total a b,
{ rw [desc_factorial_of_lt (lt_succ_of_le h), desc_factorial_of_lt (lt_succ_of_le _)],
rw [tsub_eq_zero_iff_le.mpr h, zero_add] },
{ rw tsub_add_cancel_of_le h }
end
lemma cast_factorial :
(a! : S) = (pochhammer S a).eval 1 :=
by rw [←zero_asc_factorial, cast_asc_factorial, cast_zero, zero_add]
end semiring
section ring
variables [ring S] (a b : ℕ)
/-- Convenience lemma. The `a - 1` is not using truncated substraction, as opposed to the definition
of `nat.desc_factorial` as a natural. -/
lemma cast_desc_factorial_two :
(a.desc_factorial 2 : S) = a * (a - 1) :=
begin
rw cast_desc_factorial,
cases a,
{ rw [zero_tsub, cast_zero, pochhammer_ne_zero_eval_zero _ (two_ne_zero), zero_mul] },
{ rw [succ_sub_succ, tsub_zero, cast_succ, add_sub_cancel, pochhammer_succ_right,
pochhammer_one, polynomial.X_mul, polynomial.eval_mul_X, polynomial.eval_add,
polynomial.eval_X, cast_one, polynomial.eval_one] }
end
end ring
end nat
|
a32455d63009602883cddea1ac2c52c8b66c22d5 | d406927ab5617694ec9ea7001f101b7c9e3d9702 | /src/data/fin/fin2.lean | ecfc779d73980681ebf2c9d256c3adeb2330b5eb | [
"Apache-2.0"
] | permissive | alreadydone/mathlib | dc0be621c6c8208c581f5170a8216c5ba6721927 | c982179ec21091d3e102d8a5d9f5fe06c8fafb73 | refs/heads/master | 1,685,523,275,196 | 1,670,184,141,000 | 1,670,184,141,000 | 287,574,545 | 0 | 0 | Apache-2.0 | 1,670,290,714,000 | 1,597,421,623,000 | Lean | UTF-8 | Lean | false | false | 4,243 | lean | /-
Copyright (c) 2017 Mario Carneiro. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro
-/
/-!
# Inductive type variant of `fin`
> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.
> https://github.com/leanprover-community/mathlib4/pull/478
> Any changes to this file require a corresponding PR to mathlib4.
`fin` is defined as a subtype of `ℕ`. This file defines an equivalent type, `fin2`, which is
defined inductively. This is useful for its induction principle and different definitional
equalities.
## Main declarations
* `fin2 n`: Inductive type variant of `fin n`. `fz` corresponds to `0` and `fs n` corresponds to
`n`.
* `to_nat`, `opt_of_nat`, `of_nat'`: Conversions to and from `ℕ`. `of_nat' m` takes a proof that
`m < n` through the class `is_lt`.
* `add k`: Takes `i : fin2 n` to `i + k : fin2 (n + k)`.
* `left`: Embeds `fin2 n` into `fin2 (n + k)`.
* `insert_perm a`: Permutation of `fin2 n` which cycles `0, ..., a - 1` and leaves `a, ..., n - 1`
unchanged.
* `remap_left f`: Function `fin2 (m + k) → fin2 (n + k)` by applying `f : fin m → fin n` to
`0, ..., m - 1` and sending `m + i` to `n + i`.
-/
open nat
universes u
/-- An alternate definition of `fin n` defined as an inductive type instead of a subtype of `ℕ`. -/
inductive fin2 : ℕ → Type
/-- `0` as a member of `fin (succ n)` (`fin 0` is empty) -/
| fz {n} : fin2 (succ n)
/-- `n` as a member of `fin (succ n)` -/
| fs {n} : fin2 n → fin2 (succ n)
namespace fin2
/-- Define a dependent function on `fin2 (succ n)` by giving its value at
zero (`H1`) and by giving a dependent function on the rest (`H2`). -/
@[elab_as_eliminator]
protected def cases' {n} {C : fin2 (succ n) → Sort u} (H1 : C fz) (H2 : Π n, C (fs n)) :
Π (i : fin2 (succ n)), C i
| fz := H1
| (fs n) := H2 n
/-- Ex falso. The dependent eliminator for the empty `fin2 0` type. -/
def elim0 {C : fin2 0 → Sort u} : Π (i : fin2 0), C i.
/-- Converts a `fin2` into a natural. -/
def to_nat : Π {n}, fin2 n → ℕ
| ._ (@fz n) := 0
| ._ (@fs n i) := succ (to_nat i)
/-- Converts a natural into a `fin2` if it is in range -/
def opt_of_nat : Π {n} (k : ℕ), option (fin2 n)
| 0 _ := none
| (succ n) 0 := some fz
| (succ n) (succ k) := fs <$> @opt_of_nat n k
/-- `i + k : fin2 (n + k)` when `i : fin2 n` and `k : ℕ` -/
def add {n} (i : fin2 n) : Π k, fin2 (n + k)
| 0 := i
| (succ k) := fs (add k)
/-- `left k` is the embedding `fin2 n → fin2 (k + n)` -/
def left (k) : Π {n}, fin2 n → fin2 (k + n)
| ._ (@fz n) := fz
| ._ (@fs n i) := fs (left i)
/-- `insert_perm a` is a permutation of `fin2 n` with the following properties:
* `insert_perm a i = i+1` if `i < a`
* `insert_perm a a = 0`
* `insert_perm a i = i` if `i > a` -/
def insert_perm : Π {n}, fin2 n → fin2 n → fin2 n
| ._ (@fz n) (@fz ._) := fz
| ._ (@fz n) (@fs ._ j) := fs j
| ._ (@fs (succ n) i) (@fz ._) := fs fz
| ._ (@fs (succ n) i) (@fs ._ j) := match insert_perm i j with fz := fz | fs k := fs (fs k) end
/-- `remap_left f k : fin2 (m + k) → fin2 (n + k)` applies the function
`f : fin2 m → fin2 n` to inputs less than `m`, and leaves the right part
on the right (that is, `remap_left f k (m + i) = n + i`). -/
def remap_left {m n} (f : fin2 m → fin2 n) : Π k, fin2 (m + k) → fin2 (n + k)
| 0 i := f i
| (succ k) (@fz ._) := fz
| (succ k) (@fs ._ i) := fs (remap_left _ i)
/-- This is a simple type class inference prover for proof obligations
of the form `m < n` where `m n : ℕ`. -/
class is_lt (m n : ℕ) := (h : m < n)
instance is_lt.zero (n) : is_lt 0 (succ n) := ⟨succ_pos _⟩
instance is_lt.succ (m n) [l : is_lt m n] : is_lt (succ m) (succ n) := ⟨succ_lt_succ l.h⟩
/-- Use type class inference to infer the boundedness proof, so that we can directly convert a
`nat` into a `fin2 n`. This supports notation like `&1 : fin 3`. -/
def of_nat' : Π {n} m [is_lt m n], fin2 n
| 0 m ⟨h⟩ := absurd h (nat.not_lt_zero _)
| (succ n) 0 ⟨h⟩ := fz
| (succ n) (succ m) ⟨h⟩ := fs (@of_nat' n m ⟨lt_of_succ_lt_succ h⟩)
local prefix `&`:max := of_nat'
instance : inhabited (fin2 1) := ⟨fz⟩
end fin2
|
386f076bdea1346da2a3a1cb01b52408db7ec6c0 | d406927ab5617694ec9ea7001f101b7c9e3d9702 | /archive/100-theorems-list/81_sum_of_prime_reciprocals_diverges.lean | a07a1d585cafca8837aa5f2043b810355af36833 | [
"Apache-2.0"
] | permissive | alreadydone/mathlib | dc0be621c6c8208c581f5170a8216c5ba6721927 | c982179ec21091d3e102d8a5d9f5fe06c8fafb73 | refs/heads/master | 1,685,523,275,196 | 1,670,184,141,000 | 1,670,184,141,000 | 287,574,545 | 0 | 0 | Apache-2.0 | 1,670,290,714,000 | 1,597,421,623,000 | Lean | UTF-8 | Lean | false | false | 11,533 | lean | /-
Copyright (c) 2021 Manuel Candales. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Manuel Candales
-/
import topology.instances.ennreal
import data.nat.squarefree
/-!
# Divergence of the Prime Reciprocal Series
This file proves Theorem 81 from the [100 Theorems List](https://www.cs.ru.nl/~freek/100/).
The theorem states that the sum of the reciprocals of all prime numbers diverges.
The formalization follows Erdős's proof by upper and lower estimates.
## Proof outline
1. Assume that the sum of the reciprocals of the primes converges.
2. Then there exists a `k : ℕ` such that, for any `x : ℕ`, the sum of the reciprocals of the primes
between `k` and `x + 1` is less than 1/2 (`sum_lt_half_of_not_tendsto`).
3. For any `x : ℕ`, we can partition `range x` into two subsets (`range_sdiff_eq_bUnion`):
* `M x k`, the subset of those `e` for which `e + 1` is a product of powers of primes smaller
than or equal to `k`;
* `U x k`, the subset of those `e` for which there is a prime `p > k` that divides `e + 1`.
4. Then `|U x k|` is bounded by the sum over the primes `p > k` of the number of multiples of `p`
in `(k, x]`, which is at most `x / p`. It follows that `|U x k|` is at most `x` times the sum of
the reciprocals of the primes between `k` and `x + 1`, which is less than 1/2 as noted in (2), so
`|U x k| < x / 2` (`card_le_mul_sum`).
5. By factoring `e + 1 = (m + 1)² * (r + 1)`, `r + 1` squarefree and `m + 1 ≤ √x`, and noting that
squarefree numbers correspond to subsets of `[1, k]`, we find that `|M x k| ≤ 2 ^ k * √x`
(`card_le_two_pow_mul_sqrt`).
6. Finally, setting `x := (2 ^ (k + 1))²` (`√x = 2 ^ (k + 1)`), we find that
`|M x k| ≤ 2 ^ k * 2 ^ (k + 1) = x / 2`. Combined with the strict bound for `|U k x|` from (4),
`x = |M x k| + |U x k| < x / 2 + x / 2 = x`.
## References
https://en.wikipedia.org/wiki/Divergence_of_the_sum_of_the_reciprocals_of_the_primes
-/
open_locale big_operators
open_locale classical
open filter finset
/--
The primes in `(k, x]`.
-/
noncomputable def P (x k : ℕ) := {p ∈ range (x + 1) | k < p ∧ nat.prime p}
/--
The union over those primes `p ∈ (k, x]` of the sets of `e < x` for which `e + 1` is a multiple
of `p`, i.e., those `e < x` for which there is a prime `p ∈ (k, x]` that divides `e + 1`.
-/
noncomputable def U (x k : ℕ) := finset.bUnion (P x k) (λ p, {e ∈ range x | p ∣ e + 1})
/--
Those `e < x` for which `e + 1` is a product of powers of primes smaller than or equal to `k`.
-/
noncomputable def M (x k : ℕ) := {e ∈ range x | ∀ p : ℕ, (nat.prime p ∧ p ∣ e + 1) → p ≤ k}
/--
If the sum of the reciprocals of the primes converges, there exists a `k : ℕ` such that the sum of
the reciprocals of the primes greater than `k` is less than 1/2.
More precisely, for any `x : ℕ`, the sum of the reciprocals of the primes between `k` and `x + 1`
is less than 1/2.
-/
lemma sum_lt_half_of_not_tendsto
(h : ¬ tendsto (λ n, ∑ p in {p ∈ range n | nat.prime p}, (1 / (p : ℝ))) at_top at_top) :
∃ k, ∀ x, ∑ p in P x k, 1 / (p : ℝ) < 1 / 2 :=
begin
have h0 : (λ n, ∑ p in {p ∈ range n | nat.prime p}, (1 / (p : ℝ)))
= λ n, ∑ p in range n, ite (nat.prime p) (1 / (p : ℝ)) 0,
{ simp only [sum_filter, filter_congr_decidable, sep_def] },
have hf : ∀ n : ℕ, 0 ≤ ite (nat.prime n) (1 / (n : ℝ)) 0,
{ intro n, split_ifs,
{ simp only [one_div, inv_nonneg, nat.cast_nonneg] },
{ exact le_rfl } },
rw [h0, ← summable_iff_not_tendsto_nat_at_top_of_nonneg hf, summable_iff_vanishing] at h,
obtain ⟨s, h⟩ := h (set.Ioo (-1) (1/2)) (is_open_Ioo.mem_nhds (by norm_num)),
obtain ⟨k, hk⟩ := exists_nat_subset_range s,
use k,
intro x,
rw [P, sep_def, filter_congr_decidable, ←filter_filter, sum_filter],
refine (h _ _).2,
rw disjoint_iff_ne,
simp_intros a ha b hb only [mem_filter],
exact ((mem_range.mp (hk hb)).trans ha.2).ne',
end
/--
Removing from {0, ..., x - 1} those elements `e` for which `e + 1` is a product of powers of primes
smaller than or equal to `k` leaves those `e` for which there is a prime `p > k` that divides
`e + 1`, or the union over those primes `p > k` of the sets of `e`s for which `e + 1` is a multiple
of `p`.
-/
lemma range_sdiff_eq_bUnion {x k : ℕ} : range x \ M x k = U x k :=
begin
ext e,
simp only [mem_bUnion, not_and, mem_sdiff, sep_def, mem_filter, mem_range, U, M, P],
push_neg,
split,
{ rintros ⟨hex, hexh⟩,
obtain ⟨p, ⟨hpp, hpe1⟩, hpk⟩ := hexh hex,
refine ⟨p, _, ⟨hex, hpe1⟩⟩,
exact ⟨(nat.le_of_dvd e.succ_pos hpe1).trans_lt (nat.succ_lt_succ hex), hpk, hpp⟩ },
{ rintros ⟨p, hpfilter, ⟨hex, hpe1⟩⟩,
rw imp_iff_right hex,
exact ⟨hex, ⟨p, ⟨hpfilter.2.2, hpe1⟩, hpfilter.2.1⟩⟩ },
end
/--
The number of `e < x` for which `e + 1` has a prime factor `p > k` is bounded by `x` times the sum
of reciprocals of primes in `(k, x]`.
-/
lemma card_le_mul_sum {x k : ℕ} : (card (U x k) : ℝ) ≤ x * ∑ p in P x k, 1 / p :=
begin
let P := {p ∈ range (x + 1) | k < p ∧ nat.prime p},
let N := λ p, {e ∈ range x | p ∣ e + 1},
have h : card (finset.bUnion P N) ≤ ∑ p in P, card (N p) := card_bUnion_le,
calc (card (finset.bUnion P N) : ℝ)
≤ ∑ p in P, card (N p) : by assumption_mod_cast
... ≤ ∑ p in P, x * (1 / p) : sum_le_sum (λ p hp, _)
... = x * ∑ p in P, 1 / p : mul_sum.symm,
simp only [mul_one_div, N, sep_def, filter_congr_decidable, nat.card_multiples, nat.cast_div_le],
end
/--
The number of `e < x` for which `e + 1` is a squarefree product of primes smaller than or equal to
`k` is bounded by `2 ^ k`, the number of subsets of `[1, k]`.
-/
lemma card_le_two_pow {x k : ℕ} : card {e ∈ M x k | squarefree (e + 1)} ≤ 2 ^ k :=
begin
let M₁ := {e ∈ M x k | squarefree (e + 1)},
let f := λ s, finset.prod s (λ a, a) - 1,
let K := powerset (image nat.succ (range k)),
-- Take `e` in `M x k`. If `e + 1` is squarefree, then it is the product of a subset of `[1, k]`.
-- It follows that `e` is one less than such a product.
have h : M₁ ⊆ image f K,
{ intros m hm,
simp only [M₁, M, sep_def, mem_filter, mem_range, mem_powerset, mem_image, exists_prop] at hm ⊢,
obtain ⟨⟨-, hmp⟩, hms⟩ := hm,
use (m + 1).factors,
{ rwa [multiset.coe_nodup, ← nat.squarefree_iff_nodup_factors m.succ_ne_zero] },
refine ⟨λ p, _, _⟩,
{ suffices : p ∈ (m + 1).factors → ∃ a : ℕ, a < k ∧ a.succ = p, { simpa },
simp_intros hp only [nat.mem_factors m.succ_ne_zero],
exact ⟨p.pred, (nat.pred_lt (nat.prime.ne_zero hp.1)).trans_le ((hmp p) hp),
nat.succ_pred_eq_of_pos (nat.prime.pos hp.1)⟩ },
{ simp_rw f, simp [nat.prod_factors m.succ_ne_zero, m.succ_sub_one] } },
-- The number of elements of `M x k` with `e + 1` squarefree is bounded by the number of subsets
-- of `[1, k]`.
calc card M₁ ≤ card (image f K) : card_le_of_subset h
... ≤ card K : card_image_le
... ≤ 2 ^ card (image nat.succ (range k)) : by simp only [K, card_powerset]
... ≤ 2 ^ card (range k) : pow_le_pow one_le_two card_image_le
... = 2 ^ k : by rw card_range k,
end
/--
The number of `e < x` for which `e + 1` is a product of powers of primes smaller than or equal to
`k` is bounded by `2 ^ k * nat.sqrt x`.
-/
lemma card_le_two_pow_mul_sqrt {x k : ℕ} : card (M x k) ≤ 2 ^ k * nat.sqrt x :=
begin
let M₁ := {e ∈ M x k | squarefree (e + 1)},
let M₂ := M (nat.sqrt x) k,
let K := M₁ ×ˢ M₂,
let f : ℕ × ℕ → ℕ := λ mn, (mn.2 + 1) ^ 2 * (mn.1 + 1) - 1,
-- Every element of `M x k` is one less than the product `(m + 1)² * (r + 1)` with `r + 1`
-- squarefree and `m + 1 ≤ √x`, and both `m + 1` and `r + 1` still only have prime powers
-- smaller than or equal to `k`.
have h1 : M x k ⊆ image f K,
{ intros m hm,
simp only [M, M₁, M₂, mem_image, exists_prop, prod.exists, mem_product, sep_def, mem_filter,
mem_range] at hm ⊢,
have hm' := m.zero_lt_succ,
obtain ⟨a, b, hab₁, hab₂⟩ := nat.sq_mul_squarefree_of_pos' hm',
obtain ⟨ham, hbm⟩ := ⟨dvd.intro_left _ hab₁, dvd.intro _ hab₁⟩,
refine ⟨a, b, ⟨⟨⟨_, λ p hp, _⟩, hab₂⟩, ⟨_, λ p hp, _⟩⟩, by simp_rw [f, hab₁, m.succ_sub_one]⟩,
{ exact (nat.succ_le_succ_iff.mp (nat.le_of_dvd hm' ham)).trans_lt hm.1 },
{ exact hm.2 p ⟨hp.1, hp.2.trans ham⟩ },
{ calc b < b + 1 : lt_add_one b
... ≤ (m + 1).sqrt : by simpa only [nat.le_sqrt, pow_two] using nat.le_of_dvd hm' hbm
... ≤ x.sqrt : nat.sqrt_le_sqrt (nat.succ_le_iff.mpr hm.1) },
{ exact hm.2 p ⟨hp.1, hp.2.trans (nat.dvd_of_pow_dvd one_le_two hbm)⟩ } },
have h2 : card M₂ ≤ nat.sqrt x,
{ rw ← card_range (nat.sqrt x), apply card_le_of_subset, simp [M₂, M] },
calc card (M x k) ≤ card (image f K) : card_le_of_subset h1
... ≤ card K : card_image_le
... = card M₁ * card M₂ : card_product M₁ M₂
... ≤ 2 ^ k * x.sqrt : mul_le_mul' card_le_two_pow h2,
end
theorem real.tendsto_sum_one_div_prime_at_top :
tendsto (λ n, ∑ p in {p ∈ range n | nat.prime p}, (1 / (p : ℝ))) at_top at_top :=
begin
-- Assume that the sum of the reciprocals of the primes converges.
by_contradiction h,
-- Then there is a natural number `k` such that for all `x`, the sum of the reciprocals of primes
-- between `k` and `x` is less than 1/2.
obtain ⟨k, h1⟩ := sum_lt_half_of_not_tendsto h,
-- Choose `x` sufficiently large for the argument below to work, and use a perfect square so we
-- can easily take the square root.
let x := 2 ^ (k + 1) * 2 ^ (k + 1),
-- We will partition `range x` into two subsets:
-- * `M`, the subset of those `e` for which `e + 1` is a product of powers of primes smaller
-- than or equal to `k`;
set M := M x k with hM,
-- * `U`, the subset of those `e` for which there is a prime `p > k` that divides `e + 1`.
let P := {p ∈ range (x + 1) | k < p ∧ nat.prime p},
set U := U x k with hU,
-- This is indeed a partition, so `|U| + |M| = |range x| = x`.
have h2 : x = card U + card M,
{ rw [← card_range x, hU, hM, ← range_sdiff_eq_bUnion],
exact (card_sdiff_add_card_eq_card (finset.filter_subset _ _)).symm },
-- But for the `x` we have chosen above, both `|U|` and `|M|` are less than or equal to `x / 2`,
-- and for U, the inequality is strict.
have h3 :=
calc (card U : ℝ) ≤ x * ∑ p in P, 1 / p : card_le_mul_sum
... < x * (1 / 2) : mul_lt_mul_of_pos_left (h1 x) (by norm_num)
... = x / 2 : mul_one_div x 2,
have h4 :=
calc (card M : ℝ) ≤ 2 ^ k * x.sqrt : by exact_mod_cast card_le_two_pow_mul_sqrt
... = 2 ^ k * ↑(2 ^ (k + 1)) : by rw nat.sqrt_eq
... = x / 2 : by field_simp [x, mul_right_comm, ← pow_succ'],
refine lt_irrefl (x : ℝ) _,
calc (x : ℝ) = (card U : ℝ) + (card M : ℝ) : by assumption_mod_cast
... < x / 2 + x / 2 : add_lt_add_of_lt_of_le h3 h4
... = x : add_halves ↑x,
end
|
87343c242459d8d25e6ac33e30a6b696443e4384 | 6432ea7a083ff6ba21ea17af9ee47b9c371760f7 | /tests/lean/679.lean | 80fe3766103baea8fa543b52a679751dc30791ba | [
"Apache-2.0",
"LLVM-exception",
"NCSA",
"LGPL-3.0-only",
"LicenseRef-scancode-inner-net-2.0",
"BSD-3-Clause",
"LGPL-2.0-or-later",
"Spencer-94",
"LGPL-2.1-or-later",
"HPND",
"LicenseRef-scancode-pcre",
"ISC",
"LGPL-2.1-only",
"LicenseRef-scancode-other-permissive",
"SunPro",
"CMU-Mach"... | permissive | leanprover/lean4 | 4bdf9790294964627eb9be79f5e8f6157780b4cc | f1f9dc0f2f531af3312398999d8b8303fa5f096b | refs/heads/master | 1,693,360,665,786 | 1,693,350,868,000 | 1,693,350,868,000 | 129,571,436 | 2,827 | 311 | Apache-2.0 | 1,694,716,156,000 | 1,523,760,560,000 | Lean | UTF-8 | Lean | false | false | 175 | lean | import Lean
open Lean
def encodeDecode [ToJson α] [FromJson α] (x : α) : Except String α := do
let json := toJson x
fromJson? json
#eval encodeDecode Name.anonymous
|
33b9c085bfc2819b65232fe6c98914bb71d1bad1 | f0050a24971f1b7315211eec6e02a8eee618ce6b | /src/common/stmt.lean | cdf3d0dd7b5f5401e09cd4b48d366e77e305bff4 | [
"Apache-2.0"
] | permissive | ttowncompiled/excaLibur | 9574f2acb0bafcd59f59423b63a62c15442ea5f7 | 7d8371bf998012d4f8c49d3fe2bf540e2517c688 | refs/heads/master | 1,670,710,035,703 | 1,599,670,584,000 | 1,599,670,584,000 | 292,720,923 | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 540 | lean | /-
Copyright (c) Ian Riley. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Ian Riley
-/
import .basic
inductive stmt : Type
| skip : stmt
| assign : string → (scope → Prop) → stmt
| comp : stmt → stmt → stmt
| ite : (scope → Prop) → stmt → stmt → stmt
| while : (scope → Prop) → stmt → stmt
| call : string → (scope → Prop) → (scope → Prop) →
(scope → scope) → stmt → stmt
infixr ` ;; `:90 := stmt.comp
|
a93566038ae5c54139454fac41bcd74f88e1b32d | d9d511f37a523cd7659d6f573f990e2a0af93c6f | /src/algebra/module/opposites.lean | df6f5cd7273acded068a3c09c0ab53579cac6001 | [
"Apache-2.0"
] | permissive | hikari0108/mathlib | b7ea2b7350497ab1a0b87a09d093ecc025a50dfa | a9e7d333b0cfd45f13a20f7b96b7d52e19fa2901 | refs/heads/master | 1,690,483,608,260 | 1,631,541,580,000 | 1,631,541,580,000 | null | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 1,595 | lean | /-
Copyright (c) 2020 Eric Wieser. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Eric Wieser
-/
import algebra.module.linear_map
import algebra.opposites
/-!
# Module operations on `Mᵒᵖ`
This file contains definitions that could not be placed into `algebra.opposites` due to import
cycles.
-/
namespace opposite
universes u v
variables (R : Type u) {M : Type v} [semiring R] [add_comm_monoid M] [module R M]
/-- `opposite.distrib_mul_action` extends to a `module` -/
instance : module R (opposite M) :=
{ add_smul := λ r₁ r₂ x, unop_injective $ add_smul r₁ r₂ (unop x),
zero_smul := λ x, unop_injective $ zero_smul _ (unop x),
..opposite.distrib_mul_action M R }
/-- The function `op` is a linear equivalence. -/
def op_linear_equiv : M ≃ₗ[R] Mᵒᵖ :=
{ map_smul' := opposite.op_smul, .. op_add_equiv }
@[simp] lemma coe_op_linear_equiv :
(op_linear_equiv R : M → Mᵒᵖ) = op := rfl
@[simp] lemma coe_op_linear_equiv_symm :
((op_linear_equiv R).symm : Mᵒᵖ → M) = unop := rfl
@[simp] lemma coe_op_linear_equiv_to_linear_map :
((op_linear_equiv R).to_linear_map : M → Mᵒᵖ) = op := rfl
@[simp] lemma coe_op_linear_equiv_symm_to_linear_map :
((op_linear_equiv R).symm.to_linear_map : Mᵒᵖ → M) = unop := rfl
@[simp] lemma op_linear_equiv_to_add_equiv :
(op_linear_equiv R : M ≃ₗ[R] Mᵒᵖ).to_add_equiv = op_add_equiv := rfl
@[simp] lemma op_linear_equiv_symm_to_add_equiv :
(op_linear_equiv R : M ≃ₗ[R] Mᵒᵖ).symm.to_add_equiv = op_add_equiv.symm := rfl
end opposite
|
811c1b3c3262fecc43b8d90c5c812160ecd409b9 | b7f22e51856f4989b970961f794f1c435f9b8f78 | /tests/lean/583.lean | db9e740e6b018ac8310cc60bdf20580f655f8c32 | [
"Apache-2.0"
] | permissive | soonhokong/lean | cb8aa01055ffe2af0fb99a16b4cda8463b882cd1 | 38607e3eb57f57f77c0ac114ad169e9e4262e24f | refs/heads/master | 1,611,187,284,081 | 1,450,766,737,000 | 1,476,122,547,000 | 11,513,992 | 2 | 0 | null | 1,401,763,102,000 | 1,374,182,235,000 | C++ | UTF-8 | Lean | false | false | 957 | lean | import algebra.group data.set
namespace group_hom
open algebra
-- ⁻¹ in eq.ops conflicts with group ⁻¹
-- open eq.ops
notation H1 ▸ H2 := eq.subst H1 H2
open set
open function
local attribute set [reducible]
section
variables {A B : Type}
variable [s1 : group A]
variable [s2 : group B]
include s1
include s2
variable f : A → B
definition is_hom := ∀ a b, f (a*b) = (f a)*(f b)
definition ker (Hom : is_hom f) : (set A) := {a : A | f a = 1}
theorem hom_map_id (f : A → B) (Hom : is_hom f) : f 1 = 1 :=
have P : f 1 = (f 1) * (f 1), from
calc f 1 = f (1*1) : mul_one
... = (f 1) * (f 1) : Hom,
eq.symm (mul.right_inv (f 1) ▸ (mul_inv_eq_of_eq_mul P))
theorem hom_map_inv (Hom : is_hom f) (a : A) : f a⁻¹ = (f a)⁻¹ :=
assert P : f 1 = 1, from hom_map_id f Hom,
begin
rewrite (eq.symm (mul.left_inv a)) at P,
rewrite (Hom a⁻¹ a) at P,
end
end
end group_hom
|
eaad7f9cae70994799f4f61b3083348cb18bc15d | a45212b1526d532e6e83c44ddca6a05795113ddc | /src/data/rel.lean | 9d950c235246907995eac93bb91f830dbadf6cab | [
"Apache-2.0"
] | permissive | fpvandoorn/mathlib | b21ab4068db079cbb8590b58fda9cc4bc1f35df4 | b3433a51ea8bc07c4159c1073838fc0ee9b8f227 | refs/heads/master | 1,624,791,089,608 | 1,556,715,231,000 | 1,556,715,231,000 | 165,722,980 | 5 | 0 | Apache-2.0 | 1,552,657,455,000 | 1,547,494,646,000 | Lean | UTF-8 | Lean | false | false | 6,103 | lean | /-
Copyright (c) 2018 Jeremy Avigad. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jeremy Avigad
Operations on set-valued functions, aka partial multifunctions, aka relations.
-/
import tactic.ext tactic.interactive data.set.lattice order.complete_lattice
variables {α : Type*} {β : Type*} {γ : Type*}
def rel (α : Type*) (β : Type*):= α → β → Prop
namespace rel
variables {δ : Type*} (r : rel α β)
instance : lattice.complete_lattice (rel α β) :=
by unfold rel; apply_instance
def inv : rel β α := flip r
lemma inv_def (x : α) (y : β) : r.inv y x ↔ r x y := iff.rfl
lemma inv_inv : inv (inv r) = r := by { ext x y, reflexivity }
def dom := {x | ∃ y, r x y}
def codom := {y | ∃ x, r x y}
lemma codom_inv : r.inv.codom = r.dom := by { ext x y, reflexivity }
lemma dom_inv : r.inv.dom = r.codom := by { ext x y, reflexivity}
def comp (r : rel α β) (s : rel β γ) : rel α γ :=
λ x z, ∃ y, r x y ∧ s y z
local infixr ` ∘ ` :=rel.comp
lemma comp_assoc (r : rel α β) (s : rel β γ) (t : rel γ δ) :
(r ∘ s) ∘ t = r ∘ s ∘ t :=
begin
unfold comp, ext x w, split,
{ rintros ⟨z, ⟨y, rxy, syz⟩, tzw⟩, exact ⟨y, rxy, z, syz, tzw⟩ },
rintros ⟨y, rxy, z, syz, tzw⟩, exact ⟨z, ⟨y, rxy, syz⟩, tzw⟩
end
@[simp]
lemma comp_right_id (r : rel α β) : r ∘ @eq β = r :=
by { unfold comp, ext y, simp }
@[simp]
lemma comp_left_id (r : rel α β) : @eq α ∘ r = r :=
by { unfold comp, ext x, simp }
lemma inv_id : inv (@eq α) = @eq α :=
by { ext x y, split; apply eq.symm }
lemma inv_comp (r : rel α β) (s : rel β γ) : inv (r ∘ s) = inv s ∘ inv r :=
by { ext x z, simp [comp, inv, flip, and.comm] }
def image (s : set α) : set β := {y | ∃ x ∈ s, r x y}
lemma mem_image (y : β) (s : set α) : y ∈ image r s ↔ ∃ x ∈ s, r x y :=
iff.refl _
lemma image_mono {s t : set α} (h : s ⊆ t) : r.image s ⊆ r.image t :=
assume y ⟨x, xs, rxy⟩, ⟨x, h xs, rxy⟩
lemma image_inter (s t : set α) : r.image (s ∩ t) ⊆ r.image s ∩ r.image t :=
assume y ⟨x, ⟨xs, xt⟩, rxy⟩, ⟨⟨x, xs, rxy⟩, ⟨x, xt, rxy⟩⟩
lemma image_union (s t : set α) : r.image (s ∪ t) = r.image s ∪ r.image t :=
set.subset.antisymm
(λ y ⟨x, xst, rxy⟩,
begin
cases xst with xs xt,
{ left, exact ⟨x, xs, rxy⟩ },
right, exact ⟨x, xt, rxy⟩
end)
(λ y ymem,
begin
rcases ymem with ⟨x, xs, rxy⟩ | ⟨x, xt, rxy⟩; existsi x,
{ split, { left, exact xs }, exact rxy},
split, { right, exact xt }, exact rxy
end)
@[simp]
lemma image_id (s : set α) : image (@eq α) s = s :=
by { ext x, simp [mem_image] }
lemma image_comp (s : rel β γ) (t : set α) : image (r ∘ s) t = image s (image r t) :=
begin
ext z, simp only [mem_image, comp], split,
{ rintros ⟨x, xt, y, rxy, syz⟩, exact ⟨y, ⟨x, xt, rxy⟩, syz⟩ },
rintros ⟨y, ⟨x, xt, rxy⟩, syz⟩, exact ⟨x, xt, y, rxy, syz⟩
end
lemma image_univ : r.image set.univ = r.codom := by { ext y, simp [mem_image, codom] }
def preimage (s : set β) : set α := image (inv r) s
lemma mem_preimage (x : α) (s : set β) : x ∈ preimage r s ↔ ∃ y ∈ s, r x y :=
iff.refl _
lemma preimage_def (s : set β) : preimage r s = {x | ∃ y ∈ s, r x y} :=
set.ext $ λ x, mem_preimage _ _ _
lemma preimage_mono {s t : set β} (h : s ⊆ t) : r.preimage s ⊆ r.preimage t :=
image_mono _ h
lemma preimage_inter (s t : set β) : r.preimage (s ∩ t) ⊆ r.preimage s ∩ r.preimage t :=
image_inter _ s t
lemma preimage_union (s t : set β) : r.preimage (s ∪ t) = r.preimage s ∪ r.preimage t :=
image_union _ s t
lemma preimage_id (s : set α) : preimage (@eq α) s = s :=
by simp only [preimage, inv_id, image_id]
lemma preimage_comp (s : rel β γ) (t : set γ) :
preimage (r ∘ s) t = preimage r (preimage s t) :=
by simp only [preimage, inv_comp, image_comp]
lemma preimage_univ : r.preimage set.univ = r.dom :=
by { rw [preimage, image_univ, codom_inv] }
def core (s : set β) := {x | ∀ y, r x y → y ∈ s}
lemma mem_core (x : α) (s : set β) : x ∈ core r s ↔ ∀ y, r x y → y ∈ s :=
iff.refl _
lemma core_mono {s t : set β} (h : s ⊆ t) : r.core s ⊆ r.core t :=
assume x h' y rxy, h (h' y rxy)
lemma core_inter (s t : set β) : r.core (s ∩ t) = r.core s ∩ r.core t :=
set.ext (by simp [mem_core, imp_and_distrib, forall_and_distrib])
lemma core_union (s t : set β) : r.core (s ∪ t) ⊇ r.core s ∪ r.core t :=
λ x,
begin
simp [mem_core], intro h, cases h with hs ht; intros y rxy,
{ left, exact hs y rxy },
right, exact ht y rxy
end
lemma core_univ : r.core set.univ = set.univ := set.ext (by simp [mem_core])
lemma core_id (s : set α): core (@eq α) s = s :=
by simp [core]
lemma core_comp (s : rel β γ) (t : set γ) :
core (r ∘ s) t = core r (core s t) :=
begin
ext x, simp [core, comp], split,
{ intros h y rxy z syz, exact h z y rxy syz },
intros h z y rzy syz, exact h y rzy z syz
end
def restrict_domain (s : set α) : rel {x // x ∈ s} β :=
λ x y, r x.val y
theorem image_subset_iff (s : set α) (t : set β) : image r s ⊆ t ↔ s ⊆ core r t :=
iff.intro
(λ h x xs y rxy, h ⟨x, xs, rxy⟩)
(λ h y ⟨x, xs, rxy⟩, h xs y rxy)
theorem core_preimage_gc : galois_connection (image r) (core r) :=
image_subset_iff _
end rel
namespace function
def graph (f : α → β) : rel α β := λ x y, f x = y
end function
namespace set
-- TODO: if image were defined with bounded quantification in corelib, the next two would
-- be definitional
lemma image_eq (f : α → β) (s : set α) : f '' s = (function.graph f).image s :=
by simp [set.image, function.graph, rel.image]
lemma preimage_eq (f : α → β) (s : set β) :
f ⁻¹' s = (function.graph f).preimage s :=
by simp [set.preimage, function.graph, rel.preimage, rel.inv, flip, rel.image]
lemma preimage_eq_core (f : α → β) (s : set β) :
f ⁻¹' s = (function.graph f).core s :=
by simp [set.preimage, function.graph, rel.core]
end set
|
cc50d954f021d63ad8e6c7913ae693cd0b425049 | 74addaa0e41490cbaf2abd313a764c96df57b05d | /Mathlib/data/finsupp/default_auto.lean | bd497a764981919345f75d43ca94e28e32fc5606 | [] | no_license | AurelienSaue/Mathlib4_auto | f538cfd0980f65a6361eadea39e6fc639e9dae14 | 590df64109b08190abe22358fabc3eae000943f2 | refs/heads/master | 1,683,906,849,776 | 1,622,564,669,000 | 1,622,564,669,000 | 371,723,747 | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 299 | lean | /-
Copyright (c) 2020 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes
-/
import Mathlib.PrePort
import Mathlib.Lean3Lib.init.default
import Mathlib.data.finsupp.basic
import Mathlib.PostPort
namespace Mathlib
end Mathlib |
a7847068bc74cf19839c96f8b8974ff4f92fa7b5 | 9dc8cecdf3c4634764a18254e94d43da07142918 | /src/algebraic_geometry/Scheme.lean | d3ba561ccede584cb83eb747fe4f809540d897d5 | [
"Apache-2.0"
] | permissive | jcommelin/mathlib | d8456447c36c176e14d96d9e76f39841f69d2d9b | ee8279351a2e434c2852345c51b728d22af5a156 | refs/heads/master | 1,664,782,136,488 | 1,663,638,983,000 | 1,663,638,983,000 | 132,563,656 | 0 | 0 | Apache-2.0 | 1,663,599,929,000 | 1,525,760,539,000 | Lean | UTF-8 | Lean | false | false | 9,467 | lean | /-
Copyright (c) 2020 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Scott Morrison
-/
import algebraic_geometry.Spec
import algebra.category.Ring.constructions
/-!
# The category of schemes
A scheme is a locally ringed space such that every point is contained in some open set
where there is an isomorphism of presheaves between the restriction to that open set,
and the structure sheaf of `Spec R`, for some commutative ring `R`.
A morphism of schemes is just a morphism of the underlying locally ringed spaces.
-/
noncomputable theory
open topological_space
open category_theory
open Top
open opposite
namespace algebraic_geometry
/--
We define `Scheme` as a `X : LocallyRingedSpace`,
along with a proof that every point has an open neighbourhood `U`
so that that the restriction of `X` to `U` is isomorphic,
as a locally ringed space, to `Spec.to_LocallyRingedSpace.obj (op R)`
for some `R : CommRing`.
-/
structure Scheme extends to_LocallyRingedSpace : LocallyRingedSpace :=
(local_affine : ∀ x : to_LocallyRingedSpace, ∃ (U : open_nhds x) (R : CommRing),
nonempty (to_LocallyRingedSpace.restrict U.open_embedding ≅
Spec.to_LocallyRingedSpace.obj (op R)))
namespace Scheme
/-- A morphism between schemes is a morphism between the underlying locally ringed spaces. -/
@[nolint has_nonempty_instance] -- There isn't nessecarily a morphism between two schemes.
def hom (X Y : Scheme) : Type* :=
X.to_LocallyRingedSpace ⟶ Y.to_LocallyRingedSpace
/--
Schemes are a full subcategory of locally ringed spaces.
-/
instance : category Scheme :=
{ hom := hom, ..(induced_category.category Scheme.to_LocallyRingedSpace) }
/-- The structure sheaf of a Scheme. -/
protected abbreviation sheaf (X : Scheme) := X.to_SheafedSpace.sheaf
/-- The forgetful functor from `Scheme` to `LocallyRingedSpace`. -/
@[simps, derive[full, faithful]]
def forget_to_LocallyRingedSpace : Scheme ⥤ LocallyRingedSpace :=
induced_functor _
@[simp] lemma forget_to_LocallyRingedSpace_preimage {X Y : Scheme} (f : X ⟶ Y) :
Scheme.forget_to_LocallyRingedSpace.preimage f = f := rfl
/-- The forgetful functor from `Scheme` to `Top`. -/
@[simps]
def forget_to_Top : Scheme ⥤ Top :=
Scheme.forget_to_LocallyRingedSpace ⋙ LocallyRingedSpace.forget_to_Top
@[simp]
lemma id_val_base (X : Scheme) : (𝟙 X : _).1.base = 𝟙 _ := rfl
@[simp] lemma id_app {X : Scheme} (U : (opens X.carrier)ᵒᵖ) :
(𝟙 X : _).val.c.app U = X.presheaf.map
(eq_to_hom (by { induction U using opposite.rec, cases U, refl })) :=
PresheafedSpace.id_c_app X.to_PresheafedSpace U
@[reassoc]
lemma comp_val {X Y Z : Scheme} (f : X ⟶ Y) (g : Y ⟶ Z) :
(f ≫ g).val = f.val ≫ g.val := rfl
@[reassoc, simp]
lemma comp_coe_base {X Y Z : Scheme} (f : X ⟶ Y) (g : Y ⟶ Z) :
(f ≫ g).val.base = f.val.base ≫ g.val.base := rfl
@[reassoc, elementwise]
lemma comp_val_base {X Y Z : Scheme} (f : X ⟶ Y) (g : Y ⟶ Z) :
(f ≫ g).val.base = f.val.base ≫ g.val.base := rfl
@[reassoc, simp]
lemma comp_val_c_app {X Y Z : Scheme} (f : X ⟶ Y) (g : Y ⟶ Z) (U) :
(f ≫ g).val.c.app U = g.val.c.app U ≫ f.val.c.app _ := rfl
lemma congr_app {X Y : Scheme} {f g : X ⟶ Y} (e : f = g) (U) :
f.val.c.app U = g.val.c.app U ≫ X.presheaf.map (eq_to_hom (by subst e)) :=
by { subst e, dsimp, simp }
lemma app_eq {X Y : Scheme} (f : X ⟶ Y) {U V : opens Y.carrier} (e : U = V) :
f.val.c.app (op U) = Y.presheaf.map (eq_to_hom e.symm).op ≫
f.val.c.app (op V) ≫ X.presheaf.map (eq_to_hom (congr_arg (opens.map f.val.base).obj e)).op :=
begin
rw [← is_iso.inv_comp_eq, ← functor.map_inv, f.val.c.naturality, presheaf.pushforward_obj_map],
congr
end
instance is_LocallyRingedSpace_iso {X Y : Scheme} (f : X ⟶ Y) [is_iso f] :
@is_iso LocallyRingedSpace _ _ _ f :=
forget_to_LocallyRingedSpace.map_is_iso f
@[simp]
lemma inv_val_c_app {X Y : Scheme} (f : X ⟶ Y) [is_iso f] (U : opens X.carrier) :
(inv f).val.c.app (op U) = X.presheaf.map (eq_to_hom $ by { rw is_iso.hom_inv_id, ext1, refl } :
(opens.map (f ≫ inv f).1.base).obj U ⟶ U).op ≫
inv (f.val.c.app (op $ (opens.map _).obj U)) :=
begin
rw [is_iso.eq_comp_inv],
erw ← Scheme.comp_val_c_app,
rw [Scheme.congr_app (is_iso.hom_inv_id f),
Scheme.id_app, ← functor.map_comp, eq_to_hom_trans, eq_to_hom_op],
refl
end
/--
The spectrum of a commutative ring, as a scheme.
-/
def Spec_obj (R : CommRing) : Scheme :=
{ local_affine := λ x,
⟨⟨⊤, trivial⟩, R, ⟨(Spec.to_LocallyRingedSpace.obj (op R)).restrict_top_iso⟩⟩,
to_LocallyRingedSpace := Spec.LocallyRingedSpace_obj R }
@[simp] lemma Spec_obj_to_LocallyRingedSpace (R : CommRing) :
(Spec_obj R).to_LocallyRingedSpace = Spec.LocallyRingedSpace_obj R := rfl
/--
The induced map of a ring homomorphism on the ring spectra, as a morphism of schemes.
-/
def Spec_map {R S : CommRing} (f : R ⟶ S) :
Spec_obj S ⟶ Spec_obj R :=
(Spec.LocallyRingedSpace_map f : Spec.LocallyRingedSpace_obj S ⟶ Spec.LocallyRingedSpace_obj R)
@[simp] lemma Spec_map_id (R : CommRing) :
Spec_map (𝟙 R) = 𝟙 (Spec_obj R) :=
Spec.LocallyRingedSpace_map_id R
lemma Spec_map_comp {R S T : CommRing} (f : R ⟶ S) (g : S ⟶ T) :
Spec_map (f ≫ g) = Spec_map g ≫ Spec_map f :=
Spec.LocallyRingedSpace_map_comp f g
/--
The spectrum, as a contravariant functor from commutative rings to schemes.
-/
@[simps] def Spec : CommRingᵒᵖ ⥤ Scheme :=
{ obj := λ R, Spec_obj (unop R),
map := λ R S f, Spec_map f.unop,
map_id' := λ R, by rw [unop_id, Spec_map_id],
map_comp' := λ R S T f g, by rw [unop_comp, Spec_map_comp] }
/--
The empty scheme.
-/
@[simps]
def {u} empty : Scheme.{u} :=
{ carrier := Top.of pempty,
presheaf := (category_theory.functor.const _).obj (CommRing.of punit),
is_sheaf := presheaf.is_sheaf_of_is_terminal _ CommRing.punit_is_terminal,
local_ring := λ x, pempty.elim x,
local_affine := λ x, pempty.elim x }
instance : has_emptyc Scheme := ⟨empty⟩
instance : inhabited Scheme := ⟨∅⟩
/--
The global sections, notated Gamma.
-/
def Γ : Schemeᵒᵖ ⥤ CommRing :=
(induced_functor Scheme.to_LocallyRingedSpace).op ⋙ LocallyRingedSpace.Γ
lemma Γ_def : Γ = (induced_functor Scheme.to_LocallyRingedSpace).op ⋙ LocallyRingedSpace.Γ := rfl
@[simp] lemma Γ_obj (X : Schemeᵒᵖ) : Γ.obj X = (unop X).presheaf.obj (op ⊤) := rfl
lemma Γ_obj_op (X : Scheme) : Γ.obj (op X) = X.presheaf.obj (op ⊤) := rfl
@[simp] lemma Γ_map {X Y : Schemeᵒᵖ} (f : X ⟶ Y) :
Γ.map f = f.unop.1.c.app (op ⊤) := rfl
lemma Γ_map_op {X Y : Scheme} (f : X ⟶ Y) :
Γ.map f.op = f.1.c.app (op ⊤) := rfl
section basic_open
variables (X : Scheme) {V U : opens X.carrier} (f g : X.presheaf.obj (op U))
/-- The subset of the underlying space where the given section does not vanish. -/
def basic_open : opens X.carrier := X.to_LocallyRingedSpace.to_RingedSpace.basic_open f
@[simp]
lemma mem_basic_open (x : U) : ↑x ∈ X.basic_open f ↔ is_unit (X.presheaf.germ x f) :=
RingedSpace.mem_basic_open _ _ _
@[simp]
lemma mem_basic_open_top (f : X.presheaf.obj (op ⊤)) (x : X.carrier) :
x ∈ X.basic_open f ↔ is_unit (X.presheaf.germ (⟨x, trivial⟩ : (⊤ : opens _)) f) :=
RingedSpace.mem_basic_open _ f ⟨x, trivial⟩
@[simp]
lemma basic_open_res (i : op U ⟶ op V) :
X.basic_open (X.presheaf.map i f) = V ∩ X.basic_open f :=
RingedSpace.basic_open_res _ i f
-- This should fire before `basic_open_res`.
@[simp, priority 1100]
lemma basic_open_res_eq (i : op U ⟶ op V) [is_iso i] :
X.basic_open (X.presheaf.map i f) = X.basic_open f :=
RingedSpace.basic_open_res_eq _ i f
lemma basic_open_subset : X.basic_open f ⊆ U :=
RingedSpace.basic_open_subset _ _
@[simp]
lemma preimage_basic_open {X Y : Scheme} (f : X ⟶ Y) {U : opens Y.carrier}
(r : Y.presheaf.obj $ op U) :
(opens.map f.1.base).obj (Y.basic_open r) =
@Scheme.basic_open X ((opens.map f.1.base).obj U) (f.1.c.app _ r) :=
LocallyRingedSpace.preimage_basic_open f r
@[simp]
lemma basic_open_zero (U : opens X.carrier) : X.basic_open (0 : X.presheaf.obj $ op U) = ∅ :=
LocallyRingedSpace.basic_open_zero _ U
@[simp]
lemma basic_open_mul : X.basic_open (f * g) = X.basic_open f ⊓ X.basic_open g :=
RingedSpace.basic_open_mul _ _ _
lemma basic_open_of_is_unit {f : X.presheaf.obj (op U)} (hf : is_unit f) : X.basic_open f = U :=
RingedSpace.basic_open_of_is_unit _ hf
end basic_open
end Scheme
lemma basic_open_eq_of_affine {R : CommRing} (f : R) :
(Scheme.Spec.obj $ op R).basic_open ((Spec_Γ_identity.app R).inv f) =
prime_spectrum.basic_open f :=
begin
ext,
erw Scheme.mem_basic_open_top,
suffices : is_unit (structure_sheaf.to_stalk R x f) ↔ f ∉ prime_spectrum.as_ideal x,
{ exact this },
erw [← is_unit_map_iff (structure_sheaf.stalk_to_fiber_ring_hom R x),
structure_sheaf.stalk_to_fiber_ring_hom_to_stalk],
exact (is_localization.at_prime.is_unit_to_map_iff
(localization.at_prime (prime_spectrum.as_ideal x)) (prime_spectrum.as_ideal x) f : _)
end
@[simp]
lemma basic_open_eq_of_affine' {R : CommRing}
(f : (Spec.to_SheafedSpace.obj (op R)).presheaf.obj (op ⊤)) :
(Scheme.Spec.obj $ op R).basic_open f =
prime_spectrum.basic_open ((Spec_Γ_identity.app R).hom f) :=
begin
convert basic_open_eq_of_affine ((Spec_Γ_identity.app R).hom f),
exact (iso.hom_inv_id_apply _ _).symm
end
end algebraic_geometry
|
e1cbd97d12f3fe1cdbeb219ca92ed9208d531c58 | 4727251e0cd73359b15b664c3170e5d754078599 | /src/data/multiset/nat_antidiagonal.lean | 40ca75f93016960ac365512ad26d0ccf10a3f435 | [
"Apache-2.0"
] | permissive | Vierkantor/mathlib | 0ea59ac32a3a43c93c44d70f441c4ee810ccceca | 83bc3b9ce9b13910b57bda6b56222495ebd31c2f | refs/heads/master | 1,658,323,012,449 | 1,652,256,003,000 | 1,652,256,003,000 | 209,296,341 | 0 | 1 | Apache-2.0 | 1,568,807,655,000 | 1,568,807,655,000 | null | UTF-8 | Lean | false | false | 2,519 | lean | /-
Copyright (c) 2019 Johan Commelin. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johan Commelin
-/
import data.multiset.nodup
import data.list.nat_antidiagonal
/-!
# Antidiagonals in ℕ × ℕ as multisets
This file defines the antidiagonals of ℕ × ℕ as multisets: the `n`-th antidiagonal is the multiset
of pairs `(i, j)` such that `i + j = n`. This is useful for polynomial multiplication and more
generally for sums going from `0` to `n`.
## Notes
This refines file `data.list.nat_antidiagonal` and is further refined by file
`data.finset.nat_antidiagonal`.
-/
namespace multiset
namespace nat
/-- The antidiagonal of a natural number `n` is
the multiset of pairs `(i, j)` such that `i + j = n`. -/
def antidiagonal (n : ℕ) : multiset (ℕ × ℕ) :=
list.nat.antidiagonal n
/-- A pair (i, j) is contained in the antidiagonal of `n` if and only if `i + j = n`. -/
@[simp] lemma mem_antidiagonal {n : ℕ} {x : ℕ × ℕ} :
x ∈ antidiagonal n ↔ x.1 + x.2 = n :=
by rw [antidiagonal, mem_coe, list.nat.mem_antidiagonal]
/-- The cardinality of the antidiagonal of `n` is `n+1`. -/
@[simp] lemma card_antidiagonal (n : ℕ) : (antidiagonal n).card = n+1 :=
by rw [antidiagonal, coe_card, list.nat.length_antidiagonal]
/-- The antidiagonal of `0` is the list `[(0, 0)]` -/
@[simp] lemma antidiagonal_zero : antidiagonal 0 = {(0, 0)} :=
rfl
/-- The antidiagonal of `n` does not contain duplicate entries. -/
@[simp] lemma nodup_antidiagonal (n : ℕ) : nodup (antidiagonal n) :=
coe_nodup.2 $ list.nat.nodup_antidiagonal n
@[simp] lemma antidiagonal_succ {n : ℕ} :
antidiagonal (n + 1) = (0, n + 1) ::ₘ ((antidiagonal n).map (prod.map nat.succ id)) :=
by simp only [antidiagonal, list.nat.antidiagonal_succ, coe_map, cons_coe]
lemma antidiagonal_succ' {n : ℕ} :
antidiagonal (n + 1) = (n + 1, 0) ::ₘ ((antidiagonal n).map (prod.map id nat.succ)) :=
by rw [antidiagonal, list.nat.antidiagonal_succ', ← coe_add, add_comm, antidiagonal, coe_map,
coe_add, list.singleton_append, cons_coe]
lemma antidiagonal_succ_succ' {n : ℕ} :
antidiagonal (n + 2) =
(0, n + 2) ::ₘ (n + 2, 0) ::ₘ ((antidiagonal n).map (prod.map nat.succ nat.succ)) :=
by { rw [antidiagonal_succ, antidiagonal_succ', map_cons, map_map, prod_map], refl }
lemma map_swap_antidiagonal {n : ℕ} :
(antidiagonal n).map prod.swap = antidiagonal n :=
by rw [antidiagonal, coe_map, list.nat.map_swap_antidiagonal, coe_reverse]
end nat
end multiset
|
bc117c38f7a22b02b0088a60e485137a2c5d32ec | fc086f79b20cf002d6f34b023749998408e94fbf | /examples/primes.lean | 92a268f34edde26a9db3875d55e8ed2a290d8661 | [] | no_license | semorrison/lean-tidy | f039460136b898fb282f75efedd92f2d5c5d90f8 | 6c1d46de6cff05e1c2c4c9692af812bca3e13b6c | refs/heads/master | 1,624,461,332,392 | 1,559,655,744,000 | 1,559,655,744,000 | 96,569,994 | 9 | 4 | null | 1,538,287,895,000 | 1,499,455,306,000 | Lean | UTF-8 | Lean | false | false | 557 | lean | import data.nat.prime
open nat
theorem exists_infinite_primes : ∀ n : ℕ, ∃ p, p ≥ n ∧ prime p :=
λ n,
let p := min_fac (fact n + 1) in
have fp : fact n > 0 := fact_pos n,
have f1 : fact n + 1 ≠ 1, from ne_of_gt $ succ_lt_succ $ fact_pos n,
have pp : prime p, from min_fac_prime f1,
have w : n ≤ p, from le_of_not_ge $ λ h,
have h₁ : p ∣ fact n, from dvd_fact (min_fac_pos (fact n + 1)) h,
have h₂ : p ∣ 1, from (nat.dvd_add_iff_right h₁).2 (min_fac_dvd (fact n + 1)),
pp.not_dvd_one h₂,
⟨p, w, pp⟩ |
10a90268737f8e3e87c8c6d96a3a86123bf32c23 | 6432ea7a083ff6ba21ea17af9ee47b9c371760f7 | /tests/simpperf/simp2500.lean | 500dff52f02429edba0035b8aa8efc1c7d8d4821 | [
"Apache-2.0",
"LLVM-exception",
"NCSA",
"LGPL-3.0-only",
"LicenseRef-scancode-inner-net-2.0",
"BSD-3-Clause",
"LGPL-2.0-or-later",
"Spencer-94",
"LGPL-2.1-or-later",
"HPND",
"LicenseRef-scancode-pcre",
"ISC",
"LGPL-2.1-only",
"LicenseRef-scancode-other-permissive",
"SunPro",
"CMU-Mach"... | permissive | leanprover/lean4 | 4bdf9790294964627eb9be79f5e8f6157780b4cc | f1f9dc0f2f531af3312398999d8b8303fa5f096b | refs/heads/master | 1,693,360,665,786 | 1,693,350,868,000 | 1,693,350,868,000 | 129,571,436 | 2,827 | 311 | Apache-2.0 | 1,694,716,156,000 | 1,523,760,560,000 | Lean | UTF-8 | Lean | false | false | 218,098 | lean | axiom f (x : Prop) : Prop
axiom g0 (x : Prop) : Prop
axiom g1 (x : Prop) : Prop
axiom g2 (x : Prop) : Prop
axiom g3 (x : Prop) : Prop
axiom g4 (x : Prop) : Prop
axiom g5 (x : Prop) : Prop
axiom g6 (x : Prop) : Prop
axiom g7 (x : Prop) : Prop
axiom g8 (x : Prop) : Prop
axiom g9 (x : Prop) : Prop
axiom g10 (x : Prop) : Prop
axiom g11 (x : Prop) : Prop
axiom g12 (x : Prop) : Prop
axiom g13 (x : Prop) : Prop
axiom g14 (x : Prop) : Prop
axiom g15 (x : Prop) : Prop
axiom g16 (x : Prop) : Prop
axiom g17 (x : Prop) : Prop
axiom g18 (x : Prop) : Prop
axiom g19 (x : Prop) : Prop
axiom g20 (x : Prop) : Prop
axiom g21 (x : Prop) : Prop
axiom g22 (x : Prop) : Prop
axiom g23 (x : Prop) : Prop
axiom g24 (x : Prop) : Prop
axiom g25 (x : Prop) : Prop
axiom g26 (x : Prop) : Prop
axiom g27 (x : Prop) : Prop
axiom g28 (x : Prop) : Prop
axiom g29 (x : Prop) : Prop
axiom g30 (x : Prop) : Prop
axiom g31 (x : Prop) : Prop
axiom g32 (x : Prop) : Prop
axiom g33 (x : Prop) : Prop
axiom g34 (x : Prop) : Prop
axiom g35 (x : Prop) : Prop
axiom g36 (x : Prop) : Prop
axiom g37 (x : Prop) : Prop
axiom g38 (x : Prop) : Prop
axiom g39 (x : Prop) : Prop
axiom g40 (x : Prop) : Prop
axiom g41 (x : Prop) : Prop
axiom g42 (x : Prop) : Prop
axiom g43 (x : Prop) : Prop
axiom g44 (x : Prop) : Prop
axiom g45 (x : Prop) : Prop
axiom g46 (x : Prop) : Prop
axiom g47 (x : Prop) : Prop
axiom g48 (x : Prop) : Prop
axiom g49 (x : Prop) : Prop
axiom g50 (x : Prop) : Prop
axiom g51 (x : Prop) : Prop
axiom g52 (x : Prop) : Prop
axiom g53 (x : Prop) : Prop
axiom g54 (x : Prop) : Prop
axiom g55 (x : Prop) : Prop
axiom g56 (x : Prop) : Prop
axiom g57 (x : Prop) : Prop
axiom g58 (x : Prop) : Prop
axiom g59 (x : Prop) : Prop
axiom g60 (x : Prop) : Prop
axiom g61 (x : Prop) : Prop
axiom g62 (x : Prop) : Prop
axiom g63 (x : Prop) : Prop
axiom g64 (x : Prop) : Prop
axiom g65 (x : Prop) : Prop
axiom g66 (x : Prop) : Prop
axiom g67 (x : Prop) : Prop
axiom g68 (x : Prop) : Prop
axiom g69 (x : Prop) : Prop
axiom g70 (x : Prop) : Prop
axiom g71 (x : Prop) : Prop
axiom g72 (x : Prop) : Prop
axiom g73 (x : Prop) : Prop
axiom g74 (x : Prop) : Prop
axiom g75 (x : Prop) : Prop
axiom g76 (x : Prop) : Prop
axiom g77 (x : Prop) : Prop
axiom g78 (x : Prop) : Prop
axiom g79 (x : Prop) : Prop
axiom g80 (x : Prop) : Prop
axiom g81 (x : Prop) : Prop
axiom g82 (x : Prop) : Prop
axiom g83 (x : Prop) : Prop
axiom g84 (x : Prop) : Prop
axiom g85 (x : Prop) : Prop
axiom g86 (x : Prop) : Prop
axiom g87 (x : Prop) : Prop
axiom g88 (x : Prop) : Prop
axiom g89 (x : Prop) : Prop
axiom g90 (x : Prop) : Prop
axiom g91 (x : Prop) : Prop
axiom g92 (x : Prop) : Prop
axiom g93 (x : Prop) : Prop
axiom g94 (x : Prop) : Prop
axiom g95 (x : Prop) : Prop
axiom g96 (x : Prop) : Prop
axiom g97 (x : Prop) : Prop
axiom g98 (x : Prop) : Prop
axiom g99 (x : Prop) : Prop
axiom g100 (x : Prop) : Prop
axiom g101 (x : Prop) : Prop
axiom g102 (x : Prop) : Prop
axiom g103 (x : Prop) : Prop
axiom g104 (x : Prop) : Prop
axiom g105 (x : Prop) : Prop
axiom g106 (x : Prop) : Prop
axiom g107 (x : Prop) : Prop
axiom g108 (x : Prop) : Prop
axiom g109 (x : Prop) : Prop
axiom g110 (x : Prop) : Prop
axiom g111 (x : Prop) : Prop
axiom g112 (x : Prop) : Prop
axiom g113 (x : Prop) : Prop
axiom g114 (x : Prop) : Prop
axiom g115 (x : Prop) : Prop
axiom g116 (x : Prop) : Prop
axiom g117 (x : Prop) : Prop
axiom g118 (x : Prop) : Prop
axiom g119 (x : Prop) : Prop
axiom g120 (x : Prop) : Prop
axiom g121 (x : Prop) : Prop
axiom g122 (x : Prop) : Prop
axiom g123 (x : Prop) : Prop
axiom g124 (x : Prop) : Prop
axiom g125 (x : Prop) : Prop
axiom g126 (x : Prop) : Prop
axiom g127 (x : Prop) : Prop
axiom g128 (x : Prop) : Prop
axiom g129 (x : Prop) : Prop
axiom g130 (x : Prop) : Prop
axiom g131 (x : Prop) : Prop
axiom g132 (x : Prop) : Prop
axiom g133 (x : Prop) : Prop
axiom g134 (x : Prop) : Prop
axiom g135 (x : Prop) : Prop
axiom g136 (x : Prop) : Prop
axiom g137 (x : Prop) : Prop
axiom g138 (x : Prop) : Prop
axiom g139 (x : Prop) : Prop
axiom g140 (x : Prop) : Prop
axiom g141 (x : Prop) : Prop
axiom g142 (x : Prop) : Prop
axiom g143 (x : Prop) : Prop
axiom g144 (x : Prop) : Prop
axiom g145 (x : Prop) : Prop
axiom g146 (x : Prop) : Prop
axiom g147 (x : Prop) : Prop
axiom g148 (x : Prop) : Prop
axiom g149 (x : Prop) : Prop
axiom g150 (x : Prop) : Prop
axiom g151 (x : Prop) : Prop
axiom g152 (x : Prop) : Prop
axiom g153 (x : Prop) : Prop
axiom g154 (x : Prop) : Prop
axiom g155 (x : Prop) : Prop
axiom g156 (x : Prop) : Prop
axiom g157 (x : Prop) : Prop
axiom g158 (x : Prop) : Prop
axiom g159 (x : Prop) : Prop
axiom g160 (x : Prop) : Prop
axiom g161 (x : Prop) : Prop
axiom g162 (x : Prop) : Prop
axiom g163 (x : Prop) : Prop
axiom g164 (x : Prop) : Prop
axiom g165 (x : Prop) : Prop
axiom g166 (x : Prop) : Prop
axiom g167 (x : Prop) : Prop
axiom g168 (x : Prop) : Prop
axiom g169 (x : Prop) : Prop
axiom g170 (x : Prop) : Prop
axiom g171 (x : Prop) : Prop
axiom g172 (x : Prop) : Prop
axiom g173 (x : Prop) : Prop
axiom g174 (x : Prop) : Prop
axiom g175 (x : Prop) : Prop
axiom g176 (x : Prop) : Prop
axiom g177 (x : Prop) : Prop
axiom g178 (x : Prop) : Prop
axiom g179 (x : Prop) : Prop
axiom g180 (x : Prop) : Prop
axiom g181 (x : Prop) : Prop
axiom g182 (x : Prop) : Prop
axiom g183 (x : Prop) : Prop
axiom g184 (x : Prop) : Prop
axiom g185 (x : Prop) : Prop
axiom g186 (x : Prop) : Prop
axiom g187 (x : Prop) : Prop
axiom g188 (x : Prop) : Prop
axiom g189 (x : Prop) : Prop
axiom g190 (x : Prop) : Prop
axiom g191 (x : Prop) : Prop
axiom g192 (x : Prop) : Prop
axiom g193 (x : Prop) : Prop
axiom g194 (x : Prop) : Prop
axiom g195 (x : Prop) : Prop
axiom g196 (x : Prop) : Prop
axiom g197 (x : Prop) : Prop
axiom g198 (x : Prop) : Prop
axiom g199 (x : Prop) : Prop
axiom g200 (x : Prop) : Prop
axiom g201 (x : Prop) : Prop
axiom g202 (x : Prop) : Prop
axiom g203 (x : Prop) : Prop
axiom g204 (x : Prop) : Prop
axiom g205 (x : Prop) : Prop
axiom g206 (x : Prop) : Prop
axiom g207 (x : Prop) : Prop
axiom g208 (x : Prop) : Prop
axiom g209 (x : Prop) : Prop
axiom g210 (x : Prop) : Prop
axiom g211 (x : Prop) : Prop
axiom g212 (x : Prop) : Prop
axiom g213 (x : Prop) : Prop
axiom g214 (x : Prop) : Prop
axiom g215 (x : Prop) : Prop
axiom g216 (x : Prop) : Prop
axiom g217 (x : Prop) : Prop
axiom g218 (x : Prop) : Prop
axiom g219 (x : Prop) : Prop
axiom g220 (x : Prop) : Prop
axiom g221 (x : Prop) : Prop
axiom g222 (x : Prop) : Prop
axiom g223 (x : Prop) : Prop
axiom g224 (x : Prop) : Prop
axiom g225 (x : Prop) : Prop
axiom g226 (x : Prop) : Prop
axiom g227 (x : Prop) : Prop
axiom g228 (x : Prop) : Prop
axiom g229 (x : Prop) : Prop
axiom g230 (x : Prop) : Prop
axiom g231 (x : Prop) : Prop
axiom g232 (x : Prop) : Prop
axiom g233 (x : Prop) : Prop
axiom g234 (x : Prop) : Prop
axiom g235 (x : Prop) : Prop
axiom g236 (x : Prop) : Prop
axiom g237 (x : Prop) : Prop
axiom g238 (x : Prop) : Prop
axiom g239 (x : Prop) : Prop
axiom g240 (x : Prop) : Prop
axiom g241 (x : Prop) : Prop
axiom g242 (x : Prop) : Prop
axiom g243 (x : Prop) : Prop
axiom g244 (x : Prop) : Prop
axiom g245 (x : Prop) : Prop
axiom g246 (x : Prop) : Prop
axiom g247 (x : Prop) : Prop
axiom g248 (x : Prop) : Prop
axiom g249 (x : Prop) : Prop
axiom g250 (x : Prop) : Prop
axiom g251 (x : Prop) : Prop
axiom g252 (x : Prop) : Prop
axiom g253 (x : Prop) : Prop
axiom g254 (x : Prop) : Prop
axiom g255 (x : Prop) : Prop
axiom g256 (x : Prop) : Prop
axiom g257 (x : Prop) : Prop
axiom g258 (x : Prop) : Prop
axiom g259 (x : Prop) : Prop
axiom g260 (x : Prop) : Prop
axiom g261 (x : Prop) : Prop
axiom g262 (x : Prop) : Prop
axiom g263 (x : Prop) : Prop
axiom g264 (x : Prop) : Prop
axiom g265 (x : Prop) : Prop
axiom g266 (x : Prop) : Prop
axiom g267 (x : Prop) : Prop
axiom g268 (x : Prop) : Prop
axiom g269 (x : Prop) : Prop
axiom g270 (x : Prop) : Prop
axiom g271 (x : Prop) : Prop
axiom g272 (x : Prop) : Prop
axiom g273 (x : Prop) : Prop
axiom g274 (x : Prop) : Prop
axiom g275 (x : Prop) : Prop
axiom g276 (x : Prop) : Prop
axiom g277 (x : Prop) : Prop
axiom g278 (x : Prop) : Prop
axiom g279 (x : Prop) : Prop
axiom g280 (x : Prop) : Prop
axiom g281 (x : Prop) : Prop
axiom g282 (x : Prop) : Prop
axiom g283 (x : Prop) : Prop
axiom g284 (x : Prop) : Prop
axiom g285 (x : Prop) : Prop
axiom g286 (x : Prop) : Prop
axiom g287 (x : Prop) : Prop
axiom g288 (x : Prop) : Prop
axiom g289 (x : Prop) : Prop
axiom g290 (x : Prop) : Prop
axiom g291 (x : Prop) : Prop
axiom g292 (x : Prop) : Prop
axiom g293 (x : Prop) : Prop
axiom g294 (x : Prop) : Prop
axiom g295 (x : Prop) : Prop
axiom g296 (x : Prop) : Prop
axiom g297 (x : Prop) : Prop
axiom g298 (x : Prop) : Prop
axiom g299 (x : Prop) : Prop
axiom g300 (x : Prop) : Prop
axiom g301 (x : Prop) : Prop
axiom g302 (x : Prop) : Prop
axiom g303 (x : Prop) : Prop
axiom g304 (x : Prop) : Prop
axiom g305 (x : Prop) : Prop
axiom g306 (x : Prop) : Prop
axiom g307 (x : Prop) : Prop
axiom g308 (x : Prop) : Prop
axiom g309 (x : Prop) : Prop
axiom g310 (x : Prop) : Prop
axiom g311 (x : Prop) : Prop
axiom g312 (x : Prop) : Prop
axiom g313 (x : Prop) : Prop
axiom g314 (x : Prop) : Prop
axiom g315 (x : Prop) : Prop
axiom g316 (x : Prop) : Prop
axiom g317 (x : Prop) : Prop
axiom g318 (x : Prop) : Prop
axiom g319 (x : Prop) : Prop
axiom g320 (x : Prop) : Prop
axiom g321 (x : Prop) : Prop
axiom g322 (x : Prop) : Prop
axiom g323 (x : Prop) : Prop
axiom g324 (x : Prop) : Prop
axiom g325 (x : Prop) : Prop
axiom g326 (x : Prop) : Prop
axiom g327 (x : Prop) : Prop
axiom g328 (x : Prop) : Prop
axiom g329 (x : Prop) : Prop
axiom g330 (x : Prop) : Prop
axiom g331 (x : Prop) : Prop
axiom g332 (x : Prop) : Prop
axiom g333 (x : Prop) : Prop
axiom g334 (x : Prop) : Prop
axiom g335 (x : Prop) : Prop
axiom g336 (x : Prop) : Prop
axiom g337 (x : Prop) : Prop
axiom g338 (x : Prop) : Prop
axiom g339 (x : Prop) : Prop
axiom g340 (x : Prop) : Prop
axiom g341 (x : Prop) : Prop
axiom g342 (x : Prop) : Prop
axiom g343 (x : Prop) : Prop
axiom g344 (x : Prop) : Prop
axiom g345 (x : Prop) : Prop
axiom g346 (x : Prop) : Prop
axiom g347 (x : Prop) : Prop
axiom g348 (x : Prop) : Prop
axiom g349 (x : Prop) : Prop
axiom g350 (x : Prop) : Prop
axiom g351 (x : Prop) : Prop
axiom g352 (x : Prop) : Prop
axiom g353 (x : Prop) : Prop
axiom g354 (x : Prop) : Prop
axiom g355 (x : Prop) : Prop
axiom g356 (x : Prop) : Prop
axiom g357 (x : Prop) : Prop
axiom g358 (x : Prop) : Prop
axiom g359 (x : Prop) : Prop
axiom g360 (x : Prop) : Prop
axiom g361 (x : Prop) : Prop
axiom g362 (x : Prop) : Prop
axiom g363 (x : Prop) : Prop
axiom g364 (x : Prop) : Prop
axiom g365 (x : Prop) : Prop
axiom g366 (x : Prop) : Prop
axiom g367 (x : Prop) : Prop
axiom g368 (x : Prop) : Prop
axiom g369 (x : Prop) : Prop
axiom g370 (x : Prop) : Prop
axiom g371 (x : Prop) : Prop
axiom g372 (x : Prop) : Prop
axiom g373 (x : Prop) : Prop
axiom g374 (x : Prop) : Prop
axiom g375 (x : Prop) : Prop
axiom g376 (x : Prop) : Prop
axiom g377 (x : Prop) : Prop
axiom g378 (x : Prop) : Prop
axiom g379 (x : Prop) : Prop
axiom g380 (x : Prop) : Prop
axiom g381 (x : Prop) : Prop
axiom g382 (x : Prop) : Prop
axiom g383 (x : Prop) : Prop
axiom g384 (x : Prop) : Prop
axiom g385 (x : Prop) : Prop
axiom g386 (x : Prop) : Prop
axiom g387 (x : Prop) : Prop
axiom g388 (x : Prop) : Prop
axiom g389 (x : Prop) : Prop
axiom g390 (x : Prop) : Prop
axiom g391 (x : Prop) : Prop
axiom g392 (x : Prop) : Prop
axiom g393 (x : Prop) : Prop
axiom g394 (x : Prop) : Prop
axiom g395 (x : Prop) : Prop
axiom g396 (x : Prop) : Prop
axiom g397 (x : Prop) : Prop
axiom g398 (x : Prop) : Prop
axiom g399 (x : Prop) : Prop
axiom g400 (x : Prop) : Prop
axiom g401 (x : Prop) : Prop
axiom g402 (x : Prop) : Prop
axiom g403 (x : Prop) : Prop
axiom g404 (x : Prop) : Prop
axiom g405 (x : Prop) : Prop
axiom g406 (x : Prop) : Prop
axiom g407 (x : Prop) : Prop
axiom g408 (x : Prop) : Prop
axiom g409 (x : Prop) : Prop
axiom g410 (x : Prop) : Prop
axiom g411 (x : Prop) : Prop
axiom g412 (x : Prop) : Prop
axiom g413 (x : Prop) : Prop
axiom g414 (x : Prop) : Prop
axiom g415 (x : Prop) : Prop
axiom g416 (x : Prop) : Prop
axiom g417 (x : Prop) : Prop
axiom g418 (x : Prop) : Prop
axiom g419 (x : Prop) : Prop
axiom g420 (x : Prop) : Prop
axiom g421 (x : Prop) : Prop
axiom g422 (x : Prop) : Prop
axiom g423 (x : Prop) : Prop
axiom g424 (x : Prop) : Prop
axiom g425 (x : Prop) : Prop
axiom g426 (x : Prop) : Prop
axiom g427 (x : Prop) : Prop
axiom g428 (x : Prop) : Prop
axiom g429 (x : Prop) : Prop
axiom g430 (x : Prop) : Prop
axiom g431 (x : Prop) : Prop
axiom g432 (x : Prop) : Prop
axiom g433 (x : Prop) : Prop
axiom g434 (x : Prop) : Prop
axiom g435 (x : Prop) : Prop
axiom g436 (x : Prop) : Prop
axiom g437 (x : Prop) : Prop
axiom g438 (x : Prop) : Prop
axiom g439 (x : Prop) : Prop
axiom g440 (x : Prop) : Prop
axiom g441 (x : Prop) : Prop
axiom g442 (x : Prop) : Prop
axiom g443 (x : Prop) : Prop
axiom g444 (x : Prop) : Prop
axiom g445 (x : Prop) : Prop
axiom g446 (x : Prop) : Prop
axiom g447 (x : Prop) : Prop
axiom g448 (x : Prop) : Prop
axiom g449 (x : Prop) : Prop
axiom g450 (x : Prop) : Prop
axiom g451 (x : Prop) : Prop
axiom g452 (x : Prop) : Prop
axiom g453 (x : Prop) : Prop
axiom g454 (x : Prop) : Prop
axiom g455 (x : Prop) : Prop
axiom g456 (x : Prop) : Prop
axiom g457 (x : Prop) : Prop
axiom g458 (x : Prop) : Prop
axiom g459 (x : Prop) : Prop
axiom g460 (x : Prop) : Prop
axiom g461 (x : Prop) : Prop
axiom g462 (x : Prop) : Prop
axiom g463 (x : Prop) : Prop
axiom g464 (x : Prop) : Prop
axiom g465 (x : Prop) : Prop
axiom g466 (x : Prop) : Prop
axiom g467 (x : Prop) : Prop
axiom g468 (x : Prop) : Prop
axiom g469 (x : Prop) : Prop
axiom g470 (x : Prop) : Prop
axiom g471 (x : Prop) : Prop
axiom g472 (x : Prop) : Prop
axiom g473 (x : Prop) : Prop
axiom g474 (x : Prop) : Prop
axiom g475 (x : Prop) : Prop
axiom g476 (x : Prop) : Prop
axiom g477 (x : Prop) : Prop
axiom g478 (x : Prop) : Prop
axiom g479 (x : Prop) : Prop
axiom g480 (x : Prop) : Prop
axiom g481 (x : Prop) : Prop
axiom g482 (x : Prop) : Prop
axiom g483 (x : Prop) : Prop
axiom g484 (x : Prop) : Prop
axiom g485 (x : Prop) : Prop
axiom g486 (x : Prop) : Prop
axiom g487 (x : Prop) : Prop
axiom g488 (x : Prop) : Prop
axiom g489 (x : Prop) : Prop
axiom g490 (x : Prop) : Prop
axiom g491 (x : Prop) : Prop
axiom g492 (x : Prop) : Prop
axiom g493 (x : Prop) : Prop
axiom g494 (x : Prop) : Prop
axiom g495 (x : Prop) : Prop
axiom g496 (x : Prop) : Prop
axiom g497 (x : Prop) : Prop
axiom g498 (x : Prop) : Prop
axiom g499 (x : Prop) : Prop
axiom g500 (x : Prop) : Prop
axiom g501 (x : Prop) : Prop
axiom g502 (x : Prop) : Prop
axiom g503 (x : Prop) : Prop
axiom g504 (x : Prop) : Prop
axiom g505 (x : Prop) : Prop
axiom g506 (x : Prop) : Prop
axiom g507 (x : Prop) : Prop
axiom g508 (x : Prop) : Prop
axiom g509 (x : Prop) : Prop
axiom g510 (x : Prop) : Prop
axiom g511 (x : Prop) : Prop
axiom g512 (x : Prop) : Prop
axiom g513 (x : Prop) : Prop
axiom g514 (x : Prop) : Prop
axiom g515 (x : Prop) : Prop
axiom g516 (x : Prop) : Prop
axiom g517 (x : Prop) : Prop
axiom g518 (x : Prop) : Prop
axiom g519 (x : Prop) : Prop
axiom g520 (x : Prop) : Prop
axiom g521 (x : Prop) : Prop
axiom g522 (x : Prop) : Prop
axiom g523 (x : Prop) : Prop
axiom g524 (x : Prop) : Prop
axiom g525 (x : Prop) : Prop
axiom g526 (x : Prop) : Prop
axiom g527 (x : Prop) : Prop
axiom g528 (x : Prop) : Prop
axiom g529 (x : Prop) : Prop
axiom g530 (x : Prop) : Prop
axiom g531 (x : Prop) : Prop
axiom g532 (x : Prop) : Prop
axiom g533 (x : Prop) : Prop
axiom g534 (x : Prop) : Prop
axiom g535 (x : Prop) : Prop
axiom g536 (x : Prop) : Prop
axiom g537 (x : Prop) : Prop
axiom g538 (x : Prop) : Prop
axiom g539 (x : Prop) : Prop
axiom g540 (x : Prop) : Prop
axiom g541 (x : Prop) : Prop
axiom g542 (x : Prop) : Prop
axiom g543 (x : Prop) : Prop
axiom g544 (x : Prop) : Prop
axiom g545 (x : Prop) : Prop
axiom g546 (x : Prop) : Prop
axiom g547 (x : Prop) : Prop
axiom g548 (x : Prop) : Prop
axiom g549 (x : Prop) : Prop
axiom g550 (x : Prop) : Prop
axiom g551 (x : Prop) : Prop
axiom g552 (x : Prop) : Prop
axiom g553 (x : Prop) : Prop
axiom g554 (x : Prop) : Prop
axiom g555 (x : Prop) : Prop
axiom g556 (x : Prop) : Prop
axiom g557 (x : Prop) : Prop
axiom g558 (x : Prop) : Prop
axiom g559 (x : Prop) : Prop
axiom g560 (x : Prop) : Prop
axiom g561 (x : Prop) : Prop
axiom g562 (x : Prop) : Prop
axiom g563 (x : Prop) : Prop
axiom g564 (x : Prop) : Prop
axiom g565 (x : Prop) : Prop
axiom g566 (x : Prop) : Prop
axiom g567 (x : Prop) : Prop
axiom g568 (x : Prop) : Prop
axiom g569 (x : Prop) : Prop
axiom g570 (x : Prop) : Prop
axiom g571 (x : Prop) : Prop
axiom g572 (x : Prop) : Prop
axiom g573 (x : Prop) : Prop
axiom g574 (x : Prop) : Prop
axiom g575 (x : Prop) : Prop
axiom g576 (x : Prop) : Prop
axiom g577 (x : Prop) : Prop
axiom g578 (x : Prop) : Prop
axiom g579 (x : Prop) : Prop
axiom g580 (x : Prop) : Prop
axiom g581 (x : Prop) : Prop
axiom g582 (x : Prop) : Prop
axiom g583 (x : Prop) : Prop
axiom g584 (x : Prop) : Prop
axiom g585 (x : Prop) : Prop
axiom g586 (x : Prop) : Prop
axiom g587 (x : Prop) : Prop
axiom g588 (x : Prop) : Prop
axiom g589 (x : Prop) : Prop
axiom g590 (x : Prop) : Prop
axiom g591 (x : Prop) : Prop
axiom g592 (x : Prop) : Prop
axiom g593 (x : Prop) : Prop
axiom g594 (x : Prop) : Prop
axiom g595 (x : Prop) : Prop
axiom g596 (x : Prop) : Prop
axiom g597 (x : Prop) : Prop
axiom g598 (x : Prop) : Prop
axiom g599 (x : Prop) : Prop
axiom g600 (x : Prop) : Prop
axiom g601 (x : Prop) : Prop
axiom g602 (x : Prop) : Prop
axiom g603 (x : Prop) : Prop
axiom g604 (x : Prop) : Prop
axiom g605 (x : Prop) : Prop
axiom g606 (x : Prop) : Prop
axiom g607 (x : Prop) : Prop
axiom g608 (x : Prop) : Prop
axiom g609 (x : Prop) : Prop
axiom g610 (x : Prop) : Prop
axiom g611 (x : Prop) : Prop
axiom g612 (x : Prop) : Prop
axiom g613 (x : Prop) : Prop
axiom g614 (x : Prop) : Prop
axiom g615 (x : Prop) : Prop
axiom g616 (x : Prop) : Prop
axiom g617 (x : Prop) : Prop
axiom g618 (x : Prop) : Prop
axiom g619 (x : Prop) : Prop
axiom g620 (x : Prop) : Prop
axiom g621 (x : Prop) : Prop
axiom g622 (x : Prop) : Prop
axiom g623 (x : Prop) : Prop
axiom g624 (x : Prop) : Prop
axiom g625 (x : Prop) : Prop
axiom g626 (x : Prop) : Prop
axiom g627 (x : Prop) : Prop
axiom g628 (x : Prop) : Prop
axiom g629 (x : Prop) : Prop
axiom g630 (x : Prop) : Prop
axiom g631 (x : Prop) : Prop
axiom g632 (x : Prop) : Prop
axiom g633 (x : Prop) : Prop
axiom g634 (x : Prop) : Prop
axiom g635 (x : Prop) : Prop
axiom g636 (x : Prop) : Prop
axiom g637 (x : Prop) : Prop
axiom g638 (x : Prop) : Prop
axiom g639 (x : Prop) : Prop
axiom g640 (x : Prop) : Prop
axiom g641 (x : Prop) : Prop
axiom g642 (x : Prop) : Prop
axiom g643 (x : Prop) : Prop
axiom g644 (x : Prop) : Prop
axiom g645 (x : Prop) : Prop
axiom g646 (x : Prop) : Prop
axiom g647 (x : Prop) : Prop
axiom g648 (x : Prop) : Prop
axiom g649 (x : Prop) : Prop
axiom g650 (x : Prop) : Prop
axiom g651 (x : Prop) : Prop
axiom g652 (x : Prop) : Prop
axiom g653 (x : Prop) : Prop
axiom g654 (x : Prop) : Prop
axiom g655 (x : Prop) : Prop
axiom g656 (x : Prop) : Prop
axiom g657 (x : Prop) : Prop
axiom g658 (x : Prop) : Prop
axiom g659 (x : Prop) : Prop
axiom g660 (x : Prop) : Prop
axiom g661 (x : Prop) : Prop
axiom g662 (x : Prop) : Prop
axiom g663 (x : Prop) : Prop
axiom g664 (x : Prop) : Prop
axiom g665 (x : Prop) : Prop
axiom g666 (x : Prop) : Prop
axiom g667 (x : Prop) : Prop
axiom g668 (x : Prop) : Prop
axiom g669 (x : Prop) : Prop
axiom g670 (x : Prop) : Prop
axiom g671 (x : Prop) : Prop
axiom g672 (x : Prop) : Prop
axiom g673 (x : Prop) : Prop
axiom g674 (x : Prop) : Prop
axiom g675 (x : Prop) : Prop
axiom g676 (x : Prop) : Prop
axiom g677 (x : Prop) : Prop
axiom g678 (x : Prop) : Prop
axiom g679 (x : Prop) : Prop
axiom g680 (x : Prop) : Prop
axiom g681 (x : Prop) : Prop
axiom g682 (x : Prop) : Prop
axiom g683 (x : Prop) : Prop
axiom g684 (x : Prop) : Prop
axiom g685 (x : Prop) : Prop
axiom g686 (x : Prop) : Prop
axiom g687 (x : Prop) : Prop
axiom g688 (x : Prop) : Prop
axiom g689 (x : Prop) : Prop
axiom g690 (x : Prop) : Prop
axiom g691 (x : Prop) : Prop
axiom g692 (x : Prop) : Prop
axiom g693 (x : Prop) : Prop
axiom g694 (x : Prop) : Prop
axiom g695 (x : Prop) : Prop
axiom g696 (x : Prop) : Prop
axiom g697 (x : Prop) : Prop
axiom g698 (x : Prop) : Prop
axiom g699 (x : Prop) : Prop
axiom g700 (x : Prop) : Prop
axiom g701 (x : Prop) : Prop
axiom g702 (x : Prop) : Prop
axiom g703 (x : Prop) : Prop
axiom g704 (x : Prop) : Prop
axiom g705 (x : Prop) : Prop
axiom g706 (x : Prop) : Prop
axiom g707 (x : Prop) : Prop
axiom g708 (x : Prop) : Prop
axiom g709 (x : Prop) : Prop
axiom g710 (x : Prop) : Prop
axiom g711 (x : Prop) : Prop
axiom g712 (x : Prop) : Prop
axiom g713 (x : Prop) : Prop
axiom g714 (x : Prop) : Prop
axiom g715 (x : Prop) : Prop
axiom g716 (x : Prop) : Prop
axiom g717 (x : Prop) : Prop
axiom g718 (x : Prop) : Prop
axiom g719 (x : Prop) : Prop
axiom g720 (x : Prop) : Prop
axiom g721 (x : Prop) : Prop
axiom g722 (x : Prop) : Prop
axiom g723 (x : Prop) : Prop
axiom g724 (x : Prop) : Prop
axiom g725 (x : Prop) : Prop
axiom g726 (x : Prop) : Prop
axiom g727 (x : Prop) : Prop
axiom g728 (x : Prop) : Prop
axiom g729 (x : Prop) : Prop
axiom g730 (x : Prop) : Prop
axiom g731 (x : Prop) : Prop
axiom g732 (x : Prop) : Prop
axiom g733 (x : Prop) : Prop
axiom g734 (x : Prop) : Prop
axiom g735 (x : Prop) : Prop
axiom g736 (x : Prop) : Prop
axiom g737 (x : Prop) : Prop
axiom g738 (x : Prop) : Prop
axiom g739 (x : Prop) : Prop
axiom g740 (x : Prop) : Prop
axiom g741 (x : Prop) : Prop
axiom g742 (x : Prop) : Prop
axiom g743 (x : Prop) : Prop
axiom g744 (x : Prop) : Prop
axiom g745 (x : Prop) : Prop
axiom g746 (x : Prop) : Prop
axiom g747 (x : Prop) : Prop
axiom g748 (x : Prop) : Prop
axiom g749 (x : Prop) : Prop
axiom g750 (x : Prop) : Prop
axiom g751 (x : Prop) : Prop
axiom g752 (x : Prop) : Prop
axiom g753 (x : Prop) : Prop
axiom g754 (x : Prop) : Prop
axiom g755 (x : Prop) : Prop
axiom g756 (x : Prop) : Prop
axiom g757 (x : Prop) : Prop
axiom g758 (x : Prop) : Prop
axiom g759 (x : Prop) : Prop
axiom g760 (x : Prop) : Prop
axiom g761 (x : Prop) : Prop
axiom g762 (x : Prop) : Prop
axiom g763 (x : Prop) : Prop
axiom g764 (x : Prop) : Prop
axiom g765 (x : Prop) : Prop
axiom g766 (x : Prop) : Prop
axiom g767 (x : Prop) : Prop
axiom g768 (x : Prop) : Prop
axiom g769 (x : Prop) : Prop
axiom g770 (x : Prop) : Prop
axiom g771 (x : Prop) : Prop
axiom g772 (x : Prop) : Prop
axiom g773 (x : Prop) : Prop
axiom g774 (x : Prop) : Prop
axiom g775 (x : Prop) : Prop
axiom g776 (x : Prop) : Prop
axiom g777 (x : Prop) : Prop
axiom g778 (x : Prop) : Prop
axiom g779 (x : Prop) : Prop
axiom g780 (x : Prop) : Prop
axiom g781 (x : Prop) : Prop
axiom g782 (x : Prop) : Prop
axiom g783 (x : Prop) : Prop
axiom g784 (x : Prop) : Prop
axiom g785 (x : Prop) : Prop
axiom g786 (x : Prop) : Prop
axiom g787 (x : Prop) : Prop
axiom g788 (x : Prop) : Prop
axiom g789 (x : Prop) : Prop
axiom g790 (x : Prop) : Prop
axiom g791 (x : Prop) : Prop
axiom g792 (x : Prop) : Prop
axiom g793 (x : Prop) : Prop
axiom g794 (x : Prop) : Prop
axiom g795 (x : Prop) : Prop
axiom g796 (x : Prop) : Prop
axiom g797 (x : Prop) : Prop
axiom g798 (x : Prop) : Prop
axiom g799 (x : Prop) : Prop
axiom g800 (x : Prop) : Prop
axiom g801 (x : Prop) : Prop
axiom g802 (x : Prop) : Prop
axiom g803 (x : Prop) : Prop
axiom g804 (x : Prop) : Prop
axiom g805 (x : Prop) : Prop
axiom g806 (x : Prop) : Prop
axiom g807 (x : Prop) : Prop
axiom g808 (x : Prop) : Prop
axiom g809 (x : Prop) : Prop
axiom g810 (x : Prop) : Prop
axiom g811 (x : Prop) : Prop
axiom g812 (x : Prop) : Prop
axiom g813 (x : Prop) : Prop
axiom g814 (x : Prop) : Prop
axiom g815 (x : Prop) : Prop
axiom g816 (x : Prop) : Prop
axiom g817 (x : Prop) : Prop
axiom g818 (x : Prop) : Prop
axiom g819 (x : Prop) : Prop
axiom g820 (x : Prop) : Prop
axiom g821 (x : Prop) : Prop
axiom g822 (x : Prop) : Prop
axiom g823 (x : Prop) : Prop
axiom g824 (x : Prop) : Prop
axiom g825 (x : Prop) : Prop
axiom g826 (x : Prop) : Prop
axiom g827 (x : Prop) : Prop
axiom g828 (x : Prop) : Prop
axiom g829 (x : Prop) : Prop
axiom g830 (x : Prop) : Prop
axiom g831 (x : Prop) : Prop
axiom g832 (x : Prop) : Prop
axiom g833 (x : Prop) : Prop
axiom g834 (x : Prop) : Prop
axiom g835 (x : Prop) : Prop
axiom g836 (x : Prop) : Prop
axiom g837 (x : Prop) : Prop
axiom g838 (x : Prop) : Prop
axiom g839 (x : Prop) : Prop
axiom g840 (x : Prop) : Prop
axiom g841 (x : Prop) : Prop
axiom g842 (x : Prop) : Prop
axiom g843 (x : Prop) : Prop
axiom g844 (x : Prop) : Prop
axiom g845 (x : Prop) : Prop
axiom g846 (x : Prop) : Prop
axiom g847 (x : Prop) : Prop
axiom g848 (x : Prop) : Prop
axiom g849 (x : Prop) : Prop
axiom g850 (x : Prop) : Prop
axiom g851 (x : Prop) : Prop
axiom g852 (x : Prop) : Prop
axiom g853 (x : Prop) : Prop
axiom g854 (x : Prop) : Prop
axiom g855 (x : Prop) : Prop
axiom g856 (x : Prop) : Prop
axiom g857 (x : Prop) : Prop
axiom g858 (x : Prop) : Prop
axiom g859 (x : Prop) : Prop
axiom g860 (x : Prop) : Prop
axiom g861 (x : Prop) : Prop
axiom g862 (x : Prop) : Prop
axiom g863 (x : Prop) : Prop
axiom g864 (x : Prop) : Prop
axiom g865 (x : Prop) : Prop
axiom g866 (x : Prop) : Prop
axiom g867 (x : Prop) : Prop
axiom g868 (x : Prop) : Prop
axiom g869 (x : Prop) : Prop
axiom g870 (x : Prop) : Prop
axiom g871 (x : Prop) : Prop
axiom g872 (x : Prop) : Prop
axiom g873 (x : Prop) : Prop
axiom g874 (x : Prop) : Prop
axiom g875 (x : Prop) : Prop
axiom g876 (x : Prop) : Prop
axiom g877 (x : Prop) : Prop
axiom g878 (x : Prop) : Prop
axiom g879 (x : Prop) : Prop
axiom g880 (x : Prop) : Prop
axiom g881 (x : Prop) : Prop
axiom g882 (x : Prop) : Prop
axiom g883 (x : Prop) : Prop
axiom g884 (x : Prop) : Prop
axiom g885 (x : Prop) : Prop
axiom g886 (x : Prop) : Prop
axiom g887 (x : Prop) : Prop
axiom g888 (x : Prop) : Prop
axiom g889 (x : Prop) : Prop
axiom g890 (x : Prop) : Prop
axiom g891 (x : Prop) : Prop
axiom g892 (x : Prop) : Prop
axiom g893 (x : Prop) : Prop
axiom g894 (x : Prop) : Prop
axiom g895 (x : Prop) : Prop
axiom g896 (x : Prop) : Prop
axiom g897 (x : Prop) : Prop
axiom g898 (x : Prop) : Prop
axiom g899 (x : Prop) : Prop
axiom g900 (x : Prop) : Prop
axiom g901 (x : Prop) : Prop
axiom g902 (x : Prop) : Prop
axiom g903 (x : Prop) : Prop
axiom g904 (x : Prop) : Prop
axiom g905 (x : Prop) : Prop
axiom g906 (x : Prop) : Prop
axiom g907 (x : Prop) : Prop
axiom g908 (x : Prop) : Prop
axiom g909 (x : Prop) : Prop
axiom g910 (x : Prop) : Prop
axiom g911 (x : Prop) : Prop
axiom g912 (x : Prop) : Prop
axiom g913 (x : Prop) : Prop
axiom g914 (x : Prop) : Prop
axiom g915 (x : Prop) : Prop
axiom g916 (x : Prop) : Prop
axiom g917 (x : Prop) : Prop
axiom g918 (x : Prop) : Prop
axiom g919 (x : Prop) : Prop
axiom g920 (x : Prop) : Prop
axiom g921 (x : Prop) : Prop
axiom g922 (x : Prop) : Prop
axiom g923 (x : Prop) : Prop
axiom g924 (x : Prop) : Prop
axiom g925 (x : Prop) : Prop
axiom g926 (x : Prop) : Prop
axiom g927 (x : Prop) : Prop
axiom g928 (x : Prop) : Prop
axiom g929 (x : Prop) : Prop
axiom g930 (x : Prop) : Prop
axiom g931 (x : Prop) : Prop
axiom g932 (x : Prop) : Prop
axiom g933 (x : Prop) : Prop
axiom g934 (x : Prop) : Prop
axiom g935 (x : Prop) : Prop
axiom g936 (x : Prop) : Prop
axiom g937 (x : Prop) : Prop
axiom g938 (x : Prop) : Prop
axiom g939 (x : Prop) : Prop
axiom g940 (x : Prop) : Prop
axiom g941 (x : Prop) : Prop
axiom g942 (x : Prop) : Prop
axiom g943 (x : Prop) : Prop
axiom g944 (x : Prop) : Prop
axiom g945 (x : Prop) : Prop
axiom g946 (x : Prop) : Prop
axiom g947 (x : Prop) : Prop
axiom g948 (x : Prop) : Prop
axiom g949 (x : Prop) : Prop
axiom g950 (x : Prop) : Prop
axiom g951 (x : Prop) : Prop
axiom g952 (x : Prop) : Prop
axiom g953 (x : Prop) : Prop
axiom g954 (x : Prop) : Prop
axiom g955 (x : Prop) : Prop
axiom g956 (x : Prop) : Prop
axiom g957 (x : Prop) : Prop
axiom g958 (x : Prop) : Prop
axiom g959 (x : Prop) : Prop
axiom g960 (x : Prop) : Prop
axiom g961 (x : Prop) : Prop
axiom g962 (x : Prop) : Prop
axiom g963 (x : Prop) : Prop
axiom g964 (x : Prop) : Prop
axiom g965 (x : Prop) : Prop
axiom g966 (x : Prop) : Prop
axiom g967 (x : Prop) : Prop
axiom g968 (x : Prop) : Prop
axiom g969 (x : Prop) : Prop
axiom g970 (x : Prop) : Prop
axiom g971 (x : Prop) : Prop
axiom g972 (x : Prop) : Prop
axiom g973 (x : Prop) : Prop
axiom g974 (x : Prop) : Prop
axiom g975 (x : Prop) : Prop
axiom g976 (x : Prop) : Prop
axiom g977 (x : Prop) : Prop
axiom g978 (x : Prop) : Prop
axiom g979 (x : Prop) : Prop
axiom g980 (x : Prop) : Prop
axiom g981 (x : Prop) : Prop
axiom g982 (x : Prop) : Prop
axiom g983 (x : Prop) : Prop
axiom g984 (x : Prop) : Prop
axiom g985 (x : Prop) : Prop
axiom g986 (x : Prop) : Prop
axiom g987 (x : Prop) : Prop
axiom g988 (x : Prop) : Prop
axiom g989 (x : Prop) : Prop
axiom g990 (x : Prop) : Prop
axiom g991 (x : Prop) : Prop
axiom g992 (x : Prop) : Prop
axiom g993 (x : Prop) : Prop
axiom g994 (x : Prop) : Prop
axiom g995 (x : Prop) : Prop
axiom g996 (x : Prop) : Prop
axiom g997 (x : Prop) : Prop
axiom g998 (x : Prop) : Prop
axiom g999 (x : Prop) : Prop
axiom g1000 (x : Prop) : Prop
axiom g1001 (x : Prop) : Prop
axiom g1002 (x : Prop) : Prop
axiom g1003 (x : Prop) : Prop
axiom g1004 (x : Prop) : Prop
axiom g1005 (x : Prop) : Prop
axiom g1006 (x : Prop) : Prop
axiom g1007 (x : Prop) : Prop
axiom g1008 (x : Prop) : Prop
axiom g1009 (x : Prop) : Prop
axiom g1010 (x : Prop) : Prop
axiom g1011 (x : Prop) : Prop
axiom g1012 (x : Prop) : Prop
axiom g1013 (x : Prop) : Prop
axiom g1014 (x : Prop) : Prop
axiom g1015 (x : Prop) : Prop
axiom g1016 (x : Prop) : Prop
axiom g1017 (x : Prop) : Prop
axiom g1018 (x : Prop) : Prop
axiom g1019 (x : Prop) : Prop
axiom g1020 (x : Prop) : Prop
axiom g1021 (x : Prop) : Prop
axiom g1022 (x : Prop) : Prop
axiom g1023 (x : Prop) : Prop
axiom g1024 (x : Prop) : Prop
axiom g1025 (x : Prop) : Prop
axiom g1026 (x : Prop) : Prop
axiom g1027 (x : Prop) : Prop
axiom g1028 (x : Prop) : Prop
axiom g1029 (x : Prop) : Prop
axiom g1030 (x : Prop) : Prop
axiom g1031 (x : Prop) : Prop
axiom g1032 (x : Prop) : Prop
axiom g1033 (x : Prop) : Prop
axiom g1034 (x : Prop) : Prop
axiom g1035 (x : Prop) : Prop
axiom g1036 (x : Prop) : Prop
axiom g1037 (x : Prop) : Prop
axiom g1038 (x : Prop) : Prop
axiom g1039 (x : Prop) : Prop
axiom g1040 (x : Prop) : Prop
axiom g1041 (x : Prop) : Prop
axiom g1042 (x : Prop) : Prop
axiom g1043 (x : Prop) : Prop
axiom g1044 (x : Prop) : Prop
axiom g1045 (x : Prop) : Prop
axiom g1046 (x : Prop) : Prop
axiom g1047 (x : Prop) : Prop
axiom g1048 (x : Prop) : Prop
axiom g1049 (x : Prop) : Prop
axiom g1050 (x : Prop) : Prop
axiom g1051 (x : Prop) : Prop
axiom g1052 (x : Prop) : Prop
axiom g1053 (x : Prop) : Prop
axiom g1054 (x : Prop) : Prop
axiom g1055 (x : Prop) : Prop
axiom g1056 (x : Prop) : Prop
axiom g1057 (x : Prop) : Prop
axiom g1058 (x : Prop) : Prop
axiom g1059 (x : Prop) : Prop
axiom g1060 (x : Prop) : Prop
axiom g1061 (x : Prop) : Prop
axiom g1062 (x : Prop) : Prop
axiom g1063 (x : Prop) : Prop
axiom g1064 (x : Prop) : Prop
axiom g1065 (x : Prop) : Prop
axiom g1066 (x : Prop) : Prop
axiom g1067 (x : Prop) : Prop
axiom g1068 (x : Prop) : Prop
axiom g1069 (x : Prop) : Prop
axiom g1070 (x : Prop) : Prop
axiom g1071 (x : Prop) : Prop
axiom g1072 (x : Prop) : Prop
axiom g1073 (x : Prop) : Prop
axiom g1074 (x : Prop) : Prop
axiom g1075 (x : Prop) : Prop
axiom g1076 (x : Prop) : Prop
axiom g1077 (x : Prop) : Prop
axiom g1078 (x : Prop) : Prop
axiom g1079 (x : Prop) : Prop
axiom g1080 (x : Prop) : Prop
axiom g1081 (x : Prop) : Prop
axiom g1082 (x : Prop) : Prop
axiom g1083 (x : Prop) : Prop
axiom g1084 (x : Prop) : Prop
axiom g1085 (x : Prop) : Prop
axiom g1086 (x : Prop) : Prop
axiom g1087 (x : Prop) : Prop
axiom g1088 (x : Prop) : Prop
axiom g1089 (x : Prop) : Prop
axiom g1090 (x : Prop) : Prop
axiom g1091 (x : Prop) : Prop
axiom g1092 (x : Prop) : Prop
axiom g1093 (x : Prop) : Prop
axiom g1094 (x : Prop) : Prop
axiom g1095 (x : Prop) : Prop
axiom g1096 (x : Prop) : Prop
axiom g1097 (x : Prop) : Prop
axiom g1098 (x : Prop) : Prop
axiom g1099 (x : Prop) : Prop
axiom g1100 (x : Prop) : Prop
axiom g1101 (x : Prop) : Prop
axiom g1102 (x : Prop) : Prop
axiom g1103 (x : Prop) : Prop
axiom g1104 (x : Prop) : Prop
axiom g1105 (x : Prop) : Prop
axiom g1106 (x : Prop) : Prop
axiom g1107 (x : Prop) : Prop
axiom g1108 (x : Prop) : Prop
axiom g1109 (x : Prop) : Prop
axiom g1110 (x : Prop) : Prop
axiom g1111 (x : Prop) : Prop
axiom g1112 (x : Prop) : Prop
axiom g1113 (x : Prop) : Prop
axiom g1114 (x : Prop) : Prop
axiom g1115 (x : Prop) : Prop
axiom g1116 (x : Prop) : Prop
axiom g1117 (x : Prop) : Prop
axiom g1118 (x : Prop) : Prop
axiom g1119 (x : Prop) : Prop
axiom g1120 (x : Prop) : Prop
axiom g1121 (x : Prop) : Prop
axiom g1122 (x : Prop) : Prop
axiom g1123 (x : Prop) : Prop
axiom g1124 (x : Prop) : Prop
axiom g1125 (x : Prop) : Prop
axiom g1126 (x : Prop) : Prop
axiom g1127 (x : Prop) : Prop
axiom g1128 (x : Prop) : Prop
axiom g1129 (x : Prop) : Prop
axiom g1130 (x : Prop) : Prop
axiom g1131 (x : Prop) : Prop
axiom g1132 (x : Prop) : Prop
axiom g1133 (x : Prop) : Prop
axiom g1134 (x : Prop) : Prop
axiom g1135 (x : Prop) : Prop
axiom g1136 (x : Prop) : Prop
axiom g1137 (x : Prop) : Prop
axiom g1138 (x : Prop) : Prop
axiom g1139 (x : Prop) : Prop
axiom g1140 (x : Prop) : Prop
axiom g1141 (x : Prop) : Prop
axiom g1142 (x : Prop) : Prop
axiom g1143 (x : Prop) : Prop
axiom g1144 (x : Prop) : Prop
axiom g1145 (x : Prop) : Prop
axiom g1146 (x : Prop) : Prop
axiom g1147 (x : Prop) : Prop
axiom g1148 (x : Prop) : Prop
axiom g1149 (x : Prop) : Prop
axiom g1150 (x : Prop) : Prop
axiom g1151 (x : Prop) : Prop
axiom g1152 (x : Prop) : Prop
axiom g1153 (x : Prop) : Prop
axiom g1154 (x : Prop) : Prop
axiom g1155 (x : Prop) : Prop
axiom g1156 (x : Prop) : Prop
axiom g1157 (x : Prop) : Prop
axiom g1158 (x : Prop) : Prop
axiom g1159 (x : Prop) : Prop
axiom g1160 (x : Prop) : Prop
axiom g1161 (x : Prop) : Prop
axiom g1162 (x : Prop) : Prop
axiom g1163 (x : Prop) : Prop
axiom g1164 (x : Prop) : Prop
axiom g1165 (x : Prop) : Prop
axiom g1166 (x : Prop) : Prop
axiom g1167 (x : Prop) : Prop
axiom g1168 (x : Prop) : Prop
axiom g1169 (x : Prop) : Prop
axiom g1170 (x : Prop) : Prop
axiom g1171 (x : Prop) : Prop
axiom g1172 (x : Prop) : Prop
axiom g1173 (x : Prop) : Prop
axiom g1174 (x : Prop) : Prop
axiom g1175 (x : Prop) : Prop
axiom g1176 (x : Prop) : Prop
axiom g1177 (x : Prop) : Prop
axiom g1178 (x : Prop) : Prop
axiom g1179 (x : Prop) : Prop
axiom g1180 (x : Prop) : Prop
axiom g1181 (x : Prop) : Prop
axiom g1182 (x : Prop) : Prop
axiom g1183 (x : Prop) : Prop
axiom g1184 (x : Prop) : Prop
axiom g1185 (x : Prop) : Prop
axiom g1186 (x : Prop) : Prop
axiom g1187 (x : Prop) : Prop
axiom g1188 (x : Prop) : Prop
axiom g1189 (x : Prop) : Prop
axiom g1190 (x : Prop) : Prop
axiom g1191 (x : Prop) : Prop
axiom g1192 (x : Prop) : Prop
axiom g1193 (x : Prop) : Prop
axiom g1194 (x : Prop) : Prop
axiom g1195 (x : Prop) : Prop
axiom g1196 (x : Prop) : Prop
axiom g1197 (x : Prop) : Prop
axiom g1198 (x : Prop) : Prop
axiom g1199 (x : Prop) : Prop
axiom g1200 (x : Prop) : Prop
axiom g1201 (x : Prop) : Prop
axiom g1202 (x : Prop) : Prop
axiom g1203 (x : Prop) : Prop
axiom g1204 (x : Prop) : Prop
axiom g1205 (x : Prop) : Prop
axiom g1206 (x : Prop) : Prop
axiom g1207 (x : Prop) : Prop
axiom g1208 (x : Prop) : Prop
axiom g1209 (x : Prop) : Prop
axiom g1210 (x : Prop) : Prop
axiom g1211 (x : Prop) : Prop
axiom g1212 (x : Prop) : Prop
axiom g1213 (x : Prop) : Prop
axiom g1214 (x : Prop) : Prop
axiom g1215 (x : Prop) : Prop
axiom g1216 (x : Prop) : Prop
axiom g1217 (x : Prop) : Prop
axiom g1218 (x : Prop) : Prop
axiom g1219 (x : Prop) : Prop
axiom g1220 (x : Prop) : Prop
axiom g1221 (x : Prop) : Prop
axiom g1222 (x : Prop) : Prop
axiom g1223 (x : Prop) : Prop
axiom g1224 (x : Prop) : Prop
axiom g1225 (x : Prop) : Prop
axiom g1226 (x : Prop) : Prop
axiom g1227 (x : Prop) : Prop
axiom g1228 (x : Prop) : Prop
axiom g1229 (x : Prop) : Prop
axiom g1230 (x : Prop) : Prop
axiom g1231 (x : Prop) : Prop
axiom g1232 (x : Prop) : Prop
axiom g1233 (x : Prop) : Prop
axiom g1234 (x : Prop) : Prop
axiom g1235 (x : Prop) : Prop
axiom g1236 (x : Prop) : Prop
axiom g1237 (x : Prop) : Prop
axiom g1238 (x : Prop) : Prop
axiom g1239 (x : Prop) : Prop
axiom g1240 (x : Prop) : Prop
axiom g1241 (x : Prop) : Prop
axiom g1242 (x : Prop) : Prop
axiom g1243 (x : Prop) : Prop
axiom g1244 (x : Prop) : Prop
axiom g1245 (x : Prop) : Prop
axiom g1246 (x : Prop) : Prop
axiom g1247 (x : Prop) : Prop
axiom g1248 (x : Prop) : Prop
axiom g1249 (x : Prop) : Prop
axiom g1250 (x : Prop) : Prop
axiom g1251 (x : Prop) : Prop
axiom g1252 (x : Prop) : Prop
axiom g1253 (x : Prop) : Prop
axiom g1254 (x : Prop) : Prop
axiom g1255 (x : Prop) : Prop
axiom g1256 (x : Prop) : Prop
axiom g1257 (x : Prop) : Prop
axiom g1258 (x : Prop) : Prop
axiom g1259 (x : Prop) : Prop
axiom g1260 (x : Prop) : Prop
axiom g1261 (x : Prop) : Prop
axiom g1262 (x : Prop) : Prop
axiom g1263 (x : Prop) : Prop
axiom g1264 (x : Prop) : Prop
axiom g1265 (x : Prop) : Prop
axiom g1266 (x : Prop) : Prop
axiom g1267 (x : Prop) : Prop
axiom g1268 (x : Prop) : Prop
axiom g1269 (x : Prop) : Prop
axiom g1270 (x : Prop) : Prop
axiom g1271 (x : Prop) : Prop
axiom g1272 (x : Prop) : Prop
axiom g1273 (x : Prop) : Prop
axiom g1274 (x : Prop) : Prop
axiom g1275 (x : Prop) : Prop
axiom g1276 (x : Prop) : Prop
axiom g1277 (x : Prop) : Prop
axiom g1278 (x : Prop) : Prop
axiom g1279 (x : Prop) : Prop
axiom g1280 (x : Prop) : Prop
axiom g1281 (x : Prop) : Prop
axiom g1282 (x : Prop) : Prop
axiom g1283 (x : Prop) : Prop
axiom g1284 (x : Prop) : Prop
axiom g1285 (x : Prop) : Prop
axiom g1286 (x : Prop) : Prop
axiom g1287 (x : Prop) : Prop
axiom g1288 (x : Prop) : Prop
axiom g1289 (x : Prop) : Prop
axiom g1290 (x : Prop) : Prop
axiom g1291 (x : Prop) : Prop
axiom g1292 (x : Prop) : Prop
axiom g1293 (x : Prop) : Prop
axiom g1294 (x : Prop) : Prop
axiom g1295 (x : Prop) : Prop
axiom g1296 (x : Prop) : Prop
axiom g1297 (x : Prop) : Prop
axiom g1298 (x : Prop) : Prop
axiom g1299 (x : Prop) : Prop
axiom g1300 (x : Prop) : Prop
axiom g1301 (x : Prop) : Prop
axiom g1302 (x : Prop) : Prop
axiom g1303 (x : Prop) : Prop
axiom g1304 (x : Prop) : Prop
axiom g1305 (x : Prop) : Prop
axiom g1306 (x : Prop) : Prop
axiom g1307 (x : Prop) : Prop
axiom g1308 (x : Prop) : Prop
axiom g1309 (x : Prop) : Prop
axiom g1310 (x : Prop) : Prop
axiom g1311 (x : Prop) : Prop
axiom g1312 (x : Prop) : Prop
axiom g1313 (x : Prop) : Prop
axiom g1314 (x : Prop) : Prop
axiom g1315 (x : Prop) : Prop
axiom g1316 (x : Prop) : Prop
axiom g1317 (x : Prop) : Prop
axiom g1318 (x : Prop) : Prop
axiom g1319 (x : Prop) : Prop
axiom g1320 (x : Prop) : Prop
axiom g1321 (x : Prop) : Prop
axiom g1322 (x : Prop) : Prop
axiom g1323 (x : Prop) : Prop
axiom g1324 (x : Prop) : Prop
axiom g1325 (x : Prop) : Prop
axiom g1326 (x : Prop) : Prop
axiom g1327 (x : Prop) : Prop
axiom g1328 (x : Prop) : Prop
axiom g1329 (x : Prop) : Prop
axiom g1330 (x : Prop) : Prop
axiom g1331 (x : Prop) : Prop
axiom g1332 (x : Prop) : Prop
axiom g1333 (x : Prop) : Prop
axiom g1334 (x : Prop) : Prop
axiom g1335 (x : Prop) : Prop
axiom g1336 (x : Prop) : Prop
axiom g1337 (x : Prop) : Prop
axiom g1338 (x : Prop) : Prop
axiom g1339 (x : Prop) : Prop
axiom g1340 (x : Prop) : Prop
axiom g1341 (x : Prop) : Prop
axiom g1342 (x : Prop) : Prop
axiom g1343 (x : Prop) : Prop
axiom g1344 (x : Prop) : Prop
axiom g1345 (x : Prop) : Prop
axiom g1346 (x : Prop) : Prop
axiom g1347 (x : Prop) : Prop
axiom g1348 (x : Prop) : Prop
axiom g1349 (x : Prop) : Prop
axiom g1350 (x : Prop) : Prop
axiom g1351 (x : Prop) : Prop
axiom g1352 (x : Prop) : Prop
axiom g1353 (x : Prop) : Prop
axiom g1354 (x : Prop) : Prop
axiom g1355 (x : Prop) : Prop
axiom g1356 (x : Prop) : Prop
axiom g1357 (x : Prop) : Prop
axiom g1358 (x : Prop) : Prop
axiom g1359 (x : Prop) : Prop
axiom g1360 (x : Prop) : Prop
axiom g1361 (x : Prop) : Prop
axiom g1362 (x : Prop) : Prop
axiom g1363 (x : Prop) : Prop
axiom g1364 (x : Prop) : Prop
axiom g1365 (x : Prop) : Prop
axiom g1366 (x : Prop) : Prop
axiom g1367 (x : Prop) : Prop
axiom g1368 (x : Prop) : Prop
axiom g1369 (x : Prop) : Prop
axiom g1370 (x : Prop) : Prop
axiom g1371 (x : Prop) : Prop
axiom g1372 (x : Prop) : Prop
axiom g1373 (x : Prop) : Prop
axiom g1374 (x : Prop) : Prop
axiom g1375 (x : Prop) : Prop
axiom g1376 (x : Prop) : Prop
axiom g1377 (x : Prop) : Prop
axiom g1378 (x : Prop) : Prop
axiom g1379 (x : Prop) : Prop
axiom g1380 (x : Prop) : Prop
axiom g1381 (x : Prop) : Prop
axiom g1382 (x : Prop) : Prop
axiom g1383 (x : Prop) : Prop
axiom g1384 (x : Prop) : Prop
axiom g1385 (x : Prop) : Prop
axiom g1386 (x : Prop) : Prop
axiom g1387 (x : Prop) : Prop
axiom g1388 (x : Prop) : Prop
axiom g1389 (x : Prop) : Prop
axiom g1390 (x : Prop) : Prop
axiom g1391 (x : Prop) : Prop
axiom g1392 (x : Prop) : Prop
axiom g1393 (x : Prop) : Prop
axiom g1394 (x : Prop) : Prop
axiom g1395 (x : Prop) : Prop
axiom g1396 (x : Prop) : Prop
axiom g1397 (x : Prop) : Prop
axiom g1398 (x : Prop) : Prop
axiom g1399 (x : Prop) : Prop
axiom g1400 (x : Prop) : Prop
axiom g1401 (x : Prop) : Prop
axiom g1402 (x : Prop) : Prop
axiom g1403 (x : Prop) : Prop
axiom g1404 (x : Prop) : Prop
axiom g1405 (x : Prop) : Prop
axiom g1406 (x : Prop) : Prop
axiom g1407 (x : Prop) : Prop
axiom g1408 (x : Prop) : Prop
axiom g1409 (x : Prop) : Prop
axiom g1410 (x : Prop) : Prop
axiom g1411 (x : Prop) : Prop
axiom g1412 (x : Prop) : Prop
axiom g1413 (x : Prop) : Prop
axiom g1414 (x : Prop) : Prop
axiom g1415 (x : Prop) : Prop
axiom g1416 (x : Prop) : Prop
axiom g1417 (x : Prop) : Prop
axiom g1418 (x : Prop) : Prop
axiom g1419 (x : Prop) : Prop
axiom g1420 (x : Prop) : Prop
axiom g1421 (x : Prop) : Prop
axiom g1422 (x : Prop) : Prop
axiom g1423 (x : Prop) : Prop
axiom g1424 (x : Prop) : Prop
axiom g1425 (x : Prop) : Prop
axiom g1426 (x : Prop) : Prop
axiom g1427 (x : Prop) : Prop
axiom g1428 (x : Prop) : Prop
axiom g1429 (x : Prop) : Prop
axiom g1430 (x : Prop) : Prop
axiom g1431 (x : Prop) : Prop
axiom g1432 (x : Prop) : Prop
axiom g1433 (x : Prop) : Prop
axiom g1434 (x : Prop) : Prop
axiom g1435 (x : Prop) : Prop
axiom g1436 (x : Prop) : Prop
axiom g1437 (x : Prop) : Prop
axiom g1438 (x : Prop) : Prop
axiom g1439 (x : Prop) : Prop
axiom g1440 (x : Prop) : Prop
axiom g1441 (x : Prop) : Prop
axiom g1442 (x : Prop) : Prop
axiom g1443 (x : Prop) : Prop
axiom g1444 (x : Prop) : Prop
axiom g1445 (x : Prop) : Prop
axiom g1446 (x : Prop) : Prop
axiom g1447 (x : Prop) : Prop
axiom g1448 (x : Prop) : Prop
axiom g1449 (x : Prop) : Prop
axiom g1450 (x : Prop) : Prop
axiom g1451 (x : Prop) : Prop
axiom g1452 (x : Prop) : Prop
axiom g1453 (x : Prop) : Prop
axiom g1454 (x : Prop) : Prop
axiom g1455 (x : Prop) : Prop
axiom g1456 (x : Prop) : Prop
axiom g1457 (x : Prop) : Prop
axiom g1458 (x : Prop) : Prop
axiom g1459 (x : Prop) : Prop
axiom g1460 (x : Prop) : Prop
axiom g1461 (x : Prop) : Prop
axiom g1462 (x : Prop) : Prop
axiom g1463 (x : Prop) : Prop
axiom g1464 (x : Prop) : Prop
axiom g1465 (x : Prop) : Prop
axiom g1466 (x : Prop) : Prop
axiom g1467 (x : Prop) : Prop
axiom g1468 (x : Prop) : Prop
axiom g1469 (x : Prop) : Prop
axiom g1470 (x : Prop) : Prop
axiom g1471 (x : Prop) : Prop
axiom g1472 (x : Prop) : Prop
axiom g1473 (x : Prop) : Prop
axiom g1474 (x : Prop) : Prop
axiom g1475 (x : Prop) : Prop
axiom g1476 (x : Prop) : Prop
axiom g1477 (x : Prop) : Prop
axiom g1478 (x : Prop) : Prop
axiom g1479 (x : Prop) : Prop
axiom g1480 (x : Prop) : Prop
axiom g1481 (x : Prop) : Prop
axiom g1482 (x : Prop) : Prop
axiom g1483 (x : Prop) : Prop
axiom g1484 (x : Prop) : Prop
axiom g1485 (x : Prop) : Prop
axiom g1486 (x : Prop) : Prop
axiom g1487 (x : Prop) : Prop
axiom g1488 (x : Prop) : Prop
axiom g1489 (x : Prop) : Prop
axiom g1490 (x : Prop) : Prop
axiom g1491 (x : Prop) : Prop
axiom g1492 (x : Prop) : Prop
axiom g1493 (x : Prop) : Prop
axiom g1494 (x : Prop) : Prop
axiom g1495 (x : Prop) : Prop
axiom g1496 (x : Prop) : Prop
axiom g1497 (x : Prop) : Prop
axiom g1498 (x : Prop) : Prop
axiom g1499 (x : Prop) : Prop
axiom g1500 (x : Prop) : Prop
axiom g1501 (x : Prop) : Prop
axiom g1502 (x : Prop) : Prop
axiom g1503 (x : Prop) : Prop
axiom g1504 (x : Prop) : Prop
axiom g1505 (x : Prop) : Prop
axiom g1506 (x : Prop) : Prop
axiom g1507 (x : Prop) : Prop
axiom g1508 (x : Prop) : Prop
axiom g1509 (x : Prop) : Prop
axiom g1510 (x : Prop) : Prop
axiom g1511 (x : Prop) : Prop
axiom g1512 (x : Prop) : Prop
axiom g1513 (x : Prop) : Prop
axiom g1514 (x : Prop) : Prop
axiom g1515 (x : Prop) : Prop
axiom g1516 (x : Prop) : Prop
axiom g1517 (x : Prop) : Prop
axiom g1518 (x : Prop) : Prop
axiom g1519 (x : Prop) : Prop
axiom g1520 (x : Prop) : Prop
axiom g1521 (x : Prop) : Prop
axiom g1522 (x : Prop) : Prop
axiom g1523 (x : Prop) : Prop
axiom g1524 (x : Prop) : Prop
axiom g1525 (x : Prop) : Prop
axiom g1526 (x : Prop) : Prop
axiom g1527 (x : Prop) : Prop
axiom g1528 (x : Prop) : Prop
axiom g1529 (x : Prop) : Prop
axiom g1530 (x : Prop) : Prop
axiom g1531 (x : Prop) : Prop
axiom g1532 (x : Prop) : Prop
axiom g1533 (x : Prop) : Prop
axiom g1534 (x : Prop) : Prop
axiom g1535 (x : Prop) : Prop
axiom g1536 (x : Prop) : Prop
axiom g1537 (x : Prop) : Prop
axiom g1538 (x : Prop) : Prop
axiom g1539 (x : Prop) : Prop
axiom g1540 (x : Prop) : Prop
axiom g1541 (x : Prop) : Prop
axiom g1542 (x : Prop) : Prop
axiom g1543 (x : Prop) : Prop
axiom g1544 (x : Prop) : Prop
axiom g1545 (x : Prop) : Prop
axiom g1546 (x : Prop) : Prop
axiom g1547 (x : Prop) : Prop
axiom g1548 (x : Prop) : Prop
axiom g1549 (x : Prop) : Prop
axiom g1550 (x : Prop) : Prop
axiom g1551 (x : Prop) : Prop
axiom g1552 (x : Prop) : Prop
axiom g1553 (x : Prop) : Prop
axiom g1554 (x : Prop) : Prop
axiom g1555 (x : Prop) : Prop
axiom g1556 (x : Prop) : Prop
axiom g1557 (x : Prop) : Prop
axiom g1558 (x : Prop) : Prop
axiom g1559 (x : Prop) : Prop
axiom g1560 (x : Prop) : Prop
axiom g1561 (x : Prop) : Prop
axiom g1562 (x : Prop) : Prop
axiom g1563 (x : Prop) : Prop
axiom g1564 (x : Prop) : Prop
axiom g1565 (x : Prop) : Prop
axiom g1566 (x : Prop) : Prop
axiom g1567 (x : Prop) : Prop
axiom g1568 (x : Prop) : Prop
axiom g1569 (x : Prop) : Prop
axiom g1570 (x : Prop) : Prop
axiom g1571 (x : Prop) : Prop
axiom g1572 (x : Prop) : Prop
axiom g1573 (x : Prop) : Prop
axiom g1574 (x : Prop) : Prop
axiom g1575 (x : Prop) : Prop
axiom g1576 (x : Prop) : Prop
axiom g1577 (x : Prop) : Prop
axiom g1578 (x : Prop) : Prop
axiom g1579 (x : Prop) : Prop
axiom g1580 (x : Prop) : Prop
axiom g1581 (x : Prop) : Prop
axiom g1582 (x : Prop) : Prop
axiom g1583 (x : Prop) : Prop
axiom g1584 (x : Prop) : Prop
axiom g1585 (x : Prop) : Prop
axiom g1586 (x : Prop) : Prop
axiom g1587 (x : Prop) : Prop
axiom g1588 (x : Prop) : Prop
axiom g1589 (x : Prop) : Prop
axiom g1590 (x : Prop) : Prop
axiom g1591 (x : Prop) : Prop
axiom g1592 (x : Prop) : Prop
axiom g1593 (x : Prop) : Prop
axiom g1594 (x : Prop) : Prop
axiom g1595 (x : Prop) : Prop
axiom g1596 (x : Prop) : Prop
axiom g1597 (x : Prop) : Prop
axiom g1598 (x : Prop) : Prop
axiom g1599 (x : Prop) : Prop
axiom g1600 (x : Prop) : Prop
axiom g1601 (x : Prop) : Prop
axiom g1602 (x : Prop) : Prop
axiom g1603 (x : Prop) : Prop
axiom g1604 (x : Prop) : Prop
axiom g1605 (x : Prop) : Prop
axiom g1606 (x : Prop) : Prop
axiom g1607 (x : Prop) : Prop
axiom g1608 (x : Prop) : Prop
axiom g1609 (x : Prop) : Prop
axiom g1610 (x : Prop) : Prop
axiom g1611 (x : Prop) : Prop
axiom g1612 (x : Prop) : Prop
axiom g1613 (x : Prop) : Prop
axiom g1614 (x : Prop) : Prop
axiom g1615 (x : Prop) : Prop
axiom g1616 (x : Prop) : Prop
axiom g1617 (x : Prop) : Prop
axiom g1618 (x : Prop) : Prop
axiom g1619 (x : Prop) : Prop
axiom g1620 (x : Prop) : Prop
axiom g1621 (x : Prop) : Prop
axiom g1622 (x : Prop) : Prop
axiom g1623 (x : Prop) : Prop
axiom g1624 (x : Prop) : Prop
axiom g1625 (x : Prop) : Prop
axiom g1626 (x : Prop) : Prop
axiom g1627 (x : Prop) : Prop
axiom g1628 (x : Prop) : Prop
axiom g1629 (x : Prop) : Prop
axiom g1630 (x : Prop) : Prop
axiom g1631 (x : Prop) : Prop
axiom g1632 (x : Prop) : Prop
axiom g1633 (x : Prop) : Prop
axiom g1634 (x : Prop) : Prop
axiom g1635 (x : Prop) : Prop
axiom g1636 (x : Prop) : Prop
axiom g1637 (x : Prop) : Prop
axiom g1638 (x : Prop) : Prop
axiom g1639 (x : Prop) : Prop
axiom g1640 (x : Prop) : Prop
axiom g1641 (x : Prop) : Prop
axiom g1642 (x : Prop) : Prop
axiom g1643 (x : Prop) : Prop
axiom g1644 (x : Prop) : Prop
axiom g1645 (x : Prop) : Prop
axiom g1646 (x : Prop) : Prop
axiom g1647 (x : Prop) : Prop
axiom g1648 (x : Prop) : Prop
axiom g1649 (x : Prop) : Prop
axiom g1650 (x : Prop) : Prop
axiom g1651 (x : Prop) : Prop
axiom g1652 (x : Prop) : Prop
axiom g1653 (x : Prop) : Prop
axiom g1654 (x : Prop) : Prop
axiom g1655 (x : Prop) : Prop
axiom g1656 (x : Prop) : Prop
axiom g1657 (x : Prop) : Prop
axiom g1658 (x : Prop) : Prop
axiom g1659 (x : Prop) : Prop
axiom g1660 (x : Prop) : Prop
axiom g1661 (x : Prop) : Prop
axiom g1662 (x : Prop) : Prop
axiom g1663 (x : Prop) : Prop
axiom g1664 (x : Prop) : Prop
axiom g1665 (x : Prop) : Prop
axiom g1666 (x : Prop) : Prop
axiom g1667 (x : Prop) : Prop
axiom g1668 (x : Prop) : Prop
axiom g1669 (x : Prop) : Prop
axiom g1670 (x : Prop) : Prop
axiom g1671 (x : Prop) : Prop
axiom g1672 (x : Prop) : Prop
axiom g1673 (x : Prop) : Prop
axiom g1674 (x : Prop) : Prop
axiom g1675 (x : Prop) : Prop
axiom g1676 (x : Prop) : Prop
axiom g1677 (x : Prop) : Prop
axiom g1678 (x : Prop) : Prop
axiom g1679 (x : Prop) : Prop
axiom g1680 (x : Prop) : Prop
axiom g1681 (x : Prop) : Prop
axiom g1682 (x : Prop) : Prop
axiom g1683 (x : Prop) : Prop
axiom g1684 (x : Prop) : Prop
axiom g1685 (x : Prop) : Prop
axiom g1686 (x : Prop) : Prop
axiom g1687 (x : Prop) : Prop
axiom g1688 (x : Prop) : Prop
axiom g1689 (x : Prop) : Prop
axiom g1690 (x : Prop) : Prop
axiom g1691 (x : Prop) : Prop
axiom g1692 (x : Prop) : Prop
axiom g1693 (x : Prop) : Prop
axiom g1694 (x : Prop) : Prop
axiom g1695 (x : Prop) : Prop
axiom g1696 (x : Prop) : Prop
axiom g1697 (x : Prop) : Prop
axiom g1698 (x : Prop) : Prop
axiom g1699 (x : Prop) : Prop
axiom g1700 (x : Prop) : Prop
axiom g1701 (x : Prop) : Prop
axiom g1702 (x : Prop) : Prop
axiom g1703 (x : Prop) : Prop
axiom g1704 (x : Prop) : Prop
axiom g1705 (x : Prop) : Prop
axiom g1706 (x : Prop) : Prop
axiom g1707 (x : Prop) : Prop
axiom g1708 (x : Prop) : Prop
axiom g1709 (x : Prop) : Prop
axiom g1710 (x : Prop) : Prop
axiom g1711 (x : Prop) : Prop
axiom g1712 (x : Prop) : Prop
axiom g1713 (x : Prop) : Prop
axiom g1714 (x : Prop) : Prop
axiom g1715 (x : Prop) : Prop
axiom g1716 (x : Prop) : Prop
axiom g1717 (x : Prop) : Prop
axiom g1718 (x : Prop) : Prop
axiom g1719 (x : Prop) : Prop
axiom g1720 (x : Prop) : Prop
axiom g1721 (x : Prop) : Prop
axiom g1722 (x : Prop) : Prop
axiom g1723 (x : Prop) : Prop
axiom g1724 (x : Prop) : Prop
axiom g1725 (x : Prop) : Prop
axiom g1726 (x : Prop) : Prop
axiom g1727 (x : Prop) : Prop
axiom g1728 (x : Prop) : Prop
axiom g1729 (x : Prop) : Prop
axiom g1730 (x : Prop) : Prop
axiom g1731 (x : Prop) : Prop
axiom g1732 (x : Prop) : Prop
axiom g1733 (x : Prop) : Prop
axiom g1734 (x : Prop) : Prop
axiom g1735 (x : Prop) : Prop
axiom g1736 (x : Prop) : Prop
axiom g1737 (x : Prop) : Prop
axiom g1738 (x : Prop) : Prop
axiom g1739 (x : Prop) : Prop
axiom g1740 (x : Prop) : Prop
axiom g1741 (x : Prop) : Prop
axiom g1742 (x : Prop) : Prop
axiom g1743 (x : Prop) : Prop
axiom g1744 (x : Prop) : Prop
axiom g1745 (x : Prop) : Prop
axiom g1746 (x : Prop) : Prop
axiom g1747 (x : Prop) : Prop
axiom g1748 (x : Prop) : Prop
axiom g1749 (x : Prop) : Prop
axiom g1750 (x : Prop) : Prop
axiom g1751 (x : Prop) : Prop
axiom g1752 (x : Prop) : Prop
axiom g1753 (x : Prop) : Prop
axiom g1754 (x : Prop) : Prop
axiom g1755 (x : Prop) : Prop
axiom g1756 (x : Prop) : Prop
axiom g1757 (x : Prop) : Prop
axiom g1758 (x : Prop) : Prop
axiom g1759 (x : Prop) : Prop
axiom g1760 (x : Prop) : Prop
axiom g1761 (x : Prop) : Prop
axiom g1762 (x : Prop) : Prop
axiom g1763 (x : Prop) : Prop
axiom g1764 (x : Prop) : Prop
axiom g1765 (x : Prop) : Prop
axiom g1766 (x : Prop) : Prop
axiom g1767 (x : Prop) : Prop
axiom g1768 (x : Prop) : Prop
axiom g1769 (x : Prop) : Prop
axiom g1770 (x : Prop) : Prop
axiom g1771 (x : Prop) : Prop
axiom g1772 (x : Prop) : Prop
axiom g1773 (x : Prop) : Prop
axiom g1774 (x : Prop) : Prop
axiom g1775 (x : Prop) : Prop
axiom g1776 (x : Prop) : Prop
axiom g1777 (x : Prop) : Prop
axiom g1778 (x : Prop) : Prop
axiom g1779 (x : Prop) : Prop
axiom g1780 (x : Prop) : Prop
axiom g1781 (x : Prop) : Prop
axiom g1782 (x : Prop) : Prop
axiom g1783 (x : Prop) : Prop
axiom g1784 (x : Prop) : Prop
axiom g1785 (x : Prop) : Prop
axiom g1786 (x : Prop) : Prop
axiom g1787 (x : Prop) : Prop
axiom g1788 (x : Prop) : Prop
axiom g1789 (x : Prop) : Prop
axiom g1790 (x : Prop) : Prop
axiom g1791 (x : Prop) : Prop
axiom g1792 (x : Prop) : Prop
axiom g1793 (x : Prop) : Prop
axiom g1794 (x : Prop) : Prop
axiom g1795 (x : Prop) : Prop
axiom g1796 (x : Prop) : Prop
axiom g1797 (x : Prop) : Prop
axiom g1798 (x : Prop) : Prop
axiom g1799 (x : Prop) : Prop
axiom g1800 (x : Prop) : Prop
axiom g1801 (x : Prop) : Prop
axiom g1802 (x : Prop) : Prop
axiom g1803 (x : Prop) : Prop
axiom g1804 (x : Prop) : Prop
axiom g1805 (x : Prop) : Prop
axiom g1806 (x : Prop) : Prop
axiom g1807 (x : Prop) : Prop
axiom g1808 (x : Prop) : Prop
axiom g1809 (x : Prop) : Prop
axiom g1810 (x : Prop) : Prop
axiom g1811 (x : Prop) : Prop
axiom g1812 (x : Prop) : Prop
axiom g1813 (x : Prop) : Prop
axiom g1814 (x : Prop) : Prop
axiom g1815 (x : Prop) : Prop
axiom g1816 (x : Prop) : Prop
axiom g1817 (x : Prop) : Prop
axiom g1818 (x : Prop) : Prop
axiom g1819 (x : Prop) : Prop
axiom g1820 (x : Prop) : Prop
axiom g1821 (x : Prop) : Prop
axiom g1822 (x : Prop) : Prop
axiom g1823 (x : Prop) : Prop
axiom g1824 (x : Prop) : Prop
axiom g1825 (x : Prop) : Prop
axiom g1826 (x : Prop) : Prop
axiom g1827 (x : Prop) : Prop
axiom g1828 (x : Prop) : Prop
axiom g1829 (x : Prop) : Prop
axiom g1830 (x : Prop) : Prop
axiom g1831 (x : Prop) : Prop
axiom g1832 (x : Prop) : Prop
axiom g1833 (x : Prop) : Prop
axiom g1834 (x : Prop) : Prop
axiom g1835 (x : Prop) : Prop
axiom g1836 (x : Prop) : Prop
axiom g1837 (x : Prop) : Prop
axiom g1838 (x : Prop) : Prop
axiom g1839 (x : Prop) : Prop
axiom g1840 (x : Prop) : Prop
axiom g1841 (x : Prop) : Prop
axiom g1842 (x : Prop) : Prop
axiom g1843 (x : Prop) : Prop
axiom g1844 (x : Prop) : Prop
axiom g1845 (x : Prop) : Prop
axiom g1846 (x : Prop) : Prop
axiom g1847 (x : Prop) : Prop
axiom g1848 (x : Prop) : Prop
axiom g1849 (x : Prop) : Prop
axiom g1850 (x : Prop) : Prop
axiom g1851 (x : Prop) : Prop
axiom g1852 (x : Prop) : Prop
axiom g1853 (x : Prop) : Prop
axiom g1854 (x : Prop) : Prop
axiom g1855 (x : Prop) : Prop
axiom g1856 (x : Prop) : Prop
axiom g1857 (x : Prop) : Prop
axiom g1858 (x : Prop) : Prop
axiom g1859 (x : Prop) : Prop
axiom g1860 (x : Prop) : Prop
axiom g1861 (x : Prop) : Prop
axiom g1862 (x : Prop) : Prop
axiom g1863 (x : Prop) : Prop
axiom g1864 (x : Prop) : Prop
axiom g1865 (x : Prop) : Prop
axiom g1866 (x : Prop) : Prop
axiom g1867 (x : Prop) : Prop
axiom g1868 (x : Prop) : Prop
axiom g1869 (x : Prop) : Prop
axiom g1870 (x : Prop) : Prop
axiom g1871 (x : Prop) : Prop
axiom g1872 (x : Prop) : Prop
axiom g1873 (x : Prop) : Prop
axiom g1874 (x : Prop) : Prop
axiom g1875 (x : Prop) : Prop
axiom g1876 (x : Prop) : Prop
axiom g1877 (x : Prop) : Prop
axiom g1878 (x : Prop) : Prop
axiom g1879 (x : Prop) : Prop
axiom g1880 (x : Prop) : Prop
axiom g1881 (x : Prop) : Prop
axiom g1882 (x : Prop) : Prop
axiom g1883 (x : Prop) : Prop
axiom g1884 (x : Prop) : Prop
axiom g1885 (x : Prop) : Prop
axiom g1886 (x : Prop) : Prop
axiom g1887 (x : Prop) : Prop
axiom g1888 (x : Prop) : Prop
axiom g1889 (x : Prop) : Prop
axiom g1890 (x : Prop) : Prop
axiom g1891 (x : Prop) : Prop
axiom g1892 (x : Prop) : Prop
axiom g1893 (x : Prop) : Prop
axiom g1894 (x : Prop) : Prop
axiom g1895 (x : Prop) : Prop
axiom g1896 (x : Prop) : Prop
axiom g1897 (x : Prop) : Prop
axiom g1898 (x : Prop) : Prop
axiom g1899 (x : Prop) : Prop
axiom g1900 (x : Prop) : Prop
axiom g1901 (x : Prop) : Prop
axiom g1902 (x : Prop) : Prop
axiom g1903 (x : Prop) : Prop
axiom g1904 (x : Prop) : Prop
axiom g1905 (x : Prop) : Prop
axiom g1906 (x : Prop) : Prop
axiom g1907 (x : Prop) : Prop
axiom g1908 (x : Prop) : Prop
axiom g1909 (x : Prop) : Prop
axiom g1910 (x : Prop) : Prop
axiom g1911 (x : Prop) : Prop
axiom g1912 (x : Prop) : Prop
axiom g1913 (x : Prop) : Prop
axiom g1914 (x : Prop) : Prop
axiom g1915 (x : Prop) : Prop
axiom g1916 (x : Prop) : Prop
axiom g1917 (x : Prop) : Prop
axiom g1918 (x : Prop) : Prop
axiom g1919 (x : Prop) : Prop
axiom g1920 (x : Prop) : Prop
axiom g1921 (x : Prop) : Prop
axiom g1922 (x : Prop) : Prop
axiom g1923 (x : Prop) : Prop
axiom g1924 (x : Prop) : Prop
axiom g1925 (x : Prop) : Prop
axiom g1926 (x : Prop) : Prop
axiom g1927 (x : Prop) : Prop
axiom g1928 (x : Prop) : Prop
axiom g1929 (x : Prop) : Prop
axiom g1930 (x : Prop) : Prop
axiom g1931 (x : Prop) : Prop
axiom g1932 (x : Prop) : Prop
axiom g1933 (x : Prop) : Prop
axiom g1934 (x : Prop) : Prop
axiom g1935 (x : Prop) : Prop
axiom g1936 (x : Prop) : Prop
axiom g1937 (x : Prop) : Prop
axiom g1938 (x : Prop) : Prop
axiom g1939 (x : Prop) : Prop
axiom g1940 (x : Prop) : Prop
axiom g1941 (x : Prop) : Prop
axiom g1942 (x : Prop) : Prop
axiom g1943 (x : Prop) : Prop
axiom g1944 (x : Prop) : Prop
axiom g1945 (x : Prop) : Prop
axiom g1946 (x : Prop) : Prop
axiom g1947 (x : Prop) : Prop
axiom g1948 (x : Prop) : Prop
axiom g1949 (x : Prop) : Prop
axiom g1950 (x : Prop) : Prop
axiom g1951 (x : Prop) : Prop
axiom g1952 (x : Prop) : Prop
axiom g1953 (x : Prop) : Prop
axiom g1954 (x : Prop) : Prop
axiom g1955 (x : Prop) : Prop
axiom g1956 (x : Prop) : Prop
axiom g1957 (x : Prop) : Prop
axiom g1958 (x : Prop) : Prop
axiom g1959 (x : Prop) : Prop
axiom g1960 (x : Prop) : Prop
axiom g1961 (x : Prop) : Prop
axiom g1962 (x : Prop) : Prop
axiom g1963 (x : Prop) : Prop
axiom g1964 (x : Prop) : Prop
axiom g1965 (x : Prop) : Prop
axiom g1966 (x : Prop) : Prop
axiom g1967 (x : Prop) : Prop
axiom g1968 (x : Prop) : Prop
axiom g1969 (x : Prop) : Prop
axiom g1970 (x : Prop) : Prop
axiom g1971 (x : Prop) : Prop
axiom g1972 (x : Prop) : Prop
axiom g1973 (x : Prop) : Prop
axiom g1974 (x : Prop) : Prop
axiom g1975 (x : Prop) : Prop
axiom g1976 (x : Prop) : Prop
axiom g1977 (x : Prop) : Prop
axiom g1978 (x : Prop) : Prop
axiom g1979 (x : Prop) : Prop
axiom g1980 (x : Prop) : Prop
axiom g1981 (x : Prop) : Prop
axiom g1982 (x : Prop) : Prop
axiom g1983 (x : Prop) : Prop
axiom g1984 (x : Prop) : Prop
axiom g1985 (x : Prop) : Prop
axiom g1986 (x : Prop) : Prop
axiom g1987 (x : Prop) : Prop
axiom g1988 (x : Prop) : Prop
axiom g1989 (x : Prop) : Prop
axiom g1990 (x : Prop) : Prop
axiom g1991 (x : Prop) : Prop
axiom g1992 (x : Prop) : Prop
axiom g1993 (x : Prop) : Prop
axiom g1994 (x : Prop) : Prop
axiom g1995 (x : Prop) : Prop
axiom g1996 (x : Prop) : Prop
axiom g1997 (x : Prop) : Prop
axiom g1998 (x : Prop) : Prop
axiom g1999 (x : Prop) : Prop
axiom g2000 (x : Prop) : Prop
axiom g2001 (x : Prop) : Prop
axiom g2002 (x : Prop) : Prop
axiom g2003 (x : Prop) : Prop
axiom g2004 (x : Prop) : Prop
axiom g2005 (x : Prop) : Prop
axiom g2006 (x : Prop) : Prop
axiom g2007 (x : Prop) : Prop
axiom g2008 (x : Prop) : Prop
axiom g2009 (x : Prop) : Prop
axiom g2010 (x : Prop) : Prop
axiom g2011 (x : Prop) : Prop
axiom g2012 (x : Prop) : Prop
axiom g2013 (x : Prop) : Prop
axiom g2014 (x : Prop) : Prop
axiom g2015 (x : Prop) : Prop
axiom g2016 (x : Prop) : Prop
axiom g2017 (x : Prop) : Prop
axiom g2018 (x : Prop) : Prop
axiom g2019 (x : Prop) : Prop
axiom g2020 (x : Prop) : Prop
axiom g2021 (x : Prop) : Prop
axiom g2022 (x : Prop) : Prop
axiom g2023 (x : Prop) : Prop
axiom g2024 (x : Prop) : Prop
axiom g2025 (x : Prop) : Prop
axiom g2026 (x : Prop) : Prop
axiom g2027 (x : Prop) : Prop
axiom g2028 (x : Prop) : Prop
axiom g2029 (x : Prop) : Prop
axiom g2030 (x : Prop) : Prop
axiom g2031 (x : Prop) : Prop
axiom g2032 (x : Prop) : Prop
axiom g2033 (x : Prop) : Prop
axiom g2034 (x : Prop) : Prop
axiom g2035 (x : Prop) : Prop
axiom g2036 (x : Prop) : Prop
axiom g2037 (x : Prop) : Prop
axiom g2038 (x : Prop) : Prop
axiom g2039 (x : Prop) : Prop
axiom g2040 (x : Prop) : Prop
axiom g2041 (x : Prop) : Prop
axiom g2042 (x : Prop) : Prop
axiom g2043 (x : Prop) : Prop
axiom g2044 (x : Prop) : Prop
axiom g2045 (x : Prop) : Prop
axiom g2046 (x : Prop) : Prop
axiom g2047 (x : Prop) : Prop
axiom g2048 (x : Prop) : Prop
axiom g2049 (x : Prop) : Prop
axiom g2050 (x : Prop) : Prop
axiom g2051 (x : Prop) : Prop
axiom g2052 (x : Prop) : Prop
axiom g2053 (x : Prop) : Prop
axiom g2054 (x : Prop) : Prop
axiom g2055 (x : Prop) : Prop
axiom g2056 (x : Prop) : Prop
axiom g2057 (x : Prop) : Prop
axiom g2058 (x : Prop) : Prop
axiom g2059 (x : Prop) : Prop
axiom g2060 (x : Prop) : Prop
axiom g2061 (x : Prop) : Prop
axiom g2062 (x : Prop) : Prop
axiom g2063 (x : Prop) : Prop
axiom g2064 (x : Prop) : Prop
axiom g2065 (x : Prop) : Prop
axiom g2066 (x : Prop) : Prop
axiom g2067 (x : Prop) : Prop
axiom g2068 (x : Prop) : Prop
axiom g2069 (x : Prop) : Prop
axiom g2070 (x : Prop) : Prop
axiom g2071 (x : Prop) : Prop
axiom g2072 (x : Prop) : Prop
axiom g2073 (x : Prop) : Prop
axiom g2074 (x : Prop) : Prop
axiom g2075 (x : Prop) : Prop
axiom g2076 (x : Prop) : Prop
axiom g2077 (x : Prop) : Prop
axiom g2078 (x : Prop) : Prop
axiom g2079 (x : Prop) : Prop
axiom g2080 (x : Prop) : Prop
axiom g2081 (x : Prop) : Prop
axiom g2082 (x : Prop) : Prop
axiom g2083 (x : Prop) : Prop
axiom g2084 (x : Prop) : Prop
axiom g2085 (x : Prop) : Prop
axiom g2086 (x : Prop) : Prop
axiom g2087 (x : Prop) : Prop
axiom g2088 (x : Prop) : Prop
axiom g2089 (x : Prop) : Prop
axiom g2090 (x : Prop) : Prop
axiom g2091 (x : Prop) : Prop
axiom g2092 (x : Prop) : Prop
axiom g2093 (x : Prop) : Prop
axiom g2094 (x : Prop) : Prop
axiom g2095 (x : Prop) : Prop
axiom g2096 (x : Prop) : Prop
axiom g2097 (x : Prop) : Prop
axiom g2098 (x : Prop) : Prop
axiom g2099 (x : Prop) : Prop
axiom g2100 (x : Prop) : Prop
axiom g2101 (x : Prop) : Prop
axiom g2102 (x : Prop) : Prop
axiom g2103 (x : Prop) : Prop
axiom g2104 (x : Prop) : Prop
axiom g2105 (x : Prop) : Prop
axiom g2106 (x : Prop) : Prop
axiom g2107 (x : Prop) : Prop
axiom g2108 (x : Prop) : Prop
axiom g2109 (x : Prop) : Prop
axiom g2110 (x : Prop) : Prop
axiom g2111 (x : Prop) : Prop
axiom g2112 (x : Prop) : Prop
axiom g2113 (x : Prop) : Prop
axiom g2114 (x : Prop) : Prop
axiom g2115 (x : Prop) : Prop
axiom g2116 (x : Prop) : Prop
axiom g2117 (x : Prop) : Prop
axiom g2118 (x : Prop) : Prop
axiom g2119 (x : Prop) : Prop
axiom g2120 (x : Prop) : Prop
axiom g2121 (x : Prop) : Prop
axiom g2122 (x : Prop) : Prop
axiom g2123 (x : Prop) : Prop
axiom g2124 (x : Prop) : Prop
axiom g2125 (x : Prop) : Prop
axiom g2126 (x : Prop) : Prop
axiom g2127 (x : Prop) : Prop
axiom g2128 (x : Prop) : Prop
axiom g2129 (x : Prop) : Prop
axiom g2130 (x : Prop) : Prop
axiom g2131 (x : Prop) : Prop
axiom g2132 (x : Prop) : Prop
axiom g2133 (x : Prop) : Prop
axiom g2134 (x : Prop) : Prop
axiom g2135 (x : Prop) : Prop
axiom g2136 (x : Prop) : Prop
axiom g2137 (x : Prop) : Prop
axiom g2138 (x : Prop) : Prop
axiom g2139 (x : Prop) : Prop
axiom g2140 (x : Prop) : Prop
axiom g2141 (x : Prop) : Prop
axiom g2142 (x : Prop) : Prop
axiom g2143 (x : Prop) : Prop
axiom g2144 (x : Prop) : Prop
axiom g2145 (x : Prop) : Prop
axiom g2146 (x : Prop) : Prop
axiom g2147 (x : Prop) : Prop
axiom g2148 (x : Prop) : Prop
axiom g2149 (x : Prop) : Prop
axiom g2150 (x : Prop) : Prop
axiom g2151 (x : Prop) : Prop
axiom g2152 (x : Prop) : Prop
axiom g2153 (x : Prop) : Prop
axiom g2154 (x : Prop) : Prop
axiom g2155 (x : Prop) : Prop
axiom g2156 (x : Prop) : Prop
axiom g2157 (x : Prop) : Prop
axiom g2158 (x : Prop) : Prop
axiom g2159 (x : Prop) : Prop
axiom g2160 (x : Prop) : Prop
axiom g2161 (x : Prop) : Prop
axiom g2162 (x : Prop) : Prop
axiom g2163 (x : Prop) : Prop
axiom g2164 (x : Prop) : Prop
axiom g2165 (x : Prop) : Prop
axiom g2166 (x : Prop) : Prop
axiom g2167 (x : Prop) : Prop
axiom g2168 (x : Prop) : Prop
axiom g2169 (x : Prop) : Prop
axiom g2170 (x : Prop) : Prop
axiom g2171 (x : Prop) : Prop
axiom g2172 (x : Prop) : Prop
axiom g2173 (x : Prop) : Prop
axiom g2174 (x : Prop) : Prop
axiom g2175 (x : Prop) : Prop
axiom g2176 (x : Prop) : Prop
axiom g2177 (x : Prop) : Prop
axiom g2178 (x : Prop) : Prop
axiom g2179 (x : Prop) : Prop
axiom g2180 (x : Prop) : Prop
axiom g2181 (x : Prop) : Prop
axiom g2182 (x : Prop) : Prop
axiom g2183 (x : Prop) : Prop
axiom g2184 (x : Prop) : Prop
axiom g2185 (x : Prop) : Prop
axiom g2186 (x : Prop) : Prop
axiom g2187 (x : Prop) : Prop
axiom g2188 (x : Prop) : Prop
axiom g2189 (x : Prop) : Prop
axiom g2190 (x : Prop) : Prop
axiom g2191 (x : Prop) : Prop
axiom g2192 (x : Prop) : Prop
axiom g2193 (x : Prop) : Prop
axiom g2194 (x : Prop) : Prop
axiom g2195 (x : Prop) : Prop
axiom g2196 (x : Prop) : Prop
axiom g2197 (x : Prop) : Prop
axiom g2198 (x : Prop) : Prop
axiom g2199 (x : Prop) : Prop
axiom g2200 (x : Prop) : Prop
axiom g2201 (x : Prop) : Prop
axiom g2202 (x : Prop) : Prop
axiom g2203 (x : Prop) : Prop
axiom g2204 (x : Prop) : Prop
axiom g2205 (x : Prop) : Prop
axiom g2206 (x : Prop) : Prop
axiom g2207 (x : Prop) : Prop
axiom g2208 (x : Prop) : Prop
axiom g2209 (x : Prop) : Prop
axiom g2210 (x : Prop) : Prop
axiom g2211 (x : Prop) : Prop
axiom g2212 (x : Prop) : Prop
axiom g2213 (x : Prop) : Prop
axiom g2214 (x : Prop) : Prop
axiom g2215 (x : Prop) : Prop
axiom g2216 (x : Prop) : Prop
axiom g2217 (x : Prop) : Prop
axiom g2218 (x : Prop) : Prop
axiom g2219 (x : Prop) : Prop
axiom g2220 (x : Prop) : Prop
axiom g2221 (x : Prop) : Prop
axiom g2222 (x : Prop) : Prop
axiom g2223 (x : Prop) : Prop
axiom g2224 (x : Prop) : Prop
axiom g2225 (x : Prop) : Prop
axiom g2226 (x : Prop) : Prop
axiom g2227 (x : Prop) : Prop
axiom g2228 (x : Prop) : Prop
axiom g2229 (x : Prop) : Prop
axiom g2230 (x : Prop) : Prop
axiom g2231 (x : Prop) : Prop
axiom g2232 (x : Prop) : Prop
axiom g2233 (x : Prop) : Prop
axiom g2234 (x : Prop) : Prop
axiom g2235 (x : Prop) : Prop
axiom g2236 (x : Prop) : Prop
axiom g2237 (x : Prop) : Prop
axiom g2238 (x : Prop) : Prop
axiom g2239 (x : Prop) : Prop
axiom g2240 (x : Prop) : Prop
axiom g2241 (x : Prop) : Prop
axiom g2242 (x : Prop) : Prop
axiom g2243 (x : Prop) : Prop
axiom g2244 (x : Prop) : Prop
axiom g2245 (x : Prop) : Prop
axiom g2246 (x : Prop) : Prop
axiom g2247 (x : Prop) : Prop
axiom g2248 (x : Prop) : Prop
axiom g2249 (x : Prop) : Prop
axiom g2250 (x : Prop) : Prop
axiom g2251 (x : Prop) : Prop
axiom g2252 (x : Prop) : Prop
axiom g2253 (x : Prop) : Prop
axiom g2254 (x : Prop) : Prop
axiom g2255 (x : Prop) : Prop
axiom g2256 (x : Prop) : Prop
axiom g2257 (x : Prop) : Prop
axiom g2258 (x : Prop) : Prop
axiom g2259 (x : Prop) : Prop
axiom g2260 (x : Prop) : Prop
axiom g2261 (x : Prop) : Prop
axiom g2262 (x : Prop) : Prop
axiom g2263 (x : Prop) : Prop
axiom g2264 (x : Prop) : Prop
axiom g2265 (x : Prop) : Prop
axiom g2266 (x : Prop) : Prop
axiom g2267 (x : Prop) : Prop
axiom g2268 (x : Prop) : Prop
axiom g2269 (x : Prop) : Prop
axiom g2270 (x : Prop) : Prop
axiom g2271 (x : Prop) : Prop
axiom g2272 (x : Prop) : Prop
axiom g2273 (x : Prop) : Prop
axiom g2274 (x : Prop) : Prop
axiom g2275 (x : Prop) : Prop
axiom g2276 (x : Prop) : Prop
axiom g2277 (x : Prop) : Prop
axiom g2278 (x : Prop) : Prop
axiom g2279 (x : Prop) : Prop
axiom g2280 (x : Prop) : Prop
axiom g2281 (x : Prop) : Prop
axiom g2282 (x : Prop) : Prop
axiom g2283 (x : Prop) : Prop
axiom g2284 (x : Prop) : Prop
axiom g2285 (x : Prop) : Prop
axiom g2286 (x : Prop) : Prop
axiom g2287 (x : Prop) : Prop
axiom g2288 (x : Prop) : Prop
axiom g2289 (x : Prop) : Prop
axiom g2290 (x : Prop) : Prop
axiom g2291 (x : Prop) : Prop
axiom g2292 (x : Prop) : Prop
axiom g2293 (x : Prop) : Prop
axiom g2294 (x : Prop) : Prop
axiom g2295 (x : Prop) : Prop
axiom g2296 (x : Prop) : Prop
axiom g2297 (x : Prop) : Prop
axiom g2298 (x : Prop) : Prop
axiom g2299 (x : Prop) : Prop
axiom g2300 (x : Prop) : Prop
axiom g2301 (x : Prop) : Prop
axiom g2302 (x : Prop) : Prop
axiom g2303 (x : Prop) : Prop
axiom g2304 (x : Prop) : Prop
axiom g2305 (x : Prop) : Prop
axiom g2306 (x : Prop) : Prop
axiom g2307 (x : Prop) : Prop
axiom g2308 (x : Prop) : Prop
axiom g2309 (x : Prop) : Prop
axiom g2310 (x : Prop) : Prop
axiom g2311 (x : Prop) : Prop
axiom g2312 (x : Prop) : Prop
axiom g2313 (x : Prop) : Prop
axiom g2314 (x : Prop) : Prop
axiom g2315 (x : Prop) : Prop
axiom g2316 (x : Prop) : Prop
axiom g2317 (x : Prop) : Prop
axiom g2318 (x : Prop) : Prop
axiom g2319 (x : Prop) : Prop
axiom g2320 (x : Prop) : Prop
axiom g2321 (x : Prop) : Prop
axiom g2322 (x : Prop) : Prop
axiom g2323 (x : Prop) : Prop
axiom g2324 (x : Prop) : Prop
axiom g2325 (x : Prop) : Prop
axiom g2326 (x : Prop) : Prop
axiom g2327 (x : Prop) : Prop
axiom g2328 (x : Prop) : Prop
axiom g2329 (x : Prop) : Prop
axiom g2330 (x : Prop) : Prop
axiom g2331 (x : Prop) : Prop
axiom g2332 (x : Prop) : Prop
axiom g2333 (x : Prop) : Prop
axiom g2334 (x : Prop) : Prop
axiom g2335 (x : Prop) : Prop
axiom g2336 (x : Prop) : Prop
axiom g2337 (x : Prop) : Prop
axiom g2338 (x : Prop) : Prop
axiom g2339 (x : Prop) : Prop
axiom g2340 (x : Prop) : Prop
axiom g2341 (x : Prop) : Prop
axiom g2342 (x : Prop) : Prop
axiom g2343 (x : Prop) : Prop
axiom g2344 (x : Prop) : Prop
axiom g2345 (x : Prop) : Prop
axiom g2346 (x : Prop) : Prop
axiom g2347 (x : Prop) : Prop
axiom g2348 (x : Prop) : Prop
axiom g2349 (x : Prop) : Prop
axiom g2350 (x : Prop) : Prop
axiom g2351 (x : Prop) : Prop
axiom g2352 (x : Prop) : Prop
axiom g2353 (x : Prop) : Prop
axiom g2354 (x : Prop) : Prop
axiom g2355 (x : Prop) : Prop
axiom g2356 (x : Prop) : Prop
axiom g2357 (x : Prop) : Prop
axiom g2358 (x : Prop) : Prop
axiom g2359 (x : Prop) : Prop
axiom g2360 (x : Prop) : Prop
axiom g2361 (x : Prop) : Prop
axiom g2362 (x : Prop) : Prop
axiom g2363 (x : Prop) : Prop
axiom g2364 (x : Prop) : Prop
axiom g2365 (x : Prop) : Prop
axiom g2366 (x : Prop) : Prop
axiom g2367 (x : Prop) : Prop
axiom g2368 (x : Prop) : Prop
axiom g2369 (x : Prop) : Prop
axiom g2370 (x : Prop) : Prop
axiom g2371 (x : Prop) : Prop
axiom g2372 (x : Prop) : Prop
axiom g2373 (x : Prop) : Prop
axiom g2374 (x : Prop) : Prop
axiom g2375 (x : Prop) : Prop
axiom g2376 (x : Prop) : Prop
axiom g2377 (x : Prop) : Prop
axiom g2378 (x : Prop) : Prop
axiom g2379 (x : Prop) : Prop
axiom g2380 (x : Prop) : Prop
axiom g2381 (x : Prop) : Prop
axiom g2382 (x : Prop) : Prop
axiom g2383 (x : Prop) : Prop
axiom g2384 (x : Prop) : Prop
axiom g2385 (x : Prop) : Prop
axiom g2386 (x : Prop) : Prop
axiom g2387 (x : Prop) : Prop
axiom g2388 (x : Prop) : Prop
axiom g2389 (x : Prop) : Prop
axiom g2390 (x : Prop) : Prop
axiom g2391 (x : Prop) : Prop
axiom g2392 (x : Prop) : Prop
axiom g2393 (x : Prop) : Prop
axiom g2394 (x : Prop) : Prop
axiom g2395 (x : Prop) : Prop
axiom g2396 (x : Prop) : Prop
axiom g2397 (x : Prop) : Prop
axiom g2398 (x : Prop) : Prop
axiom g2399 (x : Prop) : Prop
axiom g2400 (x : Prop) : Prop
axiom g2401 (x : Prop) : Prop
axiom g2402 (x : Prop) : Prop
axiom g2403 (x : Prop) : Prop
axiom g2404 (x : Prop) : Prop
axiom g2405 (x : Prop) : Prop
axiom g2406 (x : Prop) : Prop
axiom g2407 (x : Prop) : Prop
axiom g2408 (x : Prop) : Prop
axiom g2409 (x : Prop) : Prop
axiom g2410 (x : Prop) : Prop
axiom g2411 (x : Prop) : Prop
axiom g2412 (x : Prop) : Prop
axiom g2413 (x : Prop) : Prop
axiom g2414 (x : Prop) : Prop
axiom g2415 (x : Prop) : Prop
axiom g2416 (x : Prop) : Prop
axiom g2417 (x : Prop) : Prop
axiom g2418 (x : Prop) : Prop
axiom g2419 (x : Prop) : Prop
axiom g2420 (x : Prop) : Prop
axiom g2421 (x : Prop) : Prop
axiom g2422 (x : Prop) : Prop
axiom g2423 (x : Prop) : Prop
axiom g2424 (x : Prop) : Prop
axiom g2425 (x : Prop) : Prop
axiom g2426 (x : Prop) : Prop
axiom g2427 (x : Prop) : Prop
axiom g2428 (x : Prop) : Prop
axiom g2429 (x : Prop) : Prop
axiom g2430 (x : Prop) : Prop
axiom g2431 (x : Prop) : Prop
axiom g2432 (x : Prop) : Prop
axiom g2433 (x : Prop) : Prop
axiom g2434 (x : Prop) : Prop
axiom g2435 (x : Prop) : Prop
axiom g2436 (x : Prop) : Prop
axiom g2437 (x : Prop) : Prop
axiom g2438 (x : Prop) : Prop
axiom g2439 (x : Prop) : Prop
axiom g2440 (x : Prop) : Prop
axiom g2441 (x : Prop) : Prop
axiom g2442 (x : Prop) : Prop
axiom g2443 (x : Prop) : Prop
axiom g2444 (x : Prop) : Prop
axiom g2445 (x : Prop) : Prop
axiom g2446 (x : Prop) : Prop
axiom g2447 (x : Prop) : Prop
axiom g2448 (x : Prop) : Prop
axiom g2449 (x : Prop) : Prop
axiom g2450 (x : Prop) : Prop
axiom g2451 (x : Prop) : Prop
axiom g2452 (x : Prop) : Prop
axiom g2453 (x : Prop) : Prop
axiom g2454 (x : Prop) : Prop
axiom g2455 (x : Prop) : Prop
axiom g2456 (x : Prop) : Prop
axiom g2457 (x : Prop) : Prop
axiom g2458 (x : Prop) : Prop
axiom g2459 (x : Prop) : Prop
axiom g2460 (x : Prop) : Prop
axiom g2461 (x : Prop) : Prop
axiom g2462 (x : Prop) : Prop
axiom g2463 (x : Prop) : Prop
axiom g2464 (x : Prop) : Prop
axiom g2465 (x : Prop) : Prop
axiom g2466 (x : Prop) : Prop
axiom g2467 (x : Prop) : Prop
axiom g2468 (x : Prop) : Prop
axiom g2469 (x : Prop) : Prop
axiom g2470 (x : Prop) : Prop
axiom g2471 (x : Prop) : Prop
axiom g2472 (x : Prop) : Prop
axiom g2473 (x : Prop) : Prop
axiom g2474 (x : Prop) : Prop
axiom g2475 (x : Prop) : Prop
axiom g2476 (x : Prop) : Prop
axiom g2477 (x : Prop) : Prop
axiom g2478 (x : Prop) : Prop
axiom g2479 (x : Prop) : Prop
axiom g2480 (x : Prop) : Prop
axiom g2481 (x : Prop) : Prop
axiom g2482 (x : Prop) : Prop
axiom g2483 (x : Prop) : Prop
axiom g2484 (x : Prop) : Prop
axiom g2485 (x : Prop) : Prop
axiom g2486 (x : Prop) : Prop
axiom g2487 (x : Prop) : Prop
axiom g2488 (x : Prop) : Prop
axiom g2489 (x : Prop) : Prop
axiom g2490 (x : Prop) : Prop
axiom g2491 (x : Prop) : Prop
axiom g2492 (x : Prop) : Prop
axiom g2493 (x : Prop) : Prop
axiom g2494 (x : Prop) : Prop
axiom g2495 (x : Prop) : Prop
axiom g2496 (x : Prop) : Prop
axiom g2497 (x : Prop) : Prop
axiom g2498 (x : Prop) : Prop
axiom g2499 (x : Prop) : Prop
@[simp] axiom s0 (x : Prop) : f (g1 x) = f (g0 x)
@[simp] axiom s1 (x : Prop) : f (g2 x) = f (g1 x)
@[simp] axiom s2 (x : Prop) : f (g3 x) = f (g2 x)
@[simp] axiom s3 (x : Prop) : f (g4 x) = f (g3 x)
@[simp] axiom s4 (x : Prop) : f (g5 x) = f (g4 x)
@[simp] axiom s5 (x : Prop) : f (g6 x) = f (g5 x)
@[simp] axiom s6 (x : Prop) : f (g7 x) = f (g6 x)
@[simp] axiom s7 (x : Prop) : f (g8 x) = f (g7 x)
@[simp] axiom s8 (x : Prop) : f (g9 x) = f (g8 x)
@[simp] axiom s9 (x : Prop) : f (g10 x) = f (g9 x)
@[simp] axiom s10 (x : Prop) : f (g11 x) = f (g10 x)
@[simp] axiom s11 (x : Prop) : f (g12 x) = f (g11 x)
@[simp] axiom s12 (x : Prop) : f (g13 x) = f (g12 x)
@[simp] axiom s13 (x : Prop) : f (g14 x) = f (g13 x)
@[simp] axiom s14 (x : Prop) : f (g15 x) = f (g14 x)
@[simp] axiom s15 (x : Prop) : f (g16 x) = f (g15 x)
@[simp] axiom s16 (x : Prop) : f (g17 x) = f (g16 x)
@[simp] axiom s17 (x : Prop) : f (g18 x) = f (g17 x)
@[simp] axiom s18 (x : Prop) : f (g19 x) = f (g18 x)
@[simp] axiom s19 (x : Prop) : f (g20 x) = f (g19 x)
@[simp] axiom s20 (x : Prop) : f (g21 x) = f (g20 x)
@[simp] axiom s21 (x : Prop) : f (g22 x) = f (g21 x)
@[simp] axiom s22 (x : Prop) : f (g23 x) = f (g22 x)
@[simp] axiom s23 (x : Prop) : f (g24 x) = f (g23 x)
@[simp] axiom s24 (x : Prop) : f (g25 x) = f (g24 x)
@[simp] axiom s25 (x : Prop) : f (g26 x) = f (g25 x)
@[simp] axiom s26 (x : Prop) : f (g27 x) = f (g26 x)
@[simp] axiom s27 (x : Prop) : f (g28 x) = f (g27 x)
@[simp] axiom s28 (x : Prop) : f (g29 x) = f (g28 x)
@[simp] axiom s29 (x : Prop) : f (g30 x) = f (g29 x)
@[simp] axiom s30 (x : Prop) : f (g31 x) = f (g30 x)
@[simp] axiom s31 (x : Prop) : f (g32 x) = f (g31 x)
@[simp] axiom s32 (x : Prop) : f (g33 x) = f (g32 x)
@[simp] axiom s33 (x : Prop) : f (g34 x) = f (g33 x)
@[simp] axiom s34 (x : Prop) : f (g35 x) = f (g34 x)
@[simp] axiom s35 (x : Prop) : f (g36 x) = f (g35 x)
@[simp] axiom s36 (x : Prop) : f (g37 x) = f (g36 x)
@[simp] axiom s37 (x : Prop) : f (g38 x) = f (g37 x)
@[simp] axiom s38 (x : Prop) : f (g39 x) = f (g38 x)
@[simp] axiom s39 (x : Prop) : f (g40 x) = f (g39 x)
@[simp] axiom s40 (x : Prop) : f (g41 x) = f (g40 x)
@[simp] axiom s41 (x : Prop) : f (g42 x) = f (g41 x)
@[simp] axiom s42 (x : Prop) : f (g43 x) = f (g42 x)
@[simp] axiom s43 (x : Prop) : f (g44 x) = f (g43 x)
@[simp] axiom s44 (x : Prop) : f (g45 x) = f (g44 x)
@[simp] axiom s45 (x : Prop) : f (g46 x) = f (g45 x)
@[simp] axiom s46 (x : Prop) : f (g47 x) = f (g46 x)
@[simp] axiom s47 (x : Prop) : f (g48 x) = f (g47 x)
@[simp] axiom s48 (x : Prop) : f (g49 x) = f (g48 x)
@[simp] axiom s49 (x : Prop) : f (g50 x) = f (g49 x)
@[simp] axiom s50 (x : Prop) : f (g51 x) = f (g50 x)
@[simp] axiom s51 (x : Prop) : f (g52 x) = f (g51 x)
@[simp] axiom s52 (x : Prop) : f (g53 x) = f (g52 x)
@[simp] axiom s53 (x : Prop) : f (g54 x) = f (g53 x)
@[simp] axiom s54 (x : Prop) : f (g55 x) = f (g54 x)
@[simp] axiom s55 (x : Prop) : f (g56 x) = f (g55 x)
@[simp] axiom s56 (x : Prop) : f (g57 x) = f (g56 x)
@[simp] axiom s57 (x : Prop) : f (g58 x) = f (g57 x)
@[simp] axiom s58 (x : Prop) : f (g59 x) = f (g58 x)
@[simp] axiom s59 (x : Prop) : f (g60 x) = f (g59 x)
@[simp] axiom s60 (x : Prop) : f (g61 x) = f (g60 x)
@[simp] axiom s61 (x : Prop) : f (g62 x) = f (g61 x)
@[simp] axiom s62 (x : Prop) : f (g63 x) = f (g62 x)
@[simp] axiom s63 (x : Prop) : f (g64 x) = f (g63 x)
@[simp] axiom s64 (x : Prop) : f (g65 x) = f (g64 x)
@[simp] axiom s65 (x : Prop) : f (g66 x) = f (g65 x)
@[simp] axiom s66 (x : Prop) : f (g67 x) = f (g66 x)
@[simp] axiom s67 (x : Prop) : f (g68 x) = f (g67 x)
@[simp] axiom s68 (x : Prop) : f (g69 x) = f (g68 x)
@[simp] axiom s69 (x : Prop) : f (g70 x) = f (g69 x)
@[simp] axiom s70 (x : Prop) : f (g71 x) = f (g70 x)
@[simp] axiom s71 (x : Prop) : f (g72 x) = f (g71 x)
@[simp] axiom s72 (x : Prop) : f (g73 x) = f (g72 x)
@[simp] axiom s73 (x : Prop) : f (g74 x) = f (g73 x)
@[simp] axiom s74 (x : Prop) : f (g75 x) = f (g74 x)
@[simp] axiom s75 (x : Prop) : f (g76 x) = f (g75 x)
@[simp] axiom s76 (x : Prop) : f (g77 x) = f (g76 x)
@[simp] axiom s77 (x : Prop) : f (g78 x) = f (g77 x)
@[simp] axiom s78 (x : Prop) : f (g79 x) = f (g78 x)
@[simp] axiom s79 (x : Prop) : f (g80 x) = f (g79 x)
@[simp] axiom s80 (x : Prop) : f (g81 x) = f (g80 x)
@[simp] axiom s81 (x : Prop) : f (g82 x) = f (g81 x)
@[simp] axiom s82 (x : Prop) : f (g83 x) = f (g82 x)
@[simp] axiom s83 (x : Prop) : f (g84 x) = f (g83 x)
@[simp] axiom s84 (x : Prop) : f (g85 x) = f (g84 x)
@[simp] axiom s85 (x : Prop) : f (g86 x) = f (g85 x)
@[simp] axiom s86 (x : Prop) : f (g87 x) = f (g86 x)
@[simp] axiom s87 (x : Prop) : f (g88 x) = f (g87 x)
@[simp] axiom s88 (x : Prop) : f (g89 x) = f (g88 x)
@[simp] axiom s89 (x : Prop) : f (g90 x) = f (g89 x)
@[simp] axiom s90 (x : Prop) : f (g91 x) = f (g90 x)
@[simp] axiom s91 (x : Prop) : f (g92 x) = f (g91 x)
@[simp] axiom s92 (x : Prop) : f (g93 x) = f (g92 x)
@[simp] axiom s93 (x : Prop) : f (g94 x) = f (g93 x)
@[simp] axiom s94 (x : Prop) : f (g95 x) = f (g94 x)
@[simp] axiom s95 (x : Prop) : f (g96 x) = f (g95 x)
@[simp] axiom s96 (x : Prop) : f (g97 x) = f (g96 x)
@[simp] axiom s97 (x : Prop) : f (g98 x) = f (g97 x)
@[simp] axiom s98 (x : Prop) : f (g99 x) = f (g98 x)
@[simp] axiom s99 (x : Prop) : f (g100 x) = f (g99 x)
@[simp] axiom s100 (x : Prop) : f (g101 x) = f (g100 x)
@[simp] axiom s101 (x : Prop) : f (g102 x) = f (g101 x)
@[simp] axiom s102 (x : Prop) : f (g103 x) = f (g102 x)
@[simp] axiom s103 (x : Prop) : f (g104 x) = f (g103 x)
@[simp] axiom s104 (x : Prop) : f (g105 x) = f (g104 x)
@[simp] axiom s105 (x : Prop) : f (g106 x) = f (g105 x)
@[simp] axiom s106 (x : Prop) : f (g107 x) = f (g106 x)
@[simp] axiom s107 (x : Prop) : f (g108 x) = f (g107 x)
@[simp] axiom s108 (x : Prop) : f (g109 x) = f (g108 x)
@[simp] axiom s109 (x : Prop) : f (g110 x) = f (g109 x)
@[simp] axiom s110 (x : Prop) : f (g111 x) = f (g110 x)
@[simp] axiom s111 (x : Prop) : f (g112 x) = f (g111 x)
@[simp] axiom s112 (x : Prop) : f (g113 x) = f (g112 x)
@[simp] axiom s113 (x : Prop) : f (g114 x) = f (g113 x)
@[simp] axiom s114 (x : Prop) : f (g115 x) = f (g114 x)
@[simp] axiom s115 (x : Prop) : f (g116 x) = f (g115 x)
@[simp] axiom s116 (x : Prop) : f (g117 x) = f (g116 x)
@[simp] axiom s117 (x : Prop) : f (g118 x) = f (g117 x)
@[simp] axiom s118 (x : Prop) : f (g119 x) = f (g118 x)
@[simp] axiom s119 (x : Prop) : f (g120 x) = f (g119 x)
@[simp] axiom s120 (x : Prop) : f (g121 x) = f (g120 x)
@[simp] axiom s121 (x : Prop) : f (g122 x) = f (g121 x)
@[simp] axiom s122 (x : Prop) : f (g123 x) = f (g122 x)
@[simp] axiom s123 (x : Prop) : f (g124 x) = f (g123 x)
@[simp] axiom s124 (x : Prop) : f (g125 x) = f (g124 x)
@[simp] axiom s125 (x : Prop) : f (g126 x) = f (g125 x)
@[simp] axiom s126 (x : Prop) : f (g127 x) = f (g126 x)
@[simp] axiom s127 (x : Prop) : f (g128 x) = f (g127 x)
@[simp] axiom s128 (x : Prop) : f (g129 x) = f (g128 x)
@[simp] axiom s129 (x : Prop) : f (g130 x) = f (g129 x)
@[simp] axiom s130 (x : Prop) : f (g131 x) = f (g130 x)
@[simp] axiom s131 (x : Prop) : f (g132 x) = f (g131 x)
@[simp] axiom s132 (x : Prop) : f (g133 x) = f (g132 x)
@[simp] axiom s133 (x : Prop) : f (g134 x) = f (g133 x)
@[simp] axiom s134 (x : Prop) : f (g135 x) = f (g134 x)
@[simp] axiom s135 (x : Prop) : f (g136 x) = f (g135 x)
@[simp] axiom s136 (x : Prop) : f (g137 x) = f (g136 x)
@[simp] axiom s137 (x : Prop) : f (g138 x) = f (g137 x)
@[simp] axiom s138 (x : Prop) : f (g139 x) = f (g138 x)
@[simp] axiom s139 (x : Prop) : f (g140 x) = f (g139 x)
@[simp] axiom s140 (x : Prop) : f (g141 x) = f (g140 x)
@[simp] axiom s141 (x : Prop) : f (g142 x) = f (g141 x)
@[simp] axiom s142 (x : Prop) : f (g143 x) = f (g142 x)
@[simp] axiom s143 (x : Prop) : f (g144 x) = f (g143 x)
@[simp] axiom s144 (x : Prop) : f (g145 x) = f (g144 x)
@[simp] axiom s145 (x : Prop) : f (g146 x) = f (g145 x)
@[simp] axiom s146 (x : Prop) : f (g147 x) = f (g146 x)
@[simp] axiom s147 (x : Prop) : f (g148 x) = f (g147 x)
@[simp] axiom s148 (x : Prop) : f (g149 x) = f (g148 x)
@[simp] axiom s149 (x : Prop) : f (g150 x) = f (g149 x)
@[simp] axiom s150 (x : Prop) : f (g151 x) = f (g150 x)
@[simp] axiom s151 (x : Prop) : f (g152 x) = f (g151 x)
@[simp] axiom s152 (x : Prop) : f (g153 x) = f (g152 x)
@[simp] axiom s153 (x : Prop) : f (g154 x) = f (g153 x)
@[simp] axiom s154 (x : Prop) : f (g155 x) = f (g154 x)
@[simp] axiom s155 (x : Prop) : f (g156 x) = f (g155 x)
@[simp] axiom s156 (x : Prop) : f (g157 x) = f (g156 x)
@[simp] axiom s157 (x : Prop) : f (g158 x) = f (g157 x)
@[simp] axiom s158 (x : Prop) : f (g159 x) = f (g158 x)
@[simp] axiom s159 (x : Prop) : f (g160 x) = f (g159 x)
@[simp] axiom s160 (x : Prop) : f (g161 x) = f (g160 x)
@[simp] axiom s161 (x : Prop) : f (g162 x) = f (g161 x)
@[simp] axiom s162 (x : Prop) : f (g163 x) = f (g162 x)
@[simp] axiom s163 (x : Prop) : f (g164 x) = f (g163 x)
@[simp] axiom s164 (x : Prop) : f (g165 x) = f (g164 x)
@[simp] axiom s165 (x : Prop) : f (g166 x) = f (g165 x)
@[simp] axiom s166 (x : Prop) : f (g167 x) = f (g166 x)
@[simp] axiom s167 (x : Prop) : f (g168 x) = f (g167 x)
@[simp] axiom s168 (x : Prop) : f (g169 x) = f (g168 x)
@[simp] axiom s169 (x : Prop) : f (g170 x) = f (g169 x)
@[simp] axiom s170 (x : Prop) : f (g171 x) = f (g170 x)
@[simp] axiom s171 (x : Prop) : f (g172 x) = f (g171 x)
@[simp] axiom s172 (x : Prop) : f (g173 x) = f (g172 x)
@[simp] axiom s173 (x : Prop) : f (g174 x) = f (g173 x)
@[simp] axiom s174 (x : Prop) : f (g175 x) = f (g174 x)
@[simp] axiom s175 (x : Prop) : f (g176 x) = f (g175 x)
@[simp] axiom s176 (x : Prop) : f (g177 x) = f (g176 x)
@[simp] axiom s177 (x : Prop) : f (g178 x) = f (g177 x)
@[simp] axiom s178 (x : Prop) : f (g179 x) = f (g178 x)
@[simp] axiom s179 (x : Prop) : f (g180 x) = f (g179 x)
@[simp] axiom s180 (x : Prop) : f (g181 x) = f (g180 x)
@[simp] axiom s181 (x : Prop) : f (g182 x) = f (g181 x)
@[simp] axiom s182 (x : Prop) : f (g183 x) = f (g182 x)
@[simp] axiom s183 (x : Prop) : f (g184 x) = f (g183 x)
@[simp] axiom s184 (x : Prop) : f (g185 x) = f (g184 x)
@[simp] axiom s185 (x : Prop) : f (g186 x) = f (g185 x)
@[simp] axiom s186 (x : Prop) : f (g187 x) = f (g186 x)
@[simp] axiom s187 (x : Prop) : f (g188 x) = f (g187 x)
@[simp] axiom s188 (x : Prop) : f (g189 x) = f (g188 x)
@[simp] axiom s189 (x : Prop) : f (g190 x) = f (g189 x)
@[simp] axiom s190 (x : Prop) : f (g191 x) = f (g190 x)
@[simp] axiom s191 (x : Prop) : f (g192 x) = f (g191 x)
@[simp] axiom s192 (x : Prop) : f (g193 x) = f (g192 x)
@[simp] axiom s193 (x : Prop) : f (g194 x) = f (g193 x)
@[simp] axiom s194 (x : Prop) : f (g195 x) = f (g194 x)
@[simp] axiom s195 (x : Prop) : f (g196 x) = f (g195 x)
@[simp] axiom s196 (x : Prop) : f (g197 x) = f (g196 x)
@[simp] axiom s197 (x : Prop) : f (g198 x) = f (g197 x)
@[simp] axiom s198 (x : Prop) : f (g199 x) = f (g198 x)
@[simp] axiom s199 (x : Prop) : f (g200 x) = f (g199 x)
@[simp] axiom s200 (x : Prop) : f (g201 x) = f (g200 x)
@[simp] axiom s201 (x : Prop) : f (g202 x) = f (g201 x)
@[simp] axiom s202 (x : Prop) : f (g203 x) = f (g202 x)
@[simp] axiom s203 (x : Prop) : f (g204 x) = f (g203 x)
@[simp] axiom s204 (x : Prop) : f (g205 x) = f (g204 x)
@[simp] axiom s205 (x : Prop) : f (g206 x) = f (g205 x)
@[simp] axiom s206 (x : Prop) : f (g207 x) = f (g206 x)
@[simp] axiom s207 (x : Prop) : f (g208 x) = f (g207 x)
@[simp] axiom s208 (x : Prop) : f (g209 x) = f (g208 x)
@[simp] axiom s209 (x : Prop) : f (g210 x) = f (g209 x)
@[simp] axiom s210 (x : Prop) : f (g211 x) = f (g210 x)
@[simp] axiom s211 (x : Prop) : f (g212 x) = f (g211 x)
@[simp] axiom s212 (x : Prop) : f (g213 x) = f (g212 x)
@[simp] axiom s213 (x : Prop) : f (g214 x) = f (g213 x)
@[simp] axiom s214 (x : Prop) : f (g215 x) = f (g214 x)
@[simp] axiom s215 (x : Prop) : f (g216 x) = f (g215 x)
@[simp] axiom s216 (x : Prop) : f (g217 x) = f (g216 x)
@[simp] axiom s217 (x : Prop) : f (g218 x) = f (g217 x)
@[simp] axiom s218 (x : Prop) : f (g219 x) = f (g218 x)
@[simp] axiom s219 (x : Prop) : f (g220 x) = f (g219 x)
@[simp] axiom s220 (x : Prop) : f (g221 x) = f (g220 x)
@[simp] axiom s221 (x : Prop) : f (g222 x) = f (g221 x)
@[simp] axiom s222 (x : Prop) : f (g223 x) = f (g222 x)
@[simp] axiom s223 (x : Prop) : f (g224 x) = f (g223 x)
@[simp] axiom s224 (x : Prop) : f (g225 x) = f (g224 x)
@[simp] axiom s225 (x : Prop) : f (g226 x) = f (g225 x)
@[simp] axiom s226 (x : Prop) : f (g227 x) = f (g226 x)
@[simp] axiom s227 (x : Prop) : f (g228 x) = f (g227 x)
@[simp] axiom s228 (x : Prop) : f (g229 x) = f (g228 x)
@[simp] axiom s229 (x : Prop) : f (g230 x) = f (g229 x)
@[simp] axiom s230 (x : Prop) : f (g231 x) = f (g230 x)
@[simp] axiom s231 (x : Prop) : f (g232 x) = f (g231 x)
@[simp] axiom s232 (x : Prop) : f (g233 x) = f (g232 x)
@[simp] axiom s233 (x : Prop) : f (g234 x) = f (g233 x)
@[simp] axiom s234 (x : Prop) : f (g235 x) = f (g234 x)
@[simp] axiom s235 (x : Prop) : f (g236 x) = f (g235 x)
@[simp] axiom s236 (x : Prop) : f (g237 x) = f (g236 x)
@[simp] axiom s237 (x : Prop) : f (g238 x) = f (g237 x)
@[simp] axiom s238 (x : Prop) : f (g239 x) = f (g238 x)
@[simp] axiom s239 (x : Prop) : f (g240 x) = f (g239 x)
@[simp] axiom s240 (x : Prop) : f (g241 x) = f (g240 x)
@[simp] axiom s241 (x : Prop) : f (g242 x) = f (g241 x)
@[simp] axiom s242 (x : Prop) : f (g243 x) = f (g242 x)
@[simp] axiom s243 (x : Prop) : f (g244 x) = f (g243 x)
@[simp] axiom s244 (x : Prop) : f (g245 x) = f (g244 x)
@[simp] axiom s245 (x : Prop) : f (g246 x) = f (g245 x)
@[simp] axiom s246 (x : Prop) : f (g247 x) = f (g246 x)
@[simp] axiom s247 (x : Prop) : f (g248 x) = f (g247 x)
@[simp] axiom s248 (x : Prop) : f (g249 x) = f (g248 x)
@[simp] axiom s249 (x : Prop) : f (g250 x) = f (g249 x)
@[simp] axiom s250 (x : Prop) : f (g251 x) = f (g250 x)
@[simp] axiom s251 (x : Prop) : f (g252 x) = f (g251 x)
@[simp] axiom s252 (x : Prop) : f (g253 x) = f (g252 x)
@[simp] axiom s253 (x : Prop) : f (g254 x) = f (g253 x)
@[simp] axiom s254 (x : Prop) : f (g255 x) = f (g254 x)
@[simp] axiom s255 (x : Prop) : f (g256 x) = f (g255 x)
@[simp] axiom s256 (x : Prop) : f (g257 x) = f (g256 x)
@[simp] axiom s257 (x : Prop) : f (g258 x) = f (g257 x)
@[simp] axiom s258 (x : Prop) : f (g259 x) = f (g258 x)
@[simp] axiom s259 (x : Prop) : f (g260 x) = f (g259 x)
@[simp] axiom s260 (x : Prop) : f (g261 x) = f (g260 x)
@[simp] axiom s261 (x : Prop) : f (g262 x) = f (g261 x)
@[simp] axiom s262 (x : Prop) : f (g263 x) = f (g262 x)
@[simp] axiom s263 (x : Prop) : f (g264 x) = f (g263 x)
@[simp] axiom s264 (x : Prop) : f (g265 x) = f (g264 x)
@[simp] axiom s265 (x : Prop) : f (g266 x) = f (g265 x)
@[simp] axiom s266 (x : Prop) : f (g267 x) = f (g266 x)
@[simp] axiom s267 (x : Prop) : f (g268 x) = f (g267 x)
@[simp] axiom s268 (x : Prop) : f (g269 x) = f (g268 x)
@[simp] axiom s269 (x : Prop) : f (g270 x) = f (g269 x)
@[simp] axiom s270 (x : Prop) : f (g271 x) = f (g270 x)
@[simp] axiom s271 (x : Prop) : f (g272 x) = f (g271 x)
@[simp] axiom s272 (x : Prop) : f (g273 x) = f (g272 x)
@[simp] axiom s273 (x : Prop) : f (g274 x) = f (g273 x)
@[simp] axiom s274 (x : Prop) : f (g275 x) = f (g274 x)
@[simp] axiom s275 (x : Prop) : f (g276 x) = f (g275 x)
@[simp] axiom s276 (x : Prop) : f (g277 x) = f (g276 x)
@[simp] axiom s277 (x : Prop) : f (g278 x) = f (g277 x)
@[simp] axiom s278 (x : Prop) : f (g279 x) = f (g278 x)
@[simp] axiom s279 (x : Prop) : f (g280 x) = f (g279 x)
@[simp] axiom s280 (x : Prop) : f (g281 x) = f (g280 x)
@[simp] axiom s281 (x : Prop) : f (g282 x) = f (g281 x)
@[simp] axiom s282 (x : Prop) : f (g283 x) = f (g282 x)
@[simp] axiom s283 (x : Prop) : f (g284 x) = f (g283 x)
@[simp] axiom s284 (x : Prop) : f (g285 x) = f (g284 x)
@[simp] axiom s285 (x : Prop) : f (g286 x) = f (g285 x)
@[simp] axiom s286 (x : Prop) : f (g287 x) = f (g286 x)
@[simp] axiom s287 (x : Prop) : f (g288 x) = f (g287 x)
@[simp] axiom s288 (x : Prop) : f (g289 x) = f (g288 x)
@[simp] axiom s289 (x : Prop) : f (g290 x) = f (g289 x)
@[simp] axiom s290 (x : Prop) : f (g291 x) = f (g290 x)
@[simp] axiom s291 (x : Prop) : f (g292 x) = f (g291 x)
@[simp] axiom s292 (x : Prop) : f (g293 x) = f (g292 x)
@[simp] axiom s293 (x : Prop) : f (g294 x) = f (g293 x)
@[simp] axiom s294 (x : Prop) : f (g295 x) = f (g294 x)
@[simp] axiom s295 (x : Prop) : f (g296 x) = f (g295 x)
@[simp] axiom s296 (x : Prop) : f (g297 x) = f (g296 x)
@[simp] axiom s297 (x : Prop) : f (g298 x) = f (g297 x)
@[simp] axiom s298 (x : Prop) : f (g299 x) = f (g298 x)
@[simp] axiom s299 (x : Prop) : f (g300 x) = f (g299 x)
@[simp] axiom s300 (x : Prop) : f (g301 x) = f (g300 x)
@[simp] axiom s301 (x : Prop) : f (g302 x) = f (g301 x)
@[simp] axiom s302 (x : Prop) : f (g303 x) = f (g302 x)
@[simp] axiom s303 (x : Prop) : f (g304 x) = f (g303 x)
@[simp] axiom s304 (x : Prop) : f (g305 x) = f (g304 x)
@[simp] axiom s305 (x : Prop) : f (g306 x) = f (g305 x)
@[simp] axiom s306 (x : Prop) : f (g307 x) = f (g306 x)
@[simp] axiom s307 (x : Prop) : f (g308 x) = f (g307 x)
@[simp] axiom s308 (x : Prop) : f (g309 x) = f (g308 x)
@[simp] axiom s309 (x : Prop) : f (g310 x) = f (g309 x)
@[simp] axiom s310 (x : Prop) : f (g311 x) = f (g310 x)
@[simp] axiom s311 (x : Prop) : f (g312 x) = f (g311 x)
@[simp] axiom s312 (x : Prop) : f (g313 x) = f (g312 x)
@[simp] axiom s313 (x : Prop) : f (g314 x) = f (g313 x)
@[simp] axiom s314 (x : Prop) : f (g315 x) = f (g314 x)
@[simp] axiom s315 (x : Prop) : f (g316 x) = f (g315 x)
@[simp] axiom s316 (x : Prop) : f (g317 x) = f (g316 x)
@[simp] axiom s317 (x : Prop) : f (g318 x) = f (g317 x)
@[simp] axiom s318 (x : Prop) : f (g319 x) = f (g318 x)
@[simp] axiom s319 (x : Prop) : f (g320 x) = f (g319 x)
@[simp] axiom s320 (x : Prop) : f (g321 x) = f (g320 x)
@[simp] axiom s321 (x : Prop) : f (g322 x) = f (g321 x)
@[simp] axiom s322 (x : Prop) : f (g323 x) = f (g322 x)
@[simp] axiom s323 (x : Prop) : f (g324 x) = f (g323 x)
@[simp] axiom s324 (x : Prop) : f (g325 x) = f (g324 x)
@[simp] axiom s325 (x : Prop) : f (g326 x) = f (g325 x)
@[simp] axiom s326 (x : Prop) : f (g327 x) = f (g326 x)
@[simp] axiom s327 (x : Prop) : f (g328 x) = f (g327 x)
@[simp] axiom s328 (x : Prop) : f (g329 x) = f (g328 x)
@[simp] axiom s329 (x : Prop) : f (g330 x) = f (g329 x)
@[simp] axiom s330 (x : Prop) : f (g331 x) = f (g330 x)
@[simp] axiom s331 (x : Prop) : f (g332 x) = f (g331 x)
@[simp] axiom s332 (x : Prop) : f (g333 x) = f (g332 x)
@[simp] axiom s333 (x : Prop) : f (g334 x) = f (g333 x)
@[simp] axiom s334 (x : Prop) : f (g335 x) = f (g334 x)
@[simp] axiom s335 (x : Prop) : f (g336 x) = f (g335 x)
@[simp] axiom s336 (x : Prop) : f (g337 x) = f (g336 x)
@[simp] axiom s337 (x : Prop) : f (g338 x) = f (g337 x)
@[simp] axiom s338 (x : Prop) : f (g339 x) = f (g338 x)
@[simp] axiom s339 (x : Prop) : f (g340 x) = f (g339 x)
@[simp] axiom s340 (x : Prop) : f (g341 x) = f (g340 x)
@[simp] axiom s341 (x : Prop) : f (g342 x) = f (g341 x)
@[simp] axiom s342 (x : Prop) : f (g343 x) = f (g342 x)
@[simp] axiom s343 (x : Prop) : f (g344 x) = f (g343 x)
@[simp] axiom s344 (x : Prop) : f (g345 x) = f (g344 x)
@[simp] axiom s345 (x : Prop) : f (g346 x) = f (g345 x)
@[simp] axiom s346 (x : Prop) : f (g347 x) = f (g346 x)
@[simp] axiom s347 (x : Prop) : f (g348 x) = f (g347 x)
@[simp] axiom s348 (x : Prop) : f (g349 x) = f (g348 x)
@[simp] axiom s349 (x : Prop) : f (g350 x) = f (g349 x)
@[simp] axiom s350 (x : Prop) : f (g351 x) = f (g350 x)
@[simp] axiom s351 (x : Prop) : f (g352 x) = f (g351 x)
@[simp] axiom s352 (x : Prop) : f (g353 x) = f (g352 x)
@[simp] axiom s353 (x : Prop) : f (g354 x) = f (g353 x)
@[simp] axiom s354 (x : Prop) : f (g355 x) = f (g354 x)
@[simp] axiom s355 (x : Prop) : f (g356 x) = f (g355 x)
@[simp] axiom s356 (x : Prop) : f (g357 x) = f (g356 x)
@[simp] axiom s357 (x : Prop) : f (g358 x) = f (g357 x)
@[simp] axiom s358 (x : Prop) : f (g359 x) = f (g358 x)
@[simp] axiom s359 (x : Prop) : f (g360 x) = f (g359 x)
@[simp] axiom s360 (x : Prop) : f (g361 x) = f (g360 x)
@[simp] axiom s361 (x : Prop) : f (g362 x) = f (g361 x)
@[simp] axiom s362 (x : Prop) : f (g363 x) = f (g362 x)
@[simp] axiom s363 (x : Prop) : f (g364 x) = f (g363 x)
@[simp] axiom s364 (x : Prop) : f (g365 x) = f (g364 x)
@[simp] axiom s365 (x : Prop) : f (g366 x) = f (g365 x)
@[simp] axiom s366 (x : Prop) : f (g367 x) = f (g366 x)
@[simp] axiom s367 (x : Prop) : f (g368 x) = f (g367 x)
@[simp] axiom s368 (x : Prop) : f (g369 x) = f (g368 x)
@[simp] axiom s369 (x : Prop) : f (g370 x) = f (g369 x)
@[simp] axiom s370 (x : Prop) : f (g371 x) = f (g370 x)
@[simp] axiom s371 (x : Prop) : f (g372 x) = f (g371 x)
@[simp] axiom s372 (x : Prop) : f (g373 x) = f (g372 x)
@[simp] axiom s373 (x : Prop) : f (g374 x) = f (g373 x)
@[simp] axiom s374 (x : Prop) : f (g375 x) = f (g374 x)
@[simp] axiom s375 (x : Prop) : f (g376 x) = f (g375 x)
@[simp] axiom s376 (x : Prop) : f (g377 x) = f (g376 x)
@[simp] axiom s377 (x : Prop) : f (g378 x) = f (g377 x)
@[simp] axiom s378 (x : Prop) : f (g379 x) = f (g378 x)
@[simp] axiom s379 (x : Prop) : f (g380 x) = f (g379 x)
@[simp] axiom s380 (x : Prop) : f (g381 x) = f (g380 x)
@[simp] axiom s381 (x : Prop) : f (g382 x) = f (g381 x)
@[simp] axiom s382 (x : Prop) : f (g383 x) = f (g382 x)
@[simp] axiom s383 (x : Prop) : f (g384 x) = f (g383 x)
@[simp] axiom s384 (x : Prop) : f (g385 x) = f (g384 x)
@[simp] axiom s385 (x : Prop) : f (g386 x) = f (g385 x)
@[simp] axiom s386 (x : Prop) : f (g387 x) = f (g386 x)
@[simp] axiom s387 (x : Prop) : f (g388 x) = f (g387 x)
@[simp] axiom s388 (x : Prop) : f (g389 x) = f (g388 x)
@[simp] axiom s389 (x : Prop) : f (g390 x) = f (g389 x)
@[simp] axiom s390 (x : Prop) : f (g391 x) = f (g390 x)
@[simp] axiom s391 (x : Prop) : f (g392 x) = f (g391 x)
@[simp] axiom s392 (x : Prop) : f (g393 x) = f (g392 x)
@[simp] axiom s393 (x : Prop) : f (g394 x) = f (g393 x)
@[simp] axiom s394 (x : Prop) : f (g395 x) = f (g394 x)
@[simp] axiom s395 (x : Prop) : f (g396 x) = f (g395 x)
@[simp] axiom s396 (x : Prop) : f (g397 x) = f (g396 x)
@[simp] axiom s397 (x : Prop) : f (g398 x) = f (g397 x)
@[simp] axiom s398 (x : Prop) : f (g399 x) = f (g398 x)
@[simp] axiom s399 (x : Prop) : f (g400 x) = f (g399 x)
@[simp] axiom s400 (x : Prop) : f (g401 x) = f (g400 x)
@[simp] axiom s401 (x : Prop) : f (g402 x) = f (g401 x)
@[simp] axiom s402 (x : Prop) : f (g403 x) = f (g402 x)
@[simp] axiom s403 (x : Prop) : f (g404 x) = f (g403 x)
@[simp] axiom s404 (x : Prop) : f (g405 x) = f (g404 x)
@[simp] axiom s405 (x : Prop) : f (g406 x) = f (g405 x)
@[simp] axiom s406 (x : Prop) : f (g407 x) = f (g406 x)
@[simp] axiom s407 (x : Prop) : f (g408 x) = f (g407 x)
@[simp] axiom s408 (x : Prop) : f (g409 x) = f (g408 x)
@[simp] axiom s409 (x : Prop) : f (g410 x) = f (g409 x)
@[simp] axiom s410 (x : Prop) : f (g411 x) = f (g410 x)
@[simp] axiom s411 (x : Prop) : f (g412 x) = f (g411 x)
@[simp] axiom s412 (x : Prop) : f (g413 x) = f (g412 x)
@[simp] axiom s413 (x : Prop) : f (g414 x) = f (g413 x)
@[simp] axiom s414 (x : Prop) : f (g415 x) = f (g414 x)
@[simp] axiom s415 (x : Prop) : f (g416 x) = f (g415 x)
@[simp] axiom s416 (x : Prop) : f (g417 x) = f (g416 x)
@[simp] axiom s417 (x : Prop) : f (g418 x) = f (g417 x)
@[simp] axiom s418 (x : Prop) : f (g419 x) = f (g418 x)
@[simp] axiom s419 (x : Prop) : f (g420 x) = f (g419 x)
@[simp] axiom s420 (x : Prop) : f (g421 x) = f (g420 x)
@[simp] axiom s421 (x : Prop) : f (g422 x) = f (g421 x)
@[simp] axiom s422 (x : Prop) : f (g423 x) = f (g422 x)
@[simp] axiom s423 (x : Prop) : f (g424 x) = f (g423 x)
@[simp] axiom s424 (x : Prop) : f (g425 x) = f (g424 x)
@[simp] axiom s425 (x : Prop) : f (g426 x) = f (g425 x)
@[simp] axiom s426 (x : Prop) : f (g427 x) = f (g426 x)
@[simp] axiom s427 (x : Prop) : f (g428 x) = f (g427 x)
@[simp] axiom s428 (x : Prop) : f (g429 x) = f (g428 x)
@[simp] axiom s429 (x : Prop) : f (g430 x) = f (g429 x)
@[simp] axiom s430 (x : Prop) : f (g431 x) = f (g430 x)
@[simp] axiom s431 (x : Prop) : f (g432 x) = f (g431 x)
@[simp] axiom s432 (x : Prop) : f (g433 x) = f (g432 x)
@[simp] axiom s433 (x : Prop) : f (g434 x) = f (g433 x)
@[simp] axiom s434 (x : Prop) : f (g435 x) = f (g434 x)
@[simp] axiom s435 (x : Prop) : f (g436 x) = f (g435 x)
@[simp] axiom s436 (x : Prop) : f (g437 x) = f (g436 x)
@[simp] axiom s437 (x : Prop) : f (g438 x) = f (g437 x)
@[simp] axiom s438 (x : Prop) : f (g439 x) = f (g438 x)
@[simp] axiom s439 (x : Prop) : f (g440 x) = f (g439 x)
@[simp] axiom s440 (x : Prop) : f (g441 x) = f (g440 x)
@[simp] axiom s441 (x : Prop) : f (g442 x) = f (g441 x)
@[simp] axiom s442 (x : Prop) : f (g443 x) = f (g442 x)
@[simp] axiom s443 (x : Prop) : f (g444 x) = f (g443 x)
@[simp] axiom s444 (x : Prop) : f (g445 x) = f (g444 x)
@[simp] axiom s445 (x : Prop) : f (g446 x) = f (g445 x)
@[simp] axiom s446 (x : Prop) : f (g447 x) = f (g446 x)
@[simp] axiom s447 (x : Prop) : f (g448 x) = f (g447 x)
@[simp] axiom s448 (x : Prop) : f (g449 x) = f (g448 x)
@[simp] axiom s449 (x : Prop) : f (g450 x) = f (g449 x)
@[simp] axiom s450 (x : Prop) : f (g451 x) = f (g450 x)
@[simp] axiom s451 (x : Prop) : f (g452 x) = f (g451 x)
@[simp] axiom s452 (x : Prop) : f (g453 x) = f (g452 x)
@[simp] axiom s453 (x : Prop) : f (g454 x) = f (g453 x)
@[simp] axiom s454 (x : Prop) : f (g455 x) = f (g454 x)
@[simp] axiom s455 (x : Prop) : f (g456 x) = f (g455 x)
@[simp] axiom s456 (x : Prop) : f (g457 x) = f (g456 x)
@[simp] axiom s457 (x : Prop) : f (g458 x) = f (g457 x)
@[simp] axiom s458 (x : Prop) : f (g459 x) = f (g458 x)
@[simp] axiom s459 (x : Prop) : f (g460 x) = f (g459 x)
@[simp] axiom s460 (x : Prop) : f (g461 x) = f (g460 x)
@[simp] axiom s461 (x : Prop) : f (g462 x) = f (g461 x)
@[simp] axiom s462 (x : Prop) : f (g463 x) = f (g462 x)
@[simp] axiom s463 (x : Prop) : f (g464 x) = f (g463 x)
@[simp] axiom s464 (x : Prop) : f (g465 x) = f (g464 x)
@[simp] axiom s465 (x : Prop) : f (g466 x) = f (g465 x)
@[simp] axiom s466 (x : Prop) : f (g467 x) = f (g466 x)
@[simp] axiom s467 (x : Prop) : f (g468 x) = f (g467 x)
@[simp] axiom s468 (x : Prop) : f (g469 x) = f (g468 x)
@[simp] axiom s469 (x : Prop) : f (g470 x) = f (g469 x)
@[simp] axiom s470 (x : Prop) : f (g471 x) = f (g470 x)
@[simp] axiom s471 (x : Prop) : f (g472 x) = f (g471 x)
@[simp] axiom s472 (x : Prop) : f (g473 x) = f (g472 x)
@[simp] axiom s473 (x : Prop) : f (g474 x) = f (g473 x)
@[simp] axiom s474 (x : Prop) : f (g475 x) = f (g474 x)
@[simp] axiom s475 (x : Prop) : f (g476 x) = f (g475 x)
@[simp] axiom s476 (x : Prop) : f (g477 x) = f (g476 x)
@[simp] axiom s477 (x : Prop) : f (g478 x) = f (g477 x)
@[simp] axiom s478 (x : Prop) : f (g479 x) = f (g478 x)
@[simp] axiom s479 (x : Prop) : f (g480 x) = f (g479 x)
@[simp] axiom s480 (x : Prop) : f (g481 x) = f (g480 x)
@[simp] axiom s481 (x : Prop) : f (g482 x) = f (g481 x)
@[simp] axiom s482 (x : Prop) : f (g483 x) = f (g482 x)
@[simp] axiom s483 (x : Prop) : f (g484 x) = f (g483 x)
@[simp] axiom s484 (x : Prop) : f (g485 x) = f (g484 x)
@[simp] axiom s485 (x : Prop) : f (g486 x) = f (g485 x)
@[simp] axiom s486 (x : Prop) : f (g487 x) = f (g486 x)
@[simp] axiom s487 (x : Prop) : f (g488 x) = f (g487 x)
@[simp] axiom s488 (x : Prop) : f (g489 x) = f (g488 x)
@[simp] axiom s489 (x : Prop) : f (g490 x) = f (g489 x)
@[simp] axiom s490 (x : Prop) : f (g491 x) = f (g490 x)
@[simp] axiom s491 (x : Prop) : f (g492 x) = f (g491 x)
@[simp] axiom s492 (x : Prop) : f (g493 x) = f (g492 x)
@[simp] axiom s493 (x : Prop) : f (g494 x) = f (g493 x)
@[simp] axiom s494 (x : Prop) : f (g495 x) = f (g494 x)
@[simp] axiom s495 (x : Prop) : f (g496 x) = f (g495 x)
@[simp] axiom s496 (x : Prop) : f (g497 x) = f (g496 x)
@[simp] axiom s497 (x : Prop) : f (g498 x) = f (g497 x)
@[simp] axiom s498 (x : Prop) : f (g499 x) = f (g498 x)
@[simp] axiom s499 (x : Prop) : f (g500 x) = f (g499 x)
@[simp] axiom s500 (x : Prop) : f (g501 x) = f (g500 x)
@[simp] axiom s501 (x : Prop) : f (g502 x) = f (g501 x)
@[simp] axiom s502 (x : Prop) : f (g503 x) = f (g502 x)
@[simp] axiom s503 (x : Prop) : f (g504 x) = f (g503 x)
@[simp] axiom s504 (x : Prop) : f (g505 x) = f (g504 x)
@[simp] axiom s505 (x : Prop) : f (g506 x) = f (g505 x)
@[simp] axiom s506 (x : Prop) : f (g507 x) = f (g506 x)
@[simp] axiom s507 (x : Prop) : f (g508 x) = f (g507 x)
@[simp] axiom s508 (x : Prop) : f (g509 x) = f (g508 x)
@[simp] axiom s509 (x : Prop) : f (g510 x) = f (g509 x)
@[simp] axiom s510 (x : Prop) : f (g511 x) = f (g510 x)
@[simp] axiom s511 (x : Prop) : f (g512 x) = f (g511 x)
@[simp] axiom s512 (x : Prop) : f (g513 x) = f (g512 x)
@[simp] axiom s513 (x : Prop) : f (g514 x) = f (g513 x)
@[simp] axiom s514 (x : Prop) : f (g515 x) = f (g514 x)
@[simp] axiom s515 (x : Prop) : f (g516 x) = f (g515 x)
@[simp] axiom s516 (x : Prop) : f (g517 x) = f (g516 x)
@[simp] axiom s517 (x : Prop) : f (g518 x) = f (g517 x)
@[simp] axiom s518 (x : Prop) : f (g519 x) = f (g518 x)
@[simp] axiom s519 (x : Prop) : f (g520 x) = f (g519 x)
@[simp] axiom s520 (x : Prop) : f (g521 x) = f (g520 x)
@[simp] axiom s521 (x : Prop) : f (g522 x) = f (g521 x)
@[simp] axiom s522 (x : Prop) : f (g523 x) = f (g522 x)
@[simp] axiom s523 (x : Prop) : f (g524 x) = f (g523 x)
@[simp] axiom s524 (x : Prop) : f (g525 x) = f (g524 x)
@[simp] axiom s525 (x : Prop) : f (g526 x) = f (g525 x)
@[simp] axiom s526 (x : Prop) : f (g527 x) = f (g526 x)
@[simp] axiom s527 (x : Prop) : f (g528 x) = f (g527 x)
@[simp] axiom s528 (x : Prop) : f (g529 x) = f (g528 x)
@[simp] axiom s529 (x : Prop) : f (g530 x) = f (g529 x)
@[simp] axiom s530 (x : Prop) : f (g531 x) = f (g530 x)
@[simp] axiom s531 (x : Prop) : f (g532 x) = f (g531 x)
@[simp] axiom s532 (x : Prop) : f (g533 x) = f (g532 x)
@[simp] axiom s533 (x : Prop) : f (g534 x) = f (g533 x)
@[simp] axiom s534 (x : Prop) : f (g535 x) = f (g534 x)
@[simp] axiom s535 (x : Prop) : f (g536 x) = f (g535 x)
@[simp] axiom s536 (x : Prop) : f (g537 x) = f (g536 x)
@[simp] axiom s537 (x : Prop) : f (g538 x) = f (g537 x)
@[simp] axiom s538 (x : Prop) : f (g539 x) = f (g538 x)
@[simp] axiom s539 (x : Prop) : f (g540 x) = f (g539 x)
@[simp] axiom s540 (x : Prop) : f (g541 x) = f (g540 x)
@[simp] axiom s541 (x : Prop) : f (g542 x) = f (g541 x)
@[simp] axiom s542 (x : Prop) : f (g543 x) = f (g542 x)
@[simp] axiom s543 (x : Prop) : f (g544 x) = f (g543 x)
@[simp] axiom s544 (x : Prop) : f (g545 x) = f (g544 x)
@[simp] axiom s545 (x : Prop) : f (g546 x) = f (g545 x)
@[simp] axiom s546 (x : Prop) : f (g547 x) = f (g546 x)
@[simp] axiom s547 (x : Prop) : f (g548 x) = f (g547 x)
@[simp] axiom s548 (x : Prop) : f (g549 x) = f (g548 x)
@[simp] axiom s549 (x : Prop) : f (g550 x) = f (g549 x)
@[simp] axiom s550 (x : Prop) : f (g551 x) = f (g550 x)
@[simp] axiom s551 (x : Prop) : f (g552 x) = f (g551 x)
@[simp] axiom s552 (x : Prop) : f (g553 x) = f (g552 x)
@[simp] axiom s553 (x : Prop) : f (g554 x) = f (g553 x)
@[simp] axiom s554 (x : Prop) : f (g555 x) = f (g554 x)
@[simp] axiom s555 (x : Prop) : f (g556 x) = f (g555 x)
@[simp] axiom s556 (x : Prop) : f (g557 x) = f (g556 x)
@[simp] axiom s557 (x : Prop) : f (g558 x) = f (g557 x)
@[simp] axiom s558 (x : Prop) : f (g559 x) = f (g558 x)
@[simp] axiom s559 (x : Prop) : f (g560 x) = f (g559 x)
@[simp] axiom s560 (x : Prop) : f (g561 x) = f (g560 x)
@[simp] axiom s561 (x : Prop) : f (g562 x) = f (g561 x)
@[simp] axiom s562 (x : Prop) : f (g563 x) = f (g562 x)
@[simp] axiom s563 (x : Prop) : f (g564 x) = f (g563 x)
@[simp] axiom s564 (x : Prop) : f (g565 x) = f (g564 x)
@[simp] axiom s565 (x : Prop) : f (g566 x) = f (g565 x)
@[simp] axiom s566 (x : Prop) : f (g567 x) = f (g566 x)
@[simp] axiom s567 (x : Prop) : f (g568 x) = f (g567 x)
@[simp] axiom s568 (x : Prop) : f (g569 x) = f (g568 x)
@[simp] axiom s569 (x : Prop) : f (g570 x) = f (g569 x)
@[simp] axiom s570 (x : Prop) : f (g571 x) = f (g570 x)
@[simp] axiom s571 (x : Prop) : f (g572 x) = f (g571 x)
@[simp] axiom s572 (x : Prop) : f (g573 x) = f (g572 x)
@[simp] axiom s573 (x : Prop) : f (g574 x) = f (g573 x)
@[simp] axiom s574 (x : Prop) : f (g575 x) = f (g574 x)
@[simp] axiom s575 (x : Prop) : f (g576 x) = f (g575 x)
@[simp] axiom s576 (x : Prop) : f (g577 x) = f (g576 x)
@[simp] axiom s577 (x : Prop) : f (g578 x) = f (g577 x)
@[simp] axiom s578 (x : Prop) : f (g579 x) = f (g578 x)
@[simp] axiom s579 (x : Prop) : f (g580 x) = f (g579 x)
@[simp] axiom s580 (x : Prop) : f (g581 x) = f (g580 x)
@[simp] axiom s581 (x : Prop) : f (g582 x) = f (g581 x)
@[simp] axiom s582 (x : Prop) : f (g583 x) = f (g582 x)
@[simp] axiom s583 (x : Prop) : f (g584 x) = f (g583 x)
@[simp] axiom s584 (x : Prop) : f (g585 x) = f (g584 x)
@[simp] axiom s585 (x : Prop) : f (g586 x) = f (g585 x)
@[simp] axiom s586 (x : Prop) : f (g587 x) = f (g586 x)
@[simp] axiom s587 (x : Prop) : f (g588 x) = f (g587 x)
@[simp] axiom s588 (x : Prop) : f (g589 x) = f (g588 x)
@[simp] axiom s589 (x : Prop) : f (g590 x) = f (g589 x)
@[simp] axiom s590 (x : Prop) : f (g591 x) = f (g590 x)
@[simp] axiom s591 (x : Prop) : f (g592 x) = f (g591 x)
@[simp] axiom s592 (x : Prop) : f (g593 x) = f (g592 x)
@[simp] axiom s593 (x : Prop) : f (g594 x) = f (g593 x)
@[simp] axiom s594 (x : Prop) : f (g595 x) = f (g594 x)
@[simp] axiom s595 (x : Prop) : f (g596 x) = f (g595 x)
@[simp] axiom s596 (x : Prop) : f (g597 x) = f (g596 x)
@[simp] axiom s597 (x : Prop) : f (g598 x) = f (g597 x)
@[simp] axiom s598 (x : Prop) : f (g599 x) = f (g598 x)
@[simp] axiom s599 (x : Prop) : f (g600 x) = f (g599 x)
@[simp] axiom s600 (x : Prop) : f (g601 x) = f (g600 x)
@[simp] axiom s601 (x : Prop) : f (g602 x) = f (g601 x)
@[simp] axiom s602 (x : Prop) : f (g603 x) = f (g602 x)
@[simp] axiom s603 (x : Prop) : f (g604 x) = f (g603 x)
@[simp] axiom s604 (x : Prop) : f (g605 x) = f (g604 x)
@[simp] axiom s605 (x : Prop) : f (g606 x) = f (g605 x)
@[simp] axiom s606 (x : Prop) : f (g607 x) = f (g606 x)
@[simp] axiom s607 (x : Prop) : f (g608 x) = f (g607 x)
@[simp] axiom s608 (x : Prop) : f (g609 x) = f (g608 x)
@[simp] axiom s609 (x : Prop) : f (g610 x) = f (g609 x)
@[simp] axiom s610 (x : Prop) : f (g611 x) = f (g610 x)
@[simp] axiom s611 (x : Prop) : f (g612 x) = f (g611 x)
@[simp] axiom s612 (x : Prop) : f (g613 x) = f (g612 x)
@[simp] axiom s613 (x : Prop) : f (g614 x) = f (g613 x)
@[simp] axiom s614 (x : Prop) : f (g615 x) = f (g614 x)
@[simp] axiom s615 (x : Prop) : f (g616 x) = f (g615 x)
@[simp] axiom s616 (x : Prop) : f (g617 x) = f (g616 x)
@[simp] axiom s617 (x : Prop) : f (g618 x) = f (g617 x)
@[simp] axiom s618 (x : Prop) : f (g619 x) = f (g618 x)
@[simp] axiom s619 (x : Prop) : f (g620 x) = f (g619 x)
@[simp] axiom s620 (x : Prop) : f (g621 x) = f (g620 x)
@[simp] axiom s621 (x : Prop) : f (g622 x) = f (g621 x)
@[simp] axiom s622 (x : Prop) : f (g623 x) = f (g622 x)
@[simp] axiom s623 (x : Prop) : f (g624 x) = f (g623 x)
@[simp] axiom s624 (x : Prop) : f (g625 x) = f (g624 x)
@[simp] axiom s625 (x : Prop) : f (g626 x) = f (g625 x)
@[simp] axiom s626 (x : Prop) : f (g627 x) = f (g626 x)
@[simp] axiom s627 (x : Prop) : f (g628 x) = f (g627 x)
@[simp] axiom s628 (x : Prop) : f (g629 x) = f (g628 x)
@[simp] axiom s629 (x : Prop) : f (g630 x) = f (g629 x)
@[simp] axiom s630 (x : Prop) : f (g631 x) = f (g630 x)
@[simp] axiom s631 (x : Prop) : f (g632 x) = f (g631 x)
@[simp] axiom s632 (x : Prop) : f (g633 x) = f (g632 x)
@[simp] axiom s633 (x : Prop) : f (g634 x) = f (g633 x)
@[simp] axiom s634 (x : Prop) : f (g635 x) = f (g634 x)
@[simp] axiom s635 (x : Prop) : f (g636 x) = f (g635 x)
@[simp] axiom s636 (x : Prop) : f (g637 x) = f (g636 x)
@[simp] axiom s637 (x : Prop) : f (g638 x) = f (g637 x)
@[simp] axiom s638 (x : Prop) : f (g639 x) = f (g638 x)
@[simp] axiom s639 (x : Prop) : f (g640 x) = f (g639 x)
@[simp] axiom s640 (x : Prop) : f (g641 x) = f (g640 x)
@[simp] axiom s641 (x : Prop) : f (g642 x) = f (g641 x)
@[simp] axiom s642 (x : Prop) : f (g643 x) = f (g642 x)
@[simp] axiom s643 (x : Prop) : f (g644 x) = f (g643 x)
@[simp] axiom s644 (x : Prop) : f (g645 x) = f (g644 x)
@[simp] axiom s645 (x : Prop) : f (g646 x) = f (g645 x)
@[simp] axiom s646 (x : Prop) : f (g647 x) = f (g646 x)
@[simp] axiom s647 (x : Prop) : f (g648 x) = f (g647 x)
@[simp] axiom s648 (x : Prop) : f (g649 x) = f (g648 x)
@[simp] axiom s649 (x : Prop) : f (g650 x) = f (g649 x)
@[simp] axiom s650 (x : Prop) : f (g651 x) = f (g650 x)
@[simp] axiom s651 (x : Prop) : f (g652 x) = f (g651 x)
@[simp] axiom s652 (x : Prop) : f (g653 x) = f (g652 x)
@[simp] axiom s653 (x : Prop) : f (g654 x) = f (g653 x)
@[simp] axiom s654 (x : Prop) : f (g655 x) = f (g654 x)
@[simp] axiom s655 (x : Prop) : f (g656 x) = f (g655 x)
@[simp] axiom s656 (x : Prop) : f (g657 x) = f (g656 x)
@[simp] axiom s657 (x : Prop) : f (g658 x) = f (g657 x)
@[simp] axiom s658 (x : Prop) : f (g659 x) = f (g658 x)
@[simp] axiom s659 (x : Prop) : f (g660 x) = f (g659 x)
@[simp] axiom s660 (x : Prop) : f (g661 x) = f (g660 x)
@[simp] axiom s661 (x : Prop) : f (g662 x) = f (g661 x)
@[simp] axiom s662 (x : Prop) : f (g663 x) = f (g662 x)
@[simp] axiom s663 (x : Prop) : f (g664 x) = f (g663 x)
@[simp] axiom s664 (x : Prop) : f (g665 x) = f (g664 x)
@[simp] axiom s665 (x : Prop) : f (g666 x) = f (g665 x)
@[simp] axiom s666 (x : Prop) : f (g667 x) = f (g666 x)
@[simp] axiom s667 (x : Prop) : f (g668 x) = f (g667 x)
@[simp] axiom s668 (x : Prop) : f (g669 x) = f (g668 x)
@[simp] axiom s669 (x : Prop) : f (g670 x) = f (g669 x)
@[simp] axiom s670 (x : Prop) : f (g671 x) = f (g670 x)
@[simp] axiom s671 (x : Prop) : f (g672 x) = f (g671 x)
@[simp] axiom s672 (x : Prop) : f (g673 x) = f (g672 x)
@[simp] axiom s673 (x : Prop) : f (g674 x) = f (g673 x)
@[simp] axiom s674 (x : Prop) : f (g675 x) = f (g674 x)
@[simp] axiom s675 (x : Prop) : f (g676 x) = f (g675 x)
@[simp] axiom s676 (x : Prop) : f (g677 x) = f (g676 x)
@[simp] axiom s677 (x : Prop) : f (g678 x) = f (g677 x)
@[simp] axiom s678 (x : Prop) : f (g679 x) = f (g678 x)
@[simp] axiom s679 (x : Prop) : f (g680 x) = f (g679 x)
@[simp] axiom s680 (x : Prop) : f (g681 x) = f (g680 x)
@[simp] axiom s681 (x : Prop) : f (g682 x) = f (g681 x)
@[simp] axiom s682 (x : Prop) : f (g683 x) = f (g682 x)
@[simp] axiom s683 (x : Prop) : f (g684 x) = f (g683 x)
@[simp] axiom s684 (x : Prop) : f (g685 x) = f (g684 x)
@[simp] axiom s685 (x : Prop) : f (g686 x) = f (g685 x)
@[simp] axiom s686 (x : Prop) : f (g687 x) = f (g686 x)
@[simp] axiom s687 (x : Prop) : f (g688 x) = f (g687 x)
@[simp] axiom s688 (x : Prop) : f (g689 x) = f (g688 x)
@[simp] axiom s689 (x : Prop) : f (g690 x) = f (g689 x)
@[simp] axiom s690 (x : Prop) : f (g691 x) = f (g690 x)
@[simp] axiom s691 (x : Prop) : f (g692 x) = f (g691 x)
@[simp] axiom s692 (x : Prop) : f (g693 x) = f (g692 x)
@[simp] axiom s693 (x : Prop) : f (g694 x) = f (g693 x)
@[simp] axiom s694 (x : Prop) : f (g695 x) = f (g694 x)
@[simp] axiom s695 (x : Prop) : f (g696 x) = f (g695 x)
@[simp] axiom s696 (x : Prop) : f (g697 x) = f (g696 x)
@[simp] axiom s697 (x : Prop) : f (g698 x) = f (g697 x)
@[simp] axiom s698 (x : Prop) : f (g699 x) = f (g698 x)
@[simp] axiom s699 (x : Prop) : f (g700 x) = f (g699 x)
@[simp] axiom s700 (x : Prop) : f (g701 x) = f (g700 x)
@[simp] axiom s701 (x : Prop) : f (g702 x) = f (g701 x)
@[simp] axiom s702 (x : Prop) : f (g703 x) = f (g702 x)
@[simp] axiom s703 (x : Prop) : f (g704 x) = f (g703 x)
@[simp] axiom s704 (x : Prop) : f (g705 x) = f (g704 x)
@[simp] axiom s705 (x : Prop) : f (g706 x) = f (g705 x)
@[simp] axiom s706 (x : Prop) : f (g707 x) = f (g706 x)
@[simp] axiom s707 (x : Prop) : f (g708 x) = f (g707 x)
@[simp] axiom s708 (x : Prop) : f (g709 x) = f (g708 x)
@[simp] axiom s709 (x : Prop) : f (g710 x) = f (g709 x)
@[simp] axiom s710 (x : Prop) : f (g711 x) = f (g710 x)
@[simp] axiom s711 (x : Prop) : f (g712 x) = f (g711 x)
@[simp] axiom s712 (x : Prop) : f (g713 x) = f (g712 x)
@[simp] axiom s713 (x : Prop) : f (g714 x) = f (g713 x)
@[simp] axiom s714 (x : Prop) : f (g715 x) = f (g714 x)
@[simp] axiom s715 (x : Prop) : f (g716 x) = f (g715 x)
@[simp] axiom s716 (x : Prop) : f (g717 x) = f (g716 x)
@[simp] axiom s717 (x : Prop) : f (g718 x) = f (g717 x)
@[simp] axiom s718 (x : Prop) : f (g719 x) = f (g718 x)
@[simp] axiom s719 (x : Prop) : f (g720 x) = f (g719 x)
@[simp] axiom s720 (x : Prop) : f (g721 x) = f (g720 x)
@[simp] axiom s721 (x : Prop) : f (g722 x) = f (g721 x)
@[simp] axiom s722 (x : Prop) : f (g723 x) = f (g722 x)
@[simp] axiom s723 (x : Prop) : f (g724 x) = f (g723 x)
@[simp] axiom s724 (x : Prop) : f (g725 x) = f (g724 x)
@[simp] axiom s725 (x : Prop) : f (g726 x) = f (g725 x)
@[simp] axiom s726 (x : Prop) : f (g727 x) = f (g726 x)
@[simp] axiom s727 (x : Prop) : f (g728 x) = f (g727 x)
@[simp] axiom s728 (x : Prop) : f (g729 x) = f (g728 x)
@[simp] axiom s729 (x : Prop) : f (g730 x) = f (g729 x)
@[simp] axiom s730 (x : Prop) : f (g731 x) = f (g730 x)
@[simp] axiom s731 (x : Prop) : f (g732 x) = f (g731 x)
@[simp] axiom s732 (x : Prop) : f (g733 x) = f (g732 x)
@[simp] axiom s733 (x : Prop) : f (g734 x) = f (g733 x)
@[simp] axiom s734 (x : Prop) : f (g735 x) = f (g734 x)
@[simp] axiom s735 (x : Prop) : f (g736 x) = f (g735 x)
@[simp] axiom s736 (x : Prop) : f (g737 x) = f (g736 x)
@[simp] axiom s737 (x : Prop) : f (g738 x) = f (g737 x)
@[simp] axiom s738 (x : Prop) : f (g739 x) = f (g738 x)
@[simp] axiom s739 (x : Prop) : f (g740 x) = f (g739 x)
@[simp] axiom s740 (x : Prop) : f (g741 x) = f (g740 x)
@[simp] axiom s741 (x : Prop) : f (g742 x) = f (g741 x)
@[simp] axiom s742 (x : Prop) : f (g743 x) = f (g742 x)
@[simp] axiom s743 (x : Prop) : f (g744 x) = f (g743 x)
@[simp] axiom s744 (x : Prop) : f (g745 x) = f (g744 x)
@[simp] axiom s745 (x : Prop) : f (g746 x) = f (g745 x)
@[simp] axiom s746 (x : Prop) : f (g747 x) = f (g746 x)
@[simp] axiom s747 (x : Prop) : f (g748 x) = f (g747 x)
@[simp] axiom s748 (x : Prop) : f (g749 x) = f (g748 x)
@[simp] axiom s749 (x : Prop) : f (g750 x) = f (g749 x)
@[simp] axiom s750 (x : Prop) : f (g751 x) = f (g750 x)
@[simp] axiom s751 (x : Prop) : f (g752 x) = f (g751 x)
@[simp] axiom s752 (x : Prop) : f (g753 x) = f (g752 x)
@[simp] axiom s753 (x : Prop) : f (g754 x) = f (g753 x)
@[simp] axiom s754 (x : Prop) : f (g755 x) = f (g754 x)
@[simp] axiom s755 (x : Prop) : f (g756 x) = f (g755 x)
@[simp] axiom s756 (x : Prop) : f (g757 x) = f (g756 x)
@[simp] axiom s757 (x : Prop) : f (g758 x) = f (g757 x)
@[simp] axiom s758 (x : Prop) : f (g759 x) = f (g758 x)
@[simp] axiom s759 (x : Prop) : f (g760 x) = f (g759 x)
@[simp] axiom s760 (x : Prop) : f (g761 x) = f (g760 x)
@[simp] axiom s761 (x : Prop) : f (g762 x) = f (g761 x)
@[simp] axiom s762 (x : Prop) : f (g763 x) = f (g762 x)
@[simp] axiom s763 (x : Prop) : f (g764 x) = f (g763 x)
@[simp] axiom s764 (x : Prop) : f (g765 x) = f (g764 x)
@[simp] axiom s765 (x : Prop) : f (g766 x) = f (g765 x)
@[simp] axiom s766 (x : Prop) : f (g767 x) = f (g766 x)
@[simp] axiom s767 (x : Prop) : f (g768 x) = f (g767 x)
@[simp] axiom s768 (x : Prop) : f (g769 x) = f (g768 x)
@[simp] axiom s769 (x : Prop) : f (g770 x) = f (g769 x)
@[simp] axiom s770 (x : Prop) : f (g771 x) = f (g770 x)
@[simp] axiom s771 (x : Prop) : f (g772 x) = f (g771 x)
@[simp] axiom s772 (x : Prop) : f (g773 x) = f (g772 x)
@[simp] axiom s773 (x : Prop) : f (g774 x) = f (g773 x)
@[simp] axiom s774 (x : Prop) : f (g775 x) = f (g774 x)
@[simp] axiom s775 (x : Prop) : f (g776 x) = f (g775 x)
@[simp] axiom s776 (x : Prop) : f (g777 x) = f (g776 x)
@[simp] axiom s777 (x : Prop) : f (g778 x) = f (g777 x)
@[simp] axiom s778 (x : Prop) : f (g779 x) = f (g778 x)
@[simp] axiom s779 (x : Prop) : f (g780 x) = f (g779 x)
@[simp] axiom s780 (x : Prop) : f (g781 x) = f (g780 x)
@[simp] axiom s781 (x : Prop) : f (g782 x) = f (g781 x)
@[simp] axiom s782 (x : Prop) : f (g783 x) = f (g782 x)
@[simp] axiom s783 (x : Prop) : f (g784 x) = f (g783 x)
@[simp] axiom s784 (x : Prop) : f (g785 x) = f (g784 x)
@[simp] axiom s785 (x : Prop) : f (g786 x) = f (g785 x)
@[simp] axiom s786 (x : Prop) : f (g787 x) = f (g786 x)
@[simp] axiom s787 (x : Prop) : f (g788 x) = f (g787 x)
@[simp] axiom s788 (x : Prop) : f (g789 x) = f (g788 x)
@[simp] axiom s789 (x : Prop) : f (g790 x) = f (g789 x)
@[simp] axiom s790 (x : Prop) : f (g791 x) = f (g790 x)
@[simp] axiom s791 (x : Prop) : f (g792 x) = f (g791 x)
@[simp] axiom s792 (x : Prop) : f (g793 x) = f (g792 x)
@[simp] axiom s793 (x : Prop) : f (g794 x) = f (g793 x)
@[simp] axiom s794 (x : Prop) : f (g795 x) = f (g794 x)
@[simp] axiom s795 (x : Prop) : f (g796 x) = f (g795 x)
@[simp] axiom s796 (x : Prop) : f (g797 x) = f (g796 x)
@[simp] axiom s797 (x : Prop) : f (g798 x) = f (g797 x)
@[simp] axiom s798 (x : Prop) : f (g799 x) = f (g798 x)
@[simp] axiom s799 (x : Prop) : f (g800 x) = f (g799 x)
@[simp] axiom s800 (x : Prop) : f (g801 x) = f (g800 x)
@[simp] axiom s801 (x : Prop) : f (g802 x) = f (g801 x)
@[simp] axiom s802 (x : Prop) : f (g803 x) = f (g802 x)
@[simp] axiom s803 (x : Prop) : f (g804 x) = f (g803 x)
@[simp] axiom s804 (x : Prop) : f (g805 x) = f (g804 x)
@[simp] axiom s805 (x : Prop) : f (g806 x) = f (g805 x)
@[simp] axiom s806 (x : Prop) : f (g807 x) = f (g806 x)
@[simp] axiom s807 (x : Prop) : f (g808 x) = f (g807 x)
@[simp] axiom s808 (x : Prop) : f (g809 x) = f (g808 x)
@[simp] axiom s809 (x : Prop) : f (g810 x) = f (g809 x)
@[simp] axiom s810 (x : Prop) : f (g811 x) = f (g810 x)
@[simp] axiom s811 (x : Prop) : f (g812 x) = f (g811 x)
@[simp] axiom s812 (x : Prop) : f (g813 x) = f (g812 x)
@[simp] axiom s813 (x : Prop) : f (g814 x) = f (g813 x)
@[simp] axiom s814 (x : Prop) : f (g815 x) = f (g814 x)
@[simp] axiom s815 (x : Prop) : f (g816 x) = f (g815 x)
@[simp] axiom s816 (x : Prop) : f (g817 x) = f (g816 x)
@[simp] axiom s817 (x : Prop) : f (g818 x) = f (g817 x)
@[simp] axiom s818 (x : Prop) : f (g819 x) = f (g818 x)
@[simp] axiom s819 (x : Prop) : f (g820 x) = f (g819 x)
@[simp] axiom s820 (x : Prop) : f (g821 x) = f (g820 x)
@[simp] axiom s821 (x : Prop) : f (g822 x) = f (g821 x)
@[simp] axiom s822 (x : Prop) : f (g823 x) = f (g822 x)
@[simp] axiom s823 (x : Prop) : f (g824 x) = f (g823 x)
@[simp] axiom s824 (x : Prop) : f (g825 x) = f (g824 x)
@[simp] axiom s825 (x : Prop) : f (g826 x) = f (g825 x)
@[simp] axiom s826 (x : Prop) : f (g827 x) = f (g826 x)
@[simp] axiom s827 (x : Prop) : f (g828 x) = f (g827 x)
@[simp] axiom s828 (x : Prop) : f (g829 x) = f (g828 x)
@[simp] axiom s829 (x : Prop) : f (g830 x) = f (g829 x)
@[simp] axiom s830 (x : Prop) : f (g831 x) = f (g830 x)
@[simp] axiom s831 (x : Prop) : f (g832 x) = f (g831 x)
@[simp] axiom s832 (x : Prop) : f (g833 x) = f (g832 x)
@[simp] axiom s833 (x : Prop) : f (g834 x) = f (g833 x)
@[simp] axiom s834 (x : Prop) : f (g835 x) = f (g834 x)
@[simp] axiom s835 (x : Prop) : f (g836 x) = f (g835 x)
@[simp] axiom s836 (x : Prop) : f (g837 x) = f (g836 x)
@[simp] axiom s837 (x : Prop) : f (g838 x) = f (g837 x)
@[simp] axiom s838 (x : Prop) : f (g839 x) = f (g838 x)
@[simp] axiom s839 (x : Prop) : f (g840 x) = f (g839 x)
@[simp] axiom s840 (x : Prop) : f (g841 x) = f (g840 x)
@[simp] axiom s841 (x : Prop) : f (g842 x) = f (g841 x)
@[simp] axiom s842 (x : Prop) : f (g843 x) = f (g842 x)
@[simp] axiom s843 (x : Prop) : f (g844 x) = f (g843 x)
@[simp] axiom s844 (x : Prop) : f (g845 x) = f (g844 x)
@[simp] axiom s845 (x : Prop) : f (g846 x) = f (g845 x)
@[simp] axiom s846 (x : Prop) : f (g847 x) = f (g846 x)
@[simp] axiom s847 (x : Prop) : f (g848 x) = f (g847 x)
@[simp] axiom s848 (x : Prop) : f (g849 x) = f (g848 x)
@[simp] axiom s849 (x : Prop) : f (g850 x) = f (g849 x)
@[simp] axiom s850 (x : Prop) : f (g851 x) = f (g850 x)
@[simp] axiom s851 (x : Prop) : f (g852 x) = f (g851 x)
@[simp] axiom s852 (x : Prop) : f (g853 x) = f (g852 x)
@[simp] axiom s853 (x : Prop) : f (g854 x) = f (g853 x)
@[simp] axiom s854 (x : Prop) : f (g855 x) = f (g854 x)
@[simp] axiom s855 (x : Prop) : f (g856 x) = f (g855 x)
@[simp] axiom s856 (x : Prop) : f (g857 x) = f (g856 x)
@[simp] axiom s857 (x : Prop) : f (g858 x) = f (g857 x)
@[simp] axiom s858 (x : Prop) : f (g859 x) = f (g858 x)
@[simp] axiom s859 (x : Prop) : f (g860 x) = f (g859 x)
@[simp] axiom s860 (x : Prop) : f (g861 x) = f (g860 x)
@[simp] axiom s861 (x : Prop) : f (g862 x) = f (g861 x)
@[simp] axiom s862 (x : Prop) : f (g863 x) = f (g862 x)
@[simp] axiom s863 (x : Prop) : f (g864 x) = f (g863 x)
@[simp] axiom s864 (x : Prop) : f (g865 x) = f (g864 x)
@[simp] axiom s865 (x : Prop) : f (g866 x) = f (g865 x)
@[simp] axiom s866 (x : Prop) : f (g867 x) = f (g866 x)
@[simp] axiom s867 (x : Prop) : f (g868 x) = f (g867 x)
@[simp] axiom s868 (x : Prop) : f (g869 x) = f (g868 x)
@[simp] axiom s869 (x : Prop) : f (g870 x) = f (g869 x)
@[simp] axiom s870 (x : Prop) : f (g871 x) = f (g870 x)
@[simp] axiom s871 (x : Prop) : f (g872 x) = f (g871 x)
@[simp] axiom s872 (x : Prop) : f (g873 x) = f (g872 x)
@[simp] axiom s873 (x : Prop) : f (g874 x) = f (g873 x)
@[simp] axiom s874 (x : Prop) : f (g875 x) = f (g874 x)
@[simp] axiom s875 (x : Prop) : f (g876 x) = f (g875 x)
@[simp] axiom s876 (x : Prop) : f (g877 x) = f (g876 x)
@[simp] axiom s877 (x : Prop) : f (g878 x) = f (g877 x)
@[simp] axiom s878 (x : Prop) : f (g879 x) = f (g878 x)
@[simp] axiom s879 (x : Prop) : f (g880 x) = f (g879 x)
@[simp] axiom s880 (x : Prop) : f (g881 x) = f (g880 x)
@[simp] axiom s881 (x : Prop) : f (g882 x) = f (g881 x)
@[simp] axiom s882 (x : Prop) : f (g883 x) = f (g882 x)
@[simp] axiom s883 (x : Prop) : f (g884 x) = f (g883 x)
@[simp] axiom s884 (x : Prop) : f (g885 x) = f (g884 x)
@[simp] axiom s885 (x : Prop) : f (g886 x) = f (g885 x)
@[simp] axiom s886 (x : Prop) : f (g887 x) = f (g886 x)
@[simp] axiom s887 (x : Prop) : f (g888 x) = f (g887 x)
@[simp] axiom s888 (x : Prop) : f (g889 x) = f (g888 x)
@[simp] axiom s889 (x : Prop) : f (g890 x) = f (g889 x)
@[simp] axiom s890 (x : Prop) : f (g891 x) = f (g890 x)
@[simp] axiom s891 (x : Prop) : f (g892 x) = f (g891 x)
@[simp] axiom s892 (x : Prop) : f (g893 x) = f (g892 x)
@[simp] axiom s893 (x : Prop) : f (g894 x) = f (g893 x)
@[simp] axiom s894 (x : Prop) : f (g895 x) = f (g894 x)
@[simp] axiom s895 (x : Prop) : f (g896 x) = f (g895 x)
@[simp] axiom s896 (x : Prop) : f (g897 x) = f (g896 x)
@[simp] axiom s897 (x : Prop) : f (g898 x) = f (g897 x)
@[simp] axiom s898 (x : Prop) : f (g899 x) = f (g898 x)
@[simp] axiom s899 (x : Prop) : f (g900 x) = f (g899 x)
@[simp] axiom s900 (x : Prop) : f (g901 x) = f (g900 x)
@[simp] axiom s901 (x : Prop) : f (g902 x) = f (g901 x)
@[simp] axiom s902 (x : Prop) : f (g903 x) = f (g902 x)
@[simp] axiom s903 (x : Prop) : f (g904 x) = f (g903 x)
@[simp] axiom s904 (x : Prop) : f (g905 x) = f (g904 x)
@[simp] axiom s905 (x : Prop) : f (g906 x) = f (g905 x)
@[simp] axiom s906 (x : Prop) : f (g907 x) = f (g906 x)
@[simp] axiom s907 (x : Prop) : f (g908 x) = f (g907 x)
@[simp] axiom s908 (x : Prop) : f (g909 x) = f (g908 x)
@[simp] axiom s909 (x : Prop) : f (g910 x) = f (g909 x)
@[simp] axiom s910 (x : Prop) : f (g911 x) = f (g910 x)
@[simp] axiom s911 (x : Prop) : f (g912 x) = f (g911 x)
@[simp] axiom s912 (x : Prop) : f (g913 x) = f (g912 x)
@[simp] axiom s913 (x : Prop) : f (g914 x) = f (g913 x)
@[simp] axiom s914 (x : Prop) : f (g915 x) = f (g914 x)
@[simp] axiom s915 (x : Prop) : f (g916 x) = f (g915 x)
@[simp] axiom s916 (x : Prop) : f (g917 x) = f (g916 x)
@[simp] axiom s917 (x : Prop) : f (g918 x) = f (g917 x)
@[simp] axiom s918 (x : Prop) : f (g919 x) = f (g918 x)
@[simp] axiom s919 (x : Prop) : f (g920 x) = f (g919 x)
@[simp] axiom s920 (x : Prop) : f (g921 x) = f (g920 x)
@[simp] axiom s921 (x : Prop) : f (g922 x) = f (g921 x)
@[simp] axiom s922 (x : Prop) : f (g923 x) = f (g922 x)
@[simp] axiom s923 (x : Prop) : f (g924 x) = f (g923 x)
@[simp] axiom s924 (x : Prop) : f (g925 x) = f (g924 x)
@[simp] axiom s925 (x : Prop) : f (g926 x) = f (g925 x)
@[simp] axiom s926 (x : Prop) : f (g927 x) = f (g926 x)
@[simp] axiom s927 (x : Prop) : f (g928 x) = f (g927 x)
@[simp] axiom s928 (x : Prop) : f (g929 x) = f (g928 x)
@[simp] axiom s929 (x : Prop) : f (g930 x) = f (g929 x)
@[simp] axiom s930 (x : Prop) : f (g931 x) = f (g930 x)
@[simp] axiom s931 (x : Prop) : f (g932 x) = f (g931 x)
@[simp] axiom s932 (x : Prop) : f (g933 x) = f (g932 x)
@[simp] axiom s933 (x : Prop) : f (g934 x) = f (g933 x)
@[simp] axiom s934 (x : Prop) : f (g935 x) = f (g934 x)
@[simp] axiom s935 (x : Prop) : f (g936 x) = f (g935 x)
@[simp] axiom s936 (x : Prop) : f (g937 x) = f (g936 x)
@[simp] axiom s937 (x : Prop) : f (g938 x) = f (g937 x)
@[simp] axiom s938 (x : Prop) : f (g939 x) = f (g938 x)
@[simp] axiom s939 (x : Prop) : f (g940 x) = f (g939 x)
@[simp] axiom s940 (x : Prop) : f (g941 x) = f (g940 x)
@[simp] axiom s941 (x : Prop) : f (g942 x) = f (g941 x)
@[simp] axiom s942 (x : Prop) : f (g943 x) = f (g942 x)
@[simp] axiom s943 (x : Prop) : f (g944 x) = f (g943 x)
@[simp] axiom s944 (x : Prop) : f (g945 x) = f (g944 x)
@[simp] axiom s945 (x : Prop) : f (g946 x) = f (g945 x)
@[simp] axiom s946 (x : Prop) : f (g947 x) = f (g946 x)
@[simp] axiom s947 (x : Prop) : f (g948 x) = f (g947 x)
@[simp] axiom s948 (x : Prop) : f (g949 x) = f (g948 x)
@[simp] axiom s949 (x : Prop) : f (g950 x) = f (g949 x)
@[simp] axiom s950 (x : Prop) : f (g951 x) = f (g950 x)
@[simp] axiom s951 (x : Prop) : f (g952 x) = f (g951 x)
@[simp] axiom s952 (x : Prop) : f (g953 x) = f (g952 x)
@[simp] axiom s953 (x : Prop) : f (g954 x) = f (g953 x)
@[simp] axiom s954 (x : Prop) : f (g955 x) = f (g954 x)
@[simp] axiom s955 (x : Prop) : f (g956 x) = f (g955 x)
@[simp] axiom s956 (x : Prop) : f (g957 x) = f (g956 x)
@[simp] axiom s957 (x : Prop) : f (g958 x) = f (g957 x)
@[simp] axiom s958 (x : Prop) : f (g959 x) = f (g958 x)
@[simp] axiom s959 (x : Prop) : f (g960 x) = f (g959 x)
@[simp] axiom s960 (x : Prop) : f (g961 x) = f (g960 x)
@[simp] axiom s961 (x : Prop) : f (g962 x) = f (g961 x)
@[simp] axiom s962 (x : Prop) : f (g963 x) = f (g962 x)
@[simp] axiom s963 (x : Prop) : f (g964 x) = f (g963 x)
@[simp] axiom s964 (x : Prop) : f (g965 x) = f (g964 x)
@[simp] axiom s965 (x : Prop) : f (g966 x) = f (g965 x)
@[simp] axiom s966 (x : Prop) : f (g967 x) = f (g966 x)
@[simp] axiom s967 (x : Prop) : f (g968 x) = f (g967 x)
@[simp] axiom s968 (x : Prop) : f (g969 x) = f (g968 x)
@[simp] axiom s969 (x : Prop) : f (g970 x) = f (g969 x)
@[simp] axiom s970 (x : Prop) : f (g971 x) = f (g970 x)
@[simp] axiom s971 (x : Prop) : f (g972 x) = f (g971 x)
@[simp] axiom s972 (x : Prop) : f (g973 x) = f (g972 x)
@[simp] axiom s973 (x : Prop) : f (g974 x) = f (g973 x)
@[simp] axiom s974 (x : Prop) : f (g975 x) = f (g974 x)
@[simp] axiom s975 (x : Prop) : f (g976 x) = f (g975 x)
@[simp] axiom s976 (x : Prop) : f (g977 x) = f (g976 x)
@[simp] axiom s977 (x : Prop) : f (g978 x) = f (g977 x)
@[simp] axiom s978 (x : Prop) : f (g979 x) = f (g978 x)
@[simp] axiom s979 (x : Prop) : f (g980 x) = f (g979 x)
@[simp] axiom s980 (x : Prop) : f (g981 x) = f (g980 x)
@[simp] axiom s981 (x : Prop) : f (g982 x) = f (g981 x)
@[simp] axiom s982 (x : Prop) : f (g983 x) = f (g982 x)
@[simp] axiom s983 (x : Prop) : f (g984 x) = f (g983 x)
@[simp] axiom s984 (x : Prop) : f (g985 x) = f (g984 x)
@[simp] axiom s985 (x : Prop) : f (g986 x) = f (g985 x)
@[simp] axiom s986 (x : Prop) : f (g987 x) = f (g986 x)
@[simp] axiom s987 (x : Prop) : f (g988 x) = f (g987 x)
@[simp] axiom s988 (x : Prop) : f (g989 x) = f (g988 x)
@[simp] axiom s989 (x : Prop) : f (g990 x) = f (g989 x)
@[simp] axiom s990 (x : Prop) : f (g991 x) = f (g990 x)
@[simp] axiom s991 (x : Prop) : f (g992 x) = f (g991 x)
@[simp] axiom s992 (x : Prop) : f (g993 x) = f (g992 x)
@[simp] axiom s993 (x : Prop) : f (g994 x) = f (g993 x)
@[simp] axiom s994 (x : Prop) : f (g995 x) = f (g994 x)
@[simp] axiom s995 (x : Prop) : f (g996 x) = f (g995 x)
@[simp] axiom s996 (x : Prop) : f (g997 x) = f (g996 x)
@[simp] axiom s997 (x : Prop) : f (g998 x) = f (g997 x)
@[simp] axiom s998 (x : Prop) : f (g999 x) = f (g998 x)
@[simp] axiom s999 (x : Prop) : f (g1000 x) = f (g999 x)
@[simp] axiom s1000 (x : Prop) : f (g1001 x) = f (g1000 x)
@[simp] axiom s1001 (x : Prop) : f (g1002 x) = f (g1001 x)
@[simp] axiom s1002 (x : Prop) : f (g1003 x) = f (g1002 x)
@[simp] axiom s1003 (x : Prop) : f (g1004 x) = f (g1003 x)
@[simp] axiom s1004 (x : Prop) : f (g1005 x) = f (g1004 x)
@[simp] axiom s1005 (x : Prop) : f (g1006 x) = f (g1005 x)
@[simp] axiom s1006 (x : Prop) : f (g1007 x) = f (g1006 x)
@[simp] axiom s1007 (x : Prop) : f (g1008 x) = f (g1007 x)
@[simp] axiom s1008 (x : Prop) : f (g1009 x) = f (g1008 x)
@[simp] axiom s1009 (x : Prop) : f (g1010 x) = f (g1009 x)
@[simp] axiom s1010 (x : Prop) : f (g1011 x) = f (g1010 x)
@[simp] axiom s1011 (x : Prop) : f (g1012 x) = f (g1011 x)
@[simp] axiom s1012 (x : Prop) : f (g1013 x) = f (g1012 x)
@[simp] axiom s1013 (x : Prop) : f (g1014 x) = f (g1013 x)
@[simp] axiom s1014 (x : Prop) : f (g1015 x) = f (g1014 x)
@[simp] axiom s1015 (x : Prop) : f (g1016 x) = f (g1015 x)
@[simp] axiom s1016 (x : Prop) : f (g1017 x) = f (g1016 x)
@[simp] axiom s1017 (x : Prop) : f (g1018 x) = f (g1017 x)
@[simp] axiom s1018 (x : Prop) : f (g1019 x) = f (g1018 x)
@[simp] axiom s1019 (x : Prop) : f (g1020 x) = f (g1019 x)
@[simp] axiom s1020 (x : Prop) : f (g1021 x) = f (g1020 x)
@[simp] axiom s1021 (x : Prop) : f (g1022 x) = f (g1021 x)
@[simp] axiom s1022 (x : Prop) : f (g1023 x) = f (g1022 x)
@[simp] axiom s1023 (x : Prop) : f (g1024 x) = f (g1023 x)
@[simp] axiom s1024 (x : Prop) : f (g1025 x) = f (g1024 x)
@[simp] axiom s1025 (x : Prop) : f (g1026 x) = f (g1025 x)
@[simp] axiom s1026 (x : Prop) : f (g1027 x) = f (g1026 x)
@[simp] axiom s1027 (x : Prop) : f (g1028 x) = f (g1027 x)
@[simp] axiom s1028 (x : Prop) : f (g1029 x) = f (g1028 x)
@[simp] axiom s1029 (x : Prop) : f (g1030 x) = f (g1029 x)
@[simp] axiom s1030 (x : Prop) : f (g1031 x) = f (g1030 x)
@[simp] axiom s1031 (x : Prop) : f (g1032 x) = f (g1031 x)
@[simp] axiom s1032 (x : Prop) : f (g1033 x) = f (g1032 x)
@[simp] axiom s1033 (x : Prop) : f (g1034 x) = f (g1033 x)
@[simp] axiom s1034 (x : Prop) : f (g1035 x) = f (g1034 x)
@[simp] axiom s1035 (x : Prop) : f (g1036 x) = f (g1035 x)
@[simp] axiom s1036 (x : Prop) : f (g1037 x) = f (g1036 x)
@[simp] axiom s1037 (x : Prop) : f (g1038 x) = f (g1037 x)
@[simp] axiom s1038 (x : Prop) : f (g1039 x) = f (g1038 x)
@[simp] axiom s1039 (x : Prop) : f (g1040 x) = f (g1039 x)
@[simp] axiom s1040 (x : Prop) : f (g1041 x) = f (g1040 x)
@[simp] axiom s1041 (x : Prop) : f (g1042 x) = f (g1041 x)
@[simp] axiom s1042 (x : Prop) : f (g1043 x) = f (g1042 x)
@[simp] axiom s1043 (x : Prop) : f (g1044 x) = f (g1043 x)
@[simp] axiom s1044 (x : Prop) : f (g1045 x) = f (g1044 x)
@[simp] axiom s1045 (x : Prop) : f (g1046 x) = f (g1045 x)
@[simp] axiom s1046 (x : Prop) : f (g1047 x) = f (g1046 x)
@[simp] axiom s1047 (x : Prop) : f (g1048 x) = f (g1047 x)
@[simp] axiom s1048 (x : Prop) : f (g1049 x) = f (g1048 x)
@[simp] axiom s1049 (x : Prop) : f (g1050 x) = f (g1049 x)
@[simp] axiom s1050 (x : Prop) : f (g1051 x) = f (g1050 x)
@[simp] axiom s1051 (x : Prop) : f (g1052 x) = f (g1051 x)
@[simp] axiom s1052 (x : Prop) : f (g1053 x) = f (g1052 x)
@[simp] axiom s1053 (x : Prop) : f (g1054 x) = f (g1053 x)
@[simp] axiom s1054 (x : Prop) : f (g1055 x) = f (g1054 x)
@[simp] axiom s1055 (x : Prop) : f (g1056 x) = f (g1055 x)
@[simp] axiom s1056 (x : Prop) : f (g1057 x) = f (g1056 x)
@[simp] axiom s1057 (x : Prop) : f (g1058 x) = f (g1057 x)
@[simp] axiom s1058 (x : Prop) : f (g1059 x) = f (g1058 x)
@[simp] axiom s1059 (x : Prop) : f (g1060 x) = f (g1059 x)
@[simp] axiom s1060 (x : Prop) : f (g1061 x) = f (g1060 x)
@[simp] axiom s1061 (x : Prop) : f (g1062 x) = f (g1061 x)
@[simp] axiom s1062 (x : Prop) : f (g1063 x) = f (g1062 x)
@[simp] axiom s1063 (x : Prop) : f (g1064 x) = f (g1063 x)
@[simp] axiom s1064 (x : Prop) : f (g1065 x) = f (g1064 x)
@[simp] axiom s1065 (x : Prop) : f (g1066 x) = f (g1065 x)
@[simp] axiom s1066 (x : Prop) : f (g1067 x) = f (g1066 x)
@[simp] axiom s1067 (x : Prop) : f (g1068 x) = f (g1067 x)
@[simp] axiom s1068 (x : Prop) : f (g1069 x) = f (g1068 x)
@[simp] axiom s1069 (x : Prop) : f (g1070 x) = f (g1069 x)
@[simp] axiom s1070 (x : Prop) : f (g1071 x) = f (g1070 x)
@[simp] axiom s1071 (x : Prop) : f (g1072 x) = f (g1071 x)
@[simp] axiom s1072 (x : Prop) : f (g1073 x) = f (g1072 x)
@[simp] axiom s1073 (x : Prop) : f (g1074 x) = f (g1073 x)
@[simp] axiom s1074 (x : Prop) : f (g1075 x) = f (g1074 x)
@[simp] axiom s1075 (x : Prop) : f (g1076 x) = f (g1075 x)
@[simp] axiom s1076 (x : Prop) : f (g1077 x) = f (g1076 x)
@[simp] axiom s1077 (x : Prop) : f (g1078 x) = f (g1077 x)
@[simp] axiom s1078 (x : Prop) : f (g1079 x) = f (g1078 x)
@[simp] axiom s1079 (x : Prop) : f (g1080 x) = f (g1079 x)
@[simp] axiom s1080 (x : Prop) : f (g1081 x) = f (g1080 x)
@[simp] axiom s1081 (x : Prop) : f (g1082 x) = f (g1081 x)
@[simp] axiom s1082 (x : Prop) : f (g1083 x) = f (g1082 x)
@[simp] axiom s1083 (x : Prop) : f (g1084 x) = f (g1083 x)
@[simp] axiom s1084 (x : Prop) : f (g1085 x) = f (g1084 x)
@[simp] axiom s1085 (x : Prop) : f (g1086 x) = f (g1085 x)
@[simp] axiom s1086 (x : Prop) : f (g1087 x) = f (g1086 x)
@[simp] axiom s1087 (x : Prop) : f (g1088 x) = f (g1087 x)
@[simp] axiom s1088 (x : Prop) : f (g1089 x) = f (g1088 x)
@[simp] axiom s1089 (x : Prop) : f (g1090 x) = f (g1089 x)
@[simp] axiom s1090 (x : Prop) : f (g1091 x) = f (g1090 x)
@[simp] axiom s1091 (x : Prop) : f (g1092 x) = f (g1091 x)
@[simp] axiom s1092 (x : Prop) : f (g1093 x) = f (g1092 x)
@[simp] axiom s1093 (x : Prop) : f (g1094 x) = f (g1093 x)
@[simp] axiom s1094 (x : Prop) : f (g1095 x) = f (g1094 x)
@[simp] axiom s1095 (x : Prop) : f (g1096 x) = f (g1095 x)
@[simp] axiom s1096 (x : Prop) : f (g1097 x) = f (g1096 x)
@[simp] axiom s1097 (x : Prop) : f (g1098 x) = f (g1097 x)
@[simp] axiom s1098 (x : Prop) : f (g1099 x) = f (g1098 x)
@[simp] axiom s1099 (x : Prop) : f (g1100 x) = f (g1099 x)
@[simp] axiom s1100 (x : Prop) : f (g1101 x) = f (g1100 x)
@[simp] axiom s1101 (x : Prop) : f (g1102 x) = f (g1101 x)
@[simp] axiom s1102 (x : Prop) : f (g1103 x) = f (g1102 x)
@[simp] axiom s1103 (x : Prop) : f (g1104 x) = f (g1103 x)
@[simp] axiom s1104 (x : Prop) : f (g1105 x) = f (g1104 x)
@[simp] axiom s1105 (x : Prop) : f (g1106 x) = f (g1105 x)
@[simp] axiom s1106 (x : Prop) : f (g1107 x) = f (g1106 x)
@[simp] axiom s1107 (x : Prop) : f (g1108 x) = f (g1107 x)
@[simp] axiom s1108 (x : Prop) : f (g1109 x) = f (g1108 x)
@[simp] axiom s1109 (x : Prop) : f (g1110 x) = f (g1109 x)
@[simp] axiom s1110 (x : Prop) : f (g1111 x) = f (g1110 x)
@[simp] axiom s1111 (x : Prop) : f (g1112 x) = f (g1111 x)
@[simp] axiom s1112 (x : Prop) : f (g1113 x) = f (g1112 x)
@[simp] axiom s1113 (x : Prop) : f (g1114 x) = f (g1113 x)
@[simp] axiom s1114 (x : Prop) : f (g1115 x) = f (g1114 x)
@[simp] axiom s1115 (x : Prop) : f (g1116 x) = f (g1115 x)
@[simp] axiom s1116 (x : Prop) : f (g1117 x) = f (g1116 x)
@[simp] axiom s1117 (x : Prop) : f (g1118 x) = f (g1117 x)
@[simp] axiom s1118 (x : Prop) : f (g1119 x) = f (g1118 x)
@[simp] axiom s1119 (x : Prop) : f (g1120 x) = f (g1119 x)
@[simp] axiom s1120 (x : Prop) : f (g1121 x) = f (g1120 x)
@[simp] axiom s1121 (x : Prop) : f (g1122 x) = f (g1121 x)
@[simp] axiom s1122 (x : Prop) : f (g1123 x) = f (g1122 x)
@[simp] axiom s1123 (x : Prop) : f (g1124 x) = f (g1123 x)
@[simp] axiom s1124 (x : Prop) : f (g1125 x) = f (g1124 x)
@[simp] axiom s1125 (x : Prop) : f (g1126 x) = f (g1125 x)
@[simp] axiom s1126 (x : Prop) : f (g1127 x) = f (g1126 x)
@[simp] axiom s1127 (x : Prop) : f (g1128 x) = f (g1127 x)
@[simp] axiom s1128 (x : Prop) : f (g1129 x) = f (g1128 x)
@[simp] axiom s1129 (x : Prop) : f (g1130 x) = f (g1129 x)
@[simp] axiom s1130 (x : Prop) : f (g1131 x) = f (g1130 x)
@[simp] axiom s1131 (x : Prop) : f (g1132 x) = f (g1131 x)
@[simp] axiom s1132 (x : Prop) : f (g1133 x) = f (g1132 x)
@[simp] axiom s1133 (x : Prop) : f (g1134 x) = f (g1133 x)
@[simp] axiom s1134 (x : Prop) : f (g1135 x) = f (g1134 x)
@[simp] axiom s1135 (x : Prop) : f (g1136 x) = f (g1135 x)
@[simp] axiom s1136 (x : Prop) : f (g1137 x) = f (g1136 x)
@[simp] axiom s1137 (x : Prop) : f (g1138 x) = f (g1137 x)
@[simp] axiom s1138 (x : Prop) : f (g1139 x) = f (g1138 x)
@[simp] axiom s1139 (x : Prop) : f (g1140 x) = f (g1139 x)
@[simp] axiom s1140 (x : Prop) : f (g1141 x) = f (g1140 x)
@[simp] axiom s1141 (x : Prop) : f (g1142 x) = f (g1141 x)
@[simp] axiom s1142 (x : Prop) : f (g1143 x) = f (g1142 x)
@[simp] axiom s1143 (x : Prop) : f (g1144 x) = f (g1143 x)
@[simp] axiom s1144 (x : Prop) : f (g1145 x) = f (g1144 x)
@[simp] axiom s1145 (x : Prop) : f (g1146 x) = f (g1145 x)
@[simp] axiom s1146 (x : Prop) : f (g1147 x) = f (g1146 x)
@[simp] axiom s1147 (x : Prop) : f (g1148 x) = f (g1147 x)
@[simp] axiom s1148 (x : Prop) : f (g1149 x) = f (g1148 x)
@[simp] axiom s1149 (x : Prop) : f (g1150 x) = f (g1149 x)
@[simp] axiom s1150 (x : Prop) : f (g1151 x) = f (g1150 x)
@[simp] axiom s1151 (x : Prop) : f (g1152 x) = f (g1151 x)
@[simp] axiom s1152 (x : Prop) : f (g1153 x) = f (g1152 x)
@[simp] axiom s1153 (x : Prop) : f (g1154 x) = f (g1153 x)
@[simp] axiom s1154 (x : Prop) : f (g1155 x) = f (g1154 x)
@[simp] axiom s1155 (x : Prop) : f (g1156 x) = f (g1155 x)
@[simp] axiom s1156 (x : Prop) : f (g1157 x) = f (g1156 x)
@[simp] axiom s1157 (x : Prop) : f (g1158 x) = f (g1157 x)
@[simp] axiom s1158 (x : Prop) : f (g1159 x) = f (g1158 x)
@[simp] axiom s1159 (x : Prop) : f (g1160 x) = f (g1159 x)
@[simp] axiom s1160 (x : Prop) : f (g1161 x) = f (g1160 x)
@[simp] axiom s1161 (x : Prop) : f (g1162 x) = f (g1161 x)
@[simp] axiom s1162 (x : Prop) : f (g1163 x) = f (g1162 x)
@[simp] axiom s1163 (x : Prop) : f (g1164 x) = f (g1163 x)
@[simp] axiom s1164 (x : Prop) : f (g1165 x) = f (g1164 x)
@[simp] axiom s1165 (x : Prop) : f (g1166 x) = f (g1165 x)
@[simp] axiom s1166 (x : Prop) : f (g1167 x) = f (g1166 x)
@[simp] axiom s1167 (x : Prop) : f (g1168 x) = f (g1167 x)
@[simp] axiom s1168 (x : Prop) : f (g1169 x) = f (g1168 x)
@[simp] axiom s1169 (x : Prop) : f (g1170 x) = f (g1169 x)
@[simp] axiom s1170 (x : Prop) : f (g1171 x) = f (g1170 x)
@[simp] axiom s1171 (x : Prop) : f (g1172 x) = f (g1171 x)
@[simp] axiom s1172 (x : Prop) : f (g1173 x) = f (g1172 x)
@[simp] axiom s1173 (x : Prop) : f (g1174 x) = f (g1173 x)
@[simp] axiom s1174 (x : Prop) : f (g1175 x) = f (g1174 x)
@[simp] axiom s1175 (x : Prop) : f (g1176 x) = f (g1175 x)
@[simp] axiom s1176 (x : Prop) : f (g1177 x) = f (g1176 x)
@[simp] axiom s1177 (x : Prop) : f (g1178 x) = f (g1177 x)
@[simp] axiom s1178 (x : Prop) : f (g1179 x) = f (g1178 x)
@[simp] axiom s1179 (x : Prop) : f (g1180 x) = f (g1179 x)
@[simp] axiom s1180 (x : Prop) : f (g1181 x) = f (g1180 x)
@[simp] axiom s1181 (x : Prop) : f (g1182 x) = f (g1181 x)
@[simp] axiom s1182 (x : Prop) : f (g1183 x) = f (g1182 x)
@[simp] axiom s1183 (x : Prop) : f (g1184 x) = f (g1183 x)
@[simp] axiom s1184 (x : Prop) : f (g1185 x) = f (g1184 x)
@[simp] axiom s1185 (x : Prop) : f (g1186 x) = f (g1185 x)
@[simp] axiom s1186 (x : Prop) : f (g1187 x) = f (g1186 x)
@[simp] axiom s1187 (x : Prop) : f (g1188 x) = f (g1187 x)
@[simp] axiom s1188 (x : Prop) : f (g1189 x) = f (g1188 x)
@[simp] axiom s1189 (x : Prop) : f (g1190 x) = f (g1189 x)
@[simp] axiom s1190 (x : Prop) : f (g1191 x) = f (g1190 x)
@[simp] axiom s1191 (x : Prop) : f (g1192 x) = f (g1191 x)
@[simp] axiom s1192 (x : Prop) : f (g1193 x) = f (g1192 x)
@[simp] axiom s1193 (x : Prop) : f (g1194 x) = f (g1193 x)
@[simp] axiom s1194 (x : Prop) : f (g1195 x) = f (g1194 x)
@[simp] axiom s1195 (x : Prop) : f (g1196 x) = f (g1195 x)
@[simp] axiom s1196 (x : Prop) : f (g1197 x) = f (g1196 x)
@[simp] axiom s1197 (x : Prop) : f (g1198 x) = f (g1197 x)
@[simp] axiom s1198 (x : Prop) : f (g1199 x) = f (g1198 x)
@[simp] axiom s1199 (x : Prop) : f (g1200 x) = f (g1199 x)
@[simp] axiom s1200 (x : Prop) : f (g1201 x) = f (g1200 x)
@[simp] axiom s1201 (x : Prop) : f (g1202 x) = f (g1201 x)
@[simp] axiom s1202 (x : Prop) : f (g1203 x) = f (g1202 x)
@[simp] axiom s1203 (x : Prop) : f (g1204 x) = f (g1203 x)
@[simp] axiom s1204 (x : Prop) : f (g1205 x) = f (g1204 x)
@[simp] axiom s1205 (x : Prop) : f (g1206 x) = f (g1205 x)
@[simp] axiom s1206 (x : Prop) : f (g1207 x) = f (g1206 x)
@[simp] axiom s1207 (x : Prop) : f (g1208 x) = f (g1207 x)
@[simp] axiom s1208 (x : Prop) : f (g1209 x) = f (g1208 x)
@[simp] axiom s1209 (x : Prop) : f (g1210 x) = f (g1209 x)
@[simp] axiom s1210 (x : Prop) : f (g1211 x) = f (g1210 x)
@[simp] axiom s1211 (x : Prop) : f (g1212 x) = f (g1211 x)
@[simp] axiom s1212 (x : Prop) : f (g1213 x) = f (g1212 x)
@[simp] axiom s1213 (x : Prop) : f (g1214 x) = f (g1213 x)
@[simp] axiom s1214 (x : Prop) : f (g1215 x) = f (g1214 x)
@[simp] axiom s1215 (x : Prop) : f (g1216 x) = f (g1215 x)
@[simp] axiom s1216 (x : Prop) : f (g1217 x) = f (g1216 x)
@[simp] axiom s1217 (x : Prop) : f (g1218 x) = f (g1217 x)
@[simp] axiom s1218 (x : Prop) : f (g1219 x) = f (g1218 x)
@[simp] axiom s1219 (x : Prop) : f (g1220 x) = f (g1219 x)
@[simp] axiom s1220 (x : Prop) : f (g1221 x) = f (g1220 x)
@[simp] axiom s1221 (x : Prop) : f (g1222 x) = f (g1221 x)
@[simp] axiom s1222 (x : Prop) : f (g1223 x) = f (g1222 x)
@[simp] axiom s1223 (x : Prop) : f (g1224 x) = f (g1223 x)
@[simp] axiom s1224 (x : Prop) : f (g1225 x) = f (g1224 x)
@[simp] axiom s1225 (x : Prop) : f (g1226 x) = f (g1225 x)
@[simp] axiom s1226 (x : Prop) : f (g1227 x) = f (g1226 x)
@[simp] axiom s1227 (x : Prop) : f (g1228 x) = f (g1227 x)
@[simp] axiom s1228 (x : Prop) : f (g1229 x) = f (g1228 x)
@[simp] axiom s1229 (x : Prop) : f (g1230 x) = f (g1229 x)
@[simp] axiom s1230 (x : Prop) : f (g1231 x) = f (g1230 x)
@[simp] axiom s1231 (x : Prop) : f (g1232 x) = f (g1231 x)
@[simp] axiom s1232 (x : Prop) : f (g1233 x) = f (g1232 x)
@[simp] axiom s1233 (x : Prop) : f (g1234 x) = f (g1233 x)
@[simp] axiom s1234 (x : Prop) : f (g1235 x) = f (g1234 x)
@[simp] axiom s1235 (x : Prop) : f (g1236 x) = f (g1235 x)
@[simp] axiom s1236 (x : Prop) : f (g1237 x) = f (g1236 x)
@[simp] axiom s1237 (x : Prop) : f (g1238 x) = f (g1237 x)
@[simp] axiom s1238 (x : Prop) : f (g1239 x) = f (g1238 x)
@[simp] axiom s1239 (x : Prop) : f (g1240 x) = f (g1239 x)
@[simp] axiom s1240 (x : Prop) : f (g1241 x) = f (g1240 x)
@[simp] axiom s1241 (x : Prop) : f (g1242 x) = f (g1241 x)
@[simp] axiom s1242 (x : Prop) : f (g1243 x) = f (g1242 x)
@[simp] axiom s1243 (x : Prop) : f (g1244 x) = f (g1243 x)
@[simp] axiom s1244 (x : Prop) : f (g1245 x) = f (g1244 x)
@[simp] axiom s1245 (x : Prop) : f (g1246 x) = f (g1245 x)
@[simp] axiom s1246 (x : Prop) : f (g1247 x) = f (g1246 x)
@[simp] axiom s1247 (x : Prop) : f (g1248 x) = f (g1247 x)
@[simp] axiom s1248 (x : Prop) : f (g1249 x) = f (g1248 x)
@[simp] axiom s1249 (x : Prop) : f (g1250 x) = f (g1249 x)
@[simp] axiom s1250 (x : Prop) : f (g1251 x) = f (g1250 x)
@[simp] axiom s1251 (x : Prop) : f (g1252 x) = f (g1251 x)
@[simp] axiom s1252 (x : Prop) : f (g1253 x) = f (g1252 x)
@[simp] axiom s1253 (x : Prop) : f (g1254 x) = f (g1253 x)
@[simp] axiom s1254 (x : Prop) : f (g1255 x) = f (g1254 x)
@[simp] axiom s1255 (x : Prop) : f (g1256 x) = f (g1255 x)
@[simp] axiom s1256 (x : Prop) : f (g1257 x) = f (g1256 x)
@[simp] axiom s1257 (x : Prop) : f (g1258 x) = f (g1257 x)
@[simp] axiom s1258 (x : Prop) : f (g1259 x) = f (g1258 x)
@[simp] axiom s1259 (x : Prop) : f (g1260 x) = f (g1259 x)
@[simp] axiom s1260 (x : Prop) : f (g1261 x) = f (g1260 x)
@[simp] axiom s1261 (x : Prop) : f (g1262 x) = f (g1261 x)
@[simp] axiom s1262 (x : Prop) : f (g1263 x) = f (g1262 x)
@[simp] axiom s1263 (x : Prop) : f (g1264 x) = f (g1263 x)
@[simp] axiom s1264 (x : Prop) : f (g1265 x) = f (g1264 x)
@[simp] axiom s1265 (x : Prop) : f (g1266 x) = f (g1265 x)
@[simp] axiom s1266 (x : Prop) : f (g1267 x) = f (g1266 x)
@[simp] axiom s1267 (x : Prop) : f (g1268 x) = f (g1267 x)
@[simp] axiom s1268 (x : Prop) : f (g1269 x) = f (g1268 x)
@[simp] axiom s1269 (x : Prop) : f (g1270 x) = f (g1269 x)
@[simp] axiom s1270 (x : Prop) : f (g1271 x) = f (g1270 x)
@[simp] axiom s1271 (x : Prop) : f (g1272 x) = f (g1271 x)
@[simp] axiom s1272 (x : Prop) : f (g1273 x) = f (g1272 x)
@[simp] axiom s1273 (x : Prop) : f (g1274 x) = f (g1273 x)
@[simp] axiom s1274 (x : Prop) : f (g1275 x) = f (g1274 x)
@[simp] axiom s1275 (x : Prop) : f (g1276 x) = f (g1275 x)
@[simp] axiom s1276 (x : Prop) : f (g1277 x) = f (g1276 x)
@[simp] axiom s1277 (x : Prop) : f (g1278 x) = f (g1277 x)
@[simp] axiom s1278 (x : Prop) : f (g1279 x) = f (g1278 x)
@[simp] axiom s1279 (x : Prop) : f (g1280 x) = f (g1279 x)
@[simp] axiom s1280 (x : Prop) : f (g1281 x) = f (g1280 x)
@[simp] axiom s1281 (x : Prop) : f (g1282 x) = f (g1281 x)
@[simp] axiom s1282 (x : Prop) : f (g1283 x) = f (g1282 x)
@[simp] axiom s1283 (x : Prop) : f (g1284 x) = f (g1283 x)
@[simp] axiom s1284 (x : Prop) : f (g1285 x) = f (g1284 x)
@[simp] axiom s1285 (x : Prop) : f (g1286 x) = f (g1285 x)
@[simp] axiom s1286 (x : Prop) : f (g1287 x) = f (g1286 x)
@[simp] axiom s1287 (x : Prop) : f (g1288 x) = f (g1287 x)
@[simp] axiom s1288 (x : Prop) : f (g1289 x) = f (g1288 x)
@[simp] axiom s1289 (x : Prop) : f (g1290 x) = f (g1289 x)
@[simp] axiom s1290 (x : Prop) : f (g1291 x) = f (g1290 x)
@[simp] axiom s1291 (x : Prop) : f (g1292 x) = f (g1291 x)
@[simp] axiom s1292 (x : Prop) : f (g1293 x) = f (g1292 x)
@[simp] axiom s1293 (x : Prop) : f (g1294 x) = f (g1293 x)
@[simp] axiom s1294 (x : Prop) : f (g1295 x) = f (g1294 x)
@[simp] axiom s1295 (x : Prop) : f (g1296 x) = f (g1295 x)
@[simp] axiom s1296 (x : Prop) : f (g1297 x) = f (g1296 x)
@[simp] axiom s1297 (x : Prop) : f (g1298 x) = f (g1297 x)
@[simp] axiom s1298 (x : Prop) : f (g1299 x) = f (g1298 x)
@[simp] axiom s1299 (x : Prop) : f (g1300 x) = f (g1299 x)
@[simp] axiom s1300 (x : Prop) : f (g1301 x) = f (g1300 x)
@[simp] axiom s1301 (x : Prop) : f (g1302 x) = f (g1301 x)
@[simp] axiom s1302 (x : Prop) : f (g1303 x) = f (g1302 x)
@[simp] axiom s1303 (x : Prop) : f (g1304 x) = f (g1303 x)
@[simp] axiom s1304 (x : Prop) : f (g1305 x) = f (g1304 x)
@[simp] axiom s1305 (x : Prop) : f (g1306 x) = f (g1305 x)
@[simp] axiom s1306 (x : Prop) : f (g1307 x) = f (g1306 x)
@[simp] axiom s1307 (x : Prop) : f (g1308 x) = f (g1307 x)
@[simp] axiom s1308 (x : Prop) : f (g1309 x) = f (g1308 x)
@[simp] axiom s1309 (x : Prop) : f (g1310 x) = f (g1309 x)
@[simp] axiom s1310 (x : Prop) : f (g1311 x) = f (g1310 x)
@[simp] axiom s1311 (x : Prop) : f (g1312 x) = f (g1311 x)
@[simp] axiom s1312 (x : Prop) : f (g1313 x) = f (g1312 x)
@[simp] axiom s1313 (x : Prop) : f (g1314 x) = f (g1313 x)
@[simp] axiom s1314 (x : Prop) : f (g1315 x) = f (g1314 x)
@[simp] axiom s1315 (x : Prop) : f (g1316 x) = f (g1315 x)
@[simp] axiom s1316 (x : Prop) : f (g1317 x) = f (g1316 x)
@[simp] axiom s1317 (x : Prop) : f (g1318 x) = f (g1317 x)
@[simp] axiom s1318 (x : Prop) : f (g1319 x) = f (g1318 x)
@[simp] axiom s1319 (x : Prop) : f (g1320 x) = f (g1319 x)
@[simp] axiom s1320 (x : Prop) : f (g1321 x) = f (g1320 x)
@[simp] axiom s1321 (x : Prop) : f (g1322 x) = f (g1321 x)
@[simp] axiom s1322 (x : Prop) : f (g1323 x) = f (g1322 x)
@[simp] axiom s1323 (x : Prop) : f (g1324 x) = f (g1323 x)
@[simp] axiom s1324 (x : Prop) : f (g1325 x) = f (g1324 x)
@[simp] axiom s1325 (x : Prop) : f (g1326 x) = f (g1325 x)
@[simp] axiom s1326 (x : Prop) : f (g1327 x) = f (g1326 x)
@[simp] axiom s1327 (x : Prop) : f (g1328 x) = f (g1327 x)
@[simp] axiom s1328 (x : Prop) : f (g1329 x) = f (g1328 x)
@[simp] axiom s1329 (x : Prop) : f (g1330 x) = f (g1329 x)
@[simp] axiom s1330 (x : Prop) : f (g1331 x) = f (g1330 x)
@[simp] axiom s1331 (x : Prop) : f (g1332 x) = f (g1331 x)
@[simp] axiom s1332 (x : Prop) : f (g1333 x) = f (g1332 x)
@[simp] axiom s1333 (x : Prop) : f (g1334 x) = f (g1333 x)
@[simp] axiom s1334 (x : Prop) : f (g1335 x) = f (g1334 x)
@[simp] axiom s1335 (x : Prop) : f (g1336 x) = f (g1335 x)
@[simp] axiom s1336 (x : Prop) : f (g1337 x) = f (g1336 x)
@[simp] axiom s1337 (x : Prop) : f (g1338 x) = f (g1337 x)
@[simp] axiom s1338 (x : Prop) : f (g1339 x) = f (g1338 x)
@[simp] axiom s1339 (x : Prop) : f (g1340 x) = f (g1339 x)
@[simp] axiom s1340 (x : Prop) : f (g1341 x) = f (g1340 x)
@[simp] axiom s1341 (x : Prop) : f (g1342 x) = f (g1341 x)
@[simp] axiom s1342 (x : Prop) : f (g1343 x) = f (g1342 x)
@[simp] axiom s1343 (x : Prop) : f (g1344 x) = f (g1343 x)
@[simp] axiom s1344 (x : Prop) : f (g1345 x) = f (g1344 x)
@[simp] axiom s1345 (x : Prop) : f (g1346 x) = f (g1345 x)
@[simp] axiom s1346 (x : Prop) : f (g1347 x) = f (g1346 x)
@[simp] axiom s1347 (x : Prop) : f (g1348 x) = f (g1347 x)
@[simp] axiom s1348 (x : Prop) : f (g1349 x) = f (g1348 x)
@[simp] axiom s1349 (x : Prop) : f (g1350 x) = f (g1349 x)
@[simp] axiom s1350 (x : Prop) : f (g1351 x) = f (g1350 x)
@[simp] axiom s1351 (x : Prop) : f (g1352 x) = f (g1351 x)
@[simp] axiom s1352 (x : Prop) : f (g1353 x) = f (g1352 x)
@[simp] axiom s1353 (x : Prop) : f (g1354 x) = f (g1353 x)
@[simp] axiom s1354 (x : Prop) : f (g1355 x) = f (g1354 x)
@[simp] axiom s1355 (x : Prop) : f (g1356 x) = f (g1355 x)
@[simp] axiom s1356 (x : Prop) : f (g1357 x) = f (g1356 x)
@[simp] axiom s1357 (x : Prop) : f (g1358 x) = f (g1357 x)
@[simp] axiom s1358 (x : Prop) : f (g1359 x) = f (g1358 x)
@[simp] axiom s1359 (x : Prop) : f (g1360 x) = f (g1359 x)
@[simp] axiom s1360 (x : Prop) : f (g1361 x) = f (g1360 x)
@[simp] axiom s1361 (x : Prop) : f (g1362 x) = f (g1361 x)
@[simp] axiom s1362 (x : Prop) : f (g1363 x) = f (g1362 x)
@[simp] axiom s1363 (x : Prop) : f (g1364 x) = f (g1363 x)
@[simp] axiom s1364 (x : Prop) : f (g1365 x) = f (g1364 x)
@[simp] axiom s1365 (x : Prop) : f (g1366 x) = f (g1365 x)
@[simp] axiom s1366 (x : Prop) : f (g1367 x) = f (g1366 x)
@[simp] axiom s1367 (x : Prop) : f (g1368 x) = f (g1367 x)
@[simp] axiom s1368 (x : Prop) : f (g1369 x) = f (g1368 x)
@[simp] axiom s1369 (x : Prop) : f (g1370 x) = f (g1369 x)
@[simp] axiom s1370 (x : Prop) : f (g1371 x) = f (g1370 x)
@[simp] axiom s1371 (x : Prop) : f (g1372 x) = f (g1371 x)
@[simp] axiom s1372 (x : Prop) : f (g1373 x) = f (g1372 x)
@[simp] axiom s1373 (x : Prop) : f (g1374 x) = f (g1373 x)
@[simp] axiom s1374 (x : Prop) : f (g1375 x) = f (g1374 x)
@[simp] axiom s1375 (x : Prop) : f (g1376 x) = f (g1375 x)
@[simp] axiom s1376 (x : Prop) : f (g1377 x) = f (g1376 x)
@[simp] axiom s1377 (x : Prop) : f (g1378 x) = f (g1377 x)
@[simp] axiom s1378 (x : Prop) : f (g1379 x) = f (g1378 x)
@[simp] axiom s1379 (x : Prop) : f (g1380 x) = f (g1379 x)
@[simp] axiom s1380 (x : Prop) : f (g1381 x) = f (g1380 x)
@[simp] axiom s1381 (x : Prop) : f (g1382 x) = f (g1381 x)
@[simp] axiom s1382 (x : Prop) : f (g1383 x) = f (g1382 x)
@[simp] axiom s1383 (x : Prop) : f (g1384 x) = f (g1383 x)
@[simp] axiom s1384 (x : Prop) : f (g1385 x) = f (g1384 x)
@[simp] axiom s1385 (x : Prop) : f (g1386 x) = f (g1385 x)
@[simp] axiom s1386 (x : Prop) : f (g1387 x) = f (g1386 x)
@[simp] axiom s1387 (x : Prop) : f (g1388 x) = f (g1387 x)
@[simp] axiom s1388 (x : Prop) : f (g1389 x) = f (g1388 x)
@[simp] axiom s1389 (x : Prop) : f (g1390 x) = f (g1389 x)
@[simp] axiom s1390 (x : Prop) : f (g1391 x) = f (g1390 x)
@[simp] axiom s1391 (x : Prop) : f (g1392 x) = f (g1391 x)
@[simp] axiom s1392 (x : Prop) : f (g1393 x) = f (g1392 x)
@[simp] axiom s1393 (x : Prop) : f (g1394 x) = f (g1393 x)
@[simp] axiom s1394 (x : Prop) : f (g1395 x) = f (g1394 x)
@[simp] axiom s1395 (x : Prop) : f (g1396 x) = f (g1395 x)
@[simp] axiom s1396 (x : Prop) : f (g1397 x) = f (g1396 x)
@[simp] axiom s1397 (x : Prop) : f (g1398 x) = f (g1397 x)
@[simp] axiom s1398 (x : Prop) : f (g1399 x) = f (g1398 x)
@[simp] axiom s1399 (x : Prop) : f (g1400 x) = f (g1399 x)
@[simp] axiom s1400 (x : Prop) : f (g1401 x) = f (g1400 x)
@[simp] axiom s1401 (x : Prop) : f (g1402 x) = f (g1401 x)
@[simp] axiom s1402 (x : Prop) : f (g1403 x) = f (g1402 x)
@[simp] axiom s1403 (x : Prop) : f (g1404 x) = f (g1403 x)
@[simp] axiom s1404 (x : Prop) : f (g1405 x) = f (g1404 x)
@[simp] axiom s1405 (x : Prop) : f (g1406 x) = f (g1405 x)
@[simp] axiom s1406 (x : Prop) : f (g1407 x) = f (g1406 x)
@[simp] axiom s1407 (x : Prop) : f (g1408 x) = f (g1407 x)
@[simp] axiom s1408 (x : Prop) : f (g1409 x) = f (g1408 x)
@[simp] axiom s1409 (x : Prop) : f (g1410 x) = f (g1409 x)
@[simp] axiom s1410 (x : Prop) : f (g1411 x) = f (g1410 x)
@[simp] axiom s1411 (x : Prop) : f (g1412 x) = f (g1411 x)
@[simp] axiom s1412 (x : Prop) : f (g1413 x) = f (g1412 x)
@[simp] axiom s1413 (x : Prop) : f (g1414 x) = f (g1413 x)
@[simp] axiom s1414 (x : Prop) : f (g1415 x) = f (g1414 x)
@[simp] axiom s1415 (x : Prop) : f (g1416 x) = f (g1415 x)
@[simp] axiom s1416 (x : Prop) : f (g1417 x) = f (g1416 x)
@[simp] axiom s1417 (x : Prop) : f (g1418 x) = f (g1417 x)
@[simp] axiom s1418 (x : Prop) : f (g1419 x) = f (g1418 x)
@[simp] axiom s1419 (x : Prop) : f (g1420 x) = f (g1419 x)
@[simp] axiom s1420 (x : Prop) : f (g1421 x) = f (g1420 x)
@[simp] axiom s1421 (x : Prop) : f (g1422 x) = f (g1421 x)
@[simp] axiom s1422 (x : Prop) : f (g1423 x) = f (g1422 x)
@[simp] axiom s1423 (x : Prop) : f (g1424 x) = f (g1423 x)
@[simp] axiom s1424 (x : Prop) : f (g1425 x) = f (g1424 x)
@[simp] axiom s1425 (x : Prop) : f (g1426 x) = f (g1425 x)
@[simp] axiom s1426 (x : Prop) : f (g1427 x) = f (g1426 x)
@[simp] axiom s1427 (x : Prop) : f (g1428 x) = f (g1427 x)
@[simp] axiom s1428 (x : Prop) : f (g1429 x) = f (g1428 x)
@[simp] axiom s1429 (x : Prop) : f (g1430 x) = f (g1429 x)
@[simp] axiom s1430 (x : Prop) : f (g1431 x) = f (g1430 x)
@[simp] axiom s1431 (x : Prop) : f (g1432 x) = f (g1431 x)
@[simp] axiom s1432 (x : Prop) : f (g1433 x) = f (g1432 x)
@[simp] axiom s1433 (x : Prop) : f (g1434 x) = f (g1433 x)
@[simp] axiom s1434 (x : Prop) : f (g1435 x) = f (g1434 x)
@[simp] axiom s1435 (x : Prop) : f (g1436 x) = f (g1435 x)
@[simp] axiom s1436 (x : Prop) : f (g1437 x) = f (g1436 x)
@[simp] axiom s1437 (x : Prop) : f (g1438 x) = f (g1437 x)
@[simp] axiom s1438 (x : Prop) : f (g1439 x) = f (g1438 x)
@[simp] axiom s1439 (x : Prop) : f (g1440 x) = f (g1439 x)
@[simp] axiom s1440 (x : Prop) : f (g1441 x) = f (g1440 x)
@[simp] axiom s1441 (x : Prop) : f (g1442 x) = f (g1441 x)
@[simp] axiom s1442 (x : Prop) : f (g1443 x) = f (g1442 x)
@[simp] axiom s1443 (x : Prop) : f (g1444 x) = f (g1443 x)
@[simp] axiom s1444 (x : Prop) : f (g1445 x) = f (g1444 x)
@[simp] axiom s1445 (x : Prop) : f (g1446 x) = f (g1445 x)
@[simp] axiom s1446 (x : Prop) : f (g1447 x) = f (g1446 x)
@[simp] axiom s1447 (x : Prop) : f (g1448 x) = f (g1447 x)
@[simp] axiom s1448 (x : Prop) : f (g1449 x) = f (g1448 x)
@[simp] axiom s1449 (x : Prop) : f (g1450 x) = f (g1449 x)
@[simp] axiom s1450 (x : Prop) : f (g1451 x) = f (g1450 x)
@[simp] axiom s1451 (x : Prop) : f (g1452 x) = f (g1451 x)
@[simp] axiom s1452 (x : Prop) : f (g1453 x) = f (g1452 x)
@[simp] axiom s1453 (x : Prop) : f (g1454 x) = f (g1453 x)
@[simp] axiom s1454 (x : Prop) : f (g1455 x) = f (g1454 x)
@[simp] axiom s1455 (x : Prop) : f (g1456 x) = f (g1455 x)
@[simp] axiom s1456 (x : Prop) : f (g1457 x) = f (g1456 x)
@[simp] axiom s1457 (x : Prop) : f (g1458 x) = f (g1457 x)
@[simp] axiom s1458 (x : Prop) : f (g1459 x) = f (g1458 x)
@[simp] axiom s1459 (x : Prop) : f (g1460 x) = f (g1459 x)
@[simp] axiom s1460 (x : Prop) : f (g1461 x) = f (g1460 x)
@[simp] axiom s1461 (x : Prop) : f (g1462 x) = f (g1461 x)
@[simp] axiom s1462 (x : Prop) : f (g1463 x) = f (g1462 x)
@[simp] axiom s1463 (x : Prop) : f (g1464 x) = f (g1463 x)
@[simp] axiom s1464 (x : Prop) : f (g1465 x) = f (g1464 x)
@[simp] axiom s1465 (x : Prop) : f (g1466 x) = f (g1465 x)
@[simp] axiom s1466 (x : Prop) : f (g1467 x) = f (g1466 x)
@[simp] axiom s1467 (x : Prop) : f (g1468 x) = f (g1467 x)
@[simp] axiom s1468 (x : Prop) : f (g1469 x) = f (g1468 x)
@[simp] axiom s1469 (x : Prop) : f (g1470 x) = f (g1469 x)
@[simp] axiom s1470 (x : Prop) : f (g1471 x) = f (g1470 x)
@[simp] axiom s1471 (x : Prop) : f (g1472 x) = f (g1471 x)
@[simp] axiom s1472 (x : Prop) : f (g1473 x) = f (g1472 x)
@[simp] axiom s1473 (x : Prop) : f (g1474 x) = f (g1473 x)
@[simp] axiom s1474 (x : Prop) : f (g1475 x) = f (g1474 x)
@[simp] axiom s1475 (x : Prop) : f (g1476 x) = f (g1475 x)
@[simp] axiom s1476 (x : Prop) : f (g1477 x) = f (g1476 x)
@[simp] axiom s1477 (x : Prop) : f (g1478 x) = f (g1477 x)
@[simp] axiom s1478 (x : Prop) : f (g1479 x) = f (g1478 x)
@[simp] axiom s1479 (x : Prop) : f (g1480 x) = f (g1479 x)
@[simp] axiom s1480 (x : Prop) : f (g1481 x) = f (g1480 x)
@[simp] axiom s1481 (x : Prop) : f (g1482 x) = f (g1481 x)
@[simp] axiom s1482 (x : Prop) : f (g1483 x) = f (g1482 x)
@[simp] axiom s1483 (x : Prop) : f (g1484 x) = f (g1483 x)
@[simp] axiom s1484 (x : Prop) : f (g1485 x) = f (g1484 x)
@[simp] axiom s1485 (x : Prop) : f (g1486 x) = f (g1485 x)
@[simp] axiom s1486 (x : Prop) : f (g1487 x) = f (g1486 x)
@[simp] axiom s1487 (x : Prop) : f (g1488 x) = f (g1487 x)
@[simp] axiom s1488 (x : Prop) : f (g1489 x) = f (g1488 x)
@[simp] axiom s1489 (x : Prop) : f (g1490 x) = f (g1489 x)
@[simp] axiom s1490 (x : Prop) : f (g1491 x) = f (g1490 x)
@[simp] axiom s1491 (x : Prop) : f (g1492 x) = f (g1491 x)
@[simp] axiom s1492 (x : Prop) : f (g1493 x) = f (g1492 x)
@[simp] axiom s1493 (x : Prop) : f (g1494 x) = f (g1493 x)
@[simp] axiom s1494 (x : Prop) : f (g1495 x) = f (g1494 x)
@[simp] axiom s1495 (x : Prop) : f (g1496 x) = f (g1495 x)
@[simp] axiom s1496 (x : Prop) : f (g1497 x) = f (g1496 x)
@[simp] axiom s1497 (x : Prop) : f (g1498 x) = f (g1497 x)
@[simp] axiom s1498 (x : Prop) : f (g1499 x) = f (g1498 x)
@[simp] axiom s1499 (x : Prop) : f (g1500 x) = f (g1499 x)
@[simp] axiom s1500 (x : Prop) : f (g1501 x) = f (g1500 x)
@[simp] axiom s1501 (x : Prop) : f (g1502 x) = f (g1501 x)
@[simp] axiom s1502 (x : Prop) : f (g1503 x) = f (g1502 x)
@[simp] axiom s1503 (x : Prop) : f (g1504 x) = f (g1503 x)
@[simp] axiom s1504 (x : Prop) : f (g1505 x) = f (g1504 x)
@[simp] axiom s1505 (x : Prop) : f (g1506 x) = f (g1505 x)
@[simp] axiom s1506 (x : Prop) : f (g1507 x) = f (g1506 x)
@[simp] axiom s1507 (x : Prop) : f (g1508 x) = f (g1507 x)
@[simp] axiom s1508 (x : Prop) : f (g1509 x) = f (g1508 x)
@[simp] axiom s1509 (x : Prop) : f (g1510 x) = f (g1509 x)
@[simp] axiom s1510 (x : Prop) : f (g1511 x) = f (g1510 x)
@[simp] axiom s1511 (x : Prop) : f (g1512 x) = f (g1511 x)
@[simp] axiom s1512 (x : Prop) : f (g1513 x) = f (g1512 x)
@[simp] axiom s1513 (x : Prop) : f (g1514 x) = f (g1513 x)
@[simp] axiom s1514 (x : Prop) : f (g1515 x) = f (g1514 x)
@[simp] axiom s1515 (x : Prop) : f (g1516 x) = f (g1515 x)
@[simp] axiom s1516 (x : Prop) : f (g1517 x) = f (g1516 x)
@[simp] axiom s1517 (x : Prop) : f (g1518 x) = f (g1517 x)
@[simp] axiom s1518 (x : Prop) : f (g1519 x) = f (g1518 x)
@[simp] axiom s1519 (x : Prop) : f (g1520 x) = f (g1519 x)
@[simp] axiom s1520 (x : Prop) : f (g1521 x) = f (g1520 x)
@[simp] axiom s1521 (x : Prop) : f (g1522 x) = f (g1521 x)
@[simp] axiom s1522 (x : Prop) : f (g1523 x) = f (g1522 x)
@[simp] axiom s1523 (x : Prop) : f (g1524 x) = f (g1523 x)
@[simp] axiom s1524 (x : Prop) : f (g1525 x) = f (g1524 x)
@[simp] axiom s1525 (x : Prop) : f (g1526 x) = f (g1525 x)
@[simp] axiom s1526 (x : Prop) : f (g1527 x) = f (g1526 x)
@[simp] axiom s1527 (x : Prop) : f (g1528 x) = f (g1527 x)
@[simp] axiom s1528 (x : Prop) : f (g1529 x) = f (g1528 x)
@[simp] axiom s1529 (x : Prop) : f (g1530 x) = f (g1529 x)
@[simp] axiom s1530 (x : Prop) : f (g1531 x) = f (g1530 x)
@[simp] axiom s1531 (x : Prop) : f (g1532 x) = f (g1531 x)
@[simp] axiom s1532 (x : Prop) : f (g1533 x) = f (g1532 x)
@[simp] axiom s1533 (x : Prop) : f (g1534 x) = f (g1533 x)
@[simp] axiom s1534 (x : Prop) : f (g1535 x) = f (g1534 x)
@[simp] axiom s1535 (x : Prop) : f (g1536 x) = f (g1535 x)
@[simp] axiom s1536 (x : Prop) : f (g1537 x) = f (g1536 x)
@[simp] axiom s1537 (x : Prop) : f (g1538 x) = f (g1537 x)
@[simp] axiom s1538 (x : Prop) : f (g1539 x) = f (g1538 x)
@[simp] axiom s1539 (x : Prop) : f (g1540 x) = f (g1539 x)
@[simp] axiom s1540 (x : Prop) : f (g1541 x) = f (g1540 x)
@[simp] axiom s1541 (x : Prop) : f (g1542 x) = f (g1541 x)
@[simp] axiom s1542 (x : Prop) : f (g1543 x) = f (g1542 x)
@[simp] axiom s1543 (x : Prop) : f (g1544 x) = f (g1543 x)
@[simp] axiom s1544 (x : Prop) : f (g1545 x) = f (g1544 x)
@[simp] axiom s1545 (x : Prop) : f (g1546 x) = f (g1545 x)
@[simp] axiom s1546 (x : Prop) : f (g1547 x) = f (g1546 x)
@[simp] axiom s1547 (x : Prop) : f (g1548 x) = f (g1547 x)
@[simp] axiom s1548 (x : Prop) : f (g1549 x) = f (g1548 x)
@[simp] axiom s1549 (x : Prop) : f (g1550 x) = f (g1549 x)
@[simp] axiom s1550 (x : Prop) : f (g1551 x) = f (g1550 x)
@[simp] axiom s1551 (x : Prop) : f (g1552 x) = f (g1551 x)
@[simp] axiom s1552 (x : Prop) : f (g1553 x) = f (g1552 x)
@[simp] axiom s1553 (x : Prop) : f (g1554 x) = f (g1553 x)
@[simp] axiom s1554 (x : Prop) : f (g1555 x) = f (g1554 x)
@[simp] axiom s1555 (x : Prop) : f (g1556 x) = f (g1555 x)
@[simp] axiom s1556 (x : Prop) : f (g1557 x) = f (g1556 x)
@[simp] axiom s1557 (x : Prop) : f (g1558 x) = f (g1557 x)
@[simp] axiom s1558 (x : Prop) : f (g1559 x) = f (g1558 x)
@[simp] axiom s1559 (x : Prop) : f (g1560 x) = f (g1559 x)
@[simp] axiom s1560 (x : Prop) : f (g1561 x) = f (g1560 x)
@[simp] axiom s1561 (x : Prop) : f (g1562 x) = f (g1561 x)
@[simp] axiom s1562 (x : Prop) : f (g1563 x) = f (g1562 x)
@[simp] axiom s1563 (x : Prop) : f (g1564 x) = f (g1563 x)
@[simp] axiom s1564 (x : Prop) : f (g1565 x) = f (g1564 x)
@[simp] axiom s1565 (x : Prop) : f (g1566 x) = f (g1565 x)
@[simp] axiom s1566 (x : Prop) : f (g1567 x) = f (g1566 x)
@[simp] axiom s1567 (x : Prop) : f (g1568 x) = f (g1567 x)
@[simp] axiom s1568 (x : Prop) : f (g1569 x) = f (g1568 x)
@[simp] axiom s1569 (x : Prop) : f (g1570 x) = f (g1569 x)
@[simp] axiom s1570 (x : Prop) : f (g1571 x) = f (g1570 x)
@[simp] axiom s1571 (x : Prop) : f (g1572 x) = f (g1571 x)
@[simp] axiom s1572 (x : Prop) : f (g1573 x) = f (g1572 x)
@[simp] axiom s1573 (x : Prop) : f (g1574 x) = f (g1573 x)
@[simp] axiom s1574 (x : Prop) : f (g1575 x) = f (g1574 x)
@[simp] axiom s1575 (x : Prop) : f (g1576 x) = f (g1575 x)
@[simp] axiom s1576 (x : Prop) : f (g1577 x) = f (g1576 x)
@[simp] axiom s1577 (x : Prop) : f (g1578 x) = f (g1577 x)
@[simp] axiom s1578 (x : Prop) : f (g1579 x) = f (g1578 x)
@[simp] axiom s1579 (x : Prop) : f (g1580 x) = f (g1579 x)
@[simp] axiom s1580 (x : Prop) : f (g1581 x) = f (g1580 x)
@[simp] axiom s1581 (x : Prop) : f (g1582 x) = f (g1581 x)
@[simp] axiom s1582 (x : Prop) : f (g1583 x) = f (g1582 x)
@[simp] axiom s1583 (x : Prop) : f (g1584 x) = f (g1583 x)
@[simp] axiom s1584 (x : Prop) : f (g1585 x) = f (g1584 x)
@[simp] axiom s1585 (x : Prop) : f (g1586 x) = f (g1585 x)
@[simp] axiom s1586 (x : Prop) : f (g1587 x) = f (g1586 x)
@[simp] axiom s1587 (x : Prop) : f (g1588 x) = f (g1587 x)
@[simp] axiom s1588 (x : Prop) : f (g1589 x) = f (g1588 x)
@[simp] axiom s1589 (x : Prop) : f (g1590 x) = f (g1589 x)
@[simp] axiom s1590 (x : Prop) : f (g1591 x) = f (g1590 x)
@[simp] axiom s1591 (x : Prop) : f (g1592 x) = f (g1591 x)
@[simp] axiom s1592 (x : Prop) : f (g1593 x) = f (g1592 x)
@[simp] axiom s1593 (x : Prop) : f (g1594 x) = f (g1593 x)
@[simp] axiom s1594 (x : Prop) : f (g1595 x) = f (g1594 x)
@[simp] axiom s1595 (x : Prop) : f (g1596 x) = f (g1595 x)
@[simp] axiom s1596 (x : Prop) : f (g1597 x) = f (g1596 x)
@[simp] axiom s1597 (x : Prop) : f (g1598 x) = f (g1597 x)
@[simp] axiom s1598 (x : Prop) : f (g1599 x) = f (g1598 x)
@[simp] axiom s1599 (x : Prop) : f (g1600 x) = f (g1599 x)
@[simp] axiom s1600 (x : Prop) : f (g1601 x) = f (g1600 x)
@[simp] axiom s1601 (x : Prop) : f (g1602 x) = f (g1601 x)
@[simp] axiom s1602 (x : Prop) : f (g1603 x) = f (g1602 x)
@[simp] axiom s1603 (x : Prop) : f (g1604 x) = f (g1603 x)
@[simp] axiom s1604 (x : Prop) : f (g1605 x) = f (g1604 x)
@[simp] axiom s1605 (x : Prop) : f (g1606 x) = f (g1605 x)
@[simp] axiom s1606 (x : Prop) : f (g1607 x) = f (g1606 x)
@[simp] axiom s1607 (x : Prop) : f (g1608 x) = f (g1607 x)
@[simp] axiom s1608 (x : Prop) : f (g1609 x) = f (g1608 x)
@[simp] axiom s1609 (x : Prop) : f (g1610 x) = f (g1609 x)
@[simp] axiom s1610 (x : Prop) : f (g1611 x) = f (g1610 x)
@[simp] axiom s1611 (x : Prop) : f (g1612 x) = f (g1611 x)
@[simp] axiom s1612 (x : Prop) : f (g1613 x) = f (g1612 x)
@[simp] axiom s1613 (x : Prop) : f (g1614 x) = f (g1613 x)
@[simp] axiom s1614 (x : Prop) : f (g1615 x) = f (g1614 x)
@[simp] axiom s1615 (x : Prop) : f (g1616 x) = f (g1615 x)
@[simp] axiom s1616 (x : Prop) : f (g1617 x) = f (g1616 x)
@[simp] axiom s1617 (x : Prop) : f (g1618 x) = f (g1617 x)
@[simp] axiom s1618 (x : Prop) : f (g1619 x) = f (g1618 x)
@[simp] axiom s1619 (x : Prop) : f (g1620 x) = f (g1619 x)
@[simp] axiom s1620 (x : Prop) : f (g1621 x) = f (g1620 x)
@[simp] axiom s1621 (x : Prop) : f (g1622 x) = f (g1621 x)
@[simp] axiom s1622 (x : Prop) : f (g1623 x) = f (g1622 x)
@[simp] axiom s1623 (x : Prop) : f (g1624 x) = f (g1623 x)
@[simp] axiom s1624 (x : Prop) : f (g1625 x) = f (g1624 x)
@[simp] axiom s1625 (x : Prop) : f (g1626 x) = f (g1625 x)
@[simp] axiom s1626 (x : Prop) : f (g1627 x) = f (g1626 x)
@[simp] axiom s1627 (x : Prop) : f (g1628 x) = f (g1627 x)
@[simp] axiom s1628 (x : Prop) : f (g1629 x) = f (g1628 x)
@[simp] axiom s1629 (x : Prop) : f (g1630 x) = f (g1629 x)
@[simp] axiom s1630 (x : Prop) : f (g1631 x) = f (g1630 x)
@[simp] axiom s1631 (x : Prop) : f (g1632 x) = f (g1631 x)
@[simp] axiom s1632 (x : Prop) : f (g1633 x) = f (g1632 x)
@[simp] axiom s1633 (x : Prop) : f (g1634 x) = f (g1633 x)
@[simp] axiom s1634 (x : Prop) : f (g1635 x) = f (g1634 x)
@[simp] axiom s1635 (x : Prop) : f (g1636 x) = f (g1635 x)
@[simp] axiom s1636 (x : Prop) : f (g1637 x) = f (g1636 x)
@[simp] axiom s1637 (x : Prop) : f (g1638 x) = f (g1637 x)
@[simp] axiom s1638 (x : Prop) : f (g1639 x) = f (g1638 x)
@[simp] axiom s1639 (x : Prop) : f (g1640 x) = f (g1639 x)
@[simp] axiom s1640 (x : Prop) : f (g1641 x) = f (g1640 x)
@[simp] axiom s1641 (x : Prop) : f (g1642 x) = f (g1641 x)
@[simp] axiom s1642 (x : Prop) : f (g1643 x) = f (g1642 x)
@[simp] axiom s1643 (x : Prop) : f (g1644 x) = f (g1643 x)
@[simp] axiom s1644 (x : Prop) : f (g1645 x) = f (g1644 x)
@[simp] axiom s1645 (x : Prop) : f (g1646 x) = f (g1645 x)
@[simp] axiom s1646 (x : Prop) : f (g1647 x) = f (g1646 x)
@[simp] axiom s1647 (x : Prop) : f (g1648 x) = f (g1647 x)
@[simp] axiom s1648 (x : Prop) : f (g1649 x) = f (g1648 x)
@[simp] axiom s1649 (x : Prop) : f (g1650 x) = f (g1649 x)
@[simp] axiom s1650 (x : Prop) : f (g1651 x) = f (g1650 x)
@[simp] axiom s1651 (x : Prop) : f (g1652 x) = f (g1651 x)
@[simp] axiom s1652 (x : Prop) : f (g1653 x) = f (g1652 x)
@[simp] axiom s1653 (x : Prop) : f (g1654 x) = f (g1653 x)
@[simp] axiom s1654 (x : Prop) : f (g1655 x) = f (g1654 x)
@[simp] axiom s1655 (x : Prop) : f (g1656 x) = f (g1655 x)
@[simp] axiom s1656 (x : Prop) : f (g1657 x) = f (g1656 x)
@[simp] axiom s1657 (x : Prop) : f (g1658 x) = f (g1657 x)
@[simp] axiom s1658 (x : Prop) : f (g1659 x) = f (g1658 x)
@[simp] axiom s1659 (x : Prop) : f (g1660 x) = f (g1659 x)
@[simp] axiom s1660 (x : Prop) : f (g1661 x) = f (g1660 x)
@[simp] axiom s1661 (x : Prop) : f (g1662 x) = f (g1661 x)
@[simp] axiom s1662 (x : Prop) : f (g1663 x) = f (g1662 x)
@[simp] axiom s1663 (x : Prop) : f (g1664 x) = f (g1663 x)
@[simp] axiom s1664 (x : Prop) : f (g1665 x) = f (g1664 x)
@[simp] axiom s1665 (x : Prop) : f (g1666 x) = f (g1665 x)
@[simp] axiom s1666 (x : Prop) : f (g1667 x) = f (g1666 x)
@[simp] axiom s1667 (x : Prop) : f (g1668 x) = f (g1667 x)
@[simp] axiom s1668 (x : Prop) : f (g1669 x) = f (g1668 x)
@[simp] axiom s1669 (x : Prop) : f (g1670 x) = f (g1669 x)
@[simp] axiom s1670 (x : Prop) : f (g1671 x) = f (g1670 x)
@[simp] axiom s1671 (x : Prop) : f (g1672 x) = f (g1671 x)
@[simp] axiom s1672 (x : Prop) : f (g1673 x) = f (g1672 x)
@[simp] axiom s1673 (x : Prop) : f (g1674 x) = f (g1673 x)
@[simp] axiom s1674 (x : Prop) : f (g1675 x) = f (g1674 x)
@[simp] axiom s1675 (x : Prop) : f (g1676 x) = f (g1675 x)
@[simp] axiom s1676 (x : Prop) : f (g1677 x) = f (g1676 x)
@[simp] axiom s1677 (x : Prop) : f (g1678 x) = f (g1677 x)
@[simp] axiom s1678 (x : Prop) : f (g1679 x) = f (g1678 x)
@[simp] axiom s1679 (x : Prop) : f (g1680 x) = f (g1679 x)
@[simp] axiom s1680 (x : Prop) : f (g1681 x) = f (g1680 x)
@[simp] axiom s1681 (x : Prop) : f (g1682 x) = f (g1681 x)
@[simp] axiom s1682 (x : Prop) : f (g1683 x) = f (g1682 x)
@[simp] axiom s1683 (x : Prop) : f (g1684 x) = f (g1683 x)
@[simp] axiom s1684 (x : Prop) : f (g1685 x) = f (g1684 x)
@[simp] axiom s1685 (x : Prop) : f (g1686 x) = f (g1685 x)
@[simp] axiom s1686 (x : Prop) : f (g1687 x) = f (g1686 x)
@[simp] axiom s1687 (x : Prop) : f (g1688 x) = f (g1687 x)
@[simp] axiom s1688 (x : Prop) : f (g1689 x) = f (g1688 x)
@[simp] axiom s1689 (x : Prop) : f (g1690 x) = f (g1689 x)
@[simp] axiom s1690 (x : Prop) : f (g1691 x) = f (g1690 x)
@[simp] axiom s1691 (x : Prop) : f (g1692 x) = f (g1691 x)
@[simp] axiom s1692 (x : Prop) : f (g1693 x) = f (g1692 x)
@[simp] axiom s1693 (x : Prop) : f (g1694 x) = f (g1693 x)
@[simp] axiom s1694 (x : Prop) : f (g1695 x) = f (g1694 x)
@[simp] axiom s1695 (x : Prop) : f (g1696 x) = f (g1695 x)
@[simp] axiom s1696 (x : Prop) : f (g1697 x) = f (g1696 x)
@[simp] axiom s1697 (x : Prop) : f (g1698 x) = f (g1697 x)
@[simp] axiom s1698 (x : Prop) : f (g1699 x) = f (g1698 x)
@[simp] axiom s1699 (x : Prop) : f (g1700 x) = f (g1699 x)
@[simp] axiom s1700 (x : Prop) : f (g1701 x) = f (g1700 x)
@[simp] axiom s1701 (x : Prop) : f (g1702 x) = f (g1701 x)
@[simp] axiom s1702 (x : Prop) : f (g1703 x) = f (g1702 x)
@[simp] axiom s1703 (x : Prop) : f (g1704 x) = f (g1703 x)
@[simp] axiom s1704 (x : Prop) : f (g1705 x) = f (g1704 x)
@[simp] axiom s1705 (x : Prop) : f (g1706 x) = f (g1705 x)
@[simp] axiom s1706 (x : Prop) : f (g1707 x) = f (g1706 x)
@[simp] axiom s1707 (x : Prop) : f (g1708 x) = f (g1707 x)
@[simp] axiom s1708 (x : Prop) : f (g1709 x) = f (g1708 x)
@[simp] axiom s1709 (x : Prop) : f (g1710 x) = f (g1709 x)
@[simp] axiom s1710 (x : Prop) : f (g1711 x) = f (g1710 x)
@[simp] axiom s1711 (x : Prop) : f (g1712 x) = f (g1711 x)
@[simp] axiom s1712 (x : Prop) : f (g1713 x) = f (g1712 x)
@[simp] axiom s1713 (x : Prop) : f (g1714 x) = f (g1713 x)
@[simp] axiom s1714 (x : Prop) : f (g1715 x) = f (g1714 x)
@[simp] axiom s1715 (x : Prop) : f (g1716 x) = f (g1715 x)
@[simp] axiom s1716 (x : Prop) : f (g1717 x) = f (g1716 x)
@[simp] axiom s1717 (x : Prop) : f (g1718 x) = f (g1717 x)
@[simp] axiom s1718 (x : Prop) : f (g1719 x) = f (g1718 x)
@[simp] axiom s1719 (x : Prop) : f (g1720 x) = f (g1719 x)
@[simp] axiom s1720 (x : Prop) : f (g1721 x) = f (g1720 x)
@[simp] axiom s1721 (x : Prop) : f (g1722 x) = f (g1721 x)
@[simp] axiom s1722 (x : Prop) : f (g1723 x) = f (g1722 x)
@[simp] axiom s1723 (x : Prop) : f (g1724 x) = f (g1723 x)
@[simp] axiom s1724 (x : Prop) : f (g1725 x) = f (g1724 x)
@[simp] axiom s1725 (x : Prop) : f (g1726 x) = f (g1725 x)
@[simp] axiom s1726 (x : Prop) : f (g1727 x) = f (g1726 x)
@[simp] axiom s1727 (x : Prop) : f (g1728 x) = f (g1727 x)
@[simp] axiom s1728 (x : Prop) : f (g1729 x) = f (g1728 x)
@[simp] axiom s1729 (x : Prop) : f (g1730 x) = f (g1729 x)
@[simp] axiom s1730 (x : Prop) : f (g1731 x) = f (g1730 x)
@[simp] axiom s1731 (x : Prop) : f (g1732 x) = f (g1731 x)
@[simp] axiom s1732 (x : Prop) : f (g1733 x) = f (g1732 x)
@[simp] axiom s1733 (x : Prop) : f (g1734 x) = f (g1733 x)
@[simp] axiom s1734 (x : Prop) : f (g1735 x) = f (g1734 x)
@[simp] axiom s1735 (x : Prop) : f (g1736 x) = f (g1735 x)
@[simp] axiom s1736 (x : Prop) : f (g1737 x) = f (g1736 x)
@[simp] axiom s1737 (x : Prop) : f (g1738 x) = f (g1737 x)
@[simp] axiom s1738 (x : Prop) : f (g1739 x) = f (g1738 x)
@[simp] axiom s1739 (x : Prop) : f (g1740 x) = f (g1739 x)
@[simp] axiom s1740 (x : Prop) : f (g1741 x) = f (g1740 x)
@[simp] axiom s1741 (x : Prop) : f (g1742 x) = f (g1741 x)
@[simp] axiom s1742 (x : Prop) : f (g1743 x) = f (g1742 x)
@[simp] axiom s1743 (x : Prop) : f (g1744 x) = f (g1743 x)
@[simp] axiom s1744 (x : Prop) : f (g1745 x) = f (g1744 x)
@[simp] axiom s1745 (x : Prop) : f (g1746 x) = f (g1745 x)
@[simp] axiom s1746 (x : Prop) : f (g1747 x) = f (g1746 x)
@[simp] axiom s1747 (x : Prop) : f (g1748 x) = f (g1747 x)
@[simp] axiom s1748 (x : Prop) : f (g1749 x) = f (g1748 x)
@[simp] axiom s1749 (x : Prop) : f (g1750 x) = f (g1749 x)
@[simp] axiom s1750 (x : Prop) : f (g1751 x) = f (g1750 x)
@[simp] axiom s1751 (x : Prop) : f (g1752 x) = f (g1751 x)
@[simp] axiom s1752 (x : Prop) : f (g1753 x) = f (g1752 x)
@[simp] axiom s1753 (x : Prop) : f (g1754 x) = f (g1753 x)
@[simp] axiom s1754 (x : Prop) : f (g1755 x) = f (g1754 x)
@[simp] axiom s1755 (x : Prop) : f (g1756 x) = f (g1755 x)
@[simp] axiom s1756 (x : Prop) : f (g1757 x) = f (g1756 x)
@[simp] axiom s1757 (x : Prop) : f (g1758 x) = f (g1757 x)
@[simp] axiom s1758 (x : Prop) : f (g1759 x) = f (g1758 x)
@[simp] axiom s1759 (x : Prop) : f (g1760 x) = f (g1759 x)
@[simp] axiom s1760 (x : Prop) : f (g1761 x) = f (g1760 x)
@[simp] axiom s1761 (x : Prop) : f (g1762 x) = f (g1761 x)
@[simp] axiom s1762 (x : Prop) : f (g1763 x) = f (g1762 x)
@[simp] axiom s1763 (x : Prop) : f (g1764 x) = f (g1763 x)
@[simp] axiom s1764 (x : Prop) : f (g1765 x) = f (g1764 x)
@[simp] axiom s1765 (x : Prop) : f (g1766 x) = f (g1765 x)
@[simp] axiom s1766 (x : Prop) : f (g1767 x) = f (g1766 x)
@[simp] axiom s1767 (x : Prop) : f (g1768 x) = f (g1767 x)
@[simp] axiom s1768 (x : Prop) : f (g1769 x) = f (g1768 x)
@[simp] axiom s1769 (x : Prop) : f (g1770 x) = f (g1769 x)
@[simp] axiom s1770 (x : Prop) : f (g1771 x) = f (g1770 x)
@[simp] axiom s1771 (x : Prop) : f (g1772 x) = f (g1771 x)
@[simp] axiom s1772 (x : Prop) : f (g1773 x) = f (g1772 x)
@[simp] axiom s1773 (x : Prop) : f (g1774 x) = f (g1773 x)
@[simp] axiom s1774 (x : Prop) : f (g1775 x) = f (g1774 x)
@[simp] axiom s1775 (x : Prop) : f (g1776 x) = f (g1775 x)
@[simp] axiom s1776 (x : Prop) : f (g1777 x) = f (g1776 x)
@[simp] axiom s1777 (x : Prop) : f (g1778 x) = f (g1777 x)
@[simp] axiom s1778 (x : Prop) : f (g1779 x) = f (g1778 x)
@[simp] axiom s1779 (x : Prop) : f (g1780 x) = f (g1779 x)
@[simp] axiom s1780 (x : Prop) : f (g1781 x) = f (g1780 x)
@[simp] axiom s1781 (x : Prop) : f (g1782 x) = f (g1781 x)
@[simp] axiom s1782 (x : Prop) : f (g1783 x) = f (g1782 x)
@[simp] axiom s1783 (x : Prop) : f (g1784 x) = f (g1783 x)
@[simp] axiom s1784 (x : Prop) : f (g1785 x) = f (g1784 x)
@[simp] axiom s1785 (x : Prop) : f (g1786 x) = f (g1785 x)
@[simp] axiom s1786 (x : Prop) : f (g1787 x) = f (g1786 x)
@[simp] axiom s1787 (x : Prop) : f (g1788 x) = f (g1787 x)
@[simp] axiom s1788 (x : Prop) : f (g1789 x) = f (g1788 x)
@[simp] axiom s1789 (x : Prop) : f (g1790 x) = f (g1789 x)
@[simp] axiom s1790 (x : Prop) : f (g1791 x) = f (g1790 x)
@[simp] axiom s1791 (x : Prop) : f (g1792 x) = f (g1791 x)
@[simp] axiom s1792 (x : Prop) : f (g1793 x) = f (g1792 x)
@[simp] axiom s1793 (x : Prop) : f (g1794 x) = f (g1793 x)
@[simp] axiom s1794 (x : Prop) : f (g1795 x) = f (g1794 x)
@[simp] axiom s1795 (x : Prop) : f (g1796 x) = f (g1795 x)
@[simp] axiom s1796 (x : Prop) : f (g1797 x) = f (g1796 x)
@[simp] axiom s1797 (x : Prop) : f (g1798 x) = f (g1797 x)
@[simp] axiom s1798 (x : Prop) : f (g1799 x) = f (g1798 x)
@[simp] axiom s1799 (x : Prop) : f (g1800 x) = f (g1799 x)
@[simp] axiom s1800 (x : Prop) : f (g1801 x) = f (g1800 x)
@[simp] axiom s1801 (x : Prop) : f (g1802 x) = f (g1801 x)
@[simp] axiom s1802 (x : Prop) : f (g1803 x) = f (g1802 x)
@[simp] axiom s1803 (x : Prop) : f (g1804 x) = f (g1803 x)
@[simp] axiom s1804 (x : Prop) : f (g1805 x) = f (g1804 x)
@[simp] axiom s1805 (x : Prop) : f (g1806 x) = f (g1805 x)
@[simp] axiom s1806 (x : Prop) : f (g1807 x) = f (g1806 x)
@[simp] axiom s1807 (x : Prop) : f (g1808 x) = f (g1807 x)
@[simp] axiom s1808 (x : Prop) : f (g1809 x) = f (g1808 x)
@[simp] axiom s1809 (x : Prop) : f (g1810 x) = f (g1809 x)
@[simp] axiom s1810 (x : Prop) : f (g1811 x) = f (g1810 x)
@[simp] axiom s1811 (x : Prop) : f (g1812 x) = f (g1811 x)
@[simp] axiom s1812 (x : Prop) : f (g1813 x) = f (g1812 x)
@[simp] axiom s1813 (x : Prop) : f (g1814 x) = f (g1813 x)
@[simp] axiom s1814 (x : Prop) : f (g1815 x) = f (g1814 x)
@[simp] axiom s1815 (x : Prop) : f (g1816 x) = f (g1815 x)
@[simp] axiom s1816 (x : Prop) : f (g1817 x) = f (g1816 x)
@[simp] axiom s1817 (x : Prop) : f (g1818 x) = f (g1817 x)
@[simp] axiom s1818 (x : Prop) : f (g1819 x) = f (g1818 x)
@[simp] axiom s1819 (x : Prop) : f (g1820 x) = f (g1819 x)
@[simp] axiom s1820 (x : Prop) : f (g1821 x) = f (g1820 x)
@[simp] axiom s1821 (x : Prop) : f (g1822 x) = f (g1821 x)
@[simp] axiom s1822 (x : Prop) : f (g1823 x) = f (g1822 x)
@[simp] axiom s1823 (x : Prop) : f (g1824 x) = f (g1823 x)
@[simp] axiom s1824 (x : Prop) : f (g1825 x) = f (g1824 x)
@[simp] axiom s1825 (x : Prop) : f (g1826 x) = f (g1825 x)
@[simp] axiom s1826 (x : Prop) : f (g1827 x) = f (g1826 x)
@[simp] axiom s1827 (x : Prop) : f (g1828 x) = f (g1827 x)
@[simp] axiom s1828 (x : Prop) : f (g1829 x) = f (g1828 x)
@[simp] axiom s1829 (x : Prop) : f (g1830 x) = f (g1829 x)
@[simp] axiom s1830 (x : Prop) : f (g1831 x) = f (g1830 x)
@[simp] axiom s1831 (x : Prop) : f (g1832 x) = f (g1831 x)
@[simp] axiom s1832 (x : Prop) : f (g1833 x) = f (g1832 x)
@[simp] axiom s1833 (x : Prop) : f (g1834 x) = f (g1833 x)
@[simp] axiom s1834 (x : Prop) : f (g1835 x) = f (g1834 x)
@[simp] axiom s1835 (x : Prop) : f (g1836 x) = f (g1835 x)
@[simp] axiom s1836 (x : Prop) : f (g1837 x) = f (g1836 x)
@[simp] axiom s1837 (x : Prop) : f (g1838 x) = f (g1837 x)
@[simp] axiom s1838 (x : Prop) : f (g1839 x) = f (g1838 x)
@[simp] axiom s1839 (x : Prop) : f (g1840 x) = f (g1839 x)
@[simp] axiom s1840 (x : Prop) : f (g1841 x) = f (g1840 x)
@[simp] axiom s1841 (x : Prop) : f (g1842 x) = f (g1841 x)
@[simp] axiom s1842 (x : Prop) : f (g1843 x) = f (g1842 x)
@[simp] axiom s1843 (x : Prop) : f (g1844 x) = f (g1843 x)
@[simp] axiom s1844 (x : Prop) : f (g1845 x) = f (g1844 x)
@[simp] axiom s1845 (x : Prop) : f (g1846 x) = f (g1845 x)
@[simp] axiom s1846 (x : Prop) : f (g1847 x) = f (g1846 x)
@[simp] axiom s1847 (x : Prop) : f (g1848 x) = f (g1847 x)
@[simp] axiom s1848 (x : Prop) : f (g1849 x) = f (g1848 x)
@[simp] axiom s1849 (x : Prop) : f (g1850 x) = f (g1849 x)
@[simp] axiom s1850 (x : Prop) : f (g1851 x) = f (g1850 x)
@[simp] axiom s1851 (x : Prop) : f (g1852 x) = f (g1851 x)
@[simp] axiom s1852 (x : Prop) : f (g1853 x) = f (g1852 x)
@[simp] axiom s1853 (x : Prop) : f (g1854 x) = f (g1853 x)
@[simp] axiom s1854 (x : Prop) : f (g1855 x) = f (g1854 x)
@[simp] axiom s1855 (x : Prop) : f (g1856 x) = f (g1855 x)
@[simp] axiom s1856 (x : Prop) : f (g1857 x) = f (g1856 x)
@[simp] axiom s1857 (x : Prop) : f (g1858 x) = f (g1857 x)
@[simp] axiom s1858 (x : Prop) : f (g1859 x) = f (g1858 x)
@[simp] axiom s1859 (x : Prop) : f (g1860 x) = f (g1859 x)
@[simp] axiom s1860 (x : Prop) : f (g1861 x) = f (g1860 x)
@[simp] axiom s1861 (x : Prop) : f (g1862 x) = f (g1861 x)
@[simp] axiom s1862 (x : Prop) : f (g1863 x) = f (g1862 x)
@[simp] axiom s1863 (x : Prop) : f (g1864 x) = f (g1863 x)
@[simp] axiom s1864 (x : Prop) : f (g1865 x) = f (g1864 x)
@[simp] axiom s1865 (x : Prop) : f (g1866 x) = f (g1865 x)
@[simp] axiom s1866 (x : Prop) : f (g1867 x) = f (g1866 x)
@[simp] axiom s1867 (x : Prop) : f (g1868 x) = f (g1867 x)
@[simp] axiom s1868 (x : Prop) : f (g1869 x) = f (g1868 x)
@[simp] axiom s1869 (x : Prop) : f (g1870 x) = f (g1869 x)
@[simp] axiom s1870 (x : Prop) : f (g1871 x) = f (g1870 x)
@[simp] axiom s1871 (x : Prop) : f (g1872 x) = f (g1871 x)
@[simp] axiom s1872 (x : Prop) : f (g1873 x) = f (g1872 x)
@[simp] axiom s1873 (x : Prop) : f (g1874 x) = f (g1873 x)
@[simp] axiom s1874 (x : Prop) : f (g1875 x) = f (g1874 x)
@[simp] axiom s1875 (x : Prop) : f (g1876 x) = f (g1875 x)
@[simp] axiom s1876 (x : Prop) : f (g1877 x) = f (g1876 x)
@[simp] axiom s1877 (x : Prop) : f (g1878 x) = f (g1877 x)
@[simp] axiom s1878 (x : Prop) : f (g1879 x) = f (g1878 x)
@[simp] axiom s1879 (x : Prop) : f (g1880 x) = f (g1879 x)
@[simp] axiom s1880 (x : Prop) : f (g1881 x) = f (g1880 x)
@[simp] axiom s1881 (x : Prop) : f (g1882 x) = f (g1881 x)
@[simp] axiom s1882 (x : Prop) : f (g1883 x) = f (g1882 x)
@[simp] axiom s1883 (x : Prop) : f (g1884 x) = f (g1883 x)
@[simp] axiom s1884 (x : Prop) : f (g1885 x) = f (g1884 x)
@[simp] axiom s1885 (x : Prop) : f (g1886 x) = f (g1885 x)
@[simp] axiom s1886 (x : Prop) : f (g1887 x) = f (g1886 x)
@[simp] axiom s1887 (x : Prop) : f (g1888 x) = f (g1887 x)
@[simp] axiom s1888 (x : Prop) : f (g1889 x) = f (g1888 x)
@[simp] axiom s1889 (x : Prop) : f (g1890 x) = f (g1889 x)
@[simp] axiom s1890 (x : Prop) : f (g1891 x) = f (g1890 x)
@[simp] axiom s1891 (x : Prop) : f (g1892 x) = f (g1891 x)
@[simp] axiom s1892 (x : Prop) : f (g1893 x) = f (g1892 x)
@[simp] axiom s1893 (x : Prop) : f (g1894 x) = f (g1893 x)
@[simp] axiom s1894 (x : Prop) : f (g1895 x) = f (g1894 x)
@[simp] axiom s1895 (x : Prop) : f (g1896 x) = f (g1895 x)
@[simp] axiom s1896 (x : Prop) : f (g1897 x) = f (g1896 x)
@[simp] axiom s1897 (x : Prop) : f (g1898 x) = f (g1897 x)
@[simp] axiom s1898 (x : Prop) : f (g1899 x) = f (g1898 x)
@[simp] axiom s1899 (x : Prop) : f (g1900 x) = f (g1899 x)
@[simp] axiom s1900 (x : Prop) : f (g1901 x) = f (g1900 x)
@[simp] axiom s1901 (x : Prop) : f (g1902 x) = f (g1901 x)
@[simp] axiom s1902 (x : Prop) : f (g1903 x) = f (g1902 x)
@[simp] axiom s1903 (x : Prop) : f (g1904 x) = f (g1903 x)
@[simp] axiom s1904 (x : Prop) : f (g1905 x) = f (g1904 x)
@[simp] axiom s1905 (x : Prop) : f (g1906 x) = f (g1905 x)
@[simp] axiom s1906 (x : Prop) : f (g1907 x) = f (g1906 x)
@[simp] axiom s1907 (x : Prop) : f (g1908 x) = f (g1907 x)
@[simp] axiom s1908 (x : Prop) : f (g1909 x) = f (g1908 x)
@[simp] axiom s1909 (x : Prop) : f (g1910 x) = f (g1909 x)
@[simp] axiom s1910 (x : Prop) : f (g1911 x) = f (g1910 x)
@[simp] axiom s1911 (x : Prop) : f (g1912 x) = f (g1911 x)
@[simp] axiom s1912 (x : Prop) : f (g1913 x) = f (g1912 x)
@[simp] axiom s1913 (x : Prop) : f (g1914 x) = f (g1913 x)
@[simp] axiom s1914 (x : Prop) : f (g1915 x) = f (g1914 x)
@[simp] axiom s1915 (x : Prop) : f (g1916 x) = f (g1915 x)
@[simp] axiom s1916 (x : Prop) : f (g1917 x) = f (g1916 x)
@[simp] axiom s1917 (x : Prop) : f (g1918 x) = f (g1917 x)
@[simp] axiom s1918 (x : Prop) : f (g1919 x) = f (g1918 x)
@[simp] axiom s1919 (x : Prop) : f (g1920 x) = f (g1919 x)
@[simp] axiom s1920 (x : Prop) : f (g1921 x) = f (g1920 x)
@[simp] axiom s1921 (x : Prop) : f (g1922 x) = f (g1921 x)
@[simp] axiom s1922 (x : Prop) : f (g1923 x) = f (g1922 x)
@[simp] axiom s1923 (x : Prop) : f (g1924 x) = f (g1923 x)
@[simp] axiom s1924 (x : Prop) : f (g1925 x) = f (g1924 x)
@[simp] axiom s1925 (x : Prop) : f (g1926 x) = f (g1925 x)
@[simp] axiom s1926 (x : Prop) : f (g1927 x) = f (g1926 x)
@[simp] axiom s1927 (x : Prop) : f (g1928 x) = f (g1927 x)
@[simp] axiom s1928 (x : Prop) : f (g1929 x) = f (g1928 x)
@[simp] axiom s1929 (x : Prop) : f (g1930 x) = f (g1929 x)
@[simp] axiom s1930 (x : Prop) : f (g1931 x) = f (g1930 x)
@[simp] axiom s1931 (x : Prop) : f (g1932 x) = f (g1931 x)
@[simp] axiom s1932 (x : Prop) : f (g1933 x) = f (g1932 x)
@[simp] axiom s1933 (x : Prop) : f (g1934 x) = f (g1933 x)
@[simp] axiom s1934 (x : Prop) : f (g1935 x) = f (g1934 x)
@[simp] axiom s1935 (x : Prop) : f (g1936 x) = f (g1935 x)
@[simp] axiom s1936 (x : Prop) : f (g1937 x) = f (g1936 x)
@[simp] axiom s1937 (x : Prop) : f (g1938 x) = f (g1937 x)
@[simp] axiom s1938 (x : Prop) : f (g1939 x) = f (g1938 x)
@[simp] axiom s1939 (x : Prop) : f (g1940 x) = f (g1939 x)
@[simp] axiom s1940 (x : Prop) : f (g1941 x) = f (g1940 x)
@[simp] axiom s1941 (x : Prop) : f (g1942 x) = f (g1941 x)
@[simp] axiom s1942 (x : Prop) : f (g1943 x) = f (g1942 x)
@[simp] axiom s1943 (x : Prop) : f (g1944 x) = f (g1943 x)
@[simp] axiom s1944 (x : Prop) : f (g1945 x) = f (g1944 x)
@[simp] axiom s1945 (x : Prop) : f (g1946 x) = f (g1945 x)
@[simp] axiom s1946 (x : Prop) : f (g1947 x) = f (g1946 x)
@[simp] axiom s1947 (x : Prop) : f (g1948 x) = f (g1947 x)
@[simp] axiom s1948 (x : Prop) : f (g1949 x) = f (g1948 x)
@[simp] axiom s1949 (x : Prop) : f (g1950 x) = f (g1949 x)
@[simp] axiom s1950 (x : Prop) : f (g1951 x) = f (g1950 x)
@[simp] axiom s1951 (x : Prop) : f (g1952 x) = f (g1951 x)
@[simp] axiom s1952 (x : Prop) : f (g1953 x) = f (g1952 x)
@[simp] axiom s1953 (x : Prop) : f (g1954 x) = f (g1953 x)
@[simp] axiom s1954 (x : Prop) : f (g1955 x) = f (g1954 x)
@[simp] axiom s1955 (x : Prop) : f (g1956 x) = f (g1955 x)
@[simp] axiom s1956 (x : Prop) : f (g1957 x) = f (g1956 x)
@[simp] axiom s1957 (x : Prop) : f (g1958 x) = f (g1957 x)
@[simp] axiom s1958 (x : Prop) : f (g1959 x) = f (g1958 x)
@[simp] axiom s1959 (x : Prop) : f (g1960 x) = f (g1959 x)
@[simp] axiom s1960 (x : Prop) : f (g1961 x) = f (g1960 x)
@[simp] axiom s1961 (x : Prop) : f (g1962 x) = f (g1961 x)
@[simp] axiom s1962 (x : Prop) : f (g1963 x) = f (g1962 x)
@[simp] axiom s1963 (x : Prop) : f (g1964 x) = f (g1963 x)
@[simp] axiom s1964 (x : Prop) : f (g1965 x) = f (g1964 x)
@[simp] axiom s1965 (x : Prop) : f (g1966 x) = f (g1965 x)
@[simp] axiom s1966 (x : Prop) : f (g1967 x) = f (g1966 x)
@[simp] axiom s1967 (x : Prop) : f (g1968 x) = f (g1967 x)
@[simp] axiom s1968 (x : Prop) : f (g1969 x) = f (g1968 x)
@[simp] axiom s1969 (x : Prop) : f (g1970 x) = f (g1969 x)
@[simp] axiom s1970 (x : Prop) : f (g1971 x) = f (g1970 x)
@[simp] axiom s1971 (x : Prop) : f (g1972 x) = f (g1971 x)
@[simp] axiom s1972 (x : Prop) : f (g1973 x) = f (g1972 x)
@[simp] axiom s1973 (x : Prop) : f (g1974 x) = f (g1973 x)
@[simp] axiom s1974 (x : Prop) : f (g1975 x) = f (g1974 x)
@[simp] axiom s1975 (x : Prop) : f (g1976 x) = f (g1975 x)
@[simp] axiom s1976 (x : Prop) : f (g1977 x) = f (g1976 x)
@[simp] axiom s1977 (x : Prop) : f (g1978 x) = f (g1977 x)
@[simp] axiom s1978 (x : Prop) : f (g1979 x) = f (g1978 x)
@[simp] axiom s1979 (x : Prop) : f (g1980 x) = f (g1979 x)
@[simp] axiom s1980 (x : Prop) : f (g1981 x) = f (g1980 x)
@[simp] axiom s1981 (x : Prop) : f (g1982 x) = f (g1981 x)
@[simp] axiom s1982 (x : Prop) : f (g1983 x) = f (g1982 x)
@[simp] axiom s1983 (x : Prop) : f (g1984 x) = f (g1983 x)
@[simp] axiom s1984 (x : Prop) : f (g1985 x) = f (g1984 x)
@[simp] axiom s1985 (x : Prop) : f (g1986 x) = f (g1985 x)
@[simp] axiom s1986 (x : Prop) : f (g1987 x) = f (g1986 x)
@[simp] axiom s1987 (x : Prop) : f (g1988 x) = f (g1987 x)
@[simp] axiom s1988 (x : Prop) : f (g1989 x) = f (g1988 x)
@[simp] axiom s1989 (x : Prop) : f (g1990 x) = f (g1989 x)
@[simp] axiom s1990 (x : Prop) : f (g1991 x) = f (g1990 x)
@[simp] axiom s1991 (x : Prop) : f (g1992 x) = f (g1991 x)
@[simp] axiom s1992 (x : Prop) : f (g1993 x) = f (g1992 x)
@[simp] axiom s1993 (x : Prop) : f (g1994 x) = f (g1993 x)
@[simp] axiom s1994 (x : Prop) : f (g1995 x) = f (g1994 x)
@[simp] axiom s1995 (x : Prop) : f (g1996 x) = f (g1995 x)
@[simp] axiom s1996 (x : Prop) : f (g1997 x) = f (g1996 x)
@[simp] axiom s1997 (x : Prop) : f (g1998 x) = f (g1997 x)
@[simp] axiom s1998 (x : Prop) : f (g1999 x) = f (g1998 x)
@[simp] axiom s1999 (x : Prop) : f (g2000 x) = f (g1999 x)
@[simp] axiom s2000 (x : Prop) : f (g2001 x) = f (g2000 x)
@[simp] axiom s2001 (x : Prop) : f (g2002 x) = f (g2001 x)
@[simp] axiom s2002 (x : Prop) : f (g2003 x) = f (g2002 x)
@[simp] axiom s2003 (x : Prop) : f (g2004 x) = f (g2003 x)
@[simp] axiom s2004 (x : Prop) : f (g2005 x) = f (g2004 x)
@[simp] axiom s2005 (x : Prop) : f (g2006 x) = f (g2005 x)
@[simp] axiom s2006 (x : Prop) : f (g2007 x) = f (g2006 x)
@[simp] axiom s2007 (x : Prop) : f (g2008 x) = f (g2007 x)
@[simp] axiom s2008 (x : Prop) : f (g2009 x) = f (g2008 x)
@[simp] axiom s2009 (x : Prop) : f (g2010 x) = f (g2009 x)
@[simp] axiom s2010 (x : Prop) : f (g2011 x) = f (g2010 x)
@[simp] axiom s2011 (x : Prop) : f (g2012 x) = f (g2011 x)
@[simp] axiom s2012 (x : Prop) : f (g2013 x) = f (g2012 x)
@[simp] axiom s2013 (x : Prop) : f (g2014 x) = f (g2013 x)
@[simp] axiom s2014 (x : Prop) : f (g2015 x) = f (g2014 x)
@[simp] axiom s2015 (x : Prop) : f (g2016 x) = f (g2015 x)
@[simp] axiom s2016 (x : Prop) : f (g2017 x) = f (g2016 x)
@[simp] axiom s2017 (x : Prop) : f (g2018 x) = f (g2017 x)
@[simp] axiom s2018 (x : Prop) : f (g2019 x) = f (g2018 x)
@[simp] axiom s2019 (x : Prop) : f (g2020 x) = f (g2019 x)
@[simp] axiom s2020 (x : Prop) : f (g2021 x) = f (g2020 x)
@[simp] axiom s2021 (x : Prop) : f (g2022 x) = f (g2021 x)
@[simp] axiom s2022 (x : Prop) : f (g2023 x) = f (g2022 x)
@[simp] axiom s2023 (x : Prop) : f (g2024 x) = f (g2023 x)
@[simp] axiom s2024 (x : Prop) : f (g2025 x) = f (g2024 x)
@[simp] axiom s2025 (x : Prop) : f (g2026 x) = f (g2025 x)
@[simp] axiom s2026 (x : Prop) : f (g2027 x) = f (g2026 x)
@[simp] axiom s2027 (x : Prop) : f (g2028 x) = f (g2027 x)
@[simp] axiom s2028 (x : Prop) : f (g2029 x) = f (g2028 x)
@[simp] axiom s2029 (x : Prop) : f (g2030 x) = f (g2029 x)
@[simp] axiom s2030 (x : Prop) : f (g2031 x) = f (g2030 x)
@[simp] axiom s2031 (x : Prop) : f (g2032 x) = f (g2031 x)
@[simp] axiom s2032 (x : Prop) : f (g2033 x) = f (g2032 x)
@[simp] axiom s2033 (x : Prop) : f (g2034 x) = f (g2033 x)
@[simp] axiom s2034 (x : Prop) : f (g2035 x) = f (g2034 x)
@[simp] axiom s2035 (x : Prop) : f (g2036 x) = f (g2035 x)
@[simp] axiom s2036 (x : Prop) : f (g2037 x) = f (g2036 x)
@[simp] axiom s2037 (x : Prop) : f (g2038 x) = f (g2037 x)
@[simp] axiom s2038 (x : Prop) : f (g2039 x) = f (g2038 x)
@[simp] axiom s2039 (x : Prop) : f (g2040 x) = f (g2039 x)
@[simp] axiom s2040 (x : Prop) : f (g2041 x) = f (g2040 x)
@[simp] axiom s2041 (x : Prop) : f (g2042 x) = f (g2041 x)
@[simp] axiom s2042 (x : Prop) : f (g2043 x) = f (g2042 x)
@[simp] axiom s2043 (x : Prop) : f (g2044 x) = f (g2043 x)
@[simp] axiom s2044 (x : Prop) : f (g2045 x) = f (g2044 x)
@[simp] axiom s2045 (x : Prop) : f (g2046 x) = f (g2045 x)
@[simp] axiom s2046 (x : Prop) : f (g2047 x) = f (g2046 x)
@[simp] axiom s2047 (x : Prop) : f (g2048 x) = f (g2047 x)
@[simp] axiom s2048 (x : Prop) : f (g2049 x) = f (g2048 x)
@[simp] axiom s2049 (x : Prop) : f (g2050 x) = f (g2049 x)
@[simp] axiom s2050 (x : Prop) : f (g2051 x) = f (g2050 x)
@[simp] axiom s2051 (x : Prop) : f (g2052 x) = f (g2051 x)
@[simp] axiom s2052 (x : Prop) : f (g2053 x) = f (g2052 x)
@[simp] axiom s2053 (x : Prop) : f (g2054 x) = f (g2053 x)
@[simp] axiom s2054 (x : Prop) : f (g2055 x) = f (g2054 x)
@[simp] axiom s2055 (x : Prop) : f (g2056 x) = f (g2055 x)
@[simp] axiom s2056 (x : Prop) : f (g2057 x) = f (g2056 x)
@[simp] axiom s2057 (x : Prop) : f (g2058 x) = f (g2057 x)
@[simp] axiom s2058 (x : Prop) : f (g2059 x) = f (g2058 x)
@[simp] axiom s2059 (x : Prop) : f (g2060 x) = f (g2059 x)
@[simp] axiom s2060 (x : Prop) : f (g2061 x) = f (g2060 x)
@[simp] axiom s2061 (x : Prop) : f (g2062 x) = f (g2061 x)
@[simp] axiom s2062 (x : Prop) : f (g2063 x) = f (g2062 x)
@[simp] axiom s2063 (x : Prop) : f (g2064 x) = f (g2063 x)
@[simp] axiom s2064 (x : Prop) : f (g2065 x) = f (g2064 x)
@[simp] axiom s2065 (x : Prop) : f (g2066 x) = f (g2065 x)
@[simp] axiom s2066 (x : Prop) : f (g2067 x) = f (g2066 x)
@[simp] axiom s2067 (x : Prop) : f (g2068 x) = f (g2067 x)
@[simp] axiom s2068 (x : Prop) : f (g2069 x) = f (g2068 x)
@[simp] axiom s2069 (x : Prop) : f (g2070 x) = f (g2069 x)
@[simp] axiom s2070 (x : Prop) : f (g2071 x) = f (g2070 x)
@[simp] axiom s2071 (x : Prop) : f (g2072 x) = f (g2071 x)
@[simp] axiom s2072 (x : Prop) : f (g2073 x) = f (g2072 x)
@[simp] axiom s2073 (x : Prop) : f (g2074 x) = f (g2073 x)
@[simp] axiom s2074 (x : Prop) : f (g2075 x) = f (g2074 x)
@[simp] axiom s2075 (x : Prop) : f (g2076 x) = f (g2075 x)
@[simp] axiom s2076 (x : Prop) : f (g2077 x) = f (g2076 x)
@[simp] axiom s2077 (x : Prop) : f (g2078 x) = f (g2077 x)
@[simp] axiom s2078 (x : Prop) : f (g2079 x) = f (g2078 x)
@[simp] axiom s2079 (x : Prop) : f (g2080 x) = f (g2079 x)
@[simp] axiom s2080 (x : Prop) : f (g2081 x) = f (g2080 x)
@[simp] axiom s2081 (x : Prop) : f (g2082 x) = f (g2081 x)
@[simp] axiom s2082 (x : Prop) : f (g2083 x) = f (g2082 x)
@[simp] axiom s2083 (x : Prop) : f (g2084 x) = f (g2083 x)
@[simp] axiom s2084 (x : Prop) : f (g2085 x) = f (g2084 x)
@[simp] axiom s2085 (x : Prop) : f (g2086 x) = f (g2085 x)
@[simp] axiom s2086 (x : Prop) : f (g2087 x) = f (g2086 x)
@[simp] axiom s2087 (x : Prop) : f (g2088 x) = f (g2087 x)
@[simp] axiom s2088 (x : Prop) : f (g2089 x) = f (g2088 x)
@[simp] axiom s2089 (x : Prop) : f (g2090 x) = f (g2089 x)
@[simp] axiom s2090 (x : Prop) : f (g2091 x) = f (g2090 x)
@[simp] axiom s2091 (x : Prop) : f (g2092 x) = f (g2091 x)
@[simp] axiom s2092 (x : Prop) : f (g2093 x) = f (g2092 x)
@[simp] axiom s2093 (x : Prop) : f (g2094 x) = f (g2093 x)
@[simp] axiom s2094 (x : Prop) : f (g2095 x) = f (g2094 x)
@[simp] axiom s2095 (x : Prop) : f (g2096 x) = f (g2095 x)
@[simp] axiom s2096 (x : Prop) : f (g2097 x) = f (g2096 x)
@[simp] axiom s2097 (x : Prop) : f (g2098 x) = f (g2097 x)
@[simp] axiom s2098 (x : Prop) : f (g2099 x) = f (g2098 x)
@[simp] axiom s2099 (x : Prop) : f (g2100 x) = f (g2099 x)
@[simp] axiom s2100 (x : Prop) : f (g2101 x) = f (g2100 x)
@[simp] axiom s2101 (x : Prop) : f (g2102 x) = f (g2101 x)
@[simp] axiom s2102 (x : Prop) : f (g2103 x) = f (g2102 x)
@[simp] axiom s2103 (x : Prop) : f (g2104 x) = f (g2103 x)
@[simp] axiom s2104 (x : Prop) : f (g2105 x) = f (g2104 x)
@[simp] axiom s2105 (x : Prop) : f (g2106 x) = f (g2105 x)
@[simp] axiom s2106 (x : Prop) : f (g2107 x) = f (g2106 x)
@[simp] axiom s2107 (x : Prop) : f (g2108 x) = f (g2107 x)
@[simp] axiom s2108 (x : Prop) : f (g2109 x) = f (g2108 x)
@[simp] axiom s2109 (x : Prop) : f (g2110 x) = f (g2109 x)
@[simp] axiom s2110 (x : Prop) : f (g2111 x) = f (g2110 x)
@[simp] axiom s2111 (x : Prop) : f (g2112 x) = f (g2111 x)
@[simp] axiom s2112 (x : Prop) : f (g2113 x) = f (g2112 x)
@[simp] axiom s2113 (x : Prop) : f (g2114 x) = f (g2113 x)
@[simp] axiom s2114 (x : Prop) : f (g2115 x) = f (g2114 x)
@[simp] axiom s2115 (x : Prop) : f (g2116 x) = f (g2115 x)
@[simp] axiom s2116 (x : Prop) : f (g2117 x) = f (g2116 x)
@[simp] axiom s2117 (x : Prop) : f (g2118 x) = f (g2117 x)
@[simp] axiom s2118 (x : Prop) : f (g2119 x) = f (g2118 x)
@[simp] axiom s2119 (x : Prop) : f (g2120 x) = f (g2119 x)
@[simp] axiom s2120 (x : Prop) : f (g2121 x) = f (g2120 x)
@[simp] axiom s2121 (x : Prop) : f (g2122 x) = f (g2121 x)
@[simp] axiom s2122 (x : Prop) : f (g2123 x) = f (g2122 x)
@[simp] axiom s2123 (x : Prop) : f (g2124 x) = f (g2123 x)
@[simp] axiom s2124 (x : Prop) : f (g2125 x) = f (g2124 x)
@[simp] axiom s2125 (x : Prop) : f (g2126 x) = f (g2125 x)
@[simp] axiom s2126 (x : Prop) : f (g2127 x) = f (g2126 x)
@[simp] axiom s2127 (x : Prop) : f (g2128 x) = f (g2127 x)
@[simp] axiom s2128 (x : Prop) : f (g2129 x) = f (g2128 x)
@[simp] axiom s2129 (x : Prop) : f (g2130 x) = f (g2129 x)
@[simp] axiom s2130 (x : Prop) : f (g2131 x) = f (g2130 x)
@[simp] axiom s2131 (x : Prop) : f (g2132 x) = f (g2131 x)
@[simp] axiom s2132 (x : Prop) : f (g2133 x) = f (g2132 x)
@[simp] axiom s2133 (x : Prop) : f (g2134 x) = f (g2133 x)
@[simp] axiom s2134 (x : Prop) : f (g2135 x) = f (g2134 x)
@[simp] axiom s2135 (x : Prop) : f (g2136 x) = f (g2135 x)
@[simp] axiom s2136 (x : Prop) : f (g2137 x) = f (g2136 x)
@[simp] axiom s2137 (x : Prop) : f (g2138 x) = f (g2137 x)
@[simp] axiom s2138 (x : Prop) : f (g2139 x) = f (g2138 x)
@[simp] axiom s2139 (x : Prop) : f (g2140 x) = f (g2139 x)
@[simp] axiom s2140 (x : Prop) : f (g2141 x) = f (g2140 x)
@[simp] axiom s2141 (x : Prop) : f (g2142 x) = f (g2141 x)
@[simp] axiom s2142 (x : Prop) : f (g2143 x) = f (g2142 x)
@[simp] axiom s2143 (x : Prop) : f (g2144 x) = f (g2143 x)
@[simp] axiom s2144 (x : Prop) : f (g2145 x) = f (g2144 x)
@[simp] axiom s2145 (x : Prop) : f (g2146 x) = f (g2145 x)
@[simp] axiom s2146 (x : Prop) : f (g2147 x) = f (g2146 x)
@[simp] axiom s2147 (x : Prop) : f (g2148 x) = f (g2147 x)
@[simp] axiom s2148 (x : Prop) : f (g2149 x) = f (g2148 x)
@[simp] axiom s2149 (x : Prop) : f (g2150 x) = f (g2149 x)
@[simp] axiom s2150 (x : Prop) : f (g2151 x) = f (g2150 x)
@[simp] axiom s2151 (x : Prop) : f (g2152 x) = f (g2151 x)
@[simp] axiom s2152 (x : Prop) : f (g2153 x) = f (g2152 x)
@[simp] axiom s2153 (x : Prop) : f (g2154 x) = f (g2153 x)
@[simp] axiom s2154 (x : Prop) : f (g2155 x) = f (g2154 x)
@[simp] axiom s2155 (x : Prop) : f (g2156 x) = f (g2155 x)
@[simp] axiom s2156 (x : Prop) : f (g2157 x) = f (g2156 x)
@[simp] axiom s2157 (x : Prop) : f (g2158 x) = f (g2157 x)
@[simp] axiom s2158 (x : Prop) : f (g2159 x) = f (g2158 x)
@[simp] axiom s2159 (x : Prop) : f (g2160 x) = f (g2159 x)
@[simp] axiom s2160 (x : Prop) : f (g2161 x) = f (g2160 x)
@[simp] axiom s2161 (x : Prop) : f (g2162 x) = f (g2161 x)
@[simp] axiom s2162 (x : Prop) : f (g2163 x) = f (g2162 x)
@[simp] axiom s2163 (x : Prop) : f (g2164 x) = f (g2163 x)
@[simp] axiom s2164 (x : Prop) : f (g2165 x) = f (g2164 x)
@[simp] axiom s2165 (x : Prop) : f (g2166 x) = f (g2165 x)
@[simp] axiom s2166 (x : Prop) : f (g2167 x) = f (g2166 x)
@[simp] axiom s2167 (x : Prop) : f (g2168 x) = f (g2167 x)
@[simp] axiom s2168 (x : Prop) : f (g2169 x) = f (g2168 x)
@[simp] axiom s2169 (x : Prop) : f (g2170 x) = f (g2169 x)
@[simp] axiom s2170 (x : Prop) : f (g2171 x) = f (g2170 x)
@[simp] axiom s2171 (x : Prop) : f (g2172 x) = f (g2171 x)
@[simp] axiom s2172 (x : Prop) : f (g2173 x) = f (g2172 x)
@[simp] axiom s2173 (x : Prop) : f (g2174 x) = f (g2173 x)
@[simp] axiom s2174 (x : Prop) : f (g2175 x) = f (g2174 x)
@[simp] axiom s2175 (x : Prop) : f (g2176 x) = f (g2175 x)
@[simp] axiom s2176 (x : Prop) : f (g2177 x) = f (g2176 x)
@[simp] axiom s2177 (x : Prop) : f (g2178 x) = f (g2177 x)
@[simp] axiom s2178 (x : Prop) : f (g2179 x) = f (g2178 x)
@[simp] axiom s2179 (x : Prop) : f (g2180 x) = f (g2179 x)
@[simp] axiom s2180 (x : Prop) : f (g2181 x) = f (g2180 x)
@[simp] axiom s2181 (x : Prop) : f (g2182 x) = f (g2181 x)
@[simp] axiom s2182 (x : Prop) : f (g2183 x) = f (g2182 x)
@[simp] axiom s2183 (x : Prop) : f (g2184 x) = f (g2183 x)
@[simp] axiom s2184 (x : Prop) : f (g2185 x) = f (g2184 x)
@[simp] axiom s2185 (x : Prop) : f (g2186 x) = f (g2185 x)
@[simp] axiom s2186 (x : Prop) : f (g2187 x) = f (g2186 x)
@[simp] axiom s2187 (x : Prop) : f (g2188 x) = f (g2187 x)
@[simp] axiom s2188 (x : Prop) : f (g2189 x) = f (g2188 x)
@[simp] axiom s2189 (x : Prop) : f (g2190 x) = f (g2189 x)
@[simp] axiom s2190 (x : Prop) : f (g2191 x) = f (g2190 x)
@[simp] axiom s2191 (x : Prop) : f (g2192 x) = f (g2191 x)
@[simp] axiom s2192 (x : Prop) : f (g2193 x) = f (g2192 x)
@[simp] axiom s2193 (x : Prop) : f (g2194 x) = f (g2193 x)
@[simp] axiom s2194 (x : Prop) : f (g2195 x) = f (g2194 x)
@[simp] axiom s2195 (x : Prop) : f (g2196 x) = f (g2195 x)
@[simp] axiom s2196 (x : Prop) : f (g2197 x) = f (g2196 x)
@[simp] axiom s2197 (x : Prop) : f (g2198 x) = f (g2197 x)
@[simp] axiom s2198 (x : Prop) : f (g2199 x) = f (g2198 x)
@[simp] axiom s2199 (x : Prop) : f (g2200 x) = f (g2199 x)
@[simp] axiom s2200 (x : Prop) : f (g2201 x) = f (g2200 x)
@[simp] axiom s2201 (x : Prop) : f (g2202 x) = f (g2201 x)
@[simp] axiom s2202 (x : Prop) : f (g2203 x) = f (g2202 x)
@[simp] axiom s2203 (x : Prop) : f (g2204 x) = f (g2203 x)
@[simp] axiom s2204 (x : Prop) : f (g2205 x) = f (g2204 x)
@[simp] axiom s2205 (x : Prop) : f (g2206 x) = f (g2205 x)
@[simp] axiom s2206 (x : Prop) : f (g2207 x) = f (g2206 x)
@[simp] axiom s2207 (x : Prop) : f (g2208 x) = f (g2207 x)
@[simp] axiom s2208 (x : Prop) : f (g2209 x) = f (g2208 x)
@[simp] axiom s2209 (x : Prop) : f (g2210 x) = f (g2209 x)
@[simp] axiom s2210 (x : Prop) : f (g2211 x) = f (g2210 x)
@[simp] axiom s2211 (x : Prop) : f (g2212 x) = f (g2211 x)
@[simp] axiom s2212 (x : Prop) : f (g2213 x) = f (g2212 x)
@[simp] axiom s2213 (x : Prop) : f (g2214 x) = f (g2213 x)
@[simp] axiom s2214 (x : Prop) : f (g2215 x) = f (g2214 x)
@[simp] axiom s2215 (x : Prop) : f (g2216 x) = f (g2215 x)
@[simp] axiom s2216 (x : Prop) : f (g2217 x) = f (g2216 x)
@[simp] axiom s2217 (x : Prop) : f (g2218 x) = f (g2217 x)
@[simp] axiom s2218 (x : Prop) : f (g2219 x) = f (g2218 x)
@[simp] axiom s2219 (x : Prop) : f (g2220 x) = f (g2219 x)
@[simp] axiom s2220 (x : Prop) : f (g2221 x) = f (g2220 x)
@[simp] axiom s2221 (x : Prop) : f (g2222 x) = f (g2221 x)
@[simp] axiom s2222 (x : Prop) : f (g2223 x) = f (g2222 x)
@[simp] axiom s2223 (x : Prop) : f (g2224 x) = f (g2223 x)
@[simp] axiom s2224 (x : Prop) : f (g2225 x) = f (g2224 x)
@[simp] axiom s2225 (x : Prop) : f (g2226 x) = f (g2225 x)
@[simp] axiom s2226 (x : Prop) : f (g2227 x) = f (g2226 x)
@[simp] axiom s2227 (x : Prop) : f (g2228 x) = f (g2227 x)
@[simp] axiom s2228 (x : Prop) : f (g2229 x) = f (g2228 x)
@[simp] axiom s2229 (x : Prop) : f (g2230 x) = f (g2229 x)
@[simp] axiom s2230 (x : Prop) : f (g2231 x) = f (g2230 x)
@[simp] axiom s2231 (x : Prop) : f (g2232 x) = f (g2231 x)
@[simp] axiom s2232 (x : Prop) : f (g2233 x) = f (g2232 x)
@[simp] axiom s2233 (x : Prop) : f (g2234 x) = f (g2233 x)
@[simp] axiom s2234 (x : Prop) : f (g2235 x) = f (g2234 x)
@[simp] axiom s2235 (x : Prop) : f (g2236 x) = f (g2235 x)
@[simp] axiom s2236 (x : Prop) : f (g2237 x) = f (g2236 x)
@[simp] axiom s2237 (x : Prop) : f (g2238 x) = f (g2237 x)
@[simp] axiom s2238 (x : Prop) : f (g2239 x) = f (g2238 x)
@[simp] axiom s2239 (x : Prop) : f (g2240 x) = f (g2239 x)
@[simp] axiom s2240 (x : Prop) : f (g2241 x) = f (g2240 x)
@[simp] axiom s2241 (x : Prop) : f (g2242 x) = f (g2241 x)
@[simp] axiom s2242 (x : Prop) : f (g2243 x) = f (g2242 x)
@[simp] axiom s2243 (x : Prop) : f (g2244 x) = f (g2243 x)
@[simp] axiom s2244 (x : Prop) : f (g2245 x) = f (g2244 x)
@[simp] axiom s2245 (x : Prop) : f (g2246 x) = f (g2245 x)
@[simp] axiom s2246 (x : Prop) : f (g2247 x) = f (g2246 x)
@[simp] axiom s2247 (x : Prop) : f (g2248 x) = f (g2247 x)
@[simp] axiom s2248 (x : Prop) : f (g2249 x) = f (g2248 x)
@[simp] axiom s2249 (x : Prop) : f (g2250 x) = f (g2249 x)
@[simp] axiom s2250 (x : Prop) : f (g2251 x) = f (g2250 x)
@[simp] axiom s2251 (x : Prop) : f (g2252 x) = f (g2251 x)
@[simp] axiom s2252 (x : Prop) : f (g2253 x) = f (g2252 x)
@[simp] axiom s2253 (x : Prop) : f (g2254 x) = f (g2253 x)
@[simp] axiom s2254 (x : Prop) : f (g2255 x) = f (g2254 x)
@[simp] axiom s2255 (x : Prop) : f (g2256 x) = f (g2255 x)
@[simp] axiom s2256 (x : Prop) : f (g2257 x) = f (g2256 x)
@[simp] axiom s2257 (x : Prop) : f (g2258 x) = f (g2257 x)
@[simp] axiom s2258 (x : Prop) : f (g2259 x) = f (g2258 x)
@[simp] axiom s2259 (x : Prop) : f (g2260 x) = f (g2259 x)
@[simp] axiom s2260 (x : Prop) : f (g2261 x) = f (g2260 x)
@[simp] axiom s2261 (x : Prop) : f (g2262 x) = f (g2261 x)
@[simp] axiom s2262 (x : Prop) : f (g2263 x) = f (g2262 x)
@[simp] axiom s2263 (x : Prop) : f (g2264 x) = f (g2263 x)
@[simp] axiom s2264 (x : Prop) : f (g2265 x) = f (g2264 x)
@[simp] axiom s2265 (x : Prop) : f (g2266 x) = f (g2265 x)
@[simp] axiom s2266 (x : Prop) : f (g2267 x) = f (g2266 x)
@[simp] axiom s2267 (x : Prop) : f (g2268 x) = f (g2267 x)
@[simp] axiom s2268 (x : Prop) : f (g2269 x) = f (g2268 x)
@[simp] axiom s2269 (x : Prop) : f (g2270 x) = f (g2269 x)
@[simp] axiom s2270 (x : Prop) : f (g2271 x) = f (g2270 x)
@[simp] axiom s2271 (x : Prop) : f (g2272 x) = f (g2271 x)
@[simp] axiom s2272 (x : Prop) : f (g2273 x) = f (g2272 x)
@[simp] axiom s2273 (x : Prop) : f (g2274 x) = f (g2273 x)
@[simp] axiom s2274 (x : Prop) : f (g2275 x) = f (g2274 x)
@[simp] axiom s2275 (x : Prop) : f (g2276 x) = f (g2275 x)
@[simp] axiom s2276 (x : Prop) : f (g2277 x) = f (g2276 x)
@[simp] axiom s2277 (x : Prop) : f (g2278 x) = f (g2277 x)
@[simp] axiom s2278 (x : Prop) : f (g2279 x) = f (g2278 x)
@[simp] axiom s2279 (x : Prop) : f (g2280 x) = f (g2279 x)
@[simp] axiom s2280 (x : Prop) : f (g2281 x) = f (g2280 x)
@[simp] axiom s2281 (x : Prop) : f (g2282 x) = f (g2281 x)
@[simp] axiom s2282 (x : Prop) : f (g2283 x) = f (g2282 x)
@[simp] axiom s2283 (x : Prop) : f (g2284 x) = f (g2283 x)
@[simp] axiom s2284 (x : Prop) : f (g2285 x) = f (g2284 x)
@[simp] axiom s2285 (x : Prop) : f (g2286 x) = f (g2285 x)
@[simp] axiom s2286 (x : Prop) : f (g2287 x) = f (g2286 x)
@[simp] axiom s2287 (x : Prop) : f (g2288 x) = f (g2287 x)
@[simp] axiom s2288 (x : Prop) : f (g2289 x) = f (g2288 x)
@[simp] axiom s2289 (x : Prop) : f (g2290 x) = f (g2289 x)
@[simp] axiom s2290 (x : Prop) : f (g2291 x) = f (g2290 x)
@[simp] axiom s2291 (x : Prop) : f (g2292 x) = f (g2291 x)
@[simp] axiom s2292 (x : Prop) : f (g2293 x) = f (g2292 x)
@[simp] axiom s2293 (x : Prop) : f (g2294 x) = f (g2293 x)
@[simp] axiom s2294 (x : Prop) : f (g2295 x) = f (g2294 x)
@[simp] axiom s2295 (x : Prop) : f (g2296 x) = f (g2295 x)
@[simp] axiom s2296 (x : Prop) : f (g2297 x) = f (g2296 x)
@[simp] axiom s2297 (x : Prop) : f (g2298 x) = f (g2297 x)
@[simp] axiom s2298 (x : Prop) : f (g2299 x) = f (g2298 x)
@[simp] axiom s2299 (x : Prop) : f (g2300 x) = f (g2299 x)
@[simp] axiom s2300 (x : Prop) : f (g2301 x) = f (g2300 x)
@[simp] axiom s2301 (x : Prop) : f (g2302 x) = f (g2301 x)
@[simp] axiom s2302 (x : Prop) : f (g2303 x) = f (g2302 x)
@[simp] axiom s2303 (x : Prop) : f (g2304 x) = f (g2303 x)
@[simp] axiom s2304 (x : Prop) : f (g2305 x) = f (g2304 x)
@[simp] axiom s2305 (x : Prop) : f (g2306 x) = f (g2305 x)
@[simp] axiom s2306 (x : Prop) : f (g2307 x) = f (g2306 x)
@[simp] axiom s2307 (x : Prop) : f (g2308 x) = f (g2307 x)
@[simp] axiom s2308 (x : Prop) : f (g2309 x) = f (g2308 x)
@[simp] axiom s2309 (x : Prop) : f (g2310 x) = f (g2309 x)
@[simp] axiom s2310 (x : Prop) : f (g2311 x) = f (g2310 x)
@[simp] axiom s2311 (x : Prop) : f (g2312 x) = f (g2311 x)
@[simp] axiom s2312 (x : Prop) : f (g2313 x) = f (g2312 x)
@[simp] axiom s2313 (x : Prop) : f (g2314 x) = f (g2313 x)
@[simp] axiom s2314 (x : Prop) : f (g2315 x) = f (g2314 x)
@[simp] axiom s2315 (x : Prop) : f (g2316 x) = f (g2315 x)
@[simp] axiom s2316 (x : Prop) : f (g2317 x) = f (g2316 x)
@[simp] axiom s2317 (x : Prop) : f (g2318 x) = f (g2317 x)
@[simp] axiom s2318 (x : Prop) : f (g2319 x) = f (g2318 x)
@[simp] axiom s2319 (x : Prop) : f (g2320 x) = f (g2319 x)
@[simp] axiom s2320 (x : Prop) : f (g2321 x) = f (g2320 x)
@[simp] axiom s2321 (x : Prop) : f (g2322 x) = f (g2321 x)
@[simp] axiom s2322 (x : Prop) : f (g2323 x) = f (g2322 x)
@[simp] axiom s2323 (x : Prop) : f (g2324 x) = f (g2323 x)
@[simp] axiom s2324 (x : Prop) : f (g2325 x) = f (g2324 x)
@[simp] axiom s2325 (x : Prop) : f (g2326 x) = f (g2325 x)
@[simp] axiom s2326 (x : Prop) : f (g2327 x) = f (g2326 x)
@[simp] axiom s2327 (x : Prop) : f (g2328 x) = f (g2327 x)
@[simp] axiom s2328 (x : Prop) : f (g2329 x) = f (g2328 x)
@[simp] axiom s2329 (x : Prop) : f (g2330 x) = f (g2329 x)
@[simp] axiom s2330 (x : Prop) : f (g2331 x) = f (g2330 x)
@[simp] axiom s2331 (x : Prop) : f (g2332 x) = f (g2331 x)
@[simp] axiom s2332 (x : Prop) : f (g2333 x) = f (g2332 x)
@[simp] axiom s2333 (x : Prop) : f (g2334 x) = f (g2333 x)
@[simp] axiom s2334 (x : Prop) : f (g2335 x) = f (g2334 x)
@[simp] axiom s2335 (x : Prop) : f (g2336 x) = f (g2335 x)
@[simp] axiom s2336 (x : Prop) : f (g2337 x) = f (g2336 x)
@[simp] axiom s2337 (x : Prop) : f (g2338 x) = f (g2337 x)
@[simp] axiom s2338 (x : Prop) : f (g2339 x) = f (g2338 x)
@[simp] axiom s2339 (x : Prop) : f (g2340 x) = f (g2339 x)
@[simp] axiom s2340 (x : Prop) : f (g2341 x) = f (g2340 x)
@[simp] axiom s2341 (x : Prop) : f (g2342 x) = f (g2341 x)
@[simp] axiom s2342 (x : Prop) : f (g2343 x) = f (g2342 x)
@[simp] axiom s2343 (x : Prop) : f (g2344 x) = f (g2343 x)
@[simp] axiom s2344 (x : Prop) : f (g2345 x) = f (g2344 x)
@[simp] axiom s2345 (x : Prop) : f (g2346 x) = f (g2345 x)
@[simp] axiom s2346 (x : Prop) : f (g2347 x) = f (g2346 x)
@[simp] axiom s2347 (x : Prop) : f (g2348 x) = f (g2347 x)
@[simp] axiom s2348 (x : Prop) : f (g2349 x) = f (g2348 x)
@[simp] axiom s2349 (x : Prop) : f (g2350 x) = f (g2349 x)
@[simp] axiom s2350 (x : Prop) : f (g2351 x) = f (g2350 x)
@[simp] axiom s2351 (x : Prop) : f (g2352 x) = f (g2351 x)
@[simp] axiom s2352 (x : Prop) : f (g2353 x) = f (g2352 x)
@[simp] axiom s2353 (x : Prop) : f (g2354 x) = f (g2353 x)
@[simp] axiom s2354 (x : Prop) : f (g2355 x) = f (g2354 x)
@[simp] axiom s2355 (x : Prop) : f (g2356 x) = f (g2355 x)
@[simp] axiom s2356 (x : Prop) : f (g2357 x) = f (g2356 x)
@[simp] axiom s2357 (x : Prop) : f (g2358 x) = f (g2357 x)
@[simp] axiom s2358 (x : Prop) : f (g2359 x) = f (g2358 x)
@[simp] axiom s2359 (x : Prop) : f (g2360 x) = f (g2359 x)
@[simp] axiom s2360 (x : Prop) : f (g2361 x) = f (g2360 x)
@[simp] axiom s2361 (x : Prop) : f (g2362 x) = f (g2361 x)
@[simp] axiom s2362 (x : Prop) : f (g2363 x) = f (g2362 x)
@[simp] axiom s2363 (x : Prop) : f (g2364 x) = f (g2363 x)
@[simp] axiom s2364 (x : Prop) : f (g2365 x) = f (g2364 x)
@[simp] axiom s2365 (x : Prop) : f (g2366 x) = f (g2365 x)
@[simp] axiom s2366 (x : Prop) : f (g2367 x) = f (g2366 x)
@[simp] axiom s2367 (x : Prop) : f (g2368 x) = f (g2367 x)
@[simp] axiom s2368 (x : Prop) : f (g2369 x) = f (g2368 x)
@[simp] axiom s2369 (x : Prop) : f (g2370 x) = f (g2369 x)
@[simp] axiom s2370 (x : Prop) : f (g2371 x) = f (g2370 x)
@[simp] axiom s2371 (x : Prop) : f (g2372 x) = f (g2371 x)
@[simp] axiom s2372 (x : Prop) : f (g2373 x) = f (g2372 x)
@[simp] axiom s2373 (x : Prop) : f (g2374 x) = f (g2373 x)
@[simp] axiom s2374 (x : Prop) : f (g2375 x) = f (g2374 x)
@[simp] axiom s2375 (x : Prop) : f (g2376 x) = f (g2375 x)
@[simp] axiom s2376 (x : Prop) : f (g2377 x) = f (g2376 x)
@[simp] axiom s2377 (x : Prop) : f (g2378 x) = f (g2377 x)
@[simp] axiom s2378 (x : Prop) : f (g2379 x) = f (g2378 x)
@[simp] axiom s2379 (x : Prop) : f (g2380 x) = f (g2379 x)
@[simp] axiom s2380 (x : Prop) : f (g2381 x) = f (g2380 x)
@[simp] axiom s2381 (x : Prop) : f (g2382 x) = f (g2381 x)
@[simp] axiom s2382 (x : Prop) : f (g2383 x) = f (g2382 x)
@[simp] axiom s2383 (x : Prop) : f (g2384 x) = f (g2383 x)
@[simp] axiom s2384 (x : Prop) : f (g2385 x) = f (g2384 x)
@[simp] axiom s2385 (x : Prop) : f (g2386 x) = f (g2385 x)
@[simp] axiom s2386 (x : Prop) : f (g2387 x) = f (g2386 x)
@[simp] axiom s2387 (x : Prop) : f (g2388 x) = f (g2387 x)
@[simp] axiom s2388 (x : Prop) : f (g2389 x) = f (g2388 x)
@[simp] axiom s2389 (x : Prop) : f (g2390 x) = f (g2389 x)
@[simp] axiom s2390 (x : Prop) : f (g2391 x) = f (g2390 x)
@[simp] axiom s2391 (x : Prop) : f (g2392 x) = f (g2391 x)
@[simp] axiom s2392 (x : Prop) : f (g2393 x) = f (g2392 x)
@[simp] axiom s2393 (x : Prop) : f (g2394 x) = f (g2393 x)
@[simp] axiom s2394 (x : Prop) : f (g2395 x) = f (g2394 x)
@[simp] axiom s2395 (x : Prop) : f (g2396 x) = f (g2395 x)
@[simp] axiom s2396 (x : Prop) : f (g2397 x) = f (g2396 x)
@[simp] axiom s2397 (x : Prop) : f (g2398 x) = f (g2397 x)
@[simp] axiom s2398 (x : Prop) : f (g2399 x) = f (g2398 x)
@[simp] axiom s2399 (x : Prop) : f (g2400 x) = f (g2399 x)
@[simp] axiom s2400 (x : Prop) : f (g2401 x) = f (g2400 x)
@[simp] axiom s2401 (x : Prop) : f (g2402 x) = f (g2401 x)
@[simp] axiom s2402 (x : Prop) : f (g2403 x) = f (g2402 x)
@[simp] axiom s2403 (x : Prop) : f (g2404 x) = f (g2403 x)
@[simp] axiom s2404 (x : Prop) : f (g2405 x) = f (g2404 x)
@[simp] axiom s2405 (x : Prop) : f (g2406 x) = f (g2405 x)
@[simp] axiom s2406 (x : Prop) : f (g2407 x) = f (g2406 x)
@[simp] axiom s2407 (x : Prop) : f (g2408 x) = f (g2407 x)
@[simp] axiom s2408 (x : Prop) : f (g2409 x) = f (g2408 x)
@[simp] axiom s2409 (x : Prop) : f (g2410 x) = f (g2409 x)
@[simp] axiom s2410 (x : Prop) : f (g2411 x) = f (g2410 x)
@[simp] axiom s2411 (x : Prop) : f (g2412 x) = f (g2411 x)
@[simp] axiom s2412 (x : Prop) : f (g2413 x) = f (g2412 x)
@[simp] axiom s2413 (x : Prop) : f (g2414 x) = f (g2413 x)
@[simp] axiom s2414 (x : Prop) : f (g2415 x) = f (g2414 x)
@[simp] axiom s2415 (x : Prop) : f (g2416 x) = f (g2415 x)
@[simp] axiom s2416 (x : Prop) : f (g2417 x) = f (g2416 x)
@[simp] axiom s2417 (x : Prop) : f (g2418 x) = f (g2417 x)
@[simp] axiom s2418 (x : Prop) : f (g2419 x) = f (g2418 x)
@[simp] axiom s2419 (x : Prop) : f (g2420 x) = f (g2419 x)
@[simp] axiom s2420 (x : Prop) : f (g2421 x) = f (g2420 x)
@[simp] axiom s2421 (x : Prop) : f (g2422 x) = f (g2421 x)
@[simp] axiom s2422 (x : Prop) : f (g2423 x) = f (g2422 x)
@[simp] axiom s2423 (x : Prop) : f (g2424 x) = f (g2423 x)
@[simp] axiom s2424 (x : Prop) : f (g2425 x) = f (g2424 x)
@[simp] axiom s2425 (x : Prop) : f (g2426 x) = f (g2425 x)
@[simp] axiom s2426 (x : Prop) : f (g2427 x) = f (g2426 x)
@[simp] axiom s2427 (x : Prop) : f (g2428 x) = f (g2427 x)
@[simp] axiom s2428 (x : Prop) : f (g2429 x) = f (g2428 x)
@[simp] axiom s2429 (x : Prop) : f (g2430 x) = f (g2429 x)
@[simp] axiom s2430 (x : Prop) : f (g2431 x) = f (g2430 x)
@[simp] axiom s2431 (x : Prop) : f (g2432 x) = f (g2431 x)
@[simp] axiom s2432 (x : Prop) : f (g2433 x) = f (g2432 x)
@[simp] axiom s2433 (x : Prop) : f (g2434 x) = f (g2433 x)
@[simp] axiom s2434 (x : Prop) : f (g2435 x) = f (g2434 x)
@[simp] axiom s2435 (x : Prop) : f (g2436 x) = f (g2435 x)
@[simp] axiom s2436 (x : Prop) : f (g2437 x) = f (g2436 x)
@[simp] axiom s2437 (x : Prop) : f (g2438 x) = f (g2437 x)
@[simp] axiom s2438 (x : Prop) : f (g2439 x) = f (g2438 x)
@[simp] axiom s2439 (x : Prop) : f (g2440 x) = f (g2439 x)
@[simp] axiom s2440 (x : Prop) : f (g2441 x) = f (g2440 x)
@[simp] axiom s2441 (x : Prop) : f (g2442 x) = f (g2441 x)
@[simp] axiom s2442 (x : Prop) : f (g2443 x) = f (g2442 x)
@[simp] axiom s2443 (x : Prop) : f (g2444 x) = f (g2443 x)
@[simp] axiom s2444 (x : Prop) : f (g2445 x) = f (g2444 x)
@[simp] axiom s2445 (x : Prop) : f (g2446 x) = f (g2445 x)
@[simp] axiom s2446 (x : Prop) : f (g2447 x) = f (g2446 x)
@[simp] axiom s2447 (x : Prop) : f (g2448 x) = f (g2447 x)
@[simp] axiom s2448 (x : Prop) : f (g2449 x) = f (g2448 x)
@[simp] axiom s2449 (x : Prop) : f (g2450 x) = f (g2449 x)
@[simp] axiom s2450 (x : Prop) : f (g2451 x) = f (g2450 x)
@[simp] axiom s2451 (x : Prop) : f (g2452 x) = f (g2451 x)
@[simp] axiom s2452 (x : Prop) : f (g2453 x) = f (g2452 x)
@[simp] axiom s2453 (x : Prop) : f (g2454 x) = f (g2453 x)
@[simp] axiom s2454 (x : Prop) : f (g2455 x) = f (g2454 x)
@[simp] axiom s2455 (x : Prop) : f (g2456 x) = f (g2455 x)
@[simp] axiom s2456 (x : Prop) : f (g2457 x) = f (g2456 x)
@[simp] axiom s2457 (x : Prop) : f (g2458 x) = f (g2457 x)
@[simp] axiom s2458 (x : Prop) : f (g2459 x) = f (g2458 x)
@[simp] axiom s2459 (x : Prop) : f (g2460 x) = f (g2459 x)
@[simp] axiom s2460 (x : Prop) : f (g2461 x) = f (g2460 x)
@[simp] axiom s2461 (x : Prop) : f (g2462 x) = f (g2461 x)
@[simp] axiom s2462 (x : Prop) : f (g2463 x) = f (g2462 x)
@[simp] axiom s2463 (x : Prop) : f (g2464 x) = f (g2463 x)
@[simp] axiom s2464 (x : Prop) : f (g2465 x) = f (g2464 x)
@[simp] axiom s2465 (x : Prop) : f (g2466 x) = f (g2465 x)
@[simp] axiom s2466 (x : Prop) : f (g2467 x) = f (g2466 x)
@[simp] axiom s2467 (x : Prop) : f (g2468 x) = f (g2467 x)
@[simp] axiom s2468 (x : Prop) : f (g2469 x) = f (g2468 x)
@[simp] axiom s2469 (x : Prop) : f (g2470 x) = f (g2469 x)
@[simp] axiom s2470 (x : Prop) : f (g2471 x) = f (g2470 x)
@[simp] axiom s2471 (x : Prop) : f (g2472 x) = f (g2471 x)
@[simp] axiom s2472 (x : Prop) : f (g2473 x) = f (g2472 x)
@[simp] axiom s2473 (x : Prop) : f (g2474 x) = f (g2473 x)
@[simp] axiom s2474 (x : Prop) : f (g2475 x) = f (g2474 x)
@[simp] axiom s2475 (x : Prop) : f (g2476 x) = f (g2475 x)
@[simp] axiom s2476 (x : Prop) : f (g2477 x) = f (g2476 x)
@[simp] axiom s2477 (x : Prop) : f (g2478 x) = f (g2477 x)
@[simp] axiom s2478 (x : Prop) : f (g2479 x) = f (g2478 x)
@[simp] axiom s2479 (x : Prop) : f (g2480 x) = f (g2479 x)
@[simp] axiom s2480 (x : Prop) : f (g2481 x) = f (g2480 x)
@[simp] axiom s2481 (x : Prop) : f (g2482 x) = f (g2481 x)
@[simp] axiom s2482 (x : Prop) : f (g2483 x) = f (g2482 x)
@[simp] axiom s2483 (x : Prop) : f (g2484 x) = f (g2483 x)
@[simp] axiom s2484 (x : Prop) : f (g2485 x) = f (g2484 x)
@[simp] axiom s2485 (x : Prop) : f (g2486 x) = f (g2485 x)
@[simp] axiom s2486 (x : Prop) : f (g2487 x) = f (g2486 x)
@[simp] axiom s2487 (x : Prop) : f (g2488 x) = f (g2487 x)
@[simp] axiom s2488 (x : Prop) : f (g2489 x) = f (g2488 x)
@[simp] axiom s2489 (x : Prop) : f (g2490 x) = f (g2489 x)
@[simp] axiom s2490 (x : Prop) : f (g2491 x) = f (g2490 x)
@[simp] axiom s2491 (x : Prop) : f (g2492 x) = f (g2491 x)
@[simp] axiom s2492 (x : Prop) : f (g2493 x) = f (g2492 x)
@[simp] axiom s2493 (x : Prop) : f (g2494 x) = f (g2493 x)
@[simp] axiom s2494 (x : Prop) : f (g2495 x) = f (g2494 x)
@[simp] axiom s2495 (x : Prop) : f (g2496 x) = f (g2495 x)
@[simp] axiom s2496 (x : Prop) : f (g2497 x) = f (g2496 x)
@[simp] axiom s2497 (x : Prop) : f (g2498 x) = f (g2497 x)
@[simp] axiom s2498 (x : Prop) : f (g2499 x) = f (g2498 x)
def test (x : Prop) : f (g0 x) = f (g2499 x) := by simp
#check test
|
c54936eb62b9eb156dcf91f444df1e467df2313c | ba4794a0deca1d2aaa68914cd285d77880907b5c | /src/game/world1/level1.lean | 8df55f3b73b8761a89f8c24e281cd2a6607ea244 | [
"Apache-2.0"
] | permissive | ChrisHughes24/natural_number_game | c7c00aa1f6a95004286fd456ed13cf6e113159ce | 9d09925424da9f6275e6cfe427c8bcf12bb0944f | refs/heads/master | 1,600,715,773,528 | 1,573,910,462,000 | 1,573,910,462,000 | null | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 3,517 | lean | import mynat.definition -- imports the natural numbers {0,1,2,3,4,...}.
import mynat.add -- imports definition of addition on the natural numbers.
import mynat.mul -- imports definition of multiplication on the natural numbers.
namespace mynat -- hide
-- World name : Tutorial world
/-
# Tutorial World
## Level 1: the `refl` tactic.
Let's learn some tactics! Let's start with the `refl` tactic. `refl` stands for "reflexivity", which is a fancy
way of saying that it will prove any goal of the form `A = A`. It doesn't matter how
complicated `A` is, all that matters is that the left hand side is *exactly equal* to the
right hand side (a computer scientist would say "definitionally equal"). I really mean
"press the same buttons on your computer in the same order" equal.
For example, `x * y + z = x * y + z` can be proved by `refl`, but `x + y = y + x` cannot.
Let's see `refl` in action! At the bottom of the text in this box, there's a lemma,
which says that if $x$, $y$ and $z$ are natural numbers then $xy + z = xy + z$.
Locate this lemma (if you can't see the lemma and these instructions at the same time, make this box wider
by dragging the sides). Let's supply the proof. Click on the word `sorry` and then delete it.
When the system finishes being busy, you'll be able to see your goal -- the objective
of this level -- in the box on the top right. [NB if your system never finishes being busy, then
your computer is not running the javascript Lean which powers everything behind the scenes.
Try Chrome? Try not using private browsing?]
Remember that the goal is
the thing with the weird `⊢` thing just before it. The goal in this case is `x * y + z = x * y + z`,
where `x`, `y` and `z` are some of your very own natural numbers.
That's a pretty easy goal to prove -- you can just prove it with the `refl` tactic.
Where it used to say `sorry`, write
`refl,`
**and don't forget the comma**. Then hit enter to go onto the next line.
If all is well, Lean should tell you "Proof complete!" in the top right box, and there
should be no errors in the bottom right box. You just did the first
level of the tutorial! And you also learnt how to avoid by *far* the most
common mistake that beginner users make -- **every line must end with a comma**.
If things go weird and you don't understand why the top right box is empty,
check for missing commas. Also check you've spelt `refl` correctly: it's REFL
for "reflexivity".
For each level, the idea is to get Lean into this state: with the top right
box saying "Proof complete!" and the bottom right box empty (i.e. with no errors in).
If you want to be reminded about the `refl` tactic, you can click on the "Tactics" drop
down menu on the left. Resize the window if it's too small.
Now click on "next level" in the top right of your browser to go onto the second level of
tutorial world, where we'll learn about the `rw` tactic.
-/
/- Lemma : no-side-bar
For all natural numbers $x$, $y$ and $z$, we have $xy + z = xy + z$.
-/
lemma example1 (x y z : mynat) : x * y + z = x * y + z :=
begin [less_leaky]
refl
end
/- Tactic : refl
## Summary
`refl` proves goals of the form `X = X`.
## Details
The `refl` tactic will close any goal of the form `A = B`
where `A` and `B` are *exactly the same thing*.
### Example:
If it looks like this in the top right hand box:
```
a b c d : mynat
⊢ (a + b) * (c + d) = (a + b) * (c + d)
```
then
`refl,`
will close the goal and solve the level. Don't forget the comma.
-/
end mynat -- hide
|
ad7448365a4cbd7a830592976124ba2a9b588c35 | d9d511f37a523cd7659d6f573f990e2a0af93c6f | /src/field_theory/splitting_field.lean | d1f1a0ed844fd68d266d0f66a7e7d9b7020dc906 | [
"Apache-2.0"
] | permissive | hikari0108/mathlib | b7ea2b7350497ab1a0b87a09d093ecc025a50dfa | a9e7d333b0cfd45f13a20f7b96b7d52e19fa2901 | refs/heads/master | 1,690,483,608,260 | 1,631,541,580,000 | 1,631,541,580,000 | null | 0 | 0 | null | null | null | null | UTF-8 | Lean | false | false | 37,407 | lean | /-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes
-/
import ring_theory.adjoin_root
import ring_theory.algebra_tower
import ring_theory.algebraic
import ring_theory.polynomial
import field_theory.minpoly
import linear_algebra.finite_dimensional
import tactic.field_simp
import algebra.polynomial.big_operators
/-!
# Splitting fields
This file introduces the notion of a splitting field of a polynomial and provides an embedding from
a splitting field to any field that splits the polynomial. A polynomial `f : polynomial K` splits
over a field extension `L` of `K` if it is zero or all of its irreducible factors over `L` have
degree `1`. A field extension of `K` of a polynomial `f : polynomial K` is called a splitting field
if it is the smallest field extension of `K` such that `f` splits.
## Main definitions
* `polynomial.splits i f`: A predicate on a field homomorphism `i : K → L` and a polynomial `f`
saying that `f` is zero or all of its irreducible factors over `L` have degree `1`.
* `polynomial.splitting_field f`: A fixed splitting field of the polynomial `f`.
* `polynomial.is_splitting_field`: A predicate on a field to be a splitting field of a polynomial
`f`.
## Main statements
* `polynomial.C_leading_coeff_mul_prod_multiset_X_sub_C`: If a polynomial has as many roots as its
degree, it can be written as the product of its leading coefficient with `∏ (X - a)` where `a`
ranges through its roots.
* `lift_of_splits`: If `K` and `L` are field extensions of a field `F` and for some finite subset
`S` of `K`, the minimal polynomial of every `x ∈ K` splits as a polynomial with coefficients in
`L`, then `algebra.adjoin F S` embeds into `L`.
* `polynomial.is_splitting_field.lift`: An embedding of a splitting field of the polynomial `f` into
another field such that `f` splits.
* `polynomial.is_splitting_field.alg_equiv`: Every splitting field of a polynomial `f` is isomorpic
to `splitting_field f` and thus, being a splitting field is unique up to isomorphism.
-/
noncomputable theory
open_locale classical big_operators
universes u v w
variables {F : Type u} {K : Type v} {L : Type w}
namespace polynomial
variables [field K] [field L] [field F]
open polynomial
section splits
variables (i : K →+* L)
/-- A polynomial `splits` iff it is zero or all of its irreducible factors have `degree` 1. -/
def splits (f : polynomial K) : Prop :=
f = 0 ∨ ∀ {g : polynomial L}, irreducible g → g ∣ f.map i → degree g = 1
@[simp] lemma splits_zero : splits i (0 : polynomial K) := or.inl rfl
@[simp] lemma splits_C (a : K) : splits i (C a) :=
if ha : a = 0 then ha.symm ▸ (@C_0 K _).symm ▸ splits_zero i
else
have hia : i a ≠ 0, from mt ((i.injective_iff).1
i.injective _) ha,
or.inr $ λ g hg ⟨p, hp⟩, absurd hg.1 (not_not.2 (is_unit_iff_degree_eq_zero.2 $
by have := congr_arg degree hp;
simp [degree_C hia, @eq_comm (with_bot ℕ) 0,
nat.with_bot.add_eq_zero_iff] at this; clear _fun_match; tauto))
lemma splits_of_degree_eq_one {f : polynomial K} (hf : degree f = 1) : splits i f :=
or.inr $ λ g hg ⟨p, hp⟩,
by have := congr_arg degree hp;
simp [nat.with_bot.add_eq_one_iff, hf, @eq_comm (with_bot ℕ) 1,
mt is_unit_iff_degree_eq_zero.2 hg.1] at this;
clear _fun_match; tauto
lemma splits_of_degree_le_one {f : polynomial K} (hf : degree f ≤ 1) : splits i f :=
begin
cases h : degree f with n,
{ rw [degree_eq_bot.1 h]; exact splits_zero i },
{ cases n with n,
{ rw [eq_C_of_degree_le_zero (trans_rel_right (≤) h (le_refl _))];
exact splits_C _ _ },
{ have hn : n = 0,
{ rw h at hf,
cases n, { refl }, { exact absurd hf dec_trivial } },
exact splits_of_degree_eq_one _ (by rw [h, hn]; refl) } }
end
lemma splits_of_nat_degree_le_one {f : polynomial K} (hf : nat_degree f ≤ 1) : splits i f :=
splits_of_degree_le_one i (degree_le_of_nat_degree_le hf)
lemma splits_of_nat_degree_eq_one {f : polynomial K} (hf : nat_degree f = 1) : splits i f :=
splits_of_nat_degree_le_one i (le_of_eq hf)
lemma splits_mul {f g : polynomial K} (hf : splits i f) (hg : splits i g) : splits i (f * g) :=
if h : f * g = 0 then by simp [h]
else or.inr $ λ p hp hpf, ((principal_ideal_ring.irreducible_iff_prime.1 hp).2.2 _ _
(show p ∣ map i f * map i g, by convert hpf; rw polynomial.map_mul)).elim
(hf.resolve_left (λ hf, by simpa [hf] using h) hp)
(hg.resolve_left (λ hg, by simpa [hg] using h) hp)
lemma splits_of_splits_mul {f g : polynomial K} (hfg : f * g ≠ 0) (h : splits i (f * g)) :
splits i f ∧ splits i g :=
⟨or.inr $ λ g hgi hg, or.resolve_left h hfg hgi
(by rw map_mul; exact hg.trans (dvd_mul_right _ _)),
or.inr $ λ g hgi hg, or.resolve_left h hfg hgi
(by rw map_mul; exact hg.trans (dvd_mul_left _ _))⟩
lemma splits_of_splits_of_dvd {f g : polynomial K} (hf0 : f ≠ 0) (hf : splits i f) (hgf : g ∣ f) :
splits i g :=
by { obtain ⟨f, rfl⟩ := hgf, exact (splits_of_splits_mul i hf0 hf).1 }
lemma splits_of_splits_gcd_left {f g : polynomial K} (hf0 : f ≠ 0) (hf : splits i f) :
splits i (euclidean_domain.gcd f g) :=
polynomial.splits_of_splits_of_dvd i hf0 hf (euclidean_domain.gcd_dvd_left f g)
lemma splits_of_splits_gcd_right {f g : polynomial K} (hg0 : g ≠ 0) (hg : splits i g) :
splits i (euclidean_domain.gcd f g) :=
polynomial.splits_of_splits_of_dvd i hg0 hg (euclidean_domain.gcd_dvd_right f g)
lemma splits_map_iff (j : L →+* F) {f : polynomial K} :
splits j (f.map i) ↔ splits (j.comp i) f :=
by simp [splits, polynomial.map_map]
theorem splits_one : splits i 1 :=
splits_C i 1
theorem splits_of_is_unit {u : polynomial K} (hu : is_unit u) : u.splits i :=
splits_of_splits_of_dvd i one_ne_zero (splits_one _) $ is_unit_iff_dvd_one.1 hu
theorem splits_X_sub_C {x : K} : (X - C x).splits i :=
splits_of_degree_eq_one _ $ degree_X_sub_C x
theorem splits_X : X.splits i :=
splits_of_degree_eq_one _ $ degree_X
theorem splits_id_iff_splits {f : polynomial K} :
(f.map i).splits (ring_hom.id L) ↔ f.splits i :=
by rw [splits_map_iff, ring_hom.id_comp]
theorem splits_mul_iff {f g : polynomial K} (hf : f ≠ 0) (hg : g ≠ 0) :
(f * g).splits i ↔ f.splits i ∧ g.splits i :=
⟨splits_of_splits_mul i (mul_ne_zero hf hg), λ ⟨hfs, hgs⟩, splits_mul i hfs hgs⟩
theorem splits_prod {ι : Type u} {s : ι → polynomial K} {t : finset ι} :
(∀ j ∈ t, (s j).splits i) → (∏ x in t, s x).splits i :=
begin
refine finset.induction_on t (λ _, splits_one i) (λ a t hat ih ht, _),
rw finset.forall_mem_insert at ht, rw finset.prod_insert hat,
exact splits_mul i ht.1 (ih ht.2)
end
lemma splits_pow {f : polynomial K} (hf : f.splits i) (n : ℕ) : (f ^ n).splits i :=
begin
rw [←finset.card_range n, ←finset.prod_const],
exact splits_prod i (λ j hj, hf),
end
lemma splits_X_pow (n : ℕ) : (X ^ n).splits i := splits_pow i (splits_X i) n
theorem splits_prod_iff {ι : Type u} {s : ι → polynomial K} {t : finset ι} :
(∀ j ∈ t, s j ≠ 0) → ((∏ x in t, s x).splits i ↔ ∀ j ∈ t, (s j).splits i) :=
begin
refine finset.induction_on t (λ _, ⟨λ _ _ h, h.elim, λ _, splits_one i⟩) (λ a t hat ih ht, _),
rw finset.forall_mem_insert at ht ⊢,
rw [finset.prod_insert hat, splits_mul_iff i ht.1 (finset.prod_ne_zero_iff.2 ht.2), ih ht.2]
end
lemma degree_eq_one_of_irreducible_of_splits {p : polynomial L}
(h_nz : p ≠ 0) (hp : irreducible p) (hp_splits : splits (ring_hom.id L) p) :
p.degree = 1 :=
begin
rcases hp_splits,
{ contradiction },
{ apply hp_splits hp, simp }
end
lemma exists_root_of_splits {f : polynomial K} (hs : splits i f) (hf0 : degree f ≠ 0) :
∃ x, eval₂ i x f = 0 :=
if hf0 : f = 0 then ⟨37, by simp [hf0]⟩
else
let ⟨g, hg⟩ := wf_dvd_monoid.exists_irreducible_factor
(show ¬ is_unit (f.map i), from mt is_unit_iff_degree_eq_zero.1 (by rwa degree_map))
(map_ne_zero hf0) in
let ⟨x, hx⟩ := exists_root_of_degree_eq_one (hs.resolve_left hf0 hg.1 hg.2) in
let ⟨i, hi⟩ := hg.2 in
⟨x, by rw [← eval_map, hi, eval_mul, show _ = _, from hx, zero_mul]⟩
lemma exists_multiset_of_splits {f : polynomial K} : splits i f →
∃ (s : multiset L), f.map i = C (i f.leading_coeff) *
(s.map (λ a : L, (X : polynomial L) - C a)).prod :=
suffices splits (ring_hom.id _) (f.map i) → ∃ s : multiset L, f.map i =
(C (f.map i).leading_coeff) * (s.map (λ a : L, (X : polynomial L) - C a)).prod,
by rwa [splits_map_iff, leading_coeff_map i] at this,
wf_dvd_monoid.induction_on_irreducible (f.map i)
(λ _, ⟨{37}, by simp [i.map_zero]⟩)
(λ u hu _, ⟨0,
by conv_lhs { rw eq_C_of_degree_eq_zero (is_unit_iff_degree_eq_zero.1 hu) };
simp [leading_coeff, nat_degree_eq_of_degree_eq_some (is_unit_iff_degree_eq_zero.1 hu)]⟩)
(λ f p hf0 hp ih hfs,
have hpf0 : p * f ≠ 0, from mul_ne_zero hp.ne_zero hf0,
let ⟨s, hs⟩ := ih (splits_of_splits_mul _ hpf0 hfs).2 in
⟨-(p * norm_unit p).coeff 0 ::ₘ s,
have hp1 : degree p = 1, from hfs.resolve_left hpf0 hp (by simp),
begin
rw [multiset.map_cons, multiset.prod_cons, leading_coeff_mul, C_mul, mul_assoc,
mul_left_comm (C f.leading_coeff), ← hs, ← mul_assoc, mul_left_inj' hf0],
conv_lhs {rw eq_X_add_C_of_degree_eq_one hp1},
simp only [mul_add, coe_norm_unit_of_ne_zero hp.ne_zero, mul_comm p, coeff_neg,
C_neg, sub_eq_add_neg, neg_neg, coeff_C_mul, (mul_assoc _ _ _).symm, C_mul.symm,
mul_inv_cancel (show p.leading_coeff ≠ 0, from mt leading_coeff_eq_zero.1
hp.ne_zero), one_mul],
end⟩)
/-- Pick a root of a polynomial that splits. -/
def root_of_splits {f : polynomial K} (hf : f.splits i) (hfd : f.degree ≠ 0) : L :=
classical.some $ exists_root_of_splits i hf hfd
theorem map_root_of_splits {f : polynomial K} (hf : f.splits i) (hfd) :
f.eval₂ i (root_of_splits i hf hfd) = 0 :=
classical.some_spec $ exists_root_of_splits i hf hfd
theorem roots_map {f : polynomial K} (hf : f.splits $ ring_hom.id K) :
(f.map i).roots = (f.roots).map i :=
if hf0 : f = 0 then by rw [hf0, map_zero, roots_zero, roots_zero, multiset.map_zero] else
have hmf0 : f.map i ≠ 0 := map_ne_zero hf0,
let ⟨m, hm⟩ := exists_multiset_of_splits _ hf in
have h1 : (0 : polynomial K) ∉ m.map (λ r, X - C r),
from zero_nmem_multiset_map_X_sub_C _ _,
have h2 : (0 : polynomial L) ∉ m.map (λ r, X - C (i r)),
from zero_nmem_multiset_map_X_sub_C _ _,
begin
rw map_id at hm, rw hm at hf0 hmf0 ⊢, rw map_mul at hmf0 ⊢,
rw [roots_mul hf0, roots_mul hmf0, map_C, roots_C, zero_add, roots_C, zero_add,
map_multiset_prod, multiset.map_map], simp_rw [(∘), map_sub, map_X, map_C],
rw [roots_multiset_prod _ h2, multiset.bind_map,
roots_multiset_prod _ h1, multiset.bind_map],
simp_rw roots_X_sub_C,
rw [multiset.bind_singleton, multiset.bind_singleton, multiset.map_id']
end
lemma eq_prod_roots_of_splits {p : polynomial K} {i : K →+* L}
(hsplit : splits i p) :
p.map i = C (i p.leading_coeff) * ((p.map i).roots.map (λ a, X - C a)).prod :=
begin
by_cases p_eq_zero : p = 0,
{ rw [p_eq_zero, map_zero, leading_coeff_zero, i.map_zero, C.map_zero, zero_mul] },
obtain ⟨s, hs⟩ := exists_multiset_of_splits i hsplit,
have map_ne_zero : p.map i ≠ 0 := map_ne_zero (p_eq_zero),
have prod_ne_zero : C (i p.leading_coeff) * (multiset.map (λ a, X - C a) s).prod ≠ 0 :=
by rwa hs at map_ne_zero,
have zero_nmem : (0 : polynomial L) ∉ s.map (λ a, X - C a),
from zero_nmem_multiset_map_X_sub_C _ _,
have map_bind_roots_eq : (s.map (λ a, X - C a)).bind (λ a, a.roots) = s,
{ refine multiset.induction_on s (by rw [multiset.map_zero, multiset.zero_bind]) _,
intros a s ih,
rw [multiset.map_cons, multiset.cons_bind, ih, roots_X_sub_C, multiset.singleton_add] },
rw [hs, roots_mul prod_ne_zero, roots_C, zero_add,
roots_multiset_prod _ zero_nmem,
map_bind_roots_eq]
end
lemma eq_prod_roots_of_splits_id {p : polynomial K}
(hsplit : splits (ring_hom.id K) p) :
p = C (p.leading_coeff) * (p.roots.map (λ a, X - C a)).prod :=
by simpa using eq_prod_roots_of_splits hsplit
lemma eq_prod_roots_of_monic_of_splits_id {p : polynomial K}
(m : monic p) (hsplit : splits (ring_hom.id K) p) :
p = (p.roots.map (λ a, X - C a)).prod :=
begin
convert eq_prod_roots_of_splits_id hsplit,
simp [m],
end
lemma eq_X_sub_C_of_splits_of_single_root {x : K} {h : polynomial K} (h_splits : splits i h)
(h_roots : (h.map i).roots = {i x}) : h = (C (leading_coeff h)) * (X - C x) :=
begin
apply polynomial.map_injective _ i.injective,
rw [eq_prod_roots_of_splits h_splits, h_roots],
simp,
end
lemma nat_degree_eq_card_roots {p : polynomial K} {i : K →+* L}
(hsplit : splits i p) : p.nat_degree = (p.map i).roots.card :=
begin
by_cases p_eq_zero : p = 0,
{ rw [p_eq_zero, nat_degree_zero, map_zero, roots_zero, multiset.card_zero] },
have map_ne_zero : p.map i ≠ 0 := map_ne_zero (p_eq_zero),
rw eq_prod_roots_of_splits hsplit at map_ne_zero,
conv_lhs { rw [← nat_degree_map i, eq_prod_roots_of_splits hsplit] },
have : (0 : polynomial L) ∉ (map i p).roots.map (λ a, X - C a),
from zero_nmem_multiset_map_X_sub_C _ _,
simp [nat_degree_mul (left_ne_zero_of_mul map_ne_zero) (right_ne_zero_of_mul map_ne_zero),
nat_degree_multiset_prod _ this]
end
lemma degree_eq_card_roots {p : polynomial K} {i : K →+* L} (p_ne_zero : p ≠ 0)
(hsplit : splits i p) : p.degree = (p.map i).roots.card :=
by rw [degree_eq_nat_degree p_ne_zero, nat_degree_eq_card_roots hsplit]
section UFD
local attribute [instance, priority 10] principal_ideal_ring.to_unique_factorization_monoid
local infix ` ~ᵤ ` : 50 := associated
open unique_factorization_monoid associates
lemma splits_of_exists_multiset {f : polynomial K} {s : multiset L}
(hs : f.map i = C (i f.leading_coeff) * (s.map (λ a : L, (X : polynomial L) - C a)).prod) :
splits i f :=
if hf0 : f = 0 then or.inl hf0
else
or.inr $ λ p hp hdp,
have ht : multiset.rel associated
(factors (f.map i)) (s.map (λ a : L, (X : polynomial L) - C a)) :=
factors_unique
(λ p hp, irreducible_of_factor _ hp)
(λ p' m, begin
obtain ⟨a,m,rfl⟩ := multiset.mem_map.1 m,
exact irreducible_of_degree_eq_one (degree_X_sub_C _),
end)
(associated.symm $ calc _ ~ᵤ f.map i :
⟨(units.map C.to_monoid_hom : units L →* units (polynomial L))
(units.mk0 (f.map i).leading_coeff
(mt leading_coeff_eq_zero.1 (map_ne_zero hf0))),
by conv_rhs { rw [hs, ← leading_coeff_map i, mul_comm] }; refl⟩
... ~ᵤ _ : associated.symm (unique_factorization_monoid.factors_prod (by simpa using hf0))),
let ⟨q, hq, hpq⟩ := exists_mem_factors_of_dvd (by simpa) hp hdp in
let ⟨q', hq', hqq'⟩ := multiset.exists_mem_of_rel_of_mem ht hq in
let ⟨a, ha⟩ := multiset.mem_map.1 hq' in
by rw [← degree_X_sub_C a, ha.2];
exact degree_eq_degree_of_associated (hpq.trans hqq')
lemma splits_of_splits_id {f : polynomial K} : splits (ring_hom.id _) f → splits i f :=
unique_factorization_monoid.induction_on_prime f (λ _, splits_zero _)
(λ _ hu _, splits_of_degree_le_one _
((is_unit_iff_degree_eq_zero.1 hu).symm ▸ dec_trivial))
(λ a p ha0 hp ih hfi, splits_mul _
(splits_of_degree_eq_one _
((splits_of_splits_mul _ (mul_ne_zero hp.1 ha0) hfi).1.resolve_left
hp.1 hp.irreducible (by rw map_id)))
(ih (splits_of_splits_mul _ (mul_ne_zero hp.1 ha0) hfi).2))
end UFD
lemma splits_iff_exists_multiset {f : polynomial K} : splits i f ↔
∃ (s : multiset L), f.map i = C (i f.leading_coeff) *
(s.map (λ a : L, (X : polynomial L) - C a)).prod :=
⟨exists_multiset_of_splits i, λ ⟨s, hs⟩, splits_of_exists_multiset i hs⟩
lemma splits_comp_of_splits (j : L →+* F) {f : polynomial K}
(h : splits i f) : splits (j.comp i) f :=
begin
change i with ((ring_hom.id _).comp i) at h,
rw [← splits_map_iff],
rw [← splits_map_iff i] at h,
exact splits_of_splits_id _ h
end
/-- A monic polynomial `p` that has as many roots as its degree
can be written `p = ∏(X - a)`, for `a` in `p.roots`. -/
lemma prod_multiset_X_sub_C_of_monic_of_roots_card_eq {p : polynomial K}
(hmonic : p.monic) (hroots : p.roots.card = p.nat_degree) :
(multiset.map (λ (a : K), X - C a) p.roots).prod = p :=
begin
have hprodmonic : (multiset.map (λ (a : K), X - C a) p.roots).prod.monic,
{ simp only [prod_multiset_root_eq_finset_root (ne_zero_of_monic hmonic),
monic_prod_of_monic, monic_X_sub_C, monic_pow, forall_true_iff] },
have hdegree : (multiset.map (λ (a : K), X - C a) p.roots).prod.nat_degree = p.nat_degree,
{ rw [← hroots, nat_degree_multiset_prod _ (zero_nmem_multiset_map_X_sub_C _ (λ a : K, a))],
simp only [eq_self_iff_true, mul_one, nat.cast_id, nsmul_eq_mul, multiset.sum_repeat,
multiset.map_const,nat_degree_X_sub_C, function.comp, multiset.map_map] },
obtain ⟨q, hq⟩ := prod_multiset_X_sub_C_dvd p,
have qzero : q ≠ 0,
{ rintro rfl, apply hmonic.ne_zero, simpa only [mul_zero] using hq },
have degp :
p.nat_degree = (multiset.map (λ (a : K), X - C a) p.roots).prod.nat_degree + q.nat_degree,
{ nth_rewrite 0 [hq],
simp only [nat_degree_mul (ne_zero_of_monic hprodmonic) qzero] },
have degq : q.nat_degree = 0,
{ rw hdegree at degp,
exact (add_right_inj p.nat_degree).mp (tactic.ring_exp.add_pf_sum_z degp rfl).symm },
obtain ⟨u, hu⟩ := is_unit_iff_degree_eq_zero.2 ((degree_eq_iff_nat_degree_eq qzero).2 degq),
have hassoc : associated (multiset.map (λ (a : K), X - C a) p.roots).prod p,
{ rw associated, use u, rw [hu, ← hq] },
exact eq_of_monic_of_associated hprodmonic hmonic hassoc
end
/-- A polynomial `p` that has as many roots as its degree
can be written `p = p.leading_coeff * ∏(X - a)`, for `a` in `p.roots`. -/
lemma C_leading_coeff_mul_prod_multiset_X_sub_C {p : polynomial K}
(hroots : p.roots.card = p.nat_degree) :
(C p.leading_coeff) * (multiset.map (λ (a : K), X - C a) p.roots).prod = p :=
begin
by_cases hzero : p = 0,
{ rw [hzero, leading_coeff_zero, ring_hom.map_zero, zero_mul], },
{ have hcoeff : p.leading_coeff ≠ 0,
{ intro h, exact hzero (leading_coeff_eq_zero.1 h) },
have hrootsnorm : (normalize p).roots.card = (normalize p).nat_degree,
{ rw [roots_normalize, normalize_apply, nat_degree_mul hzero (units.ne_zero _), hroots,
coe_norm_unit, nat_degree_C, add_zero], },
have hprod := prod_multiset_X_sub_C_of_monic_of_roots_card_eq (monic_normalize hzero)
hrootsnorm,
rw [roots_normalize, normalize_apply, coe_norm_unit_of_ne_zero hzero] at hprod,
calc (C p.leading_coeff) * (multiset.map (λ (a : K), X - C a) p.roots).prod
= p * C ((p.leading_coeff)⁻¹ * p.leading_coeff) :
by rw [hprod, mul_comm, mul_assoc, ← C_mul]
... = p * C 1 : by field_simp
... = p : by simp only [mul_one, ring_hom.map_one], },
end
/-- A polynomial splits if and only if it has as many roots as its degree. -/
lemma splits_iff_card_roots {p : polynomial K} :
splits (ring_hom.id K) p ↔ p.roots.card = p.nat_degree :=
begin
split,
{ intro H, rw [nat_degree_eq_card_roots H, map_id] },
{ intro hroots,
apply (splits_iff_exists_multiset (ring_hom.id K)).2,
use p.roots,
simp only [ring_hom.id_apply, map_id],
exact (C_leading_coeff_mul_prod_multiset_X_sub_C hroots).symm },
end
end splits
end polynomial
section embeddings
variables (F) [field F]
/-- If `p` is the minimal polynomial of `a` over `F` then `F[a] ≃ₐ[F] F[x]/(p)` -/
def alg_equiv.adjoin_singleton_equiv_adjoin_root_minpoly
{R : Type*} [comm_ring R] [algebra F R] (x : R) :
algebra.adjoin F ({x} : set R) ≃ₐ[F] adjoin_root (minpoly F x) :=
alg_equiv.symm $ alg_equiv.of_bijective
(alg_hom.cod_restrict
(adjoin_root.lift_hom _ x $ minpoly.aeval F x) _
(λ p, adjoin_root.induction_on _ p $ λ p,
(algebra.adjoin_singleton_eq_range F x).symm ▸ (polynomial.aeval _).mem_range.mpr ⟨p, rfl⟩))
⟨(alg_hom.injective_cod_restrict _ _ _).2 $ (alg_hom.injective_iff _).2 $ λ p,
adjoin_root.induction_on _ p $ λ p hp, ideal.quotient.eq_zero_iff_mem.2 $
ideal.mem_span_singleton.2 $ minpoly.dvd F x hp,
λ y,
let ⟨p, hp⟩ := (set_like.ext_iff.1 (algebra.adjoin_singleton_eq_range F x) (y : R)).1 y.2 in
⟨adjoin_root.mk _ p, subtype.eq hp⟩⟩
open finset
/-- If a `subalgebra` is finite_dimensional as a submodule then it is `finite_dimensional`. -/
lemma finite_dimensional.of_subalgebra_to_submodule
{K V : Type*} [field K] [ring V] [algebra K V] {s : subalgebra K V}
(h : finite_dimensional K s.to_submodule) : finite_dimensional K s := h
/-- If `K` and `L` are field extensions of `F` and we have `s : finset K` such that
the minimal polynomial of each `x ∈ s` splits in `L` then `algebra.adjoin F s` embeds in `L`. -/
theorem lift_of_splits {F K L : Type*} [field F] [field K] [field L]
[algebra F K] [algebra F L] (s : finset K) :
(∀ x ∈ s, is_integral F x ∧ polynomial.splits (algebra_map F L) (minpoly F x)) →
nonempty (algebra.adjoin F (↑s : set K) →ₐ[F] L) :=
begin
refine finset.induction_on s (λ H, _) (λ a s has ih H, _),
{ rw [coe_empty, algebra.adjoin_empty],
exact ⟨(algebra.of_id F L).comp (algebra.bot_equiv F K)⟩ },
rw forall_mem_insert at H, rcases H with ⟨⟨H1, H2⟩, H3⟩, cases ih H3 with f,
choose H3 H4 using H3,
rw [coe_insert, set.insert_eq, set.union_comm, algebra.adjoin_union_eq_under],
letI := (f : algebra.adjoin F (↑s : set K) →+* L).to_algebra,
haveI : finite_dimensional F (algebra.adjoin F (↑s : set K)) := (
(submodule.fg_iff_finite_dimensional _).1
(fg_adjoin_of_finite (set.finite_mem_finset s) H3)).of_subalgebra_to_submodule,
letI := field_of_finite_dimensional F (algebra.adjoin F (↑s : set K)),
have H5 : is_integral (algebra.adjoin F (↑s : set K)) a := is_integral_of_is_scalar_tower a H1,
have H6 : (minpoly (algebra.adjoin F (↑s : set K)) a).splits
(algebra_map (algebra.adjoin F (↑s : set K)) L),
{ refine polynomial.splits_of_splits_of_dvd _
(polynomial.map_ne_zero $ minpoly.ne_zero H1 :
polynomial.map (algebra_map _ _) _ ≠ 0)
((polynomial.splits_map_iff _ _).2 _)
(minpoly.dvd _ _ _),
{ rw ← is_scalar_tower.algebra_map_eq, exact H2 },
{ rw [← is_scalar_tower.aeval_apply, minpoly.aeval] } },
obtain ⟨y, hy⟩ := polynomial.exists_root_of_splits _ H6 (ne_of_lt (minpoly.degree_pos H5)).symm,
refine ⟨subalgebra.of_under _ _ _⟩,
refine (adjoin_root.lift_hom (minpoly (algebra.adjoin F (↑s : set K)) a) y hy).comp _,
exact alg_equiv.adjoin_singleton_equiv_adjoin_root_minpoly (algebra.adjoin F (↑s : set K)) a
end
end embeddings
namespace polynomial
variables [field K] [field L] [field F]
open polynomial
section splitting_field
/-- Non-computably choose an irreducible factor from a polynomial. -/
def factor (f : polynomial K) : polynomial K :=
if H : ∃ g, irreducible g ∧ g ∣ f then classical.some H else X
instance irreducible_factor (f : polynomial K) : irreducible (factor f) :=
begin
rw factor, split_ifs with H, { exact (classical.some_spec H).1 }, { exact irreducible_X }
end
theorem factor_dvd_of_not_is_unit {f : polynomial K} (hf1 : ¬is_unit f) : factor f ∣ f :=
begin
by_cases hf2 : f = 0, { rw hf2, exact dvd_zero _ },
rw [factor, dif_pos (wf_dvd_monoid.exists_irreducible_factor hf1 hf2)],
exact (classical.some_spec $ wf_dvd_monoid.exists_irreducible_factor hf1 hf2).2
end
theorem factor_dvd_of_degree_ne_zero {f : polynomial K} (hf : f.degree ≠ 0) : factor f ∣ f :=
factor_dvd_of_not_is_unit (mt degree_eq_zero_of_is_unit hf)
theorem factor_dvd_of_nat_degree_ne_zero {f : polynomial K} (hf : f.nat_degree ≠ 0) :
factor f ∣ f :=
factor_dvd_of_degree_ne_zero (mt nat_degree_eq_of_degree_eq_some hf)
/-- Divide a polynomial f by X - C r where r is a root of f in a bigger field extension. -/
def remove_factor (f : polynomial K) : polynomial (adjoin_root $ factor f) :=
map (adjoin_root.of f.factor) f /ₘ (X - C (adjoin_root.root f.factor))
theorem X_sub_C_mul_remove_factor (f : polynomial K) (hf : f.nat_degree ≠ 0) :
(X - C (adjoin_root.root f.factor)) * f.remove_factor = map (adjoin_root.of f.factor) f :=
let ⟨g, hg⟩ := factor_dvd_of_nat_degree_ne_zero hf in
mul_div_by_monic_eq_iff_is_root.2 $ by rw [is_root.def, eval_map, hg, eval₂_mul, ← hg,
adjoin_root.eval₂_root, zero_mul]
theorem nat_degree_remove_factor (f : polynomial K) :
f.remove_factor.nat_degree = f.nat_degree - 1 :=
by rw [remove_factor, nat_degree_div_by_monic _ (monic_X_sub_C _), nat_degree_map,
nat_degree_X_sub_C]
theorem nat_degree_remove_factor' {f : polynomial K} {n : ℕ} (hfn : f.nat_degree = n+1) :
f.remove_factor.nat_degree = n :=
by rw [nat_degree_remove_factor, hfn, n.add_sub_cancel]
/-- Auxiliary construction to a splitting field of a polynomial. Uses induction on the degree. -/
def splitting_field_aux (n : ℕ) : Π {K : Type u} [field K], by exactI Π (f : polynomial K),
f.nat_degree = n → Type u :=
nat.rec_on n (λ K _ _ _, K) $ λ n ih K _ f hf, by exactI
ih f.remove_factor (nat_degree_remove_factor' hf)
namespace splitting_field_aux
theorem succ (n : ℕ) (f : polynomial K) (hfn : f.nat_degree = n + 1) :
splitting_field_aux (n+1) f hfn =
splitting_field_aux n f.remove_factor (nat_degree_remove_factor' hfn) := rfl
instance field (n : ℕ) : Π {K : Type u} [field K], by exactI
Π {f : polynomial K} (hfn : f.nat_degree = n), field (splitting_field_aux n f hfn) :=
nat.rec_on n (λ K _ _ _, ‹field K›) $ λ n ih K _ f hf, ih _
instance inhabited {n : ℕ} {f : polynomial K} (hfn : f.nat_degree = n) :
inhabited (splitting_field_aux n f hfn) := ⟨37⟩
instance algebra (n : ℕ) : Π {K : Type u} [field K], by exactI
Π {f : polynomial K} (hfn : f.nat_degree = n), algebra K (splitting_field_aux n f hfn) :=
nat.rec_on n (λ K _ _ _, by exactI algebra.id K) $ λ n ih K _ f hfn,
by exactI @@restrict_scalars.algebra _ _ _ _ _ (ih _) _ _
instance algebra' {n : ℕ} {f : polynomial K} (hfn : f.nat_degree = n + 1) :
algebra (adjoin_root f.factor) (splitting_field_aux _ _ hfn) :=
splitting_field_aux.algebra n _
instance algebra'' {n : ℕ} {f : polynomial K} (hfn : f.nat_degree = n + 1) :
algebra K (splitting_field_aux n f.remove_factor (nat_degree_remove_factor' hfn)) :=
splitting_field_aux.algebra (n+1) hfn
instance algebra''' {n : ℕ} {f : polynomial K} (hfn : f.nat_degree = n + 1) :
algebra (adjoin_root f.factor)
(splitting_field_aux n f.remove_factor (nat_degree_remove_factor' hfn)) :=
splitting_field_aux.algebra n _
instance scalar_tower {n : ℕ} {f : polynomial K} (hfn : f.nat_degree = n + 1) :
is_scalar_tower K (adjoin_root f.factor) (splitting_field_aux _ _ hfn) :=
is_scalar_tower.of_algebra_map_eq $ λ x, rfl
instance scalar_tower' {n : ℕ} {f : polynomial K} (hfn : f.nat_degree = n + 1) :
is_scalar_tower K (adjoin_root f.factor)
(splitting_field_aux n f.remove_factor (nat_degree_remove_factor' hfn)) :=
is_scalar_tower.of_algebra_map_eq $ λ x, rfl
theorem algebra_map_succ (n : ℕ) (f : polynomial K) (hfn : f.nat_degree = n + 1) :
by exact algebra_map K (splitting_field_aux _ _ hfn) =
(algebra_map (adjoin_root f.factor)
(splitting_field_aux n f.remove_factor (nat_degree_remove_factor' hfn))).comp
(adjoin_root.of f.factor) :=
rfl
protected theorem splits (n : ℕ) : ∀ {K : Type u} [field K], by exactI
∀ (f : polynomial K) (hfn : f.nat_degree = n),
splits (algebra_map K $ splitting_field_aux n f hfn) f :=
nat.rec_on n (λ K _ _ hf, by exactI splits_of_degree_le_one _
(le_trans degree_le_nat_degree $ hf.symm ▸ with_bot.coe_le_coe.2 zero_le_one)) $ λ n ih K _ f hf,
by { resetI, rw [← splits_id_iff_splits, algebra_map_succ, ← map_map, splits_id_iff_splits,
← X_sub_C_mul_remove_factor f (λ h, by { rw h at hf, cases hf })],
exact splits_mul _ (splits_X_sub_C _) (ih _ _) }
theorem exists_lift (n : ℕ) : ∀ {K : Type u} [field K], by exactI
∀ (f : polynomial K) (hfn : f.nat_degree = n) {L : Type*} [field L], by exactI
∀ (j : K →+* L) (hf : splits j f), ∃ k : splitting_field_aux n f hfn →+* L,
k.comp (algebra_map _ _) = j :=
nat.rec_on n (λ K _ _ _ L _ j _, by exactI ⟨j, j.comp_id⟩) $ λ n ih K _ f hf L _ j hj, by exactI
have hndf : f.nat_degree ≠ 0, by { intro h, rw h at hf, cases hf },
have hfn0 : f ≠ 0, by { intro h, rw h at hndf, exact hndf rfl },
let ⟨r, hr⟩ := exists_root_of_splits _ (splits_of_splits_of_dvd j hfn0 hj
(factor_dvd_of_nat_degree_ne_zero hndf))
(mt is_unit_iff_degree_eq_zero.2 f.irreducible_factor.1) in
have hmf0 : map (adjoin_root.of f.factor) f ≠ 0, from map_ne_zero hfn0,
have hsf : splits (adjoin_root.lift j r hr) f.remove_factor,
by { rw ← X_sub_C_mul_remove_factor _ hndf at hmf0, refine (splits_of_splits_mul _ hmf0 _).2,
rwa [X_sub_C_mul_remove_factor _ hndf, ← splits_id_iff_splits, map_map, adjoin_root.lift_comp_of,
splits_id_iff_splits] },
let ⟨k, hk⟩ := ih f.remove_factor (nat_degree_remove_factor' hf) (adjoin_root.lift j r hr) hsf in
⟨k, by rw [algebra_map_succ, ← ring_hom.comp_assoc, hk, adjoin_root.lift_comp_of]⟩
theorem adjoin_roots (n : ℕ) : ∀ {K : Type u} [field K], by exactI
∀ (f : polynomial K) (hfn : f.nat_degree = n),
algebra.adjoin K (↑(f.map $ algebra_map K $ splitting_field_aux n f hfn).roots.to_finset :
set (splitting_field_aux n f hfn)) = ⊤ :=
nat.rec_on n (λ K _ f hf, by exactI algebra.eq_top_iff.2 (λ x, subalgebra.range_le _ ⟨x, rfl⟩)) $
λ n ih K _ f hfn, by exactI
have hndf : f.nat_degree ≠ 0, by { intro h, rw h at hfn, cases hfn },
have hfn0 : f ≠ 0, by { intro h, rw h at hndf, exact hndf rfl },
have hmf0 : map (algebra_map K (splitting_field_aux n.succ f hfn)) f ≠ 0 := map_ne_zero hfn0,
by { rw [algebra_map_succ, ← map_map, ← X_sub_C_mul_remove_factor _ hndf, map_mul] at hmf0 ⊢,
rw [roots_mul hmf0, map_sub, map_X, map_C, roots_X_sub_C, multiset.to_finset_add, finset.coe_union,
multiset.to_finset_singleton, finset.coe_singleton,
algebra.adjoin_union_eq_under, ← set.image_singleton,
algebra.adjoin_algebra_map K (adjoin_root f.factor)
(splitting_field_aux n f.remove_factor (nat_degree_remove_factor' hfn)),
adjoin_root.adjoin_root_eq_top, algebra.map_top,
is_scalar_tower.range_under_adjoin K (adjoin_root f.factor)
(splitting_field_aux n f.remove_factor (nat_degree_remove_factor' hfn)),
ih, subalgebra.res_top] }
end splitting_field_aux
/-- A splitting field of a polynomial. -/
def splitting_field (f : polynomial K) :=
splitting_field_aux _ f rfl
namespace splitting_field
variables (f : polynomial K)
instance : field (splitting_field f) :=
splitting_field_aux.field _ _
instance inhabited : inhabited (splitting_field f) := ⟨37⟩
instance : algebra K (splitting_field f) :=
splitting_field_aux.algebra _ _
protected theorem splits : splits (algebra_map K (splitting_field f)) f :=
splitting_field_aux.splits _ _ _
variables [algebra K L] (hb : splits (algebra_map K L) f)
/-- Embeds the splitting field into any other field that splits the polynomial. -/
def lift : splitting_field f →ₐ[K] L :=
{ commutes' := λ r, by { have := classical.some_spec (splitting_field_aux.exists_lift _ _ _ _ hb),
exact ring_hom.ext_iff.1 this r },
.. classical.some (splitting_field_aux.exists_lift _ _ _ _ hb) }
theorem adjoin_roots : algebra.adjoin K
(↑(f.map (algebra_map K $ splitting_field f)).roots.to_finset : set (splitting_field f)) = ⊤ :=
splitting_field_aux.adjoin_roots _ _ _
theorem adjoin_root_set : algebra.adjoin K (f.root_set f.splitting_field) = ⊤ :=
adjoin_roots f
end splitting_field
variables (K L) [algebra K L]
/-- Typeclass characterising splitting fields. -/
class is_splitting_field (f : polynomial K) : Prop :=
(splits [] : splits (algebra_map K L) f)
(adjoin_roots [] : algebra.adjoin K (↑(f.map (algebra_map K L)).roots.to_finset : set L) = ⊤)
namespace is_splitting_field
variables {K}
instance splitting_field (f : polynomial K) : is_splitting_field K (splitting_field f) f :=
⟨splitting_field.splits f, splitting_field.adjoin_roots f⟩
section scalar_tower
variables {K L F} [algebra F K] [algebra F L] [is_scalar_tower F K L]
variables {K}
instance map (f : polynomial F) [is_splitting_field F L f] :
is_splitting_field K L (f.map $ algebra_map F K) :=
⟨by { rw [splits_map_iff, ← is_scalar_tower.algebra_map_eq], exact splits L f },
subalgebra.res_inj F $ by { rw [map_map, ← is_scalar_tower.algebra_map_eq, subalgebra.res_top,
eq_top_iff, ← adjoin_roots L f, algebra.adjoin_le_iff],
exact λ x hx, @algebra.subset_adjoin K _ _ _ _ _ _ hx }⟩
variables {K} (L)
theorem splits_iff (f : polynomial K) [is_splitting_field K L f] :
polynomial.splits (ring_hom.id K) f ↔ (⊤ : subalgebra K L) = ⊥ :=
⟨λ h, eq_bot_iff.2 $ adjoin_roots L f ▸ (roots_map (algebra_map K L) h).symm ▸
algebra.adjoin_le_iff.2 (λ y hy,
let ⟨x, hxs, hxy⟩ := finset.mem_image.1 (by rwa multiset.to_finset_map at hy) in
hxy ▸ set_like.mem_coe.2 $ subalgebra.algebra_map_mem _ _),
λ h, @ring_equiv.to_ring_hom_refl K _ ▸
ring_equiv.trans_symm (ring_equiv.of_bijective _ $ algebra.bijective_algebra_map_iff.2 h) ▸
by { rw ring_equiv.to_ring_hom_trans, exact splits_comp_of_splits _ _ (splits L f) }⟩
theorem mul (f g : polynomial F) (hf : f ≠ 0) (hg : g ≠ 0) [is_splitting_field F K f]
[is_splitting_field K L (g.map $ algebra_map F K)] :
is_splitting_field F L (f * g) :=
⟨(is_scalar_tower.algebra_map_eq F K L).symm ▸ splits_mul _
(splits_comp_of_splits _ _ (splits K f))
((splits_map_iff _ _).1 (splits L $ g.map $ algebra_map F K)),
by rw [map_mul, roots_mul (mul_ne_zero (map_ne_zero hf : f.map (algebra_map F L) ≠ 0)
(map_ne_zero hg)), multiset.to_finset_add, finset.coe_union, algebra.adjoin_union_eq_under,
is_scalar_tower.algebra_map_eq F K L, ← map_map,
roots_map (algebra_map K L) ((splits_id_iff_splits $ algebra_map F K).2 $ splits K f),
multiset.to_finset_map, finset.coe_image, algebra.adjoin_algebra_map, adjoin_roots,
algebra.map_top, is_scalar_tower.range_under_adjoin, ← map_map, adjoin_roots,
subalgebra.res_top]⟩
end scalar_tower
/-- Splitting field of `f` embeds into any field that splits `f`. -/
def lift [algebra K F] (f : polynomial K) [is_splitting_field K L f]
(hf : polynomial.splits (algebra_map K F) f) : L →ₐ[K] F :=
if hf0 : f = 0 then (algebra.of_id K F).comp $
(algebra.bot_equiv K L : (⊥ : subalgebra K L) →ₐ[K] K).comp $
by { rw ← (splits_iff L f).1 (show f.splits (ring_hom.id K), from hf0.symm ▸ splits_zero _),
exact algebra.to_top } else
alg_hom.comp (by { rw ← adjoin_roots L f, exact classical.choice (lift_of_splits _ $ λ y hy,
have aeval y f = 0, from (eval₂_eq_eval_map _).trans $
(mem_roots $ by exact map_ne_zero hf0).1 (multiset.mem_to_finset.mp hy),
⟨(is_algebraic_iff_is_integral _).1 ⟨f, hf0, this⟩,
splits_of_splits_of_dvd _ hf0 hf $ minpoly.dvd _ _ this⟩) })
algebra.to_top
theorem finite_dimensional (f : polynomial K) [is_splitting_field K L f] : finite_dimensional K L :=
is_noetherian.iff_fg.2 ⟨@algebra.top_to_submodule K L _ _ _ ▸ adjoin_roots L f ▸
fg_adjoin_of_finite (set.finite_mem_finset _) (λ y hy,
if hf : f = 0
then by { rw [hf, map_zero, roots_zero] at hy, cases hy }
else (is_algebraic_iff_is_integral _).1 ⟨f, hf, (eval₂_eq_eval_map _).trans $
(mem_roots $ by exact map_ne_zero hf).1 (multiset.mem_to_finset.mp hy)⟩)⟩
instance (f : polynomial K) : _root_.finite_dimensional K f.splitting_field :=
finite_dimensional f.splitting_field f
/-- Any splitting field is isomorphic to `splitting_field f`. -/
def alg_equiv (f : polynomial K) [is_splitting_field K L f] : L ≃ₐ[K] splitting_field f :=
begin
refine alg_equiv.of_bijective (lift L f $ splits (splitting_field f) f)
⟨ring_hom.injective (lift L f $ splits (splitting_field f) f).to_ring_hom, _⟩,
haveI := finite_dimensional (splitting_field f) f,
haveI := finite_dimensional L f,
have : finite_dimensional.finrank K L = finite_dimensional.finrank K (splitting_field f) :=
le_antisymm
(linear_map.finrank_le_finrank_of_injective
(show function.injective (lift L f $ splits (splitting_field f) f).to_linear_map, from
ring_hom.injective (lift L f $ splits (splitting_field f) f : L →+* f.splitting_field)))
(linear_map.finrank_le_finrank_of_injective
(show function.injective (lift (splitting_field f) f $ splits L f).to_linear_map, from
ring_hom.injective (lift (splitting_field f) f $ splits L f : f.splitting_field →+* L))),
change function.surjective (lift L f $ splits (splitting_field f) f).to_linear_map,
refine (linear_map.injective_iff_surjective_of_finrank_eq_finrank this).1 _,
exact ring_hom.injective (lift L f $ splits (splitting_field f) f : L →+* f.splitting_field)
end
end is_splitting_field
end splitting_field
end polynomial
|
9a400c2662b2ac1fd44a95b1712cbb9f4a95fef3 | a76f677b87d42a9470ba3a0a78cfddd3063118e6 | /src/congruence/Elements.lean | c9d5e6f3de80f52106d65c35b9fca335414f4e35 | [] | no_license | Ja1941/hilberts-axioms | 50219c732ad5fa167408432e8c8baae259777a40 | 5b653a92e448b77da41c9893066b641bc4e6b316 | refs/heads/master | 1,693,238,884,856 | 1,635,702,120,000 | 1,635,702,120,000 | 385,546,384 | 9 | 1 | null | null | null | null | UTF-8 | Lean | false | false | 41,405 | lean | /-
Copyright (c) 2021 Tianchen Zhao. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Tianchen Zhao
-/
import congruence.basic
import congruence.seg_lt
import congruence.ang_lt
import congruence.perpendicular
/-!
# Euclid's Elements
This file proves most propositions in Euclid's book I with some exceptions. For
instance, intersection of two circles is not guaranteed by Hilbert's axioms. Also
note that some proofs are different from Euclid's ones to fit Hilbert's axioms.
Some propositions need reintepretation. For example, the propositions on ruler
and compass contructions are understood to be existence proof.
## References
* See [Geometry: Euclid and Beyond]
-/
open incidence_geometry incidence_order_geometry hilbert_plane
variables [C : hilbert_plane]
include C
/--I.5 in Elements -/
theorem isosceles {a b c : pts} (habc : noncol a b c) :
((a-ₛb) ≅ₛ (a-ₛc)) → ((∠ a b c) ≅ₐ (∠ a c b)) :=
begin
intro habac,
have hab := (noncol_neq habc).1,
have hac := (noncol_neq habc).2.1,
cases between_extend hab with d habd,
cases between_extend hac with x hacx,
have hbd := (between_neq habd).2.2,
rcases extend_congr_seg (seg_proper_iff_neq.2 hbd)
(between_neq hacx).2.2 with ⟨e, hcxe, hbdce, -⟩,
have hace := between_same_side_pt_between hacx hcxe, clear hcxe hacx x,
have had := (between_neq habd).2.1,
have hae := (between_neq hace).2.1,
have hadc := col_noncol (between_col habd) habc had,
have haeb := col_noncol (between_col hace) (noncol23 habc) hae,
have hadcaeb : ((Δ a d c) ≅ₜ (Δ a e b)),
apply SAS; unfold three_pt_triang; simp,
exact hadc, exact haeb,
exact congr_seg_add habd hace habac hbdce,
exact seg_congr_symm habac,
{ rw [ang_symm, ←ang_eq_same_side_pt c (between_same_side_pt.1 habd).1],
rw [ang_symm, ang_symm e _ _],
rw ang_eq_same_side_pt b (between_same_side_pt.1 hace).1, exact ang_congr_refl _ },
have hce := (between_neq hace).2.2,
have hdbc := col_noncol (col132 (between_col habd))
(noncol12 hadc) hbd.symm,
have hecb := col_noncol (col132 (between_col hace))
(noncol12 haeb) hce.symm,
have hdbcecb : ((Δ d b c) ≅ₜ (Δ e c b)),
apply SAS; unfold three_pt_triang; simp,
exact hdbc, exact hecb,
rw [seg_symm, seg_symm e _], exact hbdce,
exact (tri_congr_seg hadcaeb).2.2,
{ rw [ang_symm, ←ang_eq_same_side_pt c (between_same_side_pt.1 habd).2],
rw [ang_symm _ e _, ←ang_eq_same_side_pt b (between_same_side_pt.1 hace).2],
rw [ang_symm, ang_symm b _ _], exact (tri_congr_ang hadcaeb).1 },
have key := (tri_congr_ang hdbcecb).1,
rw [ang_symm, ang_symm e _ _] at key,
rw [ang_symm, ang_symm a _ _],
apply supplementary_congr _ _ key;
rw three_pt_ang_supplementary,
{ rw between_symm at habd,
exact ⟨habd, noncol13 hdbc, noncol13 habc⟩ },
{ rw between_symm at hace,
exact ⟨hace, noncol13 hecb, noncol123 habc⟩ }
end
/--I.6 in Elements -/
theorem isosceles' {a b c : pts} (habc : noncol a b c) :
((∠ a b c) ≅ₐ (∠ a c b)) → ((a-ₛb) ≅ₛ (a-ₛc)) :=
begin
have : ∀ {a b c : pts}, noncol a b c → ((∠ a b c) ≅ₐ (∠ a c b)) → ¬((a-ₛb) <ₛ (a-ₛc)),
intros a b c habc he hf,
have hab := (noncol_neq habc).1,
have hbc := (noncol_neq habc).2.2,
rw [seg_symm a c, two_pt_seg_lt] at hf,
rcases hf with ⟨d, hcda, habcd⟩,
have hcd := (between_neq hcda).1,
have had := (between_neq hcda).2.2.symm,
have hcdb := col_noncol (col23 (between_col hcda))
(noncol132 habc) hcd,
have : ((Δ b a c) ≅ₜ (Δ c d b)),
apply SAS; unfold three_pt_triang; simp,
exact noncol12 habc, exact hcdb,
rw seg_symm, exact habcd,
rw seg_symm, exact seg_congr_refl _,
{ rw [ang_symm d c b, ang_eq_same_side_pt b (between_same_side_pt.1 hcda).1,
ang_symm b c a], exact he },
have : ((∠ d b c) ≅ₐ (∠ a b c)),
apply ang_congr_trans _ (ang_congr_symm he),
rw [ang_symm, ang_symm a c b],
exact ang_congr_symm (tri_congr_ang this).2.2,
apply (ang_tri (ang_proper_iff_noncol.2 (noncol123 hcdb))
(ang_proper_iff_noncol.2 habc)).2.1,
split,
{ rw [ang_symm a b c, three_pt_ang_lt],
use d, split,
rw inside_three_pt_ang, split,
exact t_shape_seg (noncol123 habc) d hcda,
{ rw between_symm at hcda,
exact t_shape_seg (noncol12 habc) d hcda },
rw ang_symm, exact ang_congr_refl _ },
exact this,
intro he,
have hab := (noncol_neq habc).1,
have hac := (noncol_neq habc).2.1,
rcases (seg_tri (seg_proper_iff_neq.2 hab)
(seg_proper_iff_neq.2 hac)).1 with h | h | h,
exact absurd h (this habc he),
exact h,
exact absurd h (this (noncol23 habc) (ang_congr_symm he))
end
private lemma SSS_case1 {a b c d e : pts} (habc : noncol a b c) (hbadbda : (∠ b a d) ≅ₐ (∠ b d a))
(hcadcda : (∠ c a d) ≅ₐ (∠ c d a)) (hdea : between d e a) (hebc : between e b c) :
∠ b a c ≅ₐ∠ b d c :=
begin
have hda := (between_neq hdea).2.1,
have hae := (between_neq hdea).2.2.symm,
have hce := (between_neq hebc).2.1.symm,
have hbe := (between_neq hebc).1.symm,
have hcae := col_noncol (col13 (between_col hebc)) (noncol13 habc) hce,
have hbea := col_noncol (col123 (between_col hebc)) (noncol123 habc) hbe,
rw [ang_symm, ang_symm b d a] at hbadbda,
rw [ang_symm, ang_symm c d a] at hcadcda,
have hbin : inside_ang b (∠ d a c),
rw [ang_symm, ang_eq_same_side_pt c (between_same_side_pt.1 hdea).2],
rw between_symm at hebc,
exact hypo_inside_ang (noncol23 hcae) hebc,
have hdabc : same_side_line (d-ₗa) b c,
rw two_pt_one_line (line_in_lines hda) (line_in_lines hae) hae (pt_right_in_line d a)
(col_in13 (between_col hdea) hda) (pt_left_in_line a e) (pt_right_in_line a e),
exact same_side_pt_line (between_same_side_pt.1 hebc).1 (line_in_lines hae)
(pt_right_in_line a e) (noncol_in32 hbea) (noncol_in32 hcae),
exact (congr_ang_sub hbin hdabc hda hcadcda hbadbda).2
end
private lemma SSS_case2 {a b c d e : pts} (habc : noncol a b c)
(hcadcda : (∠ c a d) ≅ₐ (∠ c d a)) (hdea : between d e a) (heb : e = b) :
∠ b a c ≅ₐ∠ b d c :=
begin
rw [←heb, ang_symm e d c, ang_eq_same_side_pt c (between_same_side_pt.1 hdea).1, ang_symm,
←ang_eq_same_side_pt c (between_same_side_pt.1 hdea).2],
exact hcadcda
end
private lemma SSS_case3 {a b c d e : pts} (habc : noncol a b c) (hbadbda : (∠ b a d) ≅ₐ (∠ b d a))
(hcadcda : (∠ c a d) ≅ₐ (∠ c d a)) (hdea : between d e a) (hbec : between b e c) :
∠ b a c ≅ₐ∠ b d c :=
begin
have hda := (between_neq hdea).2.1,
have hbe := (between_neq hbec).1,
have hce := (between_neq hbec).2.2.symm,
rw [ang_eq_same_side_pt _ (between_same_side_pt.1 hdea).2] at hbadbda,
rw [ang_symm c d a, ang_eq_same_side_pt c (between_same_side_pt.1 hdea).2,
ang_symm c a e] at hcadcda,
have hbea := col_noncol (col23 (between_col hbec)) (noncol123 habc) hbe,
have hadb := col_noncol (col13 (between_col hdea)) (noncol13 hbea) hda.symm,
have hcea := col_noncol (col132 (between_col hbec)) (noncol13 habc) hce,
have hadc := col_noncol (col13 (between_col hdea)) (noncol13 hcea) hda.symm,
have hdin := hypo_inside_ang (noncol12 habc) hbec,
have hdabc := diff_side_pt_line (between_diff_side_pt.1 hbec) (line_in_lines hda)
(col_in13 (between_col hdea) hda) (noncol_in21 hadb) (noncol_in21 hadc),
exact (congr_ang_add hdin hdabc hda hbadbda hcadcda).2
end
/--I.8 in Elements -/
theorem SSS {ABC DEF : triang} (habc : noncol ABC.v1 ABC.v2 ABC.v3)
(ha'b'c' : noncol DEF.v1 DEF.v2 DEF.v3) (haba'b' : (ABC.v1-ₛABC.v2) ≅ₛ (DEF.v1-ₛDEF.v2))
(haca'c' : (ABC.v1-ₛABC.v3) ≅ₛ (DEF.v1-ₛDEF.v3)) (hbcb'c' : (ABC.v2-ₛABC.v3) ≅ₛ (DEF.v2-ₛDEF.v3)) :
ABC ≅ₜ DEF :=
begin
set a := ABC.v1 with ha, set b := ABC.v2 with hb, set c := ABC.v3 with hc,
set a' := DEF.v1, set b' := DEF.v2, set c' := DEF.v3,
have hab := (noncol_neq habc).1,
have hac := (noncol_neq habc).2.1,
have hbc := (noncol_neq habc).2.2,
have ha'b' := (noncol_neq ha'b'c').1,
rcases extend_congr_ang' (ang_proper_iff_noncol.2 ha'b'c')
hbc (noncol_in23 habc) with ⟨d, ha'b'c'dbc, hbcda⟩,
have hbd := (diff_side_line_neq hbcda).1.symm,
rcases extend_congr_seg (seg_proper_iff_neq.2 ha'b') hbd with ⟨d', hbdd', ha'b'bd, -⟩,
replace hbcda := ray_diff_side_line hbc hbcda hbdd',
rw [ang_symm d b c, ang_eq_same_side_pt c hbdd', ang_symm c b d'] at ha'b'c'dbc,
clear hbdd' hbd d, rename [d' d],
have had := (diff_side_line_neq'' hbcda).symm,
have hbcd := (diff_side_line_noncol hbcda hbc).1,
apply tri_congr12,
have : ((Δ b d c) ≅ₜ (Δ b' a' c')),
apply SAS; unfold three_pt_triang; simp,
exact noncol23 hbcd, exact noncol12 ha'b'c',
rw seg_symm b' a', exact seg_congr_symm ha'b'bd,
exact hbcb'c', exact ang_congr_symm ha'b'c'dbc,
apply tri_congr_trans _ this,
apply tri_congr12, apply SAS;
unfold three_pt_triang; simp,
exact habc, exact noncol132 hbcd,
{ apply seg_congr_trans haba'b', rw [seg_symm, seg_symm d b],
exact seg_congr_symm (tri_congr_seg this).1 },
{ apply seg_congr_trans haca'c',
exact seg_congr_symm (tri_congr_seg this).2.2 },
have hcacd : ((c-ₛa) ≅ₛ (c-ₛd)),
rw [seg_symm, seg_symm c d],
exact seg_congr_trans haca'c' (seg_congr_symm (tri_congr_seg this).2.2),
have hbabd : ((b-ₛa) ≅ₛ (b-ₛd)),
rw [seg_symm, seg_symm b d],
exact seg_congr_trans haba'b' (seg_congr_symm (tri_congr_seg (tri_congr12 this)).1),
cases hbcda.1 with e he,
have hed : e ≠ d,
intro hf, rw hf at he, exact noncol_in12 hbcd he.1,
have hea : e ≠ a,
intro hf, rw hf at he, exact noncol_in23 habc he.1,
have hdea := seg_in_neq hed hea he.2,
by_cases heb : e = b,
apply SSS_case2 habc _ hdea heb,
apply isosceles _ hcacd,
rw heb at hdea, exact noncol132 (col_noncol (col13 (between_col hdea)) habc had),
have hbad : noncol b a d,
intros hf, apply heb,
apply two_line_one_pt (line_in_lines hbc) (line_in_lines had.symm),
intro hf, apply noncol_in23 habc, rw hf, exact pt_right_in_line d a,
exact he.1, exact (seg_in_line d a) he.2,
exact pt_left_in_line b c, exact col_in32 hf had.symm,
have hbadbda := isosceles hbad hbabd,
by_cases hec : e = c,
rw [ang_symm, ang_symm b d c],
exact SSS_case2 (noncol23 habc) hbadbda hdea hec,
have hcad : noncol c a d,
intros hf, apply hec,
apply two_line_one_pt (line_in_lines hbc) (line_in_lines had.symm),
intro hf, apply noncol_in23 habc, rw hf, exact pt_right_in_line d a,
exact he.1, exact (seg_in_line d a) he.2,
exact pt_right_in_line b c, exact col_in32 hf had.symm,
have hcadcda := isosceles hcad hcacd,
rcases between_tri (col_in23' he.1) heb hec hbc with h | h | h,
exact SSS_case1 habc hbadbda hcadcda hdea h,
{ rw [ang_symm, ang_symm b d c],
exact SSS_case1 (noncol23 habc) hcadcda hbadbda hdea h },
exact SSS_case3 habc hbadbda hcadcda hdea h
end
/--I.7 in Elements -/
lemma triang_same_side_line {a b c d : pts} (hab : a ≠ b) (hcd : same_side_line (a-ₗb) c d)
(hacad : (a-ₛc) ≅ₛ (a-ₛd)) (hbcbd : (b-ₛc) ≅ₛ (b-ₛd)) : c = d :=
begin
have habc := (same_side_line_noncol hcd hab).1,
have habd := (same_side_line_noncol hcd hab).2,
have : ((Δ a b c) ≅ₜ (Δ a b d)),
apply SSS; unfold three_pt_triang; simp,
exact habc, exact habd,
exact seg_congr_refl _, exact hacad, exact hbcbd,
rw line_symm at hcd,
have hacd := ang_unique_same_side hab.symm hcd (tri_congr_ang this).2.1,
exact seg_unique_same_side hacd hacad
end
/--Existence of an isosceles triang
NOTE : Hilbert axioms do not guarantee the existence of an equilateral triang that occurs
frequently to prove, for example, the existence of ang bisector. We prove the existence of
an isosceles triang instead which works similarly.
-/
lemma isosceles_exist {a b c : pts} (habc : noncol a b c)
: ∃ d : pts, ((a-ₛd) ≅ₛ (b-ₛd)) ∧ same_side_line (a-ₗb) c d :=
begin
have : ∀ {a b c : pts}, noncol a b c → ((∠ c a b) <ₐ (∠ c b a))
→ ∃ d : pts, ((a-ₛd) ≅ₛ (b-ₛd)) ∧ same_side_line (a-ₗb) c d,
intros a b c habc h,
have hab := (noncol_neq habc).1,
have hbc := (noncol_neq habc).2.2,
rw ang_symm c b a at h,
rcases (three_pt_ang_lt.1 h) with ⟨d, hdin, hd⟩,
cases crossbar hdin with e he,
have hae : a ≠ e,
intro hae, rw ←hae at he,
apply noncol_in12 (ang_proper_iff_noncol.1
(inside_ang_proper' hdin).1),
rw line_symm, exact ray_in_line b d he.1,
have haeb := col_noncol (col_in12' ((seg_in_line a c) he.2)) (noncol23 habc) hae,
have heb := (noncol_neq haeb).2.2,
have hbcd := (same_side_line_noncol (inside_three_pt_ang.1 hdin).2 hbc).2,
have hec : e ≠ c,
intro hf, rw hf at he, exact noncol_in13 hbcd ((ray_in_line b d) he.1),
use e, split,
{ rw [seg_symm, seg_symm b e], apply isosceles' (noncol12 haeb),
rw [ang_symm, ←ang_eq_same_side_pt b (ray_in_neq hae.symm (seg_in_ray a c he.2))],
rw [ang_symm e b a, ←ang_eq_same_side_pt a (ray_in_neq heb he.1)],
rw ang_symm, exact ang_congr_symm hd },
rw line_symm, exact t_shape_seg (noncol12 habc) e (seg_in_neq hae.symm hec he.2),
rcases (ang_tri (ang_proper_iff_noncol.2 (noncol132 habc))
(ang_proper_iff_noncol.2 (noncol13 habc))).1 with h | h | h,
exact this habc h,
use c, split,
rw [seg_symm, seg_symm b c], exact isosceles' (noncol132 habc) h,
exact same_side_line_refl (noncol_in12 habc),
cases this (noncol12 habc) h with d hd,
rw line_symm at hd, exact ⟨d, seg_congr_symm hd.1, hd.2⟩
end
lemma isosceles_exist' {a b c : pts} (habc : noncol a b c)
: ∃ d : pts, ((a-ₛd) ≅ₛ (b-ₛd)) ∧ diff_side_line (a-ₗb) c d :=
begin
cases between_extend (noncol_neq habc).2.1.symm with d hcad,
have habd := noncol23 (col_noncol
(col12 (between_col hcad)) (noncol23 habc) (between_neq hcad).2.2),
cases isosceles_exist habd with e he,
use e, split, exact he.1,
have hab := (noncol_neq habc).1,
apply diff_same_side_line (line_in_lines hab) _ he.2,
apply (diff_side_pt_line (between_diff_side_pt.1 hcad)) (line_in_lines hab),
exact pt_left_in_line a b, exact noncol_in12 habc, exact noncol_in12 habd
end
private lemma ang_bisector_exist_prep {a b d e f : pts} : (a-ₛb ≅ₛ (a-ₛd)) → (b-ₛe ≅ₛ (d-ₛe))
→ diff_side_line (b-ₗd) a e → noncol b d a → between a f e → f ∈ (b-ₗd) ∩ (a-ₛe).inside
→ noncol a b e :=
begin
intros habad hbede he hbda hafe hf,
have had := (noncol_neq hbda).2.2.symm,
have hbd := (noncol_neq hbda).1,
have hae := (between_neq hafe).2.1,
apply noncol23, apply col_noncol (between_col hafe),
apply noncol13, apply col_noncol (col_in12' hf.1) hbda,
intro hbf, rw ←hbf at hafe,
cases between_extend had with i hadi,
have hdi := (between_neq hadi).2.2,
have hbdi := noncol132 (col_noncol (col12
(between_col hadi)) (noncol123 hbda) (between_neq hadi).2.2),
have : ((∠ b d i) ≅ₐ (∠ b d e)),
rw [seg_symm, seg_symm d e] at hbede,
have hebd := λhebd, he.2.2 (col_in23 hebd hbd),
rw ang_symm b d e, apply ang_congr_trans _ (isosceles hebd hbede),
rw ang_symm e b d,
have : ((∠ b d a) ≅ₐ (∠ d b a)),
rw [ang_symm, ang_symm d b a],
exact ang_congr_symm (isosceles (noncol132 hbda) habad),
apply supplementary_congr _ _ this;
rw three_pt_ang_supplementary,
exact ⟨hadi, hbda, hbdi⟩,
split, exact hafe,
exact ⟨noncol12 hbda, noncol13 hebd⟩,
{ apply (noncol13 hbda),
apply col_trans (col123 (col_trans (col123 (between_col hadi))
_ hdi)) (col23 (between_col hafe)) hae,
have hbdie : same_side_line (b-ₗd) i e,
apply diff_side_line_cancel (line_in_lines hbd) _ he,
exact diff_side_pt_line (diff_side_pt_symm (between_diff_side_pt.1 hadi)) (line_in_lines hbd)
(pt_right_in_line b d) (noncol_in12 hbdi) (noncol_in12 hbda),
exact (ang_unique_same_side hbd hbdie this).2 },
exact hae
end
/--I.9 in Elements -/
lemma ang_bisector_exist {a b c : pts} (hbac : ang_proper (∠ b a c)) :
∃ d : pts, ((∠ b a d) ≅ₐ (∠ c a d)) ∧ inside_ang d (∠ b a c) :=
begin
rw ang_proper_iff_noncol at hbac,
have hab := (noncol_neq hbac).1.symm,
have hac := (noncol_neq hbac).2.2,
rcases extend_congr_seg (seg_proper_iff_neq.2 hab) hac with ⟨d, hacd, habad, -⟩,
have had := (same_side_pt_neq hacd).2.symm,
have hbda := noncol13 (col_noncol hacd.2 (noncol123 hbac) had),
have hbd := (noncol_neq hbda).1,
rcases isosceles_exist' hbda with ⟨e, hbede, he⟩,
cases he.1 with f hf,
have hfa : f ≠ a,
intro hfa, rw hfa at hf, exact absurd hf.1 (noncol_in12 hbda),
have hfe : f ≠ e,
intro hfe, rw hfe at hf, exact absurd hf.1 he.2.2,
have hafe := (seg_in_neq hfa hfe hf.2),
have habe := ang_bisector_exist_prep habad hbede he hbda hafe hf,
have hade : noncol a d e,
rw line_symm at he, rw line_symm at hf,
exact ang_bisector_exist_prep (seg_congr_symm habad) (seg_congr_symm hbede)
he (noncol12 hbda) hafe hf,
have : (∠ b a f ≅ₐ ∠ c a f),
rw [ang_eq_same_side_pt b (between_same_side_pt.1 hafe).1,
ang_eq_same_side_pt c (between_same_side_pt.1 hafe).1],
have hde := (diff_side_line_neq' he).2.symm,
rw [ang_symm c a e, ang_eq_same_side_pt e hacd, ang_symm e a d],
apply (tri_congr_ang _).2.1, apply SSS; unfold three_pt_triang; simp,
exact habe, exact hade,
exact habad, exact seg_congr_refl _, exact hbede,
use f, split, exact this,
rw ang_eq_same_side_pt b hacd,
by_cases hbf : b = f,
rw ←hbf at hafe, exact absurd (between_col hafe) habe,
by_cases hdf : d = f,
rw ←hdf at hafe, exact absurd (between_col hafe) hade,
have hbdf := col_in12' hf.1,
have hbaf := noncol23 (col_noncol hbdf hbda hbf),
have hdaf := noncol23 (col_noncol (col12 hbdf)
(noncol12 hbda) hdf),
rw [ang_symm c a f, ang_eq_same_side_pt f hacd, ang_symm f a d] at this,
rcases between_tri (col_in12' hf.1) hbd hbf hdf with h | h | h,
{ exfalso,
apply (ang_tri (ang_proper_iff_noncol.2 hbaf)
(ang_proper_iff_noncol.2 hdaf)).2.2.2,
split, exact this,
rw [ang_symm b a f, three_pt_ang_lt],
use d, split, rw between_symm at h,
exact hypo_inside_ang (noncol13 hbaf) h,
rw ang_symm, exact ang_congr_refl _ },
exact hypo_inside_ang (noncol23 hbda) h,
{ exfalso,
apply (ang_tri (ang_proper_iff_noncol.2 hbaf)
(ang_proper_iff_noncol.2 hdaf)).2.1,
split, rw [ang_symm d a f, three_pt_ang_lt],
use b, split, rw between_symm at h,
exact hypo_inside_ang (noncol13 hdaf) h,
rw ang_symm, exact ang_congr_refl _,
exact this }
end
/--I.10 in Elements -/
lemma midpt_exist {a b : pts} (hab : a ≠ b) : ∃ c : pts, between a c b ∧ ((a-ₛc) ≅ₛ (b-ₛc)) :=
begin
cases noncol_exist hab with c habc,
rcases isosceles_exist habc with ⟨d, hd, hcd⟩,
have hadb := noncol23 (same_side_line_noncol hcd hab).2,
rcases ang_bisector_exist (ang_proper_iff_noncol.2 hadb) with ⟨e, he, hein⟩,
cases crossbar hein with f hf,
have hfa : f ≠ a,
intro hfa, rw hfa at hf, exfalso,
have dea := noncol12 (ang_proper_iff_noncol.1
(inside_ang_proper' hein).1),
exact noncol_in12 dea ((ray_in_line d e) hf.1),
have hfb : f ≠ b,
intro hfb, rw hfb at hf, exfalso,
have deb := noncol12 (ang_proper_iff_noncol.1
(inside_ang_proper' hein).2),
exact noncol_in12 deb ((ray_in_line d e) hf.1),
have h := seg_in_neq hfa hfb hf.2,
use f, split, exact h,
have : ((Δ d a f) ≅ₜ (Δ d b f)),
apply SAS; unfold three_pt_triang; simp,
exact noncol132 (col_noncol (col23 (between_col h))
(noncol23 hadb) (between_neq h).1),
exact noncol132 (col_noncol (col132 (between_col h))
(noncol132 hadb) (between_neq h).2.2.symm),
rw [seg_symm, seg_symm d b], exact hd,
exact seg_congr_refl _,
have : same_side_pt d e f,
cases hf.1 with hf hf, exact hf,
simp at hf, rw hf at h, exact absurd (between_col h) hadb,
rw [ang_eq_same_side_pt a this, ang_eq_same_side_pt b this] at he,
exact he,
exact (tri_congr_seg this).2.2
end
def midpt (x : pts) (s : seg) : Prop :=
∃ a b : pts, s = (a-ₛb) ∧ between a x b ∧ ((a-ₛx) ≅ₛ (b-ₛx))
lemma midpt_two_pt {x a b : pts} : midpt x (a-ₛb) ↔ between a x b ∧ ((a-ₛx) ≅ₛ (b-ₛx)) :=
begin
split,
{ rintros ⟨a', b', hs, ha'xb', ha'xb'x⟩,
cases two_pt_seg_pt hs,
rw [h.1, h.2], exact ⟨ha'xb', ha'xb'x⟩,
rw [h.1, h.2, between_symm], exact ⟨ha'xb', seg_congr_symm ha'xb'x⟩ },
{ intro h,
exact ⟨a, b, rfl, h.1, h.2⟩ }
end
open_locale perp_notation
/--I.11 in Elements -/
lemma perpendicular_exist_same_side {l : set pts} (hl : l ∈ lines) {a : pts} (hal : a ∈ l)
{b : pts} (hbl : b ∉ l) : ∃ c : pts, (l ⊥ (a-ₗc)) ∧ same_side_line l b c :=
begin
have : ∃ c : pts, c ∈ l ∧ a ≠ c,
by_contra hf, push_neg at hf,
rcases two_pt_on_one_line hl with ⟨p, q, hpq, hpl, hql⟩,
exact hpq ((hf p hpl).symm.trans (hf q hql)),
rcases this with ⟨c, hcl, hac⟩,
rcases extend_congr_seg' (seg_proper_iff_neq.2 hac) hac with ⟨d, hcad, hacad, -⟩,
rw ←between_diff_side_pt at hcad,
have hcab : noncol c a b,
rw two_pt_one_line hl (line_in_lines hac.symm) hac hal hcl
(pt_right_in_line c a) (pt_left_in_line c a) at hbl,
intro hcab, exact hbl (col_in12 hcab hac.symm),
have hcd := (between_neq hcad).2.1,
have hcdb := col_noncol (between_col hcad) hcab hcd,
rcases isosceles_exist hcdb with ⟨e, hcecd, hbe⟩,
use e,
rw two_pt_one_line hl (line_in_lines hcd) hac hal hcl (col_in13 (between_col hcad) hcd)
(pt_left_in_line c d),
split,
{ rw between_symm at hcad,
have hda := (between_neq hcad).1,
have head : noncol e a d, from noncol13 (col_noncol (col23
(between_col hcad)) (noncol12 (same_side_line_noncol hbe hcd).2) hda),
use [d, e, a], rw [ang_symm, three_pt_ang_is_right_ang hcad],
have : (Δ e a d ≅ₜ Δ e a c),
apply SSS; unfold three_pt_triang; simp,
exact head,
exact noncol13 (col_noncol (col132 (between_col hcad))
((same_side_line_noncol hbe hcd).2) hac.symm),
exact seg_congr_refl _,
rw [seg_symm, seg_symm e c], exact seg_congr_symm hcecd,
exact seg_congr_symm hacad,
rw between_symm at hcad,
exact ⟨pt_right_in_line c d, pt_right_in_line a e, ⟨col_in13 (between_col hcad) hcd,
pt_left_in_line a e⟩, (tri_congr_ang this).1, ang_proper_iff_noncol.2 head⟩,
exact ⟨line_in_lines hcd, line_in_lines (noncol_neq head).1.symm⟩ },
exact hbe
end
/--I.12 in Elements -/
lemma drop_perpendicular {l : set pts} (hl : l ∈ lines) {a : pts} (hal : a ∉ l) :
∃ b : pts, l ⊥ (a-ₗb) :=
begin
rcases two_pt_on_one_line hl with ⟨b, c, hbc, hbl, hcl⟩,
rw two_pt_one_line hl (line_in_lines hbc) hbc
hbl hcl (pt_left_in_line b c) (pt_right_in_line b c) at hal,
have habc := noncol_in23' hbc hal,
have hab := (noncol_neq habc).1,
rcases extend_congr_ang' (ang_proper_iff_noncol.2 habc) hbc hal with ⟨d, habcdbc, hda⟩,
have hbd := (diff_side_line_neq hda).1.symm,
rcases extend_congr_seg (seg_proper_iff_neq.2 hab.symm) hbd with ⟨e, hbde, hbabe, -⟩,
have hea : diff_side_line (b-ₗc) e a,
apply same_diff_side_line (line_in_lines hbc) _ hda,
apply same_side_pt_line (same_side_pt_symm hbde) (line_in_lines hbc),
exact pt_left_in_line b c,
exact noncol_in13 (col_noncol hbde.2
(noncol23 (diff_side_line_noncol hda hbc).1) (same_side_pt_neq hbde).2.symm),
exact noncol_in12 (diff_side_line_noncol hda hbc).1,
cases hea.1 with f hf,
have hfe : f ≠ e,
intro hfe, rw hfe at hf, exact absurd hf.1 (noncol_in12 (diff_side_line_noncol hea hbc).1),
have hfa : f ≠ a,
intro hfa, rw hfa at hf, exact absurd hf.1 hal,
have hafe := seg_in_neq hfe hfa hf.2,
rw between_symm at hafe,
by_cases hbf : b = f,
rw ←hbf at hafe, use b,
use [c, a, b],
split, exact hcl, split, exact pt_left_in_line a b,
split, exact ⟨hbl, pt_right_in_line a b⟩,
rw three_pt_ang_is_right_ang hafe,
have : (Δ b c a ≅ₜ Δ b c e),
apply SAS; unfold three_pt_triang; simp,
exact noncol123 habc, exact (diff_side_line_noncol hea hbc).1,
exact seg_congr_refl _,
exact hbabe,
rw [ang_eq_same_side_pt c (same_side_pt_symm hbde), ang_symm, ang_symm c b d],
exact habcdbc,
exact ⟨(tri_congr_ang this).2.1, ang_proper_iff_noncol.2 (noncol13 habc)⟩,
exact ⟨hl, line_in_lines hab⟩,
use f, use [b, a, f],
split, exact hbl, split, exact pt_left_in_line a f,
split,
{ rw two_pt_one_line hl (line_in_lines hbc) hbc
hbl hcl (pt_left_in_line b c) (pt_right_in_line b c),
exact ⟨hf.1, pt_right_in_line a f⟩ },
{ rw three_pt_ang_is_right_ang hafe,
have hfe := (between_neq hafe).2.2,
have hbfa := col_noncol (col_in12' hf.1) (noncol123 habc) hbf,
have hbfe := noncol132 ((col_noncol (col23 (col_in23'
((seg_in_line e a) hf.2))) (noncol123 hbfa)) hfe),
have : (Δ b f a ≅ₜ Δ b f e),
apply SAS; unfold three_pt_triang; simp,
exact hbfa, exact hbfe,
exact seg_congr_refl _,
exact hbabe,
cases (line_separation (col_in12' hf.1) hbc.symm (ne.symm hbf)).1,
{ rw [ang_symm, ←ang_eq_same_side_pt a h, ang_symm f b e, ←ang_eq_same_side_pt e h,
ang_symm e b c, ang_eq_same_side_pt c (same_side_pt_symm hbde), ang_symm c b d],
exact habcdbc },
{ rw ←between_diff_side_pt at h,
apply supplementary_congr,
rw [ang_symm, three_pt_ang_supplementary],
exact ⟨h, habc, noncol132 hbfa⟩,
rw [ang_symm, three_pt_ang_supplementary],
exact ⟨h, noncol132 (diff_side_line_noncol hea hbc).1, noncol132 hbfe⟩,
rw [ang_symm e b c, ang_eq_same_side_pt c (same_side_pt_symm hbde), ang_symm c b d],
exact habcdbc },
exact ⟨(tri_congr_ang this).1, ang_proper_iff_noncol.2 hbfa⟩ },
exact ⟨hl, line_in_lines (between_neq hafe).1⟩
end
private lemma ang_exter_lt_inter_prep {a b c d : pts} (habc : noncol a b c) (hbcd : between b c d) :
∠ b a c <ₐ ∠ a c d :=
begin
have hac := (noncol_neq habc).2.1,
have hcd := (between_neq hbcd).2.2,
have hbc := (noncol_neq habc).2.2,
have hcda := col_noncol (col12 (between_col hbcd)) (noncol13 habc) hcd,
rcases midpt_exist hac with ⟨e, haec, he⟩,
have hae := (between_neq haec).1,
have hbe : b ≠ e,
intro hbe, rw ←hbe at haec, exact habc (between_col haec),
have hec := (between_neq haec).2.2,
rcases extend_congr_seg' (seg_proper_iff_neq.2 hbe) hbe.symm with ⟨f, hbef, hf, -⟩,
rw ←between_diff_side_pt at hbef,
have hef := (between_neq hbef).2.2,
have hbf := (between_neq hbef).2.1,
have hceb := col_noncol (col132 (between_col haec)) (noncol132 habc) hec.symm,
have hefc := col_noncol (col12 (between_col hbef)) (noncol123 hceb) hef,
have hcaf := col_noncol (col13 (between_col haec)) (noncol132 hefc) hac.symm,
have haeb := col_noncol (col23 (between_col haec)) (noncol23 habc) hae,
rw three_pt_ang_lt, use f, split,
{ rw inside_three_pt_ang, split,
{ apply diff_side_line_cancel (line_in_lines hac.symm),
{ apply diff_side_line_symm,
apply diff_side_pt_line (between_diff_side_pt.1 hbcd) (line_in_lines hac.symm),
exact pt_left_in_line c a, exact noncol_in13 (noncol13 habc),
exact noncol_in13 (col_noncol (col12 (between_col hbcd)) (noncol13 habc) hcd) },
{ apply diff_side_pt_line (between_diff_side_pt.1 hbef) (line_in_lines hac.symm),
exact col_in13 (col13 (between_col haec)) hac.symm,
exact noncol_in13 (noncol13 habc), exact noncol_in12 hcaf } },
apply same_side_line_trans (line_in_lines hcd),
rw line_symm,
rw between_symm at haec,
apply t_shape_seg (noncol12 hcda) e haec,
rw two_pt_one_line (line_in_lines hcd) (line_in_lines hbc) hbc (col_in23 (between_col hbcd) hcd)
(pt_left_in_line c d) (pt_left_in_line b c) (pt_right_in_line b c),
rw line_symm, apply t_shape_ray (noncol23 hceb) (between_same_side_pt.1 hbef).1 },
{ have : (Δ e a b ≅ₜ Δ e c f),
apply SAS; unfold three_pt_triang; simp,
exact noncol12 haeb, exact noncol23 hefc,
rw [seg_symm, seg_symm e c], exact he,
rw seg_symm, exact hf,
exact vertical_ang_congr haeb haec hbef,
rw [ang_symm, ang_eq_same_side_pt f (between_same_side_pt.1 haec).2,
←ang_eq_same_side_pt b (between_same_side_pt.1 haec).1, ang_symm, ang_symm b a e],
exact ang_congr_symm (tri_congr_ang this).1 }
end
/--I.16 in Elements -/
lemma ang_exter_lt_inter {a b c d : pts} (habc : noncol a b c) (hbcd : between b c d) :
(∠ b a c <ₐ ∠ a c d) ∧ (∠ a b c <ₐ ∠ a c d) :=
begin
split,
exact ang_exter_lt_inter_prep habc hbcd,
{ have hac := (noncol_neq habc).2.1,
have hcd := (between_neq hbcd).2.2,
have hcda := col_noncol (col12 (between_col hbcd)) (noncol13 habc) hcd,
cases between_extend hac with e hace,
apply (ang_lt_congr _).2,
exact (ang_proper_iff_noncol.2 (noncol132 hcda)),
exact ang_exter_lt_inter_prep (noncol12 habc) hace,
{ rw ang_symm,
apply vertical_ang_congr,
have hce := (between_neq hace).2.2,
exact noncol12 (col_noncol (col12 (between_col hace)) (noncol132 habc) hce),
rw between_symm, exact hace,
exact hbcd } }
end
/--I.18 in Elements -/
lemma greater_side_ang {a b c : pts} (habc : noncol a b c) (hs : (a-ₛb) <ₛ (a-ₛc)) :
∠ a c b <ₐ ∠ a b c :=
begin
have hab := (noncol_neq habc).1,
have hbc := (noncol_neq habc).2.2,
rcases two_pt_seg_lt.1 hs with ⟨d, hadc, habad⟩,
have had := (between_neq hadc).1,
have hcd := (between_neq hadc).2.2.symm,
apply ang_lt_trans (ang_proper_iff_noncol.2 (noncol23 habc)),
{ rw [ang_symm, ang_eq_same_side_pt b (between_same_side_pt.1 hadc).2],
rw between_symm at hadc,
apply (ang_exter_lt_inter _ hadc).2,
exact noncol132 (col_noncol (col23 (between_col hadc)) (noncol132 habc) hcd) },
{ apply (ang_lt_congr _).1,
rw three_pt_ang_lt, use d,
split, exact hypo_inside_ang habc hadc,
apply isosceles,
exact noncol23 (col_noncol (col23 (between_col hadc)) (noncol23 habc) had),
exact habad,
rw ang_symm, exact ang_congr_refl _ }
end
/--I.19 in Elements -/
lemma greater_ang_side {a b c : pts} (habc : noncol a b c) (ha : ∠ a c b <ₐ ∠ a b c) :
(a-ₛb) <ₛ (a-ₛc) :=
begin
have hab := (noncol_neq habc).1,
have hac := (noncol_neq habc).2.1,
rcases (seg_tri (seg_proper_iff_neq.2 hab) (seg_proper_iff_neq.2 hac)).1
with h | hf | hf,
exact h,
{ exfalso, apply (ang_tri (ang_proper_iff_noncol.2 (noncol23 habc))
(ang_proper_iff_noncol.2 habc)).2.1,
split, exact ha,
exact isosceles (noncol23 habc) (seg_congr_symm hf) },
{ exfalso, apply (ang_tri (ang_proper_iff_noncol.2 (noncol23 habc))
(ang_proper_iff_noncol.2 habc)).2.2.1,
split, exact ha,
exact greater_side_ang (noncol23 habc) hf }
end
/--I.20 in Elements -/
theorem triangular_ineq {a b c d : pts} (habc : noncol a b c) (habd : between a b d)
(hbdbc : (b-ₛd) ≅ₛ (b-ₛc)) : (a-ₛc) <ₛ (a-ₛd) :=
begin
have had := (between_neq habd).2.1,
have hbd := (between_neq habd).2.2,
have hadc := (col_noncol (between_col habd) habc) had,
have hbdc := (col_noncol (col12 (between_col habd)) (noncol12 habc)) hbd,
apply greater_ang_side (noncol23 hadc),
rw [ang_symm a c d, three_pt_ang_lt],
use b, rw ang_symm, split,
exact hypo_inside_ang (noncol23 hadc) habd,
rw [ang_symm a d c, ang_eq_same_side_pt c (between_same_side_pt.1 habd).2, ang_symm,
ang_symm c d b],
exact isosceles (noncol23 hbdc) (seg_congr_symm hbdbc)
end
private lemma ASA_prep {a b c d e f : pts} (habc : noncol a b c) (hdef : noncol d e f)
(habcdef : ∠ a b c ≅ₐ ∠ d e f) (hbacedf : ∠ b a c ≅ₐ ∠ e d f)
(habde : (a-ₛb) ≅ₛ (d-ₛe)) : ¬((d-ₛf) <ₛ (a-ₛc)) :=
begin
intro hf,
rw two_pt_seg_lt at hf,
rcases hf with ⟨x, haxc, hdfax⟩,
have hax := (between_neq haxc).1,
have haxb := col_noncol (col23 (between_col haxc)) (noncol23 habc) hax,
apply (ang_tri (ang_proper_iff_noncol.2 (noncol23 haxb))
(ang_proper_iff_noncol.2 habc)).2.1,
split,
{ rw three_pt_ang_lt,
exact ⟨x, hypo_inside_ang habc haxc, ang_congr_refl _⟩ },
{ apply ang_congr_symm,
apply ang_congr_trans habcdef,
have : (Δ a b x ≅ₜ Δ d e f),
apply SAS; unfold three_pt_triang; simp,
exact noncol23 haxb, exact hdef,
exact habde,
exact seg_congr_symm hdfax,
{ rw ang_eq_same_side_pt b (between_same_side_pt.1 haxc).1,
exact hbacedf },
exact ang_congr_symm (tri_congr_ang this).1 }
end
/--I.26 part one in Elements -/
theorem ASA {ABC DEF : triang} (habc : noncol ABC.v1 ABC.v2 ABC.v3)
(ha'b'c' : noncol DEF.v1 DEF.v2 DEF.v3) (haba'b' : (ABC.v1-ₛABC.v2) ≅ₛ (DEF.v1-ₛDEF.v2))
(habca'b'c' : (∠ABC.v1 ABC.v2 ABC.v3 ≅ₐ ∠DEF.v1 DEF.v2 DEF.v3))
(hbacb'a'c' : (∠ABC.v2 ABC.v1 ABC.v3 ≅ₐ ∠DEF.v2 DEF.v1 DEF.v3)) : ABC ≅ₜ DEF :=
begin
set a := ABC.v1 with ha, set b := ABC.v2 with hb, set c := ABC.v3 with hc,
set a' := DEF.v1, set b' := DEF.v2, set c' := DEF.v3,
have hac := (noncol_neq habc).2.1,
have ha'c' := (noncol_neq ha'b'c').2.1,
apply SAS,
exact habc, exact ha'b'c',
exact haba'b',
{ rcases (seg_tri (seg_proper_iff_neq.2 hac)
(seg_proper_iff_neq.2 ha'c')).1 with hf | haca'c' | hf,
exact absurd hf (ASA_prep ha'b'c' habc (ang_congr_symm habca'b'c')
(ang_congr_symm hbacb'a'c') (seg_congr_symm haba'b')),
exact haca'c',
exact absurd hf (ASA_prep habc ha'b'c' habca'b'c' hbacb'a'c' haba'b') },
exact hbacb'a'c'
end
private lemma AAS_prep {a b c d e f : pts} (habc : noncol a b c) (hdef : noncol d e f)
(habcdef : ∠ a b c ≅ₐ ∠ d e f) (hbacedf : ∠ b a c ≅ₐ ∠ e d f)
(hbcef : (b-ₛc) ≅ₛ (e-ₛf)) : ¬((d-ₛe) <ₛ (a-ₛb)) :=
begin
intro hf,
rw [seg_symm a b, two_pt_seg_lt] at hf,
rcases hf with ⟨x, hbxa, hdebx⟩,
have hbx := (between_neq hbxa).1,
have hbxc := col_noncol (col23 (between_col hbxa)) (noncol12 habc) hbx,
apply (ang_tri (ang_proper_iff_noncol.2 hbxc) (ang_proper_iff_noncol.2 (noncol12 habc))).2.2.2,
split,
{ apply ang_congr_trans _ (ang_congr_symm hbacedf),
apply (tri_congr_ang _).1,
apply SAS; unfold three_pt_triang; simp,
exact hbxc, exact noncol12 hdef,
rw seg_symm e d, exact seg_congr_symm hdebx,
exact hbcef,
{ rw [ang_symm, ang_eq_same_side_pt c (between_same_side_pt.1 hbxa).1, ang_symm],
exact habcdef } },
{ rw [ang_symm, ang_eq_same_side_pt c (between_same_side_pt.1 hbxa).2, ang_symm b x c],
apply (ang_exter_lt_inter _ _).2,
{ have hxa := (between_neq hbxa).2.2,
exact noncol132 (col_noncol (col132 (between_col hbxa)) habc hxa.symm) },
rw between_symm, exact hbxa }
end
/--I.26 part two in Elements -/
theorem AAS {ABC DEF : triang} (habc : noncol ABC.v1 ABC.v2 ABC.v3)
(ha'b'c' : noncol DEF.v1 DEF.v2 DEF.v3) (habca'b'c' : (∠ABC.v1 ABC.v2 ABC.v3 ≅ₐ
∠DEF.v1 DEF.v2 DEF.v3)) (hbacb'a'c' : (∠ABC.v2 ABC.v1 ABC.v3 ≅ₐ ∠DEF.v2 DEF.v1 DEF.v3))
(hbcb'c' : (ABC.v2-ₛABC.v3) ≅ₛ (DEF.v2-ₛDEF.v3)) : ABC ≅ₜ DEF :=
begin
set a := ABC.v1 with ha, set b := ABC.v2 with hb, set c := ABC.v3 with hc,
set a' := DEF.v1, set b' := DEF.v2, set c' := DEF.v3,
have hab := (noncol_neq habc).1,
have ha'b' := (noncol_neq ha'b'c').1,
apply tri_congr12, apply SAS,
exact noncol12 habc, exact noncol12 ha'b'c',
{ rcases (seg_tri (seg_proper_iff_neq.2 hab) (seg_proper_iff_neq.2 ha'b')).1
with hf | haba'b' | hf,
exact absurd hf (AAS_prep ha'b'c' habc (ang_congr_symm habca'b'c') (ang_congr_symm hbacb'a'c')
(seg_congr_symm hbcb'c')),
rw [seg_symm, seg_symm a' b'] at haba'b', exact haba'b',
exact absurd hf (AAS_prep habc ha'b'c' habca'b'c' hbacb'a'c' hbcb'c') },
exact hbcb'c', exact habca'b'c'
end
/--Hypotenuse leg theorem -/
theorem HL {ABC DEF : triang} (hr₁ : is_right_ang (∠ ABC.v1 ABC.v2 ABC.v3))
(hr₂ : is_right_ang (∠ DEF.v1 DEF.v2 DEF.v3)) (haba'b' : (ABC.v1-ₛABC.v2) ≅ₛ (DEF.v1-ₛDEF.v2))
(haca'c' : (ABC.v1-ₛABC.v3) ≅ₛ (DEF.v1-ₛDEF.v3)) : ABC ≅ₜ DEF :=
begin
set a := ABC.v1 with ha, set b := ABC.v2 with hb, set c := ABC.v3 with hc,
set a' := DEF.v1, set b' := DEF.v2, set c' := DEF.v3,
have habc := ang_proper_iff_noncol.1 hr₁.1,
have ha'b'c' := ang_proper_iff_noncol.1 hr₂.1,
have hbc := (noncol_neq habc).2.2,
have hb'c' := (noncol_neq ha'b'c').2.2,
rcases extend_congr_seg' (seg_proper_iff_neq.2 hb'c') hbc with ⟨d, hcbd, hb'c'bd, -⟩,
rw ←between_diff_side_pt at hcbd,
have hbd := (between_neq hcbd).2.2,
have hcd := (between_neq hcbd).2.1,
have hbda := col_noncol (col12 (between_col hcbd)) (noncol123 habc) hbd,
have hr₃ : is_right_ang (∠ a b d),
apply right_supplementary_right hr₁,
rw three_pt_ang_supplementary,
exact ⟨hcbd, habc, noncol132 hbda⟩,
have : (Δ b a d ≅ₜ Δ b' a' c'),
apply SAS; unfold three_pt_triang; simp,
exact noncol23 hbda, exact noncol12 ha'b'c',
rw [seg_symm, seg_symm b' a'], exact haba'b',
exact seg_congr_symm hb'c'bd,
{ apply all_right_ang_congr,
exact hr₃, exact hr₂ },
apply tri_congr_trans _ (tri_congr12 this),
apply tri_congr13,
apply AAS, exact noncol13 habc, exact noncol12 hbda,
{ apply all_right_ang_congr,
rw ang_symm, exact hr₁,
rw ang_symm, exact hr₃ },
unfold three_pt_triang,
{ rw [ang_symm, ang_eq_same_side_pt a (between_same_side_pt.1 hcbd).1, ang_symm b d a,
←ang_eq_same_side_pt a (between_same_side_pt.1 hcbd).2],
apply isosceles,
exact noncol132 (col_noncol (between_col hcbd) (noncol13 habc) hcd),
apply seg_congr_trans haca'c',
exact seg_congr_symm (tri_congr_seg this).2.2 },
exact seg_congr_refl _
end
lemma correspond_eq_parallel {a b c d e : pts}
(hab : a ≠ b) (hcd : c ≠ d) (hcae : between c a e) (hbd : same_side_line (a-ₗc) b d) :
((∠ e a b) ≅ₐ (∠ a c d)) → ((a-ₗb) ∥ₗ (c-ₗd)) :=
begin
intro h,
by_contra hf,
unfold parallel intersect at hf,
rw [not_and_distrib, not_and_distrib, not_not] at hf,
rcases hf with hf | hf | hf,
{ cases set.nonempty_def.mp hf with p hp,
have hac := (between_neq hcae).1.symm,
have hacb := (same_side_line_noncol hbd hac).1,
have hacd := (same_side_line_noncol hbd hac).2,
have hap : a ≠ p,
intro hap, rw ←hap at hp, exact hacd (col_in23' hp.2),
have hapc := col_noncol (col_in12' hp.1) (noncol23 hacb) hap,
have hae := (between_neq hcae).2.2,
have haeb := col_noncol (col12 (between_col hcae)) hacb hae,
have hce := (between_neq hcae).2.1,
have hced := col_noncol (between_col hcae) (noncol12 hacd) hce,
have hape := col_noncol (col_in12' hp.1) (noncol23 haeb) hap,
have hcp := (noncol_neq hapc).2.2.symm,
have hcpe := col_noncol (col_in12' hp.2) (noncol23 hced) hcp,
have key := (ang_exter_lt_inter (noncol123 hapc) hcae).2,
cases (plane_separation (noncol_in12 hacb) (noncol_in13 hapc)).1 with hp₁ hp₂,
{ have habp := same_side_line_pt (col_in12' hp.1) (a-ₗc) (line_in_lines hac)
(pt_left_in_line a c) (noncol_in12 hacb) (noncol_in13 hapc) hp₁,
have hcdp := same_side_line_pt (col_in12' hp.2) (a-ₗc) (line_in_lines hac)
(pt_right_in_line a c) (noncol_in12 hacd) (noncol_in13 hapc)
(same_side_line_trans (line_in_lines hac) (same_side_line_symm hbd) hp₁),
rw [ang_symm, ←ang_eq_same_side_pt a hcdp,
ang_symm p a e, ←ang_eq_same_side_pt e habp] at key,
apply (ang_tri (ang_proper_iff_noncol.2 hacd)
(ang_proper_iff_noncol.2 (noncol12 haeb))).2.1,
exact ⟨key, (ang_congr_symm h)⟩ },
have habp := diff_side_line_pt (col_in12' hp.1) (a-ₗc) (line_in_lines hac)
(pt_left_in_line a c) (noncol_in12 hacb) (noncol_in13 hapc) hp₂,
have hcdp := diff_side_line_pt (col_in12' hp.2) (a-ₗc) (line_in_lines hac)
(pt_right_in_line a c) (noncol_in12 hacd) (noncol_in13 hapc)
(same_diff_side_line (line_in_lines hac) (same_side_line_symm hbd) hp₂),
have h₁ := three_pt_ang_supplementary.2 ⟨(between_diff_side_pt.2 habp),
noncol12 haeb, noncol132 hape⟩,
have h₂ := three_pt_ang_supplementary.2 ⟨(between_diff_side_pt.2 hcdp),
noncol12 hced, noncol132 hcpe⟩,
rw [ang_symm a c d, ang_eq_same_side_pt d
(between_same_side_pt.1 hcae).1, ang_symm d c e] at h,
rw [ang_eq_same_side_pt p (between_same_side_pt.1 hcae).1,
ang_symm, ang_symm p a e] at key,
have := supplementary_congr h₁ h₂ h,
apply (ang_tri (ang_proper_iff_noncol.2 (noncol132 hape))
(ang_proper_iff_noncol.2 (noncol132 hcpe))).2.2.2,
exact ⟨this, key⟩ },
exact hf (line_in_lines hab),
exact hf (line_in_lines hcd)
end
/--/
/--Hypotenuse of a right triangle is greater than the other two sides. -/
lemma side_lt_hypo {a b c : pts} (habc : is_right_ang (∠ a b c)) : (a-ₛb) <ₛ (a-ₛc) :=
begin
sorry
end-/ |
8a40104ed1ffe39d3b034fe6505bfba1630db203 | 8cae430f0a71442d02dbb1cbb14073b31048e4b0 | /src/topology/category/Top/opens.lean | c0ea142fc31a20f0a03e6915e4a2ae5161a8187c | [
"Apache-2.0"
] | permissive | leanprover-community/mathlib | 56a2cadd17ac88caf4ece0a775932fa26327ba0e | 442a83d738cb208d3600056c489be16900ba701d | refs/heads/master | 1,693,584,102,358 | 1,693,471,902,000 | 1,693,471,902,000 | 97,922,418 | 1,595 | 352 | Apache-2.0 | 1,694,693,445,000 | 1,500,624,130,000 | Lean | UTF-8 | Lean | false | false | 11,826 | lean | /-
Copyright (c) 2019 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Scott Morrison
-/
import category_theory.category.preorder
import category_theory.eq_to_hom
import topology.category.Top.epi_mono
import topology.sets.opens
/-!
# The category of open sets in a topological space.
> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.
> Any changes to this file require a corresponding PR to mathlib4.
We define `to_Top : opens X ⥤ Top` and
`map (f : X ⟶ Y) : opens Y ⥤ opens X`, given by taking preimages of open sets.
Unfortunately `opens` isn't (usefully) a functor `Top ⥤ Cat`.
(One can in fact define such a functor,
but using it results in unresolvable `eq.rec` terms in goals.)
Really it's a 2-functor from (spaces, continuous functions, equalities)
to (categories, functors, natural isomorphisms).
We don't attempt to set up the full theory here, but do provide the natural isomorphisms
`map_id : map (𝟙 X) ≅ 𝟭 (opens X)` and
`map_comp : map (f ≫ g) ≅ map g ⋙ map f`.
Beyond that, there's a collection of simp lemmas for working with these constructions.
-/
open category_theory
open topological_space
open opposite
universe u
namespace topological_space.opens
variables {X Y Z : Top.{u}}
/-!
Since `opens X` has a partial order, it automatically receives a `category` instance.
Unfortunately, because we do not allow morphisms in `Prop`,
the morphisms `U ⟶ V` are not just proofs `U ≤ V`, but rather
`ulift (plift (U ≤ V))`.
-/
instance opens_hom_has_coe_to_fun {U V : opens X} : has_coe_to_fun (U ⟶ V) (λ f, U → V) :=
⟨λ f x, ⟨x, f.le x.2⟩⟩
/-!
We now construct as morphisms various inclusions of open sets.
-/
-- This is tedious, but necessary because we decided not to allow Prop as morphisms in a category...
/--
The inclusion `U ⊓ V ⟶ U` as a morphism in the category of open sets.
-/
def inf_le_left (U V : opens X) : U ⊓ V ⟶ U := inf_le_left.hom
/--
The inclusion `U ⊓ V ⟶ V` as a morphism in the category of open sets.
-/
def inf_le_right (U V : opens X) : U ⊓ V ⟶ V := inf_le_right.hom
/--
The inclusion `U i ⟶ supr U` as a morphism in the category of open sets.
-/
def le_supr {ι : Type*} (U : ι → opens X) (i : ι) : U i ⟶ supr U := (le_supr U i).hom
/--
The inclusion `⊥ ⟶ U` as a morphism in the category of open sets.
-/
def bot_le (U : opens X) : ⊥ ⟶ U := bot_le.hom
/--
The inclusion `U ⟶ ⊤` as a morphism in the category of open sets.
-/
def le_top (U : opens X) : U ⟶ ⊤ := le_top.hom
-- We do not mark this as a simp lemma because it breaks open `x`.
-- Nevertheless, it is useful in `sheaf_of_functions`.
lemma inf_le_left_apply (U V : opens X) (x) :
(inf_le_left U V) x = ⟨x.1, (@_root_.inf_le_left _ _ U V : _ ≤ _) x.2⟩ :=
rfl
@[simp]
lemma inf_le_left_apply_mk (U V : opens X) (x) (m) :
(inf_le_left U V) ⟨x, m⟩ = ⟨x, (@_root_.inf_le_left _ _ U V : _ ≤ _) m⟩ :=
rfl
@[simp]
lemma le_supr_apply_mk {ι : Type*} (U : ι → opens X) (i : ι) (x) (m) :
(le_supr U i) ⟨x, m⟩ = ⟨x, (_root_.le_supr U i : _) m⟩ :=
rfl
/--
The functor from open sets in `X` to `Top`,
realising each open set as a topological space itself.
-/
def to_Top (X : Top.{u}) : opens X ⥤ Top :=
{ obj := λ U, ⟨U, infer_instance⟩,
map := λ U V i, ⟨λ x, ⟨x.1, i.le x.2⟩,
(embedding.continuous_iff embedding_subtype_coe).2 continuous_induced_dom⟩ }
@[simp]
lemma to_Top_map (X : Top.{u}) {U V : opens X} {f : U ⟶ V} {x} {h} :
((to_Top X).map f) ⟨x, h⟩ = ⟨x, f.le h⟩ :=
rfl
/--
The inclusion map from an open subset to the whole space, as a morphism in `Top`.
-/
@[simps { fully_applied := ff }]
def inclusion {X : Top.{u}} (U : opens X) : (to_Top X).obj U ⟶ X :=
{ to_fun := _,
continuous_to_fun := continuous_subtype_coe }
lemma open_embedding {X : Top.{u}} (U : opens X) : open_embedding (inclusion U) :=
is_open.open_embedding_subtype_coe U.2
/--
The inclusion of the top open subset (i.e. the whole space) is an isomorphism.
-/
def inclusion_top_iso (X : Top.{u}) : (to_Top X).obj ⊤ ≅ X :=
{ hom := inclusion ⊤,
inv := ⟨λ x, ⟨x, trivial⟩, continuous_def.2 $ λ U ⟨S, hS, hSU⟩, hSU ▸ hS⟩ }
/-- `opens.map f` gives the functor from open sets in Y to open set in X,
given by taking preimages under f. -/
def map (f : X ⟶ Y) : opens Y ⥤ opens X :=
{ obj := λ U, ⟨ f ⁻¹' U, U.is_open.preimage f.continuous ⟩,
map := λ U V i, ⟨ ⟨ λ x h, i.le h ⟩ ⟩ }.
lemma map_coe (f : X ⟶ Y) (U : opens Y) :
↑((map f).obj U) = f ⁻¹' U :=
rfl
@[simp] lemma map_obj (f : X ⟶ Y) (U) (p) :
(map f).obj ⟨U, p⟩ = ⟨f ⁻¹' U, p.preimage f.continuous⟩ := rfl
@[simp] lemma map_id_obj (U : opens X) : (map (𝟙 X)).obj U = U :=
let ⟨_,_⟩ := U in rfl
@[simp] lemma map_id_obj' (U) (p) : (map (𝟙 X)).obj ⟨U, p⟩ = ⟨U, p⟩ :=
rfl
@[simp] lemma map_id_obj_unop (U : (opens X)ᵒᵖ) : (map (𝟙 X)).obj (unop U) = unop U :=
let ⟨_,_⟩ := U.unop in rfl
@[simp] lemma op_map_id_obj (U : (opens X)ᵒᵖ) : (map (𝟙 X)).op.obj U = U :=
by simp
/--
The inclusion `U ⟶ (map f).obj ⊤` as a morphism in the category of open sets.
-/
def le_map_top (f : X ⟶ Y) (U : opens X) : U ⟶ (map f).obj ⊤ :=
le_top U
@[simp] lemma map_comp_obj (f : X ⟶ Y) (g : Y ⟶ Z) (U) :
(map (f ≫ g)).obj U = (map f).obj ((map g).obj U) :=
rfl
@[simp] lemma map_comp_obj' (f : X ⟶ Y) (g : Y ⟶ Z) (U) (p) :
(map (f ≫ g)).obj ⟨U, p⟩ = (map f).obj ((map g).obj ⟨U, p⟩) :=
rfl
@[simp] lemma map_comp_map (f : X ⟶ Y) (g : Y ⟶ Z) {U V} (i : U ⟶ V) :
(map (f ≫ g)).map i = (map f).map ((map g).map i) :=
rfl
@[simp] lemma map_comp_obj_unop (f : X ⟶ Y) (g : Y ⟶ Z) (U) :
(map (f ≫ g)).obj (unop U) = (map f).obj ((map g).obj (unop U)) :=
rfl
@[simp] lemma op_map_comp_obj (f : X ⟶ Y) (g : Y ⟶ Z) (U) :
(map (f ≫ g)).op.obj U = (map f).op.obj ((map g).op.obj U) :=
rfl
lemma map_supr (f : X ⟶ Y) {ι : Type*} (U : ι → opens Y) :
(map f).obj (supr U) = supr ((map f).obj ∘ U) :=
begin
ext1, rw [supr_def, supr_def, map_obj],
dsimp, rw set.preimage_Union, refl,
end
section
variable (X)
/--
The functor `opens X ⥤ opens X` given by taking preimages under the identity function
is naturally isomorphic to the identity functor.
-/
@[simps]
def map_id : map (𝟙 X) ≅ 𝟭 (opens X) :=
{ hom := { app := λ U, eq_to_hom (map_id_obj U) },
inv := { app := λ U, eq_to_hom (map_id_obj U).symm } }
lemma map_id_eq : map (𝟙 X) = 𝟭 (opens X) :=
by { unfold map, congr, ext, refl, ext }
end
/--
The natural isomorphism between taking preimages under `f ≫ g`, and the composite
of taking preimages under `g`, then preimages under `f`.
-/
@[simps]
def map_comp (f : X ⟶ Y) (g : Y ⟶ Z) : map (f ≫ g) ≅ map g ⋙ map f :=
{ hom := { app := λ U, eq_to_hom (map_comp_obj f g U) },
inv := { app := λ U, eq_to_hom (map_comp_obj f g U).symm } }
lemma map_comp_eq (f : X ⟶ Y) (g : Y ⟶ Z) : map (f ≫ g) = map g ⋙ map f :=
rfl
/--
If two continuous maps `f g : X ⟶ Y` are equal,
then the functors `opens Y ⥤ opens X` they induce are isomorphic.
-/
-- We could make `f g` implicit here, but it's nice to be able to see when
-- they are the identity (often!)
def map_iso (f g : X ⟶ Y) (h : f = g) : map f ≅ map g :=
nat_iso.of_components (λ U, eq_to_iso (congr_fun (congr_arg functor.obj (congr_arg map h)) U) )
(by obviously)
lemma map_eq (f g : X ⟶ Y) (h : f = g) : map f = map g :=
by { unfold map, congr, ext, rw h, rw h, assumption' }
@[simp] lemma map_iso_refl (f : X ⟶ Y) (h) : map_iso f f h = iso.refl (map _) := rfl
@[simp] lemma map_iso_hom_app (f g : X ⟶ Y) (h : f = g) (U : opens Y) :
(map_iso f g h).hom.app U = eq_to_hom (congr_fun (congr_arg functor.obj (congr_arg map h)) U) :=
rfl
@[simp] lemma map_iso_inv_app (f g : X ⟶ Y) (h : f = g) (U : opens Y) :
(map_iso f g h).inv.app U =
eq_to_hom (congr_fun (congr_arg functor.obj (congr_arg map h.symm)) U) :=
rfl
/-- A homeomorphism of spaces gives an equivalence of categories of open sets.
TODO: define `order_iso.equivalence`, use it.
-/
@[simps] def map_map_iso {X Y : Top.{u}} (H : X ≅ Y) : opens Y ≌ opens X :=
{ functor := map H.hom,
inverse := map H.inv,
unit_iso := nat_iso.of_components (λ U, eq_to_iso (by simp [map, set.preimage_preimage]))
(by { intros _ _ _, simp }),
counit_iso := nat_iso.of_components (λ U, eq_to_iso (by simp [map, set.preimage_preimage]))
(by { intros _ _ _, simp }) }
end topological_space.opens
/--
An open map `f : X ⟶ Y` induces a functor `opens X ⥤ opens Y`.
-/
@[simps]
def is_open_map.functor {X Y : Top} {f : X ⟶ Y} (hf : is_open_map f) :
opens X ⥤ opens Y :=
{ obj := λ U, ⟨f '' U, hf U U.2⟩,
map := λ U V h, ⟨⟨set.image_subset _ h.down.down⟩⟩ }
/--
An open map `f : X ⟶ Y` induces an adjunction between `opens X` and `opens Y`.
-/
def is_open_map.adjunction {X Y : Top} {f : X ⟶ Y} (hf : is_open_map f) :
adjunction hf.functor (topological_space.opens.map f) :=
adjunction.mk_of_unit_counit
{ unit := { app := λ U, hom_of_le $ λ x hxU, ⟨x, hxU, rfl⟩ },
counit := { app := λ V, hom_of_le $ λ y ⟨x, hfxV, hxy⟩, hxy ▸ hfxV } }
instance is_open_map.functor_full_of_mono {X Y : Top} {f : X ⟶ Y} (hf : is_open_map f)
[H : mono f] : full hf.functor :=
{ preimage := λ U V i, hom_of_le (λ x hx, by
{ obtain ⟨y, hy, eq⟩ := i.le ⟨x, hx, rfl⟩, exact (Top.mono_iff_injective f).mp H eq ▸ hy }) }
instance is_open_map.functor_faithful {X Y : Top} {f : X ⟶ Y} (hf : is_open_map f) :
faithful hf.functor := {}
namespace topological_space.opens
open topological_space
@[simp] lemma open_embedding_obj_top {X : Top} (U : opens X) :
U.open_embedding.is_open_map.functor.obj ⊤ = U :=
by { ext1, exact set.image_univ.trans subtype.range_coe }
@[simp] lemma inclusion_map_eq_top {X : Top} (U : opens X) :
(opens.map U.inclusion).obj U = ⊤ :=
by { ext1, exact subtype.coe_preimage_self _ }
@[simp]
lemma adjunction_counit_app_self {X : Top} (U : opens X) :
U.open_embedding.is_open_map.adjunction.counit.app U = eq_to_hom (by simp) :=
by ext
lemma inclusion_top_functor (X : Top) :
(@opens.open_embedding X ⊤).is_open_map.functor =
map (inclusion_top_iso X).inv :=
begin
apply functor.hext, intro, abstract obj_eq { ext,
exact ⟨ λ ⟨⟨_,_⟩,h,rfl⟩, h, λ h, ⟨⟨x,trivial⟩,h,rfl⟩ ⟩ },
intros, apply subsingleton.helim, congr' 1,
iterate 2 {apply inclusion_top_functor.obj_eq},
end
lemma functor_obj_map_obj {X Y : Top} {f : X ⟶ Y} (hf : is_open_map f) (U : opens Y) :
hf.functor.obj ((opens.map f).obj U) = hf.functor.obj ⊤ ⊓ U :=
begin
ext, split,
{ rintros ⟨x, hx, rfl⟩, exact ⟨⟨x, trivial, rfl⟩, hx⟩ },
{ rintros ⟨⟨x, -, rfl⟩, hx⟩, exact ⟨x, hx, rfl⟩ }
end
@[simp] lemma functor_map_eq_inf {X : Top} (U V : opens X) :
U.open_embedding.is_open_map.functor.obj ((opens.map U.inclusion).obj V) = V ⊓ U :=
by { ext1, refine set.image_preimage_eq_inter_range.trans _, simpa }
lemma map_functor_eq' {X U : Top} (f : U ⟶ X) (hf : _root_.open_embedding f) (V) :
((opens.map f).obj $ hf.is_open_map.functor.obj V) = V :=
opens.ext $ set.preimage_image_eq _ hf.inj
@[simp] lemma map_functor_eq {X : Top} {U : opens X} (V : opens U) :
((opens.map U.inclusion).obj $ U.open_embedding.is_open_map.functor.obj V) = V :=
topological_space.opens.map_functor_eq' _ U.open_embedding V
@[simp] lemma adjunction_counit_map_functor {X : Top} {U : opens X} (V : opens U) :
U.open_embedding.is_open_map.adjunction.counit.app (U.open_embedding.is_open_map.functor.obj V)
= eq_to_hom (by { conv_rhs { rw ← V.map_functor_eq }, refl }) :=
by ext
end topological_space.opens
|
5df8148e0d4ebfce7b01e6a801a1765302f8f13c | 83c8119e3298c0bfc53fc195c41a6afb63d01513 | /library/init/algebra/ordered_group.lean | 6c16c9002f464bb2ef12e78d52f2398e43db1708 | [
"Apache-2.0"
] | permissive | anfelor/lean | 584b91c4e87a6d95f7630c2a93fb082a87319ed0 | 31cfc2b6bf7d674f3d0f73848b842c9c9869c9f1 | refs/heads/master | 1,610,067,141,310 | 1,585,992,232,000 | 1,585,992,232,000 | 251,683,543 | 0 | 0 | Apache-2.0 | 1,585,676,570,000 | 1,585,676,569,000 | null | UTF-8 | Lean | false | false | 20,457 | lean | /-
Copyright (c) 2016 Microsoft Corporation. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jeremy Avigad, Leonardo de Moura
-/
prelude
import init.algebra.order init.algebra.group
/- Make sure instances defined in this file have lower priority than the ones
defined for concrete structures -/
set_option default_priority 100
set_option old_structure_cmd true
universe u
class ordered_cancel_comm_monoid (α : Type u)
extends add_comm_monoid α, add_left_cancel_semigroup α,
add_right_cancel_semigroup α, partial_order α :=
(add_le_add_left : ∀ a b : α, a ≤ b → ∀ c : α, c + a ≤ c + b)
(le_of_add_le_add_left : ∀ a b c : α, a + b ≤ a + c → b ≤ c)
section ordered_cancel_comm_monoid
variable {α : Type u}
variable [s : ordered_cancel_comm_monoid α]
lemma add_le_add_left {a b : α} (h : a ≤ b) (c : α) : c + a ≤ c + b :=
@ordered_cancel_comm_monoid.add_le_add_left α s a b h c
lemma le_of_add_le_add_left {a b c : α} (h : a + b ≤ a + c) : b ≤ c :=
@ordered_cancel_comm_monoid.le_of_add_le_add_left α s a b c h
end ordered_cancel_comm_monoid
section ordered_cancel_comm_monoid
variable {α : Type u}
variable [ordered_cancel_comm_monoid α]
lemma add_lt_add_left {a b : α} (h : a < b) (c : α) : c + a < c + b :=
lt_of_le_not_le (add_le_add_left (le_of_lt h) _) $
mt le_of_add_le_add_left (not_le_of_gt h)
lemma lt_of_add_lt_add_left {a b c : α} (h : a + b < a + c) : b < c :=
lt_of_le_not_le (le_of_add_le_add_left (le_of_lt h)) $
mt (λ h, add_le_add_left h _) (not_le_of_gt h)
lemma add_le_add_right {a b : α} (h : a ≤ b) (c : α) : a + c ≤ b + c :=
add_comm c a ▸ add_comm c b ▸ add_le_add_left h c
theorem add_lt_add_right {a b : α} (h : a < b) (c : α) : a + c < b + c :=
begin
rw [add_comm a c, add_comm b c],
exact (add_lt_add_left h c)
end
lemma add_le_add {a b c d : α} (h₁ : a ≤ b) (h₂ : c ≤ d) : a + c ≤ b + d :=
le_trans (add_le_add_right h₁ c) (add_le_add_left h₂ b)
lemma le_add_of_nonneg_right {a b : α} (h : b ≥ 0) : a ≤ a + b :=
have a + b ≥ a + 0, from add_le_add_left h a,
by rwa add_zero at this
lemma le_add_of_nonneg_left {a b : α} (h : b ≥ 0) : a ≤ b + a :=
have 0 + a ≤ b + a, from add_le_add_right h a,
by rwa zero_add at this
lemma add_lt_add {a b c d : α} (h₁ : a < b) (h₂ : c < d) : a + c < b + d :=
lt_trans (add_lt_add_right h₁ c) (add_lt_add_left h₂ b)
lemma add_lt_add_of_le_of_lt {a b c d : α} (h₁ : a ≤ b) (h₂ : c < d) : a + c < b + d :=
lt_of_le_of_lt (add_le_add_right h₁ c) (add_lt_add_left h₂ b)
lemma add_lt_add_of_lt_of_le {a b c d : α} (h₁ : a < b) (h₂ : c ≤ d) : a + c < b + d :=
lt_of_lt_of_le (add_lt_add_right h₁ c) (add_le_add_left h₂ b)
lemma lt_add_of_pos_right (a : α) {b : α} (h : b > 0) : a < a + b :=
have a + 0 < a + b, from add_lt_add_left h a,
by rwa [add_zero] at this
lemma lt_add_of_pos_left (a : α) {b : α} (h : b > 0) : a < b + a :=
have 0 + a < b + a, from add_lt_add_right h a,
by rwa [zero_add] at this
lemma le_of_add_le_add_right {a b c : α} (h : a + b ≤ c + b) : a ≤ c :=
le_of_add_le_add_left
(show b + a ≤ b + c, begin rw [add_comm b a, add_comm b c], assumption end)
lemma lt_of_add_lt_add_right {a b c : α} (h : a + b < c + b) : a < c :=
lt_of_add_lt_add_left
(show b + a < b + c, begin rw [add_comm b a, add_comm b c], assumption end)
-- here we start using properties of zero.
lemma add_nonneg {a b : α} (ha : 0 ≤ a) (hb : 0 ≤ b) : 0 ≤ a + b :=
zero_add (0:α) ▸ (add_le_add ha hb)
lemma add_pos {a b : α} (ha : 0 < a) (hb : 0 < b) : 0 < a + b :=
zero_add (0:α) ▸ (add_lt_add ha hb)
lemma add_pos_of_pos_of_nonneg {a b : α} (ha : 0 < a) (hb : 0 ≤ b) : 0 < a + b :=
zero_add (0:α) ▸ (add_lt_add_of_lt_of_le ha hb)
lemma add_pos_of_nonneg_of_pos {a b : α} (ha : 0 ≤ a) (hb : 0 < b) : 0 < a + b :=
zero_add (0:α) ▸ (add_lt_add_of_le_of_lt ha hb)
lemma add_nonpos {a b : α} (ha : a ≤ 0) (hb : b ≤ 0) : a + b ≤ 0 :=
zero_add (0:α) ▸ (add_le_add ha hb)
lemma add_neg {a b : α} (ha : a < 0) (hb : b < 0) : a + b < 0 :=
zero_add (0:α) ▸ (add_lt_add ha hb)
lemma add_neg_of_neg_of_nonpos {a b : α} (ha : a < 0) (hb : b ≤ 0) : a + b < 0 :=
zero_add (0:α) ▸ (add_lt_add_of_lt_of_le ha hb)
lemma add_neg_of_nonpos_of_neg {a b : α} (ha : a ≤ 0) (hb : b < 0) : a + b < 0 :=
zero_add (0:α) ▸ (add_lt_add_of_le_of_lt ha hb)
lemma add_eq_zero_iff_eq_zero_and_eq_zero_of_nonneg_of_nonneg
{a b : α} (ha : 0 ≤ a) (hb : 0 ≤ b) : a + b = 0 ↔ a = 0 ∧ b = 0 :=
iff.intro
(assume hab : a + b = 0,
have ha' : a ≤ 0, from
calc
a = a + 0 : by rw add_zero
... ≤ a + b : add_le_add_left hb _
... = 0 : hab,
have haz : a = 0, from le_antisymm ha' ha,
have hb' : b ≤ 0, from
calc
b = 0 + b : by rw zero_add
... ≤ a + b : by exact add_le_add_right ha _
... = 0 : hab,
have hbz : b = 0, from le_antisymm hb' hb,
and.intro haz hbz)
(assume ⟨ha', hb'⟩,
by rw [ha', hb', add_zero])
lemma le_add_of_nonneg_of_le {a b c : α} (ha : 0 ≤ a) (hbc : b ≤ c) : b ≤ a + c :=
zero_add b ▸ add_le_add ha hbc
lemma le_add_of_le_of_nonneg {a b c : α} (hbc : b ≤ c) (ha : 0 ≤ a) : b ≤ c + a :=
add_zero b ▸ add_le_add hbc ha
lemma lt_add_of_pos_of_le {a b c : α} (ha : 0 < a) (hbc : b ≤ c) : b < a + c :=
zero_add b ▸ add_lt_add_of_lt_of_le ha hbc
lemma lt_add_of_le_of_pos {a b c : α} (hbc : b ≤ c) (ha : 0 < a) : b < c + a :=
add_zero b ▸ add_lt_add_of_le_of_lt hbc ha
lemma add_le_of_nonpos_of_le {a b c : α} (ha : a ≤ 0) (hbc : b ≤ c) : a + b ≤ c :=
zero_add c ▸ add_le_add ha hbc
lemma add_le_of_le_of_nonpos {a b c : α} (hbc : b ≤ c) (ha : a ≤ 0) : b + a ≤ c :=
add_zero c ▸ add_le_add hbc ha
lemma add_lt_of_neg_of_le {a b c : α} (ha : a < 0) (hbc : b ≤ c) : a + b < c :=
zero_add c ▸ add_lt_add_of_lt_of_le ha hbc
lemma add_lt_of_le_of_neg {a b c : α} (hbc : b ≤ c) (ha : a < 0) : b + a < c :=
add_zero c ▸ add_lt_add_of_le_of_lt hbc ha
lemma lt_add_of_nonneg_of_lt {a b c : α} (ha : 0 ≤ a) (hbc : b < c) : b < a + c :=
zero_add b ▸ add_lt_add_of_le_of_lt ha hbc
lemma lt_add_of_lt_of_nonneg {a b c : α} (hbc : b < c) (ha : 0 ≤ a) : b < c + a :=
add_zero b ▸ add_lt_add_of_lt_of_le hbc ha
lemma lt_add_of_pos_of_lt {a b c : α} (ha : 0 < a) (hbc : b < c) : b < a + c :=
zero_add b ▸ add_lt_add ha hbc
lemma lt_add_of_lt_of_pos {a b c : α} (hbc : b < c) (ha : 0 < a) : b < c + a :=
add_zero b ▸ add_lt_add hbc ha
lemma add_lt_of_nonpos_of_lt {a b c : α} (ha : a ≤ 0) (hbc : b < c) : a + b < c :=
zero_add c ▸ add_lt_add_of_le_of_lt ha hbc
lemma add_lt_of_lt_of_nonpos {a b c : α} (hbc : b < c) (ha : a ≤ 0) : b + a < c :=
add_zero c ▸ add_lt_add_of_lt_of_le hbc ha
lemma add_lt_of_neg_of_lt {a b c : α} (ha : a < 0) (hbc : b < c) : a + b < c :=
zero_add c ▸ add_lt_add ha hbc
lemma add_lt_of_lt_of_neg {a b c : α} (hbc : b < c) (ha : a < 0) : b + a < c :=
add_zero c ▸ add_lt_add hbc ha
end ordered_cancel_comm_monoid
class ordered_comm_group (α : Type u) extends add_comm_group α, partial_order α :=
(add_le_add_left : ∀ a b : α, a ≤ b → ∀ c : α, c + a ≤ c + b)
section ordered_comm_group
variable {α : Type u}
variable [ordered_comm_group α]
lemma ordered_comm_group.add_lt_add_left (a b : α) (h : a < b) (c : α) : c + a < c + b :=
begin
rw lt_iff_le_not_le at h ⊢,
split,
{ apply ordered_comm_group.add_le_add_left _ _ h.1 },
{ intro w,
have w : -c + (c + b) ≤ -c + (c + a) := ordered_comm_group.add_le_add_left _ _ w _,
simp only [add_zero, add_comm, add_left_neg, add_left_comm] at w,
exact h.2 w },
end
lemma ordered_comm_group.le_of_add_le_add_left {a b c : α} (h : a + b ≤ a + c) : b ≤ c :=
have -a + (a + b) ≤ -a + (a + c), from ordered_comm_group.add_le_add_left _ _ h _,
begin simp [neg_add_cancel_left] at this, assumption end
lemma ordered_comm_group.lt_of_add_lt_add_left {a b c : α} (h : a + b < a + c) : b < c :=
have -a + (a + b) < -a + (a + c), from ordered_comm_group.add_lt_add_left _ _ h _,
begin simp [neg_add_cancel_left] at this, assumption end
end ordered_comm_group
instance ordered_comm_group.to_ordered_cancel_comm_monoid (α : Type u) [s : ordered_comm_group α] : ordered_cancel_comm_monoid α :=
{ add_left_cancel := @add_left_cancel α _,
add_right_cancel := @add_right_cancel α _,
le_of_add_le_add_left := @ordered_comm_group.le_of_add_le_add_left α _,
..s }
section ordered_comm_group
variables {α : Type u} [ordered_comm_group α]
lemma neg_le_neg {a b : α} (h : a ≤ b) : -b ≤ -a :=
have 0 ≤ -a + b, from add_left_neg a ▸ add_le_add_left h (-a),
have 0 + -b ≤ -a + b + -b, from add_le_add_right this (-b),
by rwa [add_neg_cancel_right, zero_add] at this
lemma le_of_neg_le_neg {a b : α} (h : -b ≤ -a) : a ≤ b :=
suffices -(-a) ≤ -(-b), from
begin simp [neg_neg] at this, assumption end,
neg_le_neg h
lemma nonneg_of_neg_nonpos {a : α} (h : -a ≤ 0) : 0 ≤ a :=
have -a ≤ -0, by rwa neg_zero,
le_of_neg_le_neg this
lemma neg_nonpos_of_nonneg {a : α} (h : 0 ≤ a) : -a ≤ 0 :=
have -a ≤ -0, from neg_le_neg h,
by rwa neg_zero at this
lemma nonpos_of_neg_nonneg {a : α} (h : 0 ≤ -a) : a ≤ 0 :=
have -0 ≤ -a, by rwa neg_zero,
le_of_neg_le_neg this
lemma neg_nonneg_of_nonpos {a : α} (h : a ≤ 0) : 0 ≤ -a :=
have -0 ≤ -a, from neg_le_neg h,
by rwa neg_zero at this
lemma neg_lt_neg {a b : α} (h : a < b) : -b < -a :=
have 0 < -a + b, from add_left_neg a ▸ add_lt_add_left h (-a),
have 0 + -b < -a + b + -b, from add_lt_add_right this (-b),
by rwa [add_neg_cancel_right, zero_add] at this
lemma lt_of_neg_lt_neg {a b : α} (h : -b < -a) : a < b :=
neg_neg a ▸ neg_neg b ▸ neg_lt_neg h
lemma pos_of_neg_neg {a : α} (h : -a < 0) : 0 < a :=
have -a < -0, by rwa neg_zero,
lt_of_neg_lt_neg this
lemma neg_neg_of_pos {a : α} (h : 0 < a) : -a < 0 :=
have -a < -0, from neg_lt_neg h,
by rwa neg_zero at this
lemma neg_of_neg_pos {a : α} (h : 0 < -a) : a < 0 :=
have -0 < -a, by rwa neg_zero,
lt_of_neg_lt_neg this
lemma neg_pos_of_neg {a : α} (h : a < 0) : 0 < -a :=
have -0 < -a, from neg_lt_neg h,
by rwa neg_zero at this
lemma le_neg_of_le_neg {a b : α} (h : a ≤ -b) : b ≤ -a :=
begin
have h := neg_le_neg h,
rwa neg_neg at h
end
lemma neg_le_of_neg_le {a b : α} (h : -a ≤ b) : -b ≤ a :=
begin
have h := neg_le_neg h,
rwa neg_neg at h
end
lemma lt_neg_of_lt_neg {a b : α} (h : a < -b) : b < -a :=
begin
have h := neg_lt_neg h,
rwa neg_neg at h
end
lemma neg_lt_of_neg_lt {a b : α} (h : -a < b) : -b < a :=
begin
have h := neg_lt_neg h,
rwa neg_neg at h
end
lemma sub_nonneg_of_le {a b : α} (h : b ≤ a) : 0 ≤ a - b :=
begin
have h := add_le_add_right h (-b),
rwa add_right_neg at h
end
lemma le_of_sub_nonneg {a b : α} (h : 0 ≤ a - b) : b ≤ a :=
begin
have h := add_le_add_right h b,
rwa [sub_add_cancel, zero_add] at h
end
lemma sub_nonpos_of_le {a b : α} (h : a ≤ b) : a - b ≤ 0 :=
begin
have h := add_le_add_right h (-b),
rwa add_right_neg at h
end
lemma le_of_sub_nonpos {a b : α} (h : a - b ≤ 0) : a ≤ b :=
begin
have h := add_le_add_right h b,
rwa [sub_add_cancel, zero_add] at h
end
lemma sub_pos_of_lt {a b : α} (h : b < a) : 0 < a - b :=
begin
have h := add_lt_add_right h (-b),
rwa add_right_neg at h
end
lemma lt_of_sub_pos {a b : α} (h : 0 < a - b) : b < a :=
begin
have h := add_lt_add_right h b,
rwa [sub_add_cancel, zero_add] at h
end
lemma sub_neg_of_lt {a b : α} (h : a < b) : a - b < 0 :=
begin
have h := add_lt_add_right h (-b),
rwa add_right_neg at h
end
lemma lt_of_sub_neg {a b : α} (h : a - b < 0) : a < b :=
begin
have h := add_lt_add_right h b,
rwa [sub_add_cancel, zero_add] at h
end
lemma add_le_of_le_neg_add {a b c : α} (h : b ≤ -a + c) : a + b ≤ c :=
begin
have h := add_le_add_left h a,
rwa add_neg_cancel_left at h
end
lemma le_neg_add_of_add_le {a b c : α} (h : a + b ≤ c) : b ≤ -a + c :=
begin
have h := add_le_add_left h (-a),
rwa neg_add_cancel_left at h
end
lemma add_le_of_le_sub_left {a b c : α} (h : b ≤ c - a) : a + b ≤ c :=
begin
have h := add_le_add_left h a,
rwa [← add_sub_assoc, add_comm a c, add_sub_cancel] at h
end
lemma le_sub_left_of_add_le {a b c : α} (h : a + b ≤ c) : b ≤ c - a :=
begin
have h := add_le_add_right h (-a),
rwa [add_comm a b, add_neg_cancel_right] at h
end
lemma add_le_of_le_sub_right {a b c : α} (h : a ≤ c - b) : a + b ≤ c :=
begin
have h := add_le_add_right h b,
rwa sub_add_cancel at h
end
lemma le_sub_right_of_add_le {a b c : α} (h : a + b ≤ c) : a ≤ c - b :=
begin
have h := add_le_add_right h (-b),
rwa add_neg_cancel_right at h
end
lemma le_add_of_neg_add_le {a b c : α} (h : -b + a ≤ c) : a ≤ b + c :=
begin
have h := add_le_add_left h b,
rwa add_neg_cancel_left at h
end
lemma neg_add_le_of_le_add {a b c : α} (h : a ≤ b + c) : -b + a ≤ c :=
begin
have h := add_le_add_left h (-b),
rwa neg_add_cancel_left at h
end
lemma le_add_of_sub_left_le {a b c : α} (h : a - b ≤ c) : a ≤ b + c :=
begin
have h := add_le_add_right h b,
rwa [sub_add_cancel, add_comm] at h
end
lemma sub_left_le_of_le_add {a b c : α} (h : a ≤ b + c) : a - b ≤ c :=
begin
have h := add_le_add_right h (-b),
rwa [add_comm b c, add_neg_cancel_right] at h
end
lemma le_add_of_sub_right_le {a b c : α} (h : a - c ≤ b) : a ≤ b + c :=
begin
have h := add_le_add_right h c,
rwa sub_add_cancel at h
end
lemma sub_right_le_of_le_add {a b c : α} (h : a ≤ b + c) : a - c ≤ b :=
begin
have h := add_le_add_right h (-c),
rwa add_neg_cancel_right at h
end
lemma le_add_of_neg_add_le_left {a b c : α} (h : -b + a ≤ c) : a ≤ b + c :=
begin
rw add_comm at h,
exact le_add_of_sub_left_le h
end
lemma neg_add_le_left_of_le_add {a b c : α} (h : a ≤ b + c) : -b + a ≤ c :=
begin
rw add_comm,
exact sub_left_le_of_le_add h
end
lemma le_add_of_neg_add_le_right {a b c : α} (h : -c + a ≤ b) : a ≤ b + c :=
begin
rw add_comm at h,
exact le_add_of_sub_right_le h
end
lemma neg_add_le_right_of_le_add {a b c : α} (h : a ≤ b + c) : -c + a ≤ b :=
begin
rw add_comm at h,
apply neg_add_le_left_of_le_add h
end
lemma le_add_of_neg_le_sub_left {a b c : α} (h : -a ≤ b - c) : c ≤ a + b :=
le_add_of_neg_add_le_left (add_le_of_le_sub_right h)
lemma neg_le_sub_left_of_le_add {a b c : α} (h : c ≤ a + b) : -a ≤ b - c :=
begin
have h := le_neg_add_of_add_le (sub_left_le_of_le_add h),
rwa add_comm at h
end
lemma le_add_of_neg_le_sub_right {a b c : α} (h : -b ≤ a - c) : c ≤ a + b :=
le_add_of_sub_right_le (add_le_of_le_sub_left h)
lemma neg_le_sub_right_of_le_add {a b c : α} (h : c ≤ a + b) : -b ≤ a - c :=
le_sub_left_of_add_le (sub_right_le_of_le_add h)
lemma sub_le_of_sub_le {a b c : α} (h : a - b ≤ c) : a - c ≤ b :=
sub_left_le_of_le_add (le_add_of_sub_right_le h)
lemma sub_le_sub_left {a b : α} (h : a ≤ b) (c : α) : c - b ≤ c - a :=
add_le_add_left (neg_le_neg h) c
lemma sub_le_sub_right {a b : α} (h : a ≤ b) (c : α) : a - c ≤ b - c :=
add_le_add_right h (-c)
lemma sub_le_sub {a b c d : α} (hab : a ≤ b) (hcd : c ≤ d) : a - d ≤ b - c :=
add_le_add hab (neg_le_neg hcd)
lemma add_lt_of_lt_neg_add {a b c : α} (h : b < -a + c) : a + b < c :=
begin
have h := add_lt_add_left h a,
rwa add_neg_cancel_left at h
end
lemma lt_neg_add_of_add_lt {a b c : α} (h : a + b < c) : b < -a + c :=
begin
have h := add_lt_add_left h (-a),
rwa neg_add_cancel_left at h
end
lemma add_lt_of_lt_sub_left {a b c : α} (h : b < c - a) : a + b < c :=
begin
have h := add_lt_add_left h a,
rwa [← add_sub_assoc, add_comm a c, add_sub_cancel] at h
end
lemma lt_sub_left_of_add_lt {a b c : α} (h : a + b < c) : b < c - a :=
begin
have h := add_lt_add_right h (-a),
rwa [add_comm a b, add_neg_cancel_right] at h
end
lemma add_lt_of_lt_sub_right {a b c : α} (h : a < c - b) : a + b < c :=
begin
have h := add_lt_add_right h b,
rwa sub_add_cancel at h
end
lemma lt_sub_right_of_add_lt {a b c : α} (h : a + b < c) : a < c - b :=
begin
have h := add_lt_add_right h (-b),
rwa add_neg_cancel_right at h
end
lemma lt_add_of_neg_add_lt {a b c : α} (h : -b + a < c) : a < b + c :=
begin
have h := add_lt_add_left h b,
rwa add_neg_cancel_left at h
end
lemma neg_add_lt_of_lt_add {a b c : α} (h : a < b + c) : -b + a < c :=
begin
have h := add_lt_add_left h (-b),
rwa neg_add_cancel_left at h
end
lemma lt_add_of_sub_left_lt {a b c : α} (h : a - b < c) : a < b + c :=
begin
have h := add_lt_add_right h b,
rwa [sub_add_cancel, add_comm] at h
end
lemma sub_left_lt_of_lt_add {a b c : α} (h : a < b + c) : a - b < c :=
begin
have h := add_lt_add_right h (-b),
rwa [add_comm b c, add_neg_cancel_right] at h
end
lemma lt_add_of_sub_right_lt {a b c : α} (h : a - c < b) : a < b + c :=
begin
have h := add_lt_add_right h c,
rwa sub_add_cancel at h
end
lemma sub_right_lt_of_lt_add {a b c : α} (h : a < b + c) : a - c < b :=
begin
have h := add_lt_add_right h (-c),
rwa add_neg_cancel_right at h
end
lemma lt_add_of_neg_add_lt_left {a b c : α} (h : -b + a < c) : a < b + c :=
begin
rw add_comm at h,
exact lt_add_of_sub_left_lt h
end
lemma neg_add_lt_left_of_lt_add {a b c : α} (h : a < b + c) : -b + a < c :=
begin
rw add_comm,
exact sub_left_lt_of_lt_add h
end
lemma lt_add_of_neg_add_lt_right {a b c : α} (h : -c + a < b) : a < b + c :=
begin
rw add_comm at h,
exact lt_add_of_sub_right_lt h
end
lemma neg_add_lt_right_of_lt_add {a b c : α} (h : a < b + c) : -c + a < b :=
begin
rw add_comm at h,
apply neg_add_lt_left_of_lt_add h
end
lemma lt_add_of_neg_lt_sub_left {a b c : α} (h : -a < b - c) : c < a + b :=
lt_add_of_neg_add_lt_left (add_lt_of_lt_sub_right h)
lemma neg_lt_sub_left_of_lt_add {a b c : α} (h : c < a + b) : -a < b - c :=
begin
have h := lt_neg_add_of_add_lt (sub_left_lt_of_lt_add h),
rwa add_comm at h
end
lemma lt_add_of_neg_lt_sub_right {a b c : α} (h : -b < a - c) : c < a + b :=
lt_add_of_sub_right_lt (add_lt_of_lt_sub_left h)
lemma neg_lt_sub_right_of_lt_add {a b c : α} (h : c < a + b) : -b < a - c :=
lt_sub_left_of_add_lt (sub_right_lt_of_lt_add h)
lemma sub_lt_of_sub_lt {a b c : α} (h : a - b < c) : a - c < b :=
sub_left_lt_of_lt_add (lt_add_of_sub_right_lt h)
lemma sub_lt_sub_left {a b : α} (h : a < b) (c : α) : c - b < c - a :=
add_lt_add_left (neg_lt_neg h) c
lemma sub_lt_sub_right {a b : α} (h : a < b) (c : α) : a - c < b - c :=
add_lt_add_right h (-c)
lemma sub_lt_sub {a b c d : α} (hab : a < b) (hcd : c < d) : a - d < b - c :=
add_lt_add hab (neg_lt_neg hcd)
lemma sub_lt_sub_of_le_of_lt {a b c d : α} (hab : a ≤ b) (hcd : c < d) : a - d < b - c :=
add_lt_add_of_le_of_lt hab (neg_lt_neg hcd)
lemma sub_lt_sub_of_lt_of_le {a b c d : α} (hab : a < b) (hcd : c ≤ d) : a - d < b - c :=
add_lt_add_of_lt_of_le hab (neg_le_neg hcd)
lemma sub_le_self (a : α) {b : α} (h : b ≥ 0) : a - b ≤ a :=
calc
a - b = a + -b : rfl
... ≤ a + 0 : add_le_add_left (neg_nonpos_of_nonneg h) _
... = a : by rw add_zero
lemma sub_lt_self (a : α) {b : α} (h : b > 0) : a - b < a :=
calc
a - b = a + -b : rfl
... < a + 0 : add_lt_add_left (neg_neg_of_pos h) _
... = a : by rw add_zero
lemma add_le_add_three {a b c d e f : α} (h₁ : a ≤ d) (h₂ : b ≤ e) (h₃ : c ≤ f) :
a + b + c ≤ d + e + f :=
begin
apply le_trans,
apply add_le_add,
apply add_le_add,
assumption',
apply le_refl
end
end ordered_comm_group
class decidable_linear_ordered_comm_group (α : Type u)
extends add_comm_group α, decidable_linear_order α :=
(add_le_add_left : ∀ a b : α, a ≤ b → ∀ c : α, c + a ≤ c + b)
instance decidable_linear_ordered_comm_group.to_ordered_comm_group (α : Type u)
[s : decidable_linear_ordered_comm_group α] : ordered_comm_group α :=
{ add := s.add, ..s }
class decidable_linear_ordered_cancel_comm_monoid (α : Type u)
extends ordered_cancel_comm_monoid α, decidable_linear_order α
lemma decidable_linear_ordered_comm_group.add_lt_add_left {α} [decidable_linear_ordered_comm_group α]
(a b : α) (h : a < b) (c : α) : c + a < c + b :=
ordered_comm_group.add_lt_add_left a b h c
|
7475bfeaade604c7a3342a51cddc78a137ac8619 | c055f4b7c29cf1aac2223bd8c1ac8d181a7c6447 | /src/categories/universal/types/default.lean | 410e221ee367de1ebd1b76cdf375fd7730d573cf | [
"Apache-2.0"
] | permissive | rwbarton/lean-category-theory-pr | 77207b6674eeec1e258ec85dea58f3bff8d27065 | 591847d70c6a11c4d5561cd0eaf69b1fe85a70ab | refs/heads/master | 1,584,595,111,303 | 1,528,029,041,000 | 1,528,029,041,000 | 135,919,126 | 0 | 0 | null | 1,528,041,805,000 | 1,528,041,805,000 | null | UTF-8 | Lean | false | false | 11,040 | lean | import ...types
import ..instances
open categories.universal
open categories.isomorphism
namespace categories.types
universe u
instance Types_has_Products : has_Products (Type u) :=
{ product := λ I φ, { product := Π i : I, φ i,
projection := λ i x, x i,
map := λ Z f z i, f i z,
factorisation := begin
-- `obviously'` says:
intros,
refl
end,
uniqueness := begin
-- `obviously'` says:
intros,
apply funext,
intros,
apply funext,
intros,
simp only [funext_simp] at *,
solve_by_elim {discharger := `[cc]},
end } }
instance Types_has_Coproducts : has_Coproducts (Type u) :=
{ coproduct := λ I φ, { coproduct := Σ i : I, φ i,
inclusion := λ i x, ⟨ i, x ⟩,
map := λ Z f p, f p.1 p.2,
factorisation := begin
-- `obviously'` says:
intros,
refl
end,
uniqueness := begin
-- `obviously'` says:
intros,
apply funext,
intros,
automatic_induction,
dsimp,
dsimp at *,
simp only [funext_simp] at *,
solve_by_elim {discharger := `[cc]},
end } }
-- Even though this can be automatically generated from `Types_has_Products`, this is a cleaner version.
instance Types_has_BinaryProducts : has_BinaryProducts.{u+1 u} (Type u) :=
{ binary_product := λ X Y, { product := X × Y,
left_projection := prod.fst,
right_projection := prod.snd,
map := λ _ f g z, (f z, g z),
left_factorisation := begin
-- `obviously'` says:
intros,
refl
end,
right_factorisation := begin
-- `obviously'` says:
intros,
refl
end,
uniqueness := begin
-- `obviously'` says:
intros,
apply funext,
intros,
apply pairs_equal,
simp only [funext_simp] at *,
solve_by_elim {discharger := `[cc]},
simp only [funext_simp] at *,
solve_by_elim {discharger := `[cc]},
end } }
instance Types_has_BinaryCoproducts : has_BinaryCoproducts.{u+1 u} (Type u) :=
{ binary_coproduct := λ X Y, { coproduct := X ⊕ Y,
left_inclusion := sum.inl,
right_inclusion := sum.inr,
map := λ _ f g z, sum.cases_on z f g,
left_factorisation := begin
-- `obviously'` says:
intros,
refl
end,
right_factorisation := begin
-- `obviously'` says:
intros,
refl
end,
uniqueness := λ Z f g lw rw, begin
-- `obviously'` says (with a little help!):
apply funext,
intros,
simp only [funext_simp] at *,
cases x,
solve_by_elim {discharger := `[cc]},
solve_by_elim {discharger := `[cc]},
end } }
instance Types_has_Equalizers : has_Equalizers.{u+1 u} (Type u) :=
{ equalizer := λ α β f g, { equalizer := {x : α // f x = g x},
inclusion := λ x, x.val,
map := λ γ k h g, ⟨ k g, begin
-- `obviously'` says:
simp only [funext_simp] at *,
solve_by_elim {discharger := `[cc]},
end ⟩,
factorisation := begin
-- `obviously'` says:
intros,
refl
end,
witness := begin
-- `obviously'` says:
apply funext,
intros,
automatic_induction,
dsimp,
solve_by_elim {discharger := `[cc]},
end,
uniqueness := begin
-- `obviously'` says:
intros,
apply funext,
intros,
apply subtype.eq,
dsimp at *,
simp only [funext_simp] at *,
solve_by_elim {discharger := `[cc]},
end } }
@[semiapplicable] lemma constant_on_quotient {α β : Type u} (f g : α → β) {Z : Type u} (k : β → Z) (x y : β) (h : eqv_gen (λ (x y : β), ∃ (a : α), f a = x ∧ g a = y) x y) (w : ∀ (a : α), k (f a) = k (g a)) : k x = k y :=
begin
induction h,
-- obviously' says:
{ cases h_a,
cases h_a_h,
induction h_a_h_right, induction h_a_h_left,
solve_by_elim {discharger := `[cc]} },
{ refl },
{ solve_by_elim {discharger := `[cc]} },
{ solve_by_elim {discharger := `[cc]} },
end
instance Types_has_Coequalizers : has_Coequalizers.{u+1 u} (Type u) :=
{ coequalizer := λ α β f g, by letI s := eqv_gen.setoid (λ x y, ∃ a : α, f a = x ∧ g a = y);
exact { coequalizer := quotient s,
projection := begin
-- `obviously'` says:
apply quotient.mk
end,
map := λ Z k w, quotient.lift k begin /- `obviously'` says: -/ intros, simp only [funext_simp] at *, apply categories.types.constant_on_quotient ; assumption end,
factorisation := begin
-- `obviously'` says:
intros,
refl
end,
witness := begin
-- `obviously'` says:
apply funext,
intros,
apply quotient.sound,
apply eqv_gen.rel,
fsplit,
solve_by_elim {discharger := `[cc]},
fsplit,
refl,
refl
end,
uniqueness := begin
-- `obviously'` says:
---
intros,
apply funext,
intros,
induction x,
simp only [funext_simp] at *,
solve_by_elim {discharger := `[cc]},
refl
---
end } }
end categories.types |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.