src/HOL/Codatatype/Examples/Misc_Codata.thy
author traytel
Mon, 03 Sep 2012 17:55:42 +0200
changeset 49102 ce2ef34eb828
parent 49074 d8af889dcbe3
child 49115 c9c09dbdbd1c
permissions -rw-r--r--
added examples for testing of coinductive witnesses
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
     1
(*  Title:      Codatatype_Examples/Misc_Data.thy
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
     2
    Author:     Dmitriy Traytel, TU Muenchen
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
     3
    Author:     Andrei Popescu, TU Muenchen
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
     4
    Copyright   2012
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
     5
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
     6
Miscellaneous codatatype declarations.
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
     7
*)
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
     8
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
     9
header {* Miscellaneous Codatatype Declarations *}
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    10
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    11
theory Misc_Codata
48980
debfa361f648 fixed import paths in examples
blanchet
parents: 48975
diff changeset
    12
imports "../Codatatype"
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    13
begin
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    14
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    15
ML {* quick_and_dirty := false *}
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    16
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    17
ML {* PolyML.fullGC (); *}
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    18
49074
d8af889dcbe3 renamed three BNF/(co)datatype-related commands
blanchet
parents: 48980
diff changeset
    19
codata_raw simple: 'a = "unit + unit + unit + unit"
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    20
49074
d8af889dcbe3 renamed three BNF/(co)datatype-related commands
blanchet
parents: 48980
diff changeset
    21
codata_raw stream: 's = "'a \<times> 's"
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    22
49074
d8af889dcbe3 renamed three BNF/(co)datatype-related commands
blanchet
parents: 48980
diff changeset
    23
codata_raw llist: 'llist = "unit + 'a \<times> 'llist"
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    24
49074
d8af889dcbe3 renamed three BNF/(co)datatype-related commands
blanchet
parents: 48980
diff changeset
    25
codata_raw some_passive: 'a = "'a + 'b + 'c + 'd + 'e"
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    26
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    27
(*
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    28
  ('a, 'b1, 'b2) F1 = 'a * 'b1 + 'a * 'b2
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    29
  ('a, 'b1, 'b2) F2 = unit + 'b1 * 'b2
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    30
*)
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    31
49074
d8af889dcbe3 renamed three BNF/(co)datatype-related commands
blanchet
parents: 48980
diff changeset
    32
codata_raw F1: 'b1 = "'a \<times> 'b1 + 'a \<times> 'b2"
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    33
and F2: 'b2 = "unit + 'b1 * 'b2"
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    34
49074
d8af889dcbe3 renamed three BNF/(co)datatype-related commands
blanchet
parents: 48980
diff changeset
    35
codata_raw EXPR:   'E = "'T + 'T \<times> 'E"
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    36
and TERM:   'T = "'F + 'F \<times> 'T"
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    37
and FACTOR: 'F = "'a + 'b + 'E"
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    38
49074
d8af889dcbe3 renamed three BNF/(co)datatype-related commands
blanchet
parents: 48980
diff changeset
    39
codata_raw llambda:
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    40
  'trm = "string +
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    41
          'trm \<times> 'trm +
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    42
          string \<times> 'trm +
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    43
          (string \<times> 'trm) fset \<times> 'trm"
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    44
49074
d8af889dcbe3 renamed three BNF/(co)datatype-related commands
blanchet
parents: 48980
diff changeset
    45
codata_raw par_llambda:
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    46
  'trm = "'a +
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    47
          'trm \<times> 'trm +
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    48
          'a \<times> 'trm +
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    49
          ('a \<times> 'trm) fset \<times> 'trm"
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    50
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    51
(*
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    52
  'a tree = Empty | Node of 'a * 'a forest      ('b = unit + 'a * 'c)
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    53
  'a forest = Nil | Cons of 'a tree * 'a forest ('c = unit + 'b * 'c)
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    54
*)
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    55
49074
d8af889dcbe3 renamed three BNF/(co)datatype-related commands
blanchet
parents: 48980
diff changeset
    56
codata_raw tree:     'tree = "unit + 'a \<times> 'forest"
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    57
and forest: 'forest = "unit + 'tree \<times> 'forest"
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    58
49074
d8af889dcbe3 renamed three BNF/(co)datatype-related commands
blanchet
parents: 48980
diff changeset
    59
codata_raw CPS: 'a = "'b + 'b \<Rightarrow> 'a"
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    60
49074
d8af889dcbe3 renamed three BNF/(co)datatype-related commands
blanchet
parents: 48980
diff changeset
    61
codata_raw fun_rhs: 'a = "'b1 \<Rightarrow> 'b2 \<Rightarrow> 'b3 \<Rightarrow> 'b4 \<Rightarrow> 'b5 \<Rightarrow> 'b6 \<Rightarrow> 'b7 \<Rightarrow> 'b8 \<Rightarrow> 'b9 \<Rightarrow> 'a"
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    62
49074
d8af889dcbe3 renamed three BNF/(co)datatype-related commands
blanchet
parents: 48980
diff changeset
    63
codata_raw fun_rhs': 'a = "'b1 \<Rightarrow> 'b2 \<Rightarrow> 'b3 \<Rightarrow> 'b4 \<Rightarrow> 'b5 \<Rightarrow> 'b6 \<Rightarrow> 'b7 \<Rightarrow> 'b8 \<Rightarrow> 'b9 \<Rightarrow> 'b10 \<Rightarrow>
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    64
                    'b11 \<Rightarrow> 'b12 \<Rightarrow> 'b13 \<Rightarrow> 'b14 \<Rightarrow> 'b15 \<Rightarrow> 'b16 \<Rightarrow> 'b17 \<Rightarrow> 'b18 \<Rightarrow> 'b19 \<Rightarrow> 'b20 \<Rightarrow> 'a"
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    65
49074
d8af889dcbe3 renamed three BNF/(co)datatype-related commands
blanchet
parents: 48980
diff changeset
    66
codata_raw some_killing: 'a = "'b \<Rightarrow> 'd \<Rightarrow> ('a + 'c)"
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    67
and in_here: 'c = "'d \<times> 'b + 'e"
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    68
49074
d8af889dcbe3 renamed three BNF/(co)datatype-related commands
blanchet
parents: 48980
diff changeset
    69
codata_raw some_killing': 'a = "'b \<Rightarrow> 'd \<Rightarrow> ('a + 'c)"
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    70
and in_here': 'c = "'d + 'e"
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    71
49074
d8af889dcbe3 renamed three BNF/(co)datatype-related commands
blanchet
parents: 48980
diff changeset
    72
codata_raw some_killing'': 'a = "'b \<Rightarrow> 'c"
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    73
and in_here'': 'c = "'d \<times> 'b + 'e"
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    74
49074
d8af889dcbe3 renamed three BNF/(co)datatype-related commands
blanchet
parents: 48980
diff changeset
    75
codata_raw less_killing: 'a = "'b \<Rightarrow> 'c"
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    76
49102
ce2ef34eb828 added examples for testing of coinductive witnesses
traytel
parents: 49074
diff changeset
    77
codata_raw
ce2ef34eb828 added examples for testing of coinductive witnesses
traytel
parents: 49074
diff changeset
    78
    wit3_F1: 'b1 = "'a1 \<times> 'b1 \<times> 'b2"
ce2ef34eb828 added examples for testing of coinductive witnesses
traytel
parents: 49074
diff changeset
    79
and wit3_F2: 'b2 = "'a2 \<times> 'b2"
ce2ef34eb828 added examples for testing of coinductive witnesses
traytel
parents: 49074
diff changeset
    80
and wit3_F3: 'b3 = "'a1 \<times> 'a2 \<times> 'b1 + 'a3 \<times> 'a1 \<times> 'a2 \<times> 'b1"
ce2ef34eb828 added examples for testing of coinductive witnesses
traytel
parents: 49074
diff changeset
    81
ce2ef34eb828 added examples for testing of coinductive witnesses
traytel
parents: 49074
diff changeset
    82
codata_raw
ce2ef34eb828 added examples for testing of coinductive witnesses
traytel
parents: 49074
diff changeset
    83
    coind_wit1: 'a = "'c \<times> 'a \<times> 'b \<times> 'd"
ce2ef34eb828 added examples for testing of coinductive witnesses
traytel
parents: 49074
diff changeset
    84
and coind_wit2: 'd = "'d \<times> 'e + 'c \<times> 'g"
ce2ef34eb828 added examples for testing of coinductive witnesses
traytel
parents: 49074
diff changeset
    85
and ind_wit:    'b = "unit + 'c"
ce2ef34eb828 added examples for testing of coinductive witnesses
traytel
parents: 49074
diff changeset
    86
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    87
(* SLOW, MEMORY-HUNGRY
49074
d8af889dcbe3 renamed three BNF/(co)datatype-related commands
blanchet
parents: 48980
diff changeset
    88
codata_raw K1': 'K1 = "'K2 + 'a list"
48975
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    89
and K2': 'K2 = "'K3 + 'c fset"
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    90
and K3': 'K3 = "'K3 + 'K4 + 'K4 \<times> 'K5"
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    91
and K4': 'K4 = "'K5 + 'a list list list"
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    92
and K5': 'K5 = "'K6"
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    93
and K6': 'K6 = "'K7"
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    94
and K7': 'K7 = "'K8"
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    95
and K8': 'K8 = "'K1 list"
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    96
*)
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    97
7f79f94a432c added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff changeset
    98
end