src/HOL/Induct/Ordinals.thy
author paulson <lp15@cam.ac.uk>
Sun, 29 Mar 2020 21:30:52 +0100
changeset 71627 2a24c2015a61
parent 63680 6e1e8b5abbfa
child 76063 24c9f56aa035
permissions -rw-r--r--
more ugly old proofs
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
11649
wenzelm
parents: 11641
diff changeset
     1
(*  Title:      HOL/Induct/Ordinals.thy
11641
0c248bed5225 added Ordinals example;
wenzelm
parents:
diff changeset
     2
    Author:     Stefan Berghofer and Markus Wenzel, TU Muenchen
0c248bed5225 added Ordinals example;
wenzelm
parents:
diff changeset
     3
*)
0c248bed5225 added Ordinals example;
wenzelm
parents:
diff changeset
     4
60530
44f9873d6f6f isabelle update_cartouches;
wenzelm
parents: 58889
diff changeset
     5
section \<open>Ordinals\<close>
11641
0c248bed5225 added Ordinals example;
wenzelm
parents:
diff changeset
     6
46914
c2ca2c3d23a6 misc tuning;
wenzelm
parents: 39246
diff changeset
     7
theory Ordinals
c2ca2c3d23a6 misc tuning;
wenzelm
parents: 39246
diff changeset
     8
imports Main
c2ca2c3d23a6 misc tuning;
wenzelm
parents: 39246
diff changeset
     9
begin
11641
0c248bed5225 added Ordinals example;
wenzelm
parents:
diff changeset
    10
60530
44f9873d6f6f isabelle update_cartouches;
wenzelm
parents: 58889
diff changeset
    11
text \<open>
11641
0c248bed5225 added Ordinals example;
wenzelm
parents:
diff changeset
    12
  Some basic definitions of ordinal numbers.  Draws an Agda
11649
wenzelm
parents: 11641
diff changeset
    13
  development (in Martin-L\"of type theory) by Peter Hancock (see
63680
6e1e8b5abbfa more symbols;
wenzelm
parents: 60532
diff changeset
    14
  \<^url>\<open>http://www.dcs.ed.ac.uk/home/pgh/chat.html\<close>).
60530
44f9873d6f6f isabelle update_cartouches;
wenzelm
parents: 58889
diff changeset
    15
\<close>
11641
0c248bed5225 added Ordinals example;
wenzelm
parents:
diff changeset
    16
58310
91ea607a34d8 updated news
blanchet
parents: 58249
diff changeset
    17
datatype ordinal =
11641
0c248bed5225 added Ordinals example;
wenzelm
parents:
diff changeset
    18
    Zero
0c248bed5225 added Ordinals example;
wenzelm
parents:
diff changeset
    19
  | Succ ordinal
60532
7fb5b7dc8332 misc tuning;
wenzelm
parents: 60530
diff changeset
    20
  | Limit "nat \<Rightarrow> ordinal"
11641
0c248bed5225 added Ordinals example;
wenzelm
parents:
diff changeset
    21
60532
7fb5b7dc8332 misc tuning;
wenzelm
parents: 60530
diff changeset
    22
primrec pred :: "ordinal \<Rightarrow> nat \<Rightarrow> ordinal option"
46914
c2ca2c3d23a6 misc tuning;
wenzelm
parents: 39246
diff changeset
    23
where
11641
0c248bed5225 added Ordinals example;
wenzelm
parents:
diff changeset
    24
  "pred Zero n = None"
39246
9e58f0499f57 modernized primrec
haftmann
parents: 36862
diff changeset
    25
| "pred (Succ a) n = Some a"
9e58f0499f57 modernized primrec
haftmann
parents: 36862
diff changeset
    26
| "pred (Limit f) n = Some (f n)"
11641
0c248bed5225 added Ordinals example;
wenzelm
parents:
diff changeset
    27
60532
7fb5b7dc8332 misc tuning;
wenzelm
parents: 60530
diff changeset
    28
abbreviation (input) iter :: "('a \<Rightarrow> 'a) \<Rightarrow> nat \<Rightarrow> ('a \<Rightarrow> 'a)"
46914
c2ca2c3d23a6 misc tuning;
wenzelm
parents: 39246
diff changeset
    29
  where "iter f n \<equiv> f ^^ n"
c2ca2c3d23a6 misc tuning;
wenzelm
parents: 39246
diff changeset
    30
60532
7fb5b7dc8332 misc tuning;
wenzelm
parents: 60530
diff changeset
    31
definition OpLim :: "(nat \<Rightarrow> (ordinal \<Rightarrow> ordinal)) \<Rightarrow> (ordinal \<Rightarrow> ordinal)"
46914
c2ca2c3d23a6 misc tuning;
wenzelm
parents: 39246
diff changeset
    32
  where "OpLim F a = Limit (\<lambda>n. F n a)"
11641
0c248bed5225 added Ordinals example;
wenzelm
parents:
diff changeset
    33
60532
7fb5b7dc8332 misc tuning;
wenzelm
parents: 60530
diff changeset
    34
definition OpItw :: "(ordinal \<Rightarrow> ordinal) \<Rightarrow> (ordinal \<Rightarrow> ordinal)"  ("\<Squnion>")
46914
c2ca2c3d23a6 misc tuning;
wenzelm
parents: 39246
diff changeset
    35
  where "\<Squnion>f = OpLim (iter f)"
21404
eb85850d3eb7 more robust syntax for definition/abbreviation/notation;
wenzelm
parents: 19736
diff changeset
    36
60532
7fb5b7dc8332 misc tuning;
wenzelm
parents: 60530
diff changeset
    37
primrec cantor :: "ordinal \<Rightarrow> ordinal \<Rightarrow> ordinal"
46914
c2ca2c3d23a6 misc tuning;
wenzelm
parents: 39246
diff changeset
    38
where
11641
0c248bed5225 added Ordinals example;
wenzelm
parents:
diff changeset
    39
  "cantor a Zero = Succ a"
39246
9e58f0499f57 modernized primrec
haftmann
parents: 36862
diff changeset
    40
| "cantor a (Succ b) = \<Squnion>(\<lambda>x. cantor x b) a"
9e58f0499f57 modernized primrec
haftmann
parents: 36862
diff changeset
    41
| "cantor a (Limit f) = Limit (\<lambda>n. cantor a (f n))"
11641
0c248bed5225 added Ordinals example;
wenzelm
parents:
diff changeset
    42
60532
7fb5b7dc8332 misc tuning;
wenzelm
parents: 60530
diff changeset
    43
primrec Nabla :: "(ordinal \<Rightarrow> ordinal) \<Rightarrow> (ordinal \<Rightarrow> ordinal)"  ("\<nabla>")
46914
c2ca2c3d23a6 misc tuning;
wenzelm
parents: 39246
diff changeset
    44
where
11641
0c248bed5225 added Ordinals example;
wenzelm
parents:
diff changeset
    45
  "\<nabla>f Zero = f Zero"
39246
9e58f0499f57 modernized primrec
haftmann
parents: 36862
diff changeset
    46
| "\<nabla>f (Succ a) = f (Succ (\<nabla>f a))"
9e58f0499f57 modernized primrec
haftmann
parents: 36862
diff changeset
    47
| "\<nabla>f (Limit h) = Limit (\<lambda>n. \<nabla>f (h n))"
11641
0c248bed5225 added Ordinals example;
wenzelm
parents:
diff changeset
    48
60532
7fb5b7dc8332 misc tuning;
wenzelm
parents: 60530
diff changeset
    49
definition deriv :: "(ordinal \<Rightarrow> ordinal) \<Rightarrow> (ordinal \<Rightarrow> ordinal)"
46914
c2ca2c3d23a6 misc tuning;
wenzelm
parents: 39246
diff changeset
    50
  where "deriv f = \<nabla>(\<Squnion>f)"
11641
0c248bed5225 added Ordinals example;
wenzelm
parents:
diff changeset
    51
60532
7fb5b7dc8332 misc tuning;
wenzelm
parents: 60530
diff changeset
    52
primrec veblen :: "ordinal \<Rightarrow> ordinal \<Rightarrow> ordinal"
46914
c2ca2c3d23a6 misc tuning;
wenzelm
parents: 39246
diff changeset
    53
where
11641
0c248bed5225 added Ordinals example;
wenzelm
parents:
diff changeset
    54
  "veblen Zero = \<nabla>(OpLim (iter (cantor Zero)))"
39246
9e58f0499f57 modernized primrec
haftmann
parents: 36862
diff changeset
    55
| "veblen (Succ a) = \<nabla>(OpLim (iter (veblen a)))"
9e58f0499f57 modernized primrec
haftmann
parents: 36862
diff changeset
    56
| "veblen (Limit f) = \<nabla>(OpLim (\<lambda>n. veblen (f n)))"
11641
0c248bed5225 added Ordinals example;
wenzelm
parents:
diff changeset
    57
21404
eb85850d3eb7 more robust syntax for definition/abbreviation/notation;
wenzelm
parents: 19736
diff changeset
    58
definition "veb a = veblen a Zero"
53015
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 46914
diff changeset
    59
definition "\<epsilon>\<^sub>0 = veb Zero"
a1119cf551e8 standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
wenzelm
parents: 46914
diff changeset
    60
definition "\<Gamma>\<^sub>0 = Limit (\<lambda>n. iter veb n Zero)"
11641
0c248bed5225 added Ordinals example;
wenzelm
parents:
diff changeset
    61
0c248bed5225 added Ordinals example;
wenzelm
parents:
diff changeset
    62
end