GoalWhat we already discussed
Real NumbersConclusion
Constructing Number Systems in Coq
Carsten Hornung
April 29, 2011
Carsten Hornung Constructing Number Systems in Coq
GoalWhat we already discussed
Real NumbersConclusion
Table of contents
1 Goal
2 What we already discussedLandau’s Grundlagen der AnalysisNatural Numbers NFractionsPositive Rational NumbersDedekind Cuts
3 Real NumbersDefinitionOrderMultiplicationAdditionCompleteness
4 Conclusion
Carsten Hornung Constructing Number Systems in Coq
GoalWhat we already discussed
Real NumbersConclusion
Goal of my thesis
Elegant construction of number systems in Coq
N+ → Q+ → R+ → R
Discuss the necessity of additional assumptions
Excluded middle XM - R+
Extensionality PE , FE , CE - R+
Proof irrelevance PI - R+
Strong excluded middle SXM - R
Carsten Hornung Constructing Number Systems in Coq
GoalWhat we already discussed
Real NumbersConclusion
Goal of my thesis
Elegant construction of number systems in Coq
N+ → Q+ → R+ → R
Discuss the necessity of additional assumptions
Excluded middle XM - R+
Extensionality PE , FE , CE - R+
Proof irrelevance PI - R+
Strong excluded middle SXM - R
Carsten Hornung Constructing Number Systems in Coq
GoalWhat we already discussed
Real NumbersConclusion
Landau’s Grundlagen der AnalysisNatural Numbers NFractionsPositive Rational NumbersDedekind Cuts
Landau’s Grundlagen der Analysis
Natural Numbers, Peano Axioms
Construction of
Fractions, Rational, Real and Complex Numbers
Basic theorems and their proofs (about 300)
Carsten Hornung Constructing Number Systems in Coq
GoalWhat we already discussed
Real NumbersConclusion
Landau’s Grundlagen der AnalysisNatural Numbers NFractionsPositive Rational NumbersDedekind Cuts
Natural Numbers NN = {1, 2, 3 . . . }
Inductive nat : Type :=
| O : nat
| S : nat -> nat
O as origin or one
S as the successor function
Coercion bool → Prop, (leq : nat → nat → bool)
Carsten Hornung Constructing Number Systems in Coq
GoalWhat we already discussed
Real NumbersConclusion
Landau’s Grundlagen der AnalysisNatural Numbers NFractionsPositive Rational NumbersDedekind Cuts
Fractions F
F = {x1
x2: x1, x2 ∈ N}
Definition (Equivalence of fractions)
∀x1, x2, y1, y2 ∈ N :
x1x2
∼y1y2
:⇔ x1 · y2 = y1 · x2
Definition (Order of fractions)
∀x1, x2, y1, y2 ∈ N :
x1
x2<
y1
y2:⇔ x1 · y2 < y1 · x2
Carsten Hornung Constructing Number Systems in Coq
GoalWhat we already discussed
Real NumbersConclusion
Landau’s Grundlagen der AnalysisNatural Numbers NFractionsPositive Rational NumbersDedekind Cuts
Positive Rational Numbers
Definition (Positive Rational Numbers)
The (positive) Rational Numbers Q+ are defined as F modulo ∼:Q+ := F/ ∼
In other words: Let X ∈ Q+:
∀x y . x ∈ X → (y ∈ X ↔ x ∼ y)
Carsten Hornung Constructing Number Systems in Coq
GoalWhat we already discussed
Real NumbersConclusion
Landau’s Grundlagen der AnalysisNatural Numbers NFractionsPositive Rational NumbersDedekind Cuts
Reducing a fraction
Let red : frac → frac be the function that reduces a fraction
Property (1)
∀x . x ∼ red x
Property (2)
∀x y . x ∼ y → red x = red y
Carsten Hornung Constructing Number Systems in Coq
GoalWhat we already discussed
Real NumbersConclusion
Landau’s Grundlagen der AnalysisNatural Numbers NFractionsPositive Rational NumbersDedekind Cuts
Goal
Definition (Positive Rational Numbers)
The (positive) Rational Numbers Q+ are defined as:Q+ := {f ∈ F | red f = f }
Avoid the use of FE
The theorems about the rationals reduce to the theoremsabout fractions.
Carsten Hornung Constructing Number Systems in Coq
GoalWhat we already discussed
Real NumbersConclusion
Landau’s Grundlagen der AnalysisNatural Numbers NFractionsPositive Rational NumbersDedekind Cuts
Defining red
Different possibilities to define red (gcd , first)
Prove the 2 properties of red
Property (1)
∀x . x ∼ red x
Property (2)
∀x y . x ∼ y → red x = red y
Carsten Hornung Constructing Number Systems in Coq
GoalWhat we already discussed
Real NumbersConclusion
Landau’s Grundlagen der AnalysisNatural Numbers NFractionsPositive Rational NumbersDedekind Cuts
Defining red
Preliminary note
Function first : (nat → bool) → nat → nat yields to a set pand an upper bound x for the minimum the least element in p
first p x = min p
We can represent ∃y ≤ x . p y having type bool using first:
p(first p x)
Carsten Hornung Constructing Number Systems in Coq
GoalWhat we already discussed
Real NumbersConclusion
Landau’s Grundlagen der AnalysisNatural Numbers NFractionsPositive Rational NumbersDedekind Cuts
Defining red
Given a fraction x = x1
x2we define
Nx := { y1 | ∃y2.x1x2
∼y1y2
}
rednumx := minNx
Dx := { y2 |x1x2
∼rednumx
y2}
reddenx := minDx
Carsten Hornung Constructing Number Systems in Coq
GoalWhat we already discussed
Real NumbersConclusion
Landau’s Grundlagen der AnalysisNatural Numbers NFractionsPositive Rational NumbersDedekind Cuts
Defining red
Given a fraction x = x1
x2we define
Nx := { y1 | ∃y2.x1x2
∼y1y2
}
rednumx := min Nx
minNx := first Nx x1
Nx := { y1 | ∃y2 ≤ y1 · x2.x1x2
∼y1y2
}
Carsten Hornung Constructing Number Systems in Coq
GoalWhat we already discussed
Real NumbersConclusion
Landau’s Grundlagen der AnalysisNatural Numbers NFractionsPositive Rational NumbersDedekind Cuts
Defining red
Given a fraction x = x1
x2we define
Nx := { y1 | ∃y2.x1x2
∼y1y2
}
rednumx := min Nx
minNx := first Nx x1
Nx := { y1 | ∃y2 ≤ y1 · x2.x1x2
∼y1y2
}
Carsten Hornung Constructing Number Systems in Coq
GoalWhat we already discussed
Real NumbersConclusion
Landau’s Grundlagen der AnalysisNatural Numbers NFractionsPositive Rational NumbersDedekind Cuts
Defining red
Given a fraction x = x1
x2we define
Nx := { y1 | ∃y2.x1x2
∼y1y2
}
rednumx := min Nx
minNx := first Nx x1
Nx := { y1 | ∃y2 ≤ y1 · x2.x1x2
∼y1y2
}
Carsten Hornung Constructing Number Systems in Coq
GoalWhat we already discussed
Real NumbersConclusion
Landau’s Grundlagen der AnalysisNatural Numbers NFractionsPositive Rational NumbersDedekind Cuts
Defining red
Given a fraction x = x1
x2we define
Dx := { y2 |x1x2
∼rednumx
y2}
reddenx := minDx
minDx := first Dx (rednumx · x2)
Carsten Hornung Constructing Number Systems in Coq
GoalWhat we already discussed
Real NumbersConclusion
Landau’s Grundlagen der AnalysisNatural Numbers NFractionsPositive Rational NumbersDedekind Cuts
Defining red
Given a fraction x = x1
x2we define
Dx := { y2 |x1x2
∼rednumx
y2}
reddenx := minDx
minDx := first Dx (rednumx · x2)
Carsten Hornung Constructing Number Systems in Coq
GoalWhat we already discussed
Real NumbersConclusion
Landau’s Grundlagen der AnalysisNatural Numbers NFractionsPositive Rational NumbersDedekind Cuts
Dedekind Cuts
Definition (Dedekind Cut)
A Dedekind Cut Θ is a set of positive Rational Numbers with thefollowing properties:
∃X . X ∈ Θ
∃X . X /∈ Θ
∀X Y . Y ∈ Θ → X < Y → X ∈ Θ
∀X . X ∈ Θ → ∃Y . X < Y ∧ Y ∈ Θ
Intuition: Θ = (0, θ) ∩Q where θ ∈ R+.
Carsten Hornung Constructing Number Systems in Coq
GoalWhat we already discussed
Real NumbersConclusion
Landau’s Grundlagen der AnalysisNatural Numbers NFractionsPositive Rational NumbersDedekind Cuts
Dedekind Cuts
Definition (Cut Extensionality)
Two Cuts Θ and Ξ are equal if they contain the same rationalnumbers. That is,
CE := ∀Θ Ξ. (∀X . X ∈ Θ ↔ X ∈ Ξ) → Θ = Ξ
We can prove PE → FE → CE or SE → CE . Note PE → PI .
Definition (Order)
Given two Cuts Θ and Ξ we define
Θ < Ξ :⇔ Θ ( Ξ ⇔ ∃Z . Z ∈ Ξ ∧ Z /∈ Θ
Carsten Hornung Constructing Number Systems in Coq
GoalWhat we already discussed
Real NumbersConclusion
DefinitionOrderMultiplicationAdditionCompleteness
Definition
Inductive real : Type :=
| Z : real
| P : cut -> real
| N : cut -> real.
Carsten Hornung Constructing Number Systems in Coq
GoalWhat we already discussed
Real NumbersConclusion
DefinitionOrderMultiplicationAdditionCompleteness
Order of Real Numbers
N Θ < N Ξ := Ξ < Θ
N Θ < P Ξ := True
...
P Θ < Z := False
P Θ < P Ξ := Θ < Ξ
Carsten Hornung Constructing Number Systems in Coq
GoalWhat we already discussed
Real NumbersConclusion
DefinitionOrderMultiplicationAdditionCompleteness
Multiplication
Z · η := Z
ǫ · Z := Z if ǫ 6= Z
P Θ · P Ξ := P (Θ · Ξ)
N Θ · N Ξ := P (Θ · Ξ)
N Θ · P Ξ := N (Θ · Ξ)
P Θ · N Ξ := N (Θ · Ξ)
Carsten Hornung Constructing Number Systems in Coq
GoalWhat we already discussed
Real NumbersConclusion
DefinitionOrderMultiplicationAdditionCompleteness
Addition
ǫ+ Z := ǫ
Z + η := η if η 6= Z
N Θ+N Ξ := N (Θ + Ξ)
P Θ+ P Ξ := P (Θ + Ξ)
P Θ+N Ξ := Z if Θ = Ξ
P Θ+N Ξ := N (Ξ −Θ) if Θ < Ξ
P Θ+N Ξ := P (Θ− Ξ) if Θ > Ξ
N Θ+ P Ξ := P Ξ +N Θ
Carsten Hornung Constructing Number Systems in Coq
GoalWhat we already discussed
Real NumbersConclusion
DefinitionOrderMultiplicationAdditionCompleteness
Addition
ǫ+ Z := ǫ
Z + η := η if η 6= Z
N Θ+N Ξ := N (Θ + Ξ)
P Θ+ P Ξ := P (Θ + Ξ)
P Θ+N Ξ := Z if Θ = Ξ
P Θ+N Ξ := N (Ξ −Θ) if Θ < Ξ
P Θ+N Ξ := P (Θ− Ξ) if Θ > Ξ
N Θ+ P Ξ := P Ξ +N Θ
Carsten Hornung Constructing Number Systems in Coq
GoalWhat we already discussed
Real NumbersConclusion
DefinitionOrderMultiplicationAdditionCompleteness
Strong Excluded Middle
XM := ∀X : Prop. X ∨ ¬X
SXM := ∀X : Prop. { X }+ { ¬X }
STR := ∀Θ Ξ. { Θ < Ξ }+ { Θ = Ξ }+ { Ξ < Θ }
SXM ↔ STR
Carsten Hornung Constructing Number Systems in Coq
GoalWhat we already discussed
Real NumbersConclusion
DefinitionOrderMultiplicationAdditionCompleteness
Strong Excluded Middle
XM := ∀X : Prop. X ∨ ¬X
SXM := ∀X : Prop. { X }+ { ¬X }
STR := ∀Θ Ξ. { Θ < Ξ }+ { Θ = Ξ }+ { Ξ < Θ }
SXM ↔ STR
Carsten Hornung Constructing Number Systems in Coq
GoalWhat we already discussed
Real NumbersConclusion
DefinitionOrderMultiplicationAdditionCompleteness
Completeness
Given two subsets P and Q of the real numbers we define
P < Q := ∀ǫ η. ǫ ∈ P → η ∈ Q → ǫ < η
P 6= ∅ := ∃ǫ. ǫ ∈ P
P ∪ Q = R := ∀ǫ. ǫ ∈ P ∨ ǫ ∈ Q
ub P η := ∀ǫ ∈ P . ǫ ≤ η
Carsten Hornung Constructing Number Systems in Coq
GoalWhat we already discussed
Real NumbersConclusion
DefinitionOrderMultiplicationAdditionCompleteness
Completeness
Theorem (Supremum Property)
Let P be a nonempty subset of the real numbers that is boundedfrom above. That is,
P 6= ∅ and ∃η. ub P η
Then there is a (unique) least upper bound ζ. This is a realnumber ζ with the following property:
ub P ζ and ∀η. ub P η → ζ ≤ η
Carsten Hornung Constructing Number Systems in Coq
GoalWhat we already discussed
Real NumbersConclusion
DefinitionOrderMultiplicationAdditionCompleteness
Completeness
Theorem (Dedekind’s Fundamental Theorem)
Let P and Q be given with P < Q, P 6= ∅, Q 6= ∅, andP ∪ Q = R. Then there is a unique ζ such that
∀ǫ.(ǫ < ζ → ǫ ∈ P) ∧ (ζ < ǫ → ǫ ∈ Q)
Carsten Hornung Constructing Number Systems in Coq
GoalWhat we already discussed
Real NumbersConclusion
DefinitionOrderMultiplicationAdditionCompleteness
Completeness
Theorem (Fundamental Theorem)
Let P and Q be given with P < Q, P 6= ∅ and Q 6= ∅. Then thereis a ζ such that
∀ǫ.(ǫ < ζ → ǫ /∈ Q) ∧ (ζ < ǫ → ǫ /∈ P)
If P ∪ Q = R, we can prove Dedekind’s Fundamental Theorem.
Carsten Hornung Constructing Number Systems in Coq
GoalWhat we already discussed
Real NumbersConclusion
DefinitionOrderMultiplicationAdditionCompleteness
Completeness
Let P and Q be given with P < Q, P 6= ∅ and Q 6= ∅.
If neither P contains a positive number nor Q contains anegative number, we set ζ to Z.
If both P contains a positive number and Q contains anegative number, we have a contradiction.
If P contains a positive number, we construct the cut
Θ = {X | ∃ǫ ∈ P . X < ǫ}
and set ζ to P Θ. (Analogous if Q contains a negativenumber.)
Carsten Hornung Constructing Number Systems in Coq
GoalWhat we already discussed
Real NumbersConclusion
DefinitionOrderMultiplicationAdditionCompleteness
Completeness
Let P and Q be given with P < Q, P 6= ∅ and Q 6= ∅.
If neither P contains a positive number nor Q contains anegative number, we set ζ to Z.
If both P contains a positive number and Q contains anegative number, we have a contradiction.
If P contains a positive number, we construct the cut
Θ = {X | ∃ǫ ∈ P . X < ǫ}
and set ζ to P Θ. (Analogous if Q contains a negativenumber.)
Carsten Hornung Constructing Number Systems in Coq
GoalWhat we already discussed
Real NumbersConclusion
DefinitionOrderMultiplicationAdditionCompleteness
Completeness
Let P and Q be given with P < Q, P 6= ∅ and Q 6= ∅.
If neither P contains a positive number nor Q contains anegative number, we set ζ to Z.
If both P contains a positive number and Q contains anegative number, we have a contradiction.
If P contains a positive number, we construct the cut
Θ = {X | ∃ǫ ∈ P . X < ǫ}
and set ζ to P Θ. (Analogous if Q contains a negativenumber.)
Carsten Hornung Constructing Number Systems in Coq
GoalWhat we already discussed
Real NumbersConclusion
DefinitionOrderMultiplicationAdditionCompleteness
Completeness
Landau defines Θ in a different way.
Define Θ′ to be the cut
Θ′ = {X | X ∈ P ∧ ∃ǫ ∈ P . X < ǫ}
If P ∪ Q = R we have Θ = Θ′
Carsten Hornung Constructing Number Systems in Coq
GoalWhat we already discussed
Real NumbersConclusion
Differences to Landau
Proof of Peano axioms
Definition of < independent from +
Function first for Well-Ordering Principle
Definition of Rational Numbers using red
Third property of cuts
More general formulation of Dedekind’s FundamentalTheorem
Carsten Hornung Constructing Number Systems in Coq
GoalWhat we already discussed
Real NumbersConclusion
Additional Assumptions
Excluded middle
Well-Ordering Principle WP ↔ XMTrichotomy for cuts TR ↔ XM
Other assumptions
Cut extensionality CE , SE → CE or PE → FE → CEStrong excluded middle or strong trichotomy for cutsSXM ↔ STR
Carsten Hornung Constructing Number Systems in Coq
GoalWhat we already discussed
Real NumbersConclusion
References
E. Landau : Grundlagen der Analysis (1930)
G. Smolka, C. E. Brown : Introduction to Computational
Logic (Lecture Notes SS 2010)
Y. Bertot, P. Casteran : Interactive Theorem Proving and
Program Development: Coq’Art: The Calculus of
Inductive Constructions (2004)
J. Harrison : Theorem Proving with the Real Numbers
(1998)
Carsten Hornung Constructing Number Systems in Coq