Grace/Cumulus/Algebra/Field/RealSubfield.g17

Open in Workbench Download source

Imports

Grace.Cumulus.Real.Rationals · Grace.Cumulus.Real.Field · Grace.Cumulus.Algebra.Ring.Subring

Declarations

Source

1-- Subfields of the reals as sets of reals closed under the field2-- operations, their membership laws, the bridge to the bundled subring,3-- and the two bounds: every subfield contains the rationals and sits in ℝ.4-- Part of Cumulus, the Grace17 mathematics library.5-- Copyright (c) 2026 Grant Passmore.6-- Released under the Apache License 2.0. See LICENSE in the repository root.7-- Authors: Grant Passmore89module Grace.Cumulus.Algebra.Field.RealSubfield10import Grace.Cumulus.Real.Rationals11import Grace.Cumulus.Real.Field12import Grace.Cumulus.Algebra.Ring.Subring1314-- The definition1516-- A subfield of ℝ: a set of reals with 0 and 1, closed under negation,17-- addition, multiplication, and inverses of nonzero elements.18predicate RealSubfield (F : Set) :=19  F ⊆ ℝ ∧ (0:R) ∈ F ∧ (1:R) ∈ F ∧20  (∀ x ∈ F, -(x:R) ∈ F) ∧ (∀ x y ∈ F, (x:R) + (y:R) ∈ F) ∧21  (∀ x y ∈ F, (x:R) * (y:R) ∈ F) ∧22  (∀ x ∈ F, x ≠ (0:R) → realInvValue(x) ∈ F)2324theorem RealSubfield.mk (F : Set)25  requires bounded : F ⊆ ℝ26  requires zeroIn : (0:R) ∈ F27  requires oneIn : (1:R) ∈ F28  requires negatives : ∀ x ∈ F, -(x:R) ∈ F29  requires sums : ∀ x y ∈ F, (x:R) + (y:R) ∈ F30  requires products : ∀ x y ∈ F, (x:R) * (y:R) ∈ F31  requires inverses : ∀ x ∈ F, x ≠ (0:R) → realInvValue(x) ∈ F32  shows RealSubfield(F)33proof34  unfold RealSubfield35  exact ⟨bounded, zeroIn, oneIn, negatives, sums, products, inverses⟩3637theorem RealSubfield.subset (F : Set)38  requires field : RealSubfield(F)39  shows F ⊆ ℝ40proof41  exact field.left4243theorem RealSubfield.real (F x : Set)44  requires field : RealSubfield(F)45  requires member : x ∈ F46  shows Real(x)47proof48  have bounded := RealSubfield.subset with field49  exact bounded with x, member5051-- The membership laws5253instance RealSubfield.zero_mem (F : Set)54  requires field : RealSubfield(F)55  shows (0:R) ∈ F56proof57  obtain ⟨_, zeroIn, _⟩ := field58  exact zeroIn5960instance RealSubfield.one_mem (F : Set)61  requires field : RealSubfield(F)62  shows (1:R) ∈ F63proof64  obtain ⟨_, _, oneIn, _⟩ := field65  exact oneIn6667instance RealSubfield.neg_mem (F : Set) (x : Real)68  requires field : RealSubfield(F)69  requires xIn : x ∈ F70  shows -x ∈ F71proof72  obtain ⟨_, _, _, negatives, _⟩ := field73  exact negatives with x, xIn7475instance RealSubfield.add_mem (F : Set) (x y : Real)76  requires field : RealSubfield(F)77  requires xIn : x ∈ F78  requires yIn : y ∈ F79  shows x + y ∈ F80proof81  obtain ⟨_, _, _, _, sums, _⟩ := field82  exact sums with x, xIn, y, yIn8384instance RealSubfield.mul_mem (F : Set) (x y : Real)85  requires field : RealSubfield(F)86  requires xIn : x ∈ F87  requires yIn : y ∈ F88  shows x * y ∈ F89proof90  obtain ⟨_, _, _, _, _, products, _⟩ := field91  exact products with x, xIn, y, yIn9293instance RealSubfield.sub_mem (F : Set) (x y : Real)94  requires field : RealSubfield(F)95  requires xIn : x ∈ F96  requires yIn : y ∈ F97  shows x - y ∈ F98proof99  have negIn : -y ∈ F := RealSubfield.neg_mem with field, yIn100  unfold realSubValue101  exact RealSubfield.add_mem with field, xIn, negIn102103-- A nonvanishing premise is not a predicate, so the inverse and quotient104-- laws are theorems rather than instances.105theorem RealSubfield.inv_mem (F : Set) (x : Real)106  requires field : RealSubfield(F)107  requires xIn : x ∈ F108  requires nonzero : x ≠ 0109  shows realInvValue(x) ∈ F110proof111  obtain ⟨_, _, _, _, _, _, inverses⟩ := field112  exact inverses with x, xIn, nonzero113114theorem RealSubfield.div_mem (F : Set) (x y : Real)115  requires field : RealSubfield(F)116  requires xIn : x ∈ F117  requires yIn : y ∈ F118  requires nonzero : y ≠ 0119  shows x / y ∈ F120proof121  have invIn := RealSubfield.inv_mem with field, yIn, nonzero122  rw realDiv.eq_mul_inv123  exact RealSubfield.mul_mem with field, xIn, invIn124125-- Naturals, integers, and rationals126127-- Induction on n: the step is realNumeral.succ through realNumeral.nat.128theorem RealSubfield.numeral_mem (F : Set) (n : Nat)129  requires field : RealSubfield(F)130  shows realNat(n) ∈ F131proof132  induction n133  | zero =>134    rw realNat.zero135    exact RealSubfield.zero_mem with field136  | succ(k) using ih =>137    have oneIn : (1:R) ∈ F := RealSubfield.one_mem with field138    rw [← realNumeral.nat, realNumeral.succ, realNumeral.nat]139    exact RealSubfield.add_mem with field, ih, oneIn140141-- A real numeral literal lies in every subfield: it is realNat(n).142theorem realNumeral.subfield_mem (F : Set) (n : Nat)143  requires field : RealSubfield(F)144  shows realNumeral(n) ∈ F145proof146  rw realNumeral.nat147  exact RealSubfield.numeral_mem with field148149theorem RealSubfield.int_mem (F : Set) (z : Integer)150  requires field : RealSubfield(F)151  shows realInt(z) ∈ F152proof153  obtain ⟨a, aNat, b, bNat, shape⟩ := Integer.representatives at z with *154  have value := realInt.class at a, b with aNat, bNat155  have aIn := RealSubfield.numeral_mem at F, a with field156  have bIn := RealSubfield.numeral_mem at F, b with field157  rw [shape, value]158  exact RealSubfield.sub_mem with field, aIn, bIn159160theorem RealSubfield.whole161  shows RealSubfield(ℝ)162proof163  have reflexive := Subset.reflexive at ℝ164  have zeroIn : (0:R) ∈ ℝ := realZero.real165  have oneIn : (1:R) ∈ ℝ := realOne.real166  apply RealSubfield.mk with reflexive, zeroIn, oneIn167  . intros x hx168    exact realNegValue.real at x169  . intros x hx y hy170    exact realAddValue.real at x, y171  . intros x hx y hy172    exact realMulValue.real at x, y173  . intros x hx nonzero174    exact realInvValue.real at x175176theorem RealSubfield.rationals177  shows RealSubfield(rationalReals)178proof179  have bounded : rationalReals ⊆ ℝ180    intros x hx181    exact rationalReals.real with hx182  have zeroIn := rationalReals.zero_mem183  have oneIn := rationalReals.one_mem184  apply RealSubfield.mk with bounded, zeroIn, oneIn185  . intros x hx186    exact rationalReals.neg_mem with hx187  . intros x hx y hy188    exact rationalReals.add_mem with hx, hy189  . intros x hx y hy190    exact rationalReals.mul_mem with hx, hy191  . intros x hx nonzero192    exact rationalReals.inv_mem with hx, nonzero193194-- A rational is a quotient realInt(p) / realInt(q) of elements of F.195theorem RealSubfield.rationals_subset (F : Set)196  requires field : RealSubfield(F)197  shows rationalReals ⊆ F198proof199  intros x hx200  have quotient := rationalReals.quotient at x201  obtain ⟨p, pInt, q, qInt, qNonzero, equation⟩ := quotient.forward with hx202  have pIn := RealSubfield.int_mem at F, p with field203  have qIn := RealSubfield.int_mem at F, q with field204  have qNonzeroReal := realInt.nonzero at q with qNonzero205  have cancel := realInvValue.mul_right with qNonzeroReal206  have shape : x = realInt(p) / realInt(q)207    rw realDiv.eq_mul_inv208    linear_combination realInvValue(realInt(q)) * equation - x * cancel209  rw shape210  exact RealSubfield.div_mem with field, pIn, qIn, qNonzeroReal211212-- The bridges213214-- To the bundled ring of the reals.215theorem RealSubfield.subring (F : Set)216  requires field : RealSubfield(F)217  shows Subring(realRing, F)218proof219  obtain ⟨bounded, zeroIn, oneIn, negatives, sums, products, _⟩ := field220  have parts : IsSubring(ℝ, realAdd, realZero, realNeg, realMul, realOne, F)221    unfold IsSubring222    refine ⟨bounded, zeroIn, oneIn, ?_, ?_, ?_⟩223    . unfold ClosedUnary224      exact negatives225    . unfold ClosedBinary226      exact sums227    . unfold ClosedBinary228      exact products229  unfold realRing230  exact Subring.of_parts with parts231