-- Every constructible number lies in the field of a quadratic tower: the -- union of the tower fields is constructibly closed, so it contains the -- least closed set, and it is contained in it. -- Part of Cumulus, the Grace17 mathematics library. -- Copyright (c) 2026 Grant Passmore. -- Released under the Apache License 2.0. See LICENSE in the repository root. -- Authors: Grant Passmore module Grace.Cumulus.Geometry.Construction.Tower import Grace.Cumulus.Algebra.Field.QuadraticTower import Grace.Cumulus.Geometry.Construction.Numbers -- The tower numbers -- The reals reached by some quadratic tower. def towerReals : Set := { x ∈ ℝ | ∃ ds, List(ℝ, ds) ∧ QuadraticTower(ds) ∧ x ∈ towerField(ds) } theorem towerReals.mem_iff (x : Set) shows x ∈ towerReals ↔ x ∈ ℝ ∧ (∃ ds, List(ℝ, ds) ∧ QuadraticTower(ds) ∧ x ∈ towerField(ds)) proof simp theorem towerReals.subset_reals shows towerReals ⊆ ℝ proof simp theorem towerReals.of_tower (ds : List(ℝ)) (x : Set) requires tower : QuadraticTower(ds) requires xIn : x ∈ towerField(ds) shows x ∈ towerReals proof have bounded := towerField.subset_reals at ds have xReal := bounded with x, xIn have dsList : List(ℝ, ds) by typecheck apply towerReals.mem_iff.backward exact ⟨xReal, ds, dsList, tower, xIn⟩ -- Two tower numbers share a tower: the stack of their two towers. theorem towerReals.common_tower (x y : Set) requires xIn : x ∈ towerReals requires yIn : y ∈ towerReals shows ∃ ds, List(ℝ, ds) ∧ QuadraticTower(ds) ∧ x ∈ towerField(ds) ∧ y ∈ towerField(ds) proof have first := towerReals.mem_iff.forward with xIn have second := towerReals.mem_iff.forward with yIn obtain ⟨ds, dsList, towerD, xInD⟩ := first.right obtain ⟨es, esList, towerE, yInE⟩ := second.right have joined : List(ℝ, append(ds, es)) by typecheck have tower := QuadraticTower.append with towerD, towerE have left := towerField.subset_append with towerD, towerE have right := towerField.subset_append_right at ds, es with towerD have xUp := left with x, xInD have yUp := right with y, yInE exact ⟨append(ds, es), joined, tower, xUp, yUp⟩ -- The tower numbers are constructibly closed -- 0 and 1 by the empty tower; a sum or product by the common tower of its -- terms; a negation or inverse by the same tower; √x by x :: ds. theorem towerReals.closed shows ConstructiblyClosed(towerReals) proof have bounded := towerReals.subset_reals have nilTower := QuadraticTower.nil have zeroMember : (0:R) ∈ towerReals have zeroIn : (0:R) ∈ towerField([]) rw towerField.nil exact rationalReals.zero_mem exact towerReals.of_tower with nilTower, zeroIn have oneMember : (1:R) ∈ towerReals have oneIn : (1:R) ∈ towerField([]) rw towerField.nil exact rationalReals.one_mem exact towerReals.of_tower with nilTower, oneIn have negatives : ∀ x ∈ towerReals, -(x:R) ∈ towerReals intros x hx have data := towerReals.mem_iff.forward with hx obtain ⟨ds, dsList, tower, xIn⟩ := data.right have field := towerField.subfield with tower have negIn := RealSubfield.neg_mem with field, xIn exact towerReals.of_tower with tower, negIn have sums : ∀ x y ∈ towerReals, (x:R) + (y:R) ∈ towerReals intros x hx y hy have xReal : Real(x) := bounded with x, hx have yReal : Real(y) := bounded with y, hy obtain ⟨ds, dsList, tower, xIn, yIn⟩ := towerReals.common_tower with hx, hy have field := towerField.subfield with tower have sumIn := RealSubfield.add_mem with field, xIn, yIn exact towerReals.of_tower with tower, sumIn have products : ∀ x y ∈ towerReals, (x:R) * (y:R) ∈ towerReals intros x hx y hy have xReal : Real(x) := bounded with x, hx have yReal : Real(y) := bounded with y, hy obtain ⟨ds, dsList, tower, xIn, yIn⟩ := towerReals.common_tower with hx, hy have field := towerField.subfield with tower have productIn := RealSubfield.mul_mem with field, xIn, yIn exact towerReals.of_tower with tower, productIn have inverses : ∀ x ∈ towerReals, x ≠ (0:R) → realInvValue(x) ∈ towerReals intros x hx nonzero have data := towerReals.mem_iff.forward with hx obtain ⟨ds, dsList, tower, xIn⟩ := data.right have field := towerField.subfield with tower have inverseIn := RealSubfield.inv_mem with field, xIn, nonzero exact towerReals.of_tower with tower, inverseIn have roots : ∀ x ∈ towerReals, (0:R) ≤ (x:R) → realSqrt(x) ∈ towerReals intros x hx nonneg have data := towerReals.mem_iff.forward with hx obtain ⟨ds, dsList, tower, xIn⟩ := data.right have field := towerField.subfield with tower have taller := QuadraticTower.cons with tower, xIn, nonneg have rootIn : realSqrt(x) ∈ towerField(x :: ds) rw towerField.cons have member := adjoinSqrt.sqrt_mem with field, nonneg unfold sqrt at member exact member exact towerReals.of_tower with taller, rootIn have field := RealSubfield.mk with bounded, zeroMember, oneMember, negatives, sums, products, inverses unfold ConstructiblyClosed exact ⟨field, roots⟩ -- The constructibles are the tower numbers theorem Constructible.in_tower (x : Real) requires constructible : Constructible(x) shows ∃ ds, List(ℝ, ds) ∧ QuadraticTower(ds) ∧ x ∈ towerField(ds) proof have closed := towerReals.closed have least := constructibles.least with closed have member := least with x, constructible have data := towerReals.mem_iff.forward with member exact data.right -- Induction on ds: the rationals are constructible, and the constructibles -- contain a + b√d once they contain a, b, and d ≥ 0. theorem towerField.constructible (ds : List(ℝ)) requires tower : QuadraticTower(ds) shows towerField(ds) ⊆ constructibles proof induction ds | List.nil => intro tower rw towerField.nil have field := constructibles.subfield exact RealSubfield.rationals_subset with field | List.cons(d, tail) using ih => intro tower have below := QuadraticTower.tail with tower obtain ⟨dIn, dNonneg⟩ := QuadraticTower.head with tower have inner := ih with below have closedField := constructibles.subfield have closed := constructibles.closed have dC := inner with d, dIn have rootC := closed.right with d, dC, dNonneg rw towerField.cons intros z hz obtain ⟨a, aIn, b, bIn, same⟩ := adjoinSqrt.cases with dNonneg, hz have aC := inner with a, aIn have bC := inner with b, bIn have productC := RealSubfield.mul_mem with closedField, bC, rootC have sumC := RealSubfield.add_mem with closedField, aC, productC rw same unfold sqrt exact sumC theorem constructibles.eq_tower shows constructibles = towerReals proof have closed := towerReals.closed have least := constructibles.least with closed have back : towerReals ⊆ constructibles intros x hx have data := towerReals.mem_iff.forward with hx obtain ⟨ds, dsList, tower, xIn⟩ := data.right have included := towerField.constructible with tower exact included with x, xIn exact Subset.antisymmetric with least, back