Skip to content

Commit 1796a65

Browse files
committed
Small corrections in Chapter 3
1 parent 0fbd8ec commit 1796a65

File tree

13 files changed

+77
-70
lines changed

13 files changed

+77
-70
lines changed

doc/hydra-chapter.tex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -846,7 +846,7 @@ \subsection{Big steps}
846846

847847
\input{movies/snippets/Hydra_Definitions/battleRelDef}
848848

849-
The following property allows us to build battle rounds by composition of smaller ones.
849+
The following property allows us to build battles by composition of smaller ones.
850850

851851
%% TODO display subgoals when fixed
852852

doc/ordinal-chapter.tex

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@ \chapter{Introduction to ordinal numbers and ordinal notations}
4646
\item Dots : ``$\ldots$'' stand for infinite sequences of ordinals, not shown for lack of space. For instance, the ordinal $42$ is not shown in the first line, but it exists, somewhere between $17$ and $\omega$.
4747
\item Each ordinal printed in black is the immediate successor of another ordinal. We call it a \emph{successor} ordinal. For instance, $12$ is the successor of $11$, and $\omega^4+1$ the successor of $\omega^4$.
4848
\item Ordinals (displayed in red) that follow immediately dots are called \emph{limit ordinals}. With respect to the order induced by this sequence, any limit ordinal $\alpha$ is the least upper bound of the set $\mathbb{O}_\alpha$ of all ordinals strictly less than $\alpha$.
49-
\item
50-
For instance $\omega$ is the least upper bound of the set of all finite ordinals (in the first line). It is also the first limit ordinal, and the first infinite ordinal, in the sense that
49+
For instance,$\omega$ is the least upper bound of the set of all finite ordinals (in the first line). It is also the first limit ordinal, and the first \emph{infinite ordinal number}, in the sense that
5150
the set $\mathbb{O}_\omega$ is infinite.
5251
\item The ordinal $\epsilon_0$ is the first number which is equal to its own exponential of base $\omega$. It plays an important role in proof theory, and is particularly studied in chapters~\ref{chap:T1} to \ref{chap:alpha-large}.
5352
\item Any ordinal is either the ordinal \textcolor{blue}{$0$},
@@ -59,6 +58,15 @@ \chapter{Introduction to ordinal numbers and ordinal notations}
5958

6059
\section{The mathematical point of view}
6160

61+
62+
63+
We cannot cite all the literature published on ordinals since Cantor's book
64+
\cite{cantorbook}, and
65+
leave it to the reader to explore the bibliography.
66+
The introduction of Jos\'e Grimm's report~\cite{grimm:hal-00911710} contains also a nice presentation of the main properties of ordinals.
67+
68+
For simplicity's sake, we will only give the definitions which are useful for understanding our \coq development.
69+
6270
\subsection{Well-ordered sets}
6371
Let us start with some definitions.
6472
A \emph{well-ordered set} is a set provided with a binary relation $<$ which has the following properties.
@@ -88,21 +96,15 @@ \subsection{Ordinal numbers}
8896
there exists a strictly monotonous bijection $b$ from $A$ to $B$, \emph{i.e.} which verifies the proposition
8997
$\forall x\,y\in A,\, x <_A y \Rightarrow b(x) <_B b(y)$.
9098

91-
Having the same order type is an equivalence relation between well-ordered sets. Ordinal numbers (in short: \emph{ordinals}) are descriptions (\emph{names}) of the equivalence classes.
99+
Having the same order type is an equivalence relation between well-ordered sets. Ordinal numbers (in short: \emph{ordinals}) are descriptions (\emph{names}) of the associated equivalence classes.
92100
For instance, the order type of $(\mathbb{N},<)$ is associated with the ordinal called $\omega$, and the order we considered on
93-
the disjoint union of $\mathbb{N}$ and itself is named $\omega+\omega$.
101+
the disjoint union of two copies of $\mathbb{N}$ is associated with $\omega \times 2$ (a.k.a. $\omega+\omega$).
94102

95103
In a set-theoretic framework, one can consider any ordinal $\alpha$ as a well-ordered set, whose elements are just the ordinals strictly less than $\alpha$, \emph{i.e.} the \emph{segment} $\mathbb{O}_\alpha=[0, \alpha)$. So, one can speak about \emph{finite}, \emph{infinite}, \emph{countable}, etc., ordinals. Nevertheless, since we work within type theory,
96104
we do not identify ordinals as sets of ordinals, but consider the correspondence between ordinals and sets of ordinals as the function that maps $\alpha$ to $\mathbb{O}_\alpha$.
97105
For instance $\mathbb{O}_\omega=\mathbb{N}$, and $\mathbb{O}_7=\{0,1,2,3,4,5,6\}$.
98106

99107

100-
We cannot cite all the literature published on ordinals since Cantor's book
101-
\cite{cantorbook}, and
102-
leave it to the reader to explore the bibliography.
103-
104-
The introduction of Jos\'e Grimm's report~\cite{grimm:hal-00911710} contains a nice presentation of the main properties of ordinals.
105-
106108

107109
\section{Ordinal numbers in Coq}
108110

@@ -139,7 +141,7 @@ \section{Ordinal Notations}
139141
Fortunately, the ordinals we need for studying hydra battles are much simpler than Schütte's, and can be represented as quite simple data types in \gallina.
140142

141143
Let $\alpha$ be some (countable) ordinal;
142-
in \coq{} terms, we call \emph{ordinal notation for $\alpha$} a structure composed
144+
we call \emph{ordinal notation for $\alpha$} any structure composed
143145
of:
144146
\begin{itemize}
145147
\item A data type $A$ for representing all ordinals strictly below $\alpha$,
@@ -163,7 +165,7 @@ \subsubsection{The \texttt{Comparable} class}
163165

164166
The \texttt{Comparable} class, contributed by Jérémy Damour and Théo Zimmermann, allows us to apply generic lemmas and tactics about decidable strict orders.
165167
The correctness of the comparison function is expressed through Stdlib's type
166-
\texttt{Datatypes.CompareSpec} as specialized by \texttt{Datatypes.CompSpec}.
168+
\texttt{Datatypes.CompareSpec} and predicate \texttt{Datatypes.CompSpec}.
167169

168170
\begin{Coqsrc}
169171
Inductive CompareSpec (Peq Plt Pgt : Prop) :
@@ -291,13 +293,16 @@ \section{Sum of two ordinal notations}
291293
Standard library's lemma \texttt{Wellfounded.Disjoint\_Union.wf\_disjoint\_sum}
292294
is applied to prove that our order \texttt{lt} is well-founded, allowing us to build an instance of \texttt{ON}:
293295

294-
\inputsnippets{ON_plus/ltWf, ON_plus/OnPlus}
296+
\inputsnippets{ON_plus/ltWf}
295297

296-
\subsection{The ordinal \texorpdfstring{$\omega+\omega$}{omega + omega}}
298+
\inputsnippets{ON_plus/OnPlus}
299+
300+
\subsection{Example: The ordinal \texorpdfstring{$\omega+\omega$}{omega + omega}}
297301

298302
The ordinal $\omega+\omega$ (also known as $\omega\times 2$) may be represented as the concatenation
299303
of two copies of $\omega$ (Figure~\ref{fig:omega-plus-omega}).
300304
It is also represented by the two first lines of Figure~\ref{fig:ordinal-sequence}.
305+
We define this notation in \coq{} as an instance of \texttt{ON\_plus}.
301306

302307
\begin{figure}[h]
303308
\centering
@@ -324,7 +329,7 @@ \subsection{The ordinal \texorpdfstring{$\omega+\omega$}{omega + omega}}
324329
\label{fig:omega-plus-omega}
325330
\end{figure}
326331

327-
We can define this notation in \coq{} as an instance of \texttt{ON\_plus}.
332+
328333

329334

330335
\vspace{4pt}
@@ -523,7 +528,9 @@ \subsubsection{Addition}
523528

524529
We can define on \texttt{Omega2} an addition which extends the addition on \texttt{nat}. Please note that this operation is not commutative:
525530

526-
\inputsnippets{ON_Omega2/plusDef, ON_Omega2/plusExamples}
531+
\inputsnippets{ON_Omega2/plusDef}
532+
533+
\inputsnippets{ON_Omega2/plusExamples}
527534

528535

529536
\subsubsection{Finite multiplication}

theories/ordinals/Hydra/Hydra_Definitions.v

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,7 @@ Class Hvariant {A:Type}{Lt:relation A}
497497
(Wf: well_founded Lt)(B : Battle)
498498
(m: Hydra -> A): Prop :=
499499
{variant_decr: forall i h h',
500-
h <> head -> battle_rel B i h h' -> Lt (m h') (m h)}.
500+
h <> head -> battle_rel B i h h' -> Lt (m h') (m h)}.
501501

502502
(* end snippet HvariantDef *)
503503

theories/ordinals/Hydra/Hydra_Lemmas.v

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -206,10 +206,10 @@ Qed.
206206
(** ** Properties of [battle] *)
207207

208208
(* begin snippet battleTrans *)
209-
Lemma rounds_trans {b:Battle} :
210-
forall i h j h', rounds b i h j h' ->
211-
forall k h0, rounds b k h0 i h ->
212-
rounds b k h0 j h'. (* .no-out *)
209+
Lemma rounds_trans {B:Battle} :
210+
forall i h j h', rounds B i h j h' ->
211+
forall k h0, rounds B k h0 i h ->
212+
rounds B k h0 j h'. (* .no-out *)
213213
(*| .. coq:: no-out |*)
214214
Proof.
215215
intros i h j h' H k h0. induction 1 /dr.

theories/ordinals/Hydra/Omega2_Small.v

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Section Impossibility_Proof.
2121

2222
Variable m : Hydra -> ON_Omega2.t.
2323
Context
24-
(Hvar: @Hvariant _ _ (ON_Generic.ON_wf (ON:=Omega2)) free m).
24+
(Hvar: Hvariant (ON_Generic.ON_wf (ON:=Omega2)) free m).
2525

2626
(* end snippet Impossibilitya *)
2727

theories/ordinals/OrdinalNotations/ON_Finite.v

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Abort.
4343

4444
(* begin snippet compareDef:: no-out *)
4545

46-
#[global] Instance compare_t {n:nat} : Compare (t n) :=
46+
#[global] Instance compare_fin {n:nat} : Compare (t n) :=
4747
fun (alpha beta : t n) => Nat.compare (proj1_sig alpha) (proj1_sig beta).
4848

4949
Lemma compare_correct {n} (alpha beta : t n) :

theories/ordinals/OrdinalNotations/ON_Generic.v

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ Class ON {A:Type} (lt: relation A) (cmp: Compare A) :=
2626
ON_comp :> Comparable lt cmp;
2727
ON_wf : well_founded lt;
2828
}.
29+
#[global] Existing Instance ON_comp.
2930
(* end snippet ONDef *)
3031

3132
(* begin snippet ONDefsa:: no-out *)
@@ -333,3 +334,5 @@ End SubON_properties.
333334

334335

335336

337+
338+

theories/ordinals/OrdinalNotations/ON_O.v

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@ Definition le {a:A} : relation (t a) :=
3131
clos_refl (t a) lt.
3232

3333
#[global]
34-
Instance compare_t {a:A} : Compare (t a) :=
34+
Instance compare_O {a:A} : Compare (t a) :=
3535
fun (alpha beta : t a) =>
3636
compare (proj1_sig alpha) (proj1_sig beta).
3737

3838
Lemma compare_correct {a} (alpha beta : t a) :
3939
CompSpec eq lt alpha beta (compare alpha beta).
4040
Proof.
4141
unfold CompSpec, compare.
42-
- destruct alpha, beta; unfold compare,compare_t; cbn.
42+
- destruct alpha, beta; unfold compare,compare_O; cbn.
4343
case_eq (compare x x0); unfold lt; cbn.
4444
+ constructor 1.
4545
destruct (comparable_comp_spec x x0); try discriminate.

theories/ordinals/OrdinalNotations/ON_Omega2.v

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ Open Scope ON_scope.
1313

1414
(* begin snippet Omega2Def:: no-out *)
1515

16-
#[ global ] Instance compare_nat_nat : Compare t :=
17-
compare_t compare_nat compare_nat.
16+
#[ global ] Instance compare_omega2 : Compare ON_mult.t :=
17+
compare_mult compare_nat compare_nat.
1818

19-
#[ global ] Instance Omega2: ON _ compare_nat_nat := ON_mult Omega Omega.
19+
#[ global ] Instance Omega2: ON _ compare_omega2 := ON_mult Omega Omega.
2020

2121
Definition t := ON_t.
2222
(* end snippet Omega2Def *)
@@ -89,6 +89,7 @@ Qed.
8989

9090
Lemma lt_succ_le alpha beta :
9191
alpha o< beta <-> succ alpha o<= beta. (* .no-out *)
92+
(* ... *)
9293
(*|
9394
.. coq:: none
9495
|*)
@@ -241,6 +242,7 @@ Qed.
241242

242243
Lemma succ_ok alpha beta :
243244
Successor beta alpha <-> beta = succ alpha. (* .no-out *)
245+
(* ... *)
244246
(*|
245247
.. coq:: none
246248
|*)
@@ -380,9 +382,8 @@ Infix "+" := plus : ON_scope.
380382

381383
Lemma plus_compat (n p: nat) :
382384
fin (n + p )%nat = fin n + fin p. (* .no-out *)
383-
Proof. (* .no-out *)
384-
destruct n; now cbn.
385-
Qed.
385+
Proof. (* .no-out *) destruct n; reflexivity. Qed.
386+
386387
(* end snippet plusDef *)
387388

388389

@@ -391,12 +392,10 @@ Qed.
391392
Compute 3 + omega.
392393

393394
Compute omega + 3.
394-
(* end snippet plusExamples *)
395-
396-
397-
Example non_commutativity_of_plus : omega + 3 <> 3 + omega.
398-
Proof. discriminate. Qed.
399395

396+
Example non_commutativity_of_plus: omega + 3 <> 3 + omega. (* .no-out *)
397+
Proof. (* .no-out *) discriminate. Qed.
398+
(* end snippet plusExamples *)
400399

401400
(* begin snippet multFinDef *)
402401

@@ -436,16 +435,14 @@ Proof. reflexivity. Qed.
436435

437436
#[global] Instance plus_assoc: Assoc eq plus.
438437
Proof.
439-
intros alpha beta gamma; destruct alpha, beta, gamma.
438+
intros (n,n0) (n1, n2) (n3,n4); cbn.
440439
destruct n, n0, n1, n2, n3, n4; cbn; auto; f_equal; abstract lia.
441440
Qed.
442441

443-
444442
Lemma succ_is_plus_1 alpha : alpha + 1 = succ alpha.
445443
Proof.
446-
unfold succ ;
447-
simpl;
448-
destruct alpha; cbn; destruct n, n0; try f_equal; abstract lia.
444+
unfold succ ; cbn; destruct alpha; cbn; destruct n, n0;
445+
try f_equal; abstract lia.
449446
Qed.
450447

451448
Lemma lt_omega alpha : alpha o< omega <-> exists n:nat, alpha = fin n.

theories/ordinals/OrdinalNotations/ON_Omega_plus_omega.v

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,17 @@ Open Scope opo_scope.
1515
(* begin snippet OmegaPlusOmegaDef:: no-out *)
1616

1717
#[global] Instance compare_nat_nat : Compare t :=
18-
compare_t compare_nat compare_nat.
18+
compare_plus compare_nat compare_nat.
1919

2020
#[global] Instance Omega_plus_Omega: ON _ compare_nat_nat :=
2121
ON_plus Omega Omega.
2222

2323
Definition t := ON_t.
2424

25-
Example ex1 : inl 7 o< inr 0.
26-
Proof. now apply compare_lt_iff. Qed.
25+
Compute inl 42 o?= inr 0.
26+
27+
Example ex1 : inl 7 o< inr 8.
28+
Proof. apply compare_lt_iff. trivial. Qed.
2729

2830
(* end snippet OmegaPlusOmegaDef *)
2931

0 commit comments

Comments
 (0)