Theory Field_ZF

(*
This file is a part of IsarMathLib -
a library of formalized mathematics for Isabelle/Isar.
Copyright (C) 2005, 2006 Slawomir Kolodynski
This program is free software; Redistribution and use in source and binary forms,
with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.
3. The name of the author may not be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*)section‹Fields - introduction›theoryField_ZFimportsRing_ZFbegintext{*This theory covers basic facts about fields.*}subsection{*Definition and basic properties*}text{*In this section we define what is a field and list the basic properties
of fields. *}text{*Field is a notrivial commutative ring such that all
non-zero elements have an inverse. We define the notion of being a field as
a statement about three sets. The first set, denoted @{text "K"} is the
carrier of the field. The second set, denoted @{text "A"} represents the
additive operation on @{text "K"} (recall that in ZF set theory functions
are sets). The third set @{text "M"} represents the multiplicative operation
on @{text "K"}.*}definition"IsAfield(K,A,M) ≡
(IsAring(K,A,M) ∧ (M {is commutative on} K) ∧
TheNeutralElement(K,A) ≠ TheNeutralElement(K,M) ∧
(∀a∈K. a≠TheNeutralElement(K,A)⟶
(∃b∈K. M`⟨a,b⟩ = TheNeutralElement(K,M))))"text{*The @{text "field0"} context extends the @{text "ring0"}
context adding field-related assumptions and notation related to the
multiplicative inverse. *}localefield0=ring0KAMforKAM+assumesmult_commute:"M {is commutative on} K"assumesnot_triv:"𝟬 ≠ 𝟭"assumesinv_exists:"∀a∈K. a≠𝟬 ⟶ (∃b∈K. a⋅b = 𝟭)"fixesnon_zero("K⇩0")definesnon_zero_def[simp]:"K⇩0 ≡ K-{𝟬}"fixesinv("_¯ "[96]97)definesinv_def[simp]:"a¯ ≡ GroupInv(K⇩0,restrict(M,K⇩0×K⇩0))`(a)"text{*The next lemma assures us that we are talking fields
in the @{text "field0"} context.*}lemma(infield0)Field_ZF_1_L1:shows"IsAfield(K,A,M)"usingringAssummult_commutenot_trivinv_existsIsAfield_defbysimptext{*We can use theorems proven in the @{text "field0"} context whenever we
talk about a field.*}lemmafield_field0:assumes"IsAfield(K,A,M)"shows"field0(K,A,M)"usingassmsIsAfield_deffield0_axioms.introring0_deffield0_defbysimptext{*Let's have an explicit statement that the multiplication
in fields is commutative.*}lemma(infield0)field_mult_comm:assumes"a∈K""b∈K"shows"a⋅b = b⋅a"usingmult_commuteassmsIsCommutative_defbysimptext{*Fields do not have zero divisors.*}lemma(infield0)field_has_no_zero_divs:shows"HasNoZeroDivs(K,A,M)"proof-{fixabassumeA1:"a∈K""b∈K"andA2:"a⋅b = 𝟬"andA3:"b≠𝟬"frominv_existsA1A3obtaincwhereI:"c∈K"andII:"b⋅c = 𝟭"byautofromA2have"a⋅b⋅c = 𝟬⋅c"bysimpwithA1Ihave"a⋅(b⋅c) = 𝟬"usingRing_ZF_1_L11Ring_ZF_1_L6bysimpwithA1IIhave"a=𝟬 "usingRing_ZF_1_L3bysimp}thenhave"∀a∈K.∀b∈K. a⋅b = 𝟬 ⟶ a=𝟬 ∨ b=𝟬"byautothenshow?thesisusingHasNoZeroDivs_defbyautoqedtext{*$K_0$ (the set of nonzero field elements is closed with respect
to multiplication.*}lemma(infield0)Field_ZF_1_L2:shows"K⇩0 {is closed under} M"usingRing_ZF_1_L4field_has_no_zero_divsRing_ZF_1_L12IsOpClosed_defbyautotext{*Any nonzero element has a right inverse that is nonzero.*}lemma(infield0)Field_ZF_1_L3:assumesA1:"a∈K⇩0"shows"∃b∈K⇩0. a⋅b = 𝟭"proof-frominv_existsA1obtainbwhere"b∈K"and"a⋅b = 𝟭"byautowithnot_trivA1show"∃b∈K⇩0. a⋅b = 𝟭"usingRing_ZF_1_L6byautoqedtext{*If we remove zero, the field with multiplication
becomes a group and we can use all theorems proven in
@{text "group0"} context.*}theorem(infield0)Field_ZF_1_L4:shows"IsAgroup(K⇩0,restrict(M,K⇩0×K⇩0))""group0(K⇩0,restrict(M,K⇩0×K⇩0))""𝟭 = TheNeutralElement(K⇩0,restrict(M,K⇩0×K⇩0))"proof-let?f="restrict(M,K⇩0×K⇩0)"have"M {is associative on} K""K⇩0 ⊆ K""K⇩0 {is closed under} M"usingField_ZF_1_L1IsAfield_defIsAring_defIsAgroup_defIsAmonoid_defField_ZF_1_L2byautothenhave"?f {is associative on} K⇩0"usingfunc_ZF_4_L3bysimpmoreoverfromnot_trivhaveI:"𝟭∈K⇩0 ∧ (∀a∈K⇩0. ?f`⟨𝟭,a⟩ = a ∧ ?f`⟨a,𝟭⟩ = a)"usingRing_ZF_1_L2Ring_ZF_1_L3byautothenhave"∃n∈K⇩0. ∀a∈K⇩0. ?f`⟨n,a⟩ = a ∧ ?f`⟨a,n⟩ = a"byblastultimatelyhaveII:"IsAmonoid(K⇩0,?f)"usingIsAmonoid_defbysimpthenhave"monoid0(K⇩0,?f)"usingmonoid0_defbysimpmoreovernoteIultimatelyshow"𝟭 = TheNeutralElement(K⇩0,?f)"by(rulemonoid0.group0_1_L4)thenhave"∀a∈K⇩0.∃b∈K⇩0. ?f`⟨a,b⟩ = TheNeutralElement(K⇩0,?f)"usingField_ZF_1_L3byautowithIIshow"IsAgroup(K⇩0,?f)"by(ruledefinition_of_group)thenshow"group0(K⇩0,?f)"usinggroup0_defbysimpqedtext{*The inverse of a nonzero field element is nonzero.*}lemma(infield0)Field_ZF_1_L5:assumesA1:"a∈K""a≠𝟬"shows"a¯ ∈ K⇩0""(a¯)⇧2 ∈ K⇩0""a¯ ∈ K""a¯ ≠ 𝟬"proof-fromA1have"a ∈ K⇩0"bysimpthenshow"a¯ ∈ K⇩0"usingField_ZF_1_L4group0.inverse_in_groupbyautothenshow"(a¯)⇧2 ∈ K⇩0""a¯ ∈ K""a¯ ≠ 𝟬"usingField_ZF_1_L2IsOpClosed_defbyautoqedtext{*The inverse is really the inverse.*}lemma(infield0)Field_ZF_1_L6:assumesA1:"a∈K""a≠𝟬"shows"a⋅a¯ = 𝟭""a¯⋅a = 𝟭"proof-let?f="restrict(M,K⇩0×K⇩0)"fromA1have"group0(K⇩0,?f)""a ∈ K⇩0"usingField_ZF_1_L4byautothenhave"?f`⟨a,GroupInv(K⇩0, ?f)`(a)⟩ = TheNeutralElement(K⇩0,?f) ∧
?f`⟨GroupInv(K⇩0,?f)`(a),a⟩ = TheNeutralElement(K⇩0, ?f)"by(rulegroup0.group0_2_L6)withA1show"a⋅a¯ = 𝟭""a¯⋅a = 𝟭"usingField_ZF_1_L5Field_ZF_1_L4byautoqedtext{*A lemma with two field elements and cancelling.*}lemma(infield0)Field_ZF_1_L7:assumes"a∈K""b∈K""b≠𝟬"shows"a⋅b⋅b¯ = a""a⋅b¯⋅b = a"usingassmsField_ZF_1_L5Ring_ZF_1_L11Field_ZF_1_L6Ring_ZF_1_L3byautosubsection{*Equations and identities*}text{*This section deals with more specialized identities that are true in
fields.*}text{*$a/(a^2) = 1/a$.*}lemma(infield0)Field_ZF_2_L1:assumesA1:"a∈K""a≠𝟬"shows"a⋅(a¯)⇧2 = a¯"proof-have"a⋅(a¯)⇧2 = a⋅(a¯⋅a¯)"bysimpalsofromA1have"… = (a⋅a¯)⋅a¯"usingField_ZF_1_L5Ring_ZF_1_L11bysimpalsofromA1have"… = a¯"usingField_ZF_1_L6Field_ZF_1_L5Ring_ZF_1_L3bysimpfinallyshow"a⋅(a¯)⇧2 = a¯"bysimpqedtext{*If we multiply two different numbers by a nonzero number, the results
will be different.*}lemma(infield0)Field_ZF_2_L2:assumes"a∈K""b∈K""c∈K""a≠b""c≠𝟬"shows"a⋅c¯ ≠ b⋅c¯"usingassmsfield_has_no_zero_divsField_ZF_1_L5Ring_ZF_1_L12Bbysimptext{*We can put a nonzero factor on the other side of non-identity
(is this the best way to call it?) changing it to the inverse.*}lemma(infield0)Field_ZF_2_L3:assumesA1:"a∈K""b∈K""b≠𝟬""c∈K"andA2:"a⋅b ≠ c"shows"a ≠ c⋅b¯"proof-fromA1A2have"a⋅b⋅b¯ ≠ c⋅b¯"usingRing_ZF_1_L4Field_ZF_2_L2bysimpwithA1show"a ≠ c⋅b¯"usingField_ZF_1_L7bysimpqedtext{*If if the inverse of $b$ is different than $a$, then the
inverse of $a$ is different than $b$.*}lemma(infield0)Field_ZF_2_L4:assumes"a∈K""a≠𝟬"and"b¯ ≠ a"shows"a¯ ≠ b"usingassmsField_ZF_1_L4group0.group0_2_L11Bbysimptext{*An identity with two field elements, one and an inverse.*}lemma(infield0)Field_ZF_2_L5:assumes"a∈K""b∈K""b≠𝟬"shows"(𝟭 \<ra> a⋅b)⋅b¯ = a \<ra> b¯"usingassmsRing_ZF_1_L4Field_ZF_1_L5Ring_ZF_1_L2ring_oper_distrField_ZF_1_L7Ring_ZF_1_L3bysimptext{*An identity with three field elements, inverse and cancelling.*}lemma(infield0)Field_ZF_2_L6:assumesA1:"a∈K""b∈K""b≠𝟬""c∈K"shows"a⋅b⋅(c⋅b¯) = a⋅c"proof-fromA1haveT:"a⋅b ∈ K""b¯ ∈ K"usingRing_ZF_1_L4Field_ZF_1_L5byautowithmult_commuteA1have"a⋅b⋅(c⋅b¯) = a⋅b⋅(b¯⋅c)"usingIsCommutative_defbysimpmoreoverfromA1Thave"a⋅b ∈ K""b¯ ∈ K""c∈K"byautothenhave"a⋅b⋅b¯⋅c = a⋅b⋅(b¯⋅c)"by(ruleRing_ZF_1_L11)ultimatelyhave"a⋅b⋅(c⋅b¯) = a⋅b⋅b¯⋅c"bysimpwithA1show"a⋅b⋅(c⋅b¯) = a⋅c"usingField_ZF_1_L7bysimpqedsubsection{*1/0=0*}text{* In ZF if $f: X\rightarrow Y$ and $x\notin X$ we have $f(x)=\emptyset$.
Since $\emptyset$ (the empty set) in ZF is the same as zero of natural numbers we
can claim that $1/0=0$ in certain sense. In this section we prove a theorem that
makes makes it explicit.*}text{*The next locale extends the @{text "field0"} locale to introduce notation
for division operation.*}localefieldd=field0+fixesdivisiondefinesdivision_def[simp]:"division ≡ {⟨p,fst(p)⋅snd(p)¯⟩. p∈K×K⇩0}"fixesfdiv(infixl"\<fd>"95)definesfdiv_def[simp]:"x\<fd>y ≡ division`⟨x,y⟩"text{*Division is a function on $K\times K_0$ with values in $K$.*}lemma(infieldd)div_fun:shows"division: K×K⇩0 → K"proof-have"∀p ∈ K×K⇩0. fst(p)⋅snd(p)¯ ∈ K"prooffixpassume"p ∈ K×K⇩0"hence"fst(p) ∈ K"and"snd(p) ∈ K⇩0"byautothenshow"fst(p)⋅snd(p)¯ ∈ K"usingRing_ZF_1_L4Field_ZF_1_L5byautoqedthenhave"{⟨p,fst(p)⋅snd(p)¯⟩. p∈K×K⇩0}: K×K⇩0 → K"by(ruleZF_fun_from_total)thus?thesisbysimpqedtext{*So, really $1/0=0$. The essential lemma is @{text "apply_0"} from standard
Isabelle's @{text "func.thy"}.*}theorem(infieldd)one_over_zero:shows"𝟭\<fd>𝟬 = 0"proof-have"domain(division) = K×K⇩0"usingdiv_funfunc1_1_L1bysimphence"⟨𝟭,𝟬⟩ ∉ domain(division)"byautothenshow?thesisusingapply_0bysimpqedend