src/HOL/Library/LSC.thy
author bulwahn
Fri, 11 Mar 2011 10:37:35 +0100
changeset 41905 e2611bc96022
child 41908 3bd9a21366d2
permissions -rw-r--r--
adding files for prototype of lazysmallcheck
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
41905
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
     1
(* Author: Lukas Bulwahn, TU Muenchen *)
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
     2
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
     3
header {* Counterexample generator based on LazySmallCheck *}
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
     4
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
     5
theory LSC
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
     6
imports Main "~~/src/HOL/Library/Code_Char"
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
     7
uses ("~~/src/HOL/Tools/LSC/lazysmallcheck.ML")
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
     8
begin
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
     9
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    10
subsection {* Counterexample generator *}
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    11
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    12
subsubsection {* LSC's deep representation of types of terms *}
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    13
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    14
datatype type = SumOfProd "type list list"
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    15
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    16
datatype "term" = Var "code_numeral list" type | Ctr code_numeral "term list"
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    17
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    18
datatype 'a cons = C type "(term list => 'a) list"
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    19
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    20
subsubsection {* auxilary functions for LSC *}
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    21
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    22
definition nth :: "'a list => code_numeral => 'a"
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    23
where
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    24
  "nth xs i = List.nth xs (Code_Numeral.nat_of i)"
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    25
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    26
lemma [code]:
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    27
  "nth (x # xs) i = (if i = 0 then x else nth xs (i - 1))"
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    28
unfolding nth_def by (cases i) simp
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    29
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    30
definition error :: "char list => 'a"
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    31
where
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    32
  "error = undefined"
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    33
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    34
code_const error ("Haskell" "error")
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    35
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    36
definition toEnum' :: "code_numeral => char"
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    37
where
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    38
  "toEnum' = undefined"
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    39
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    40
code_const toEnum' ("Haskell" "(toEnum . fromInteger)")
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    41
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    42
subsubsection {* LSC's basic operations *}
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    43
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    44
type_synonym 'a series = "code_numeral => 'a cons"
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    45
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    46
definition empty :: "'a series"
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    47
where
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    48
  "empty d = C (SumOfProd []) []"
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    49
  
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    50
definition cons :: "'a => 'a series"
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    51
where
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    52
  "cons a d = (C (SumOfProd [[]]) [(%_. a)])"
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    53
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    54
fun conv :: "(term list => 'a) list => term => 'a"
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    55
where
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    56
  "conv cs (Var p _) = error (Char Nibble0 Nibble0 # map toEnum' p)"
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    57
| "conv cs (Ctr i xs) = (nth cs i) xs"
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    58
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    59
fun nonEmpty :: "type => bool"
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    60
where
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    61
  "nonEmpty (SumOfProd ps) = (\<not> (List.null ps))"
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    62
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    63
definition "apply" :: "('a => 'b) series => 'a series => 'b series"
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    64
where
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    65
  "apply f a d =
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    66
     (case f d of C (SumOfProd ps) cfs =>
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    67
       case a (d - 1) of C ta cas =>
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    68
       let
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    69
         shallow = (d > 0 \<and> nonEmpty ta);
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    70
         cs = [(%xs'. (case xs' of [] => undefined | x # xs => cf xs (conv cas x))). shallow, cf <- cfs]
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    71
       in C (SumOfProd [ta # p. shallow, p <- ps]) cs)"
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    72
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    73
definition sum :: "'a series => 'a series => 'a series"
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    74
where
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    75
  "sum a b d =
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    76
    (case a d of C (SumOfProd ssa) ca => 
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    77
      case b d of C (SumOfProd ssb) cb =>
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    78
      C (SumOfProd (ssa @ ssb)) (ca @ cb))"
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    79
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    80
definition cons0 :: "'a => 'a series"
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    81
where
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    82
  "cons0 f = cons f"
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    83
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    84
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    85
subsubsection {* LSC's type class for enumeration *}
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    86
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    87
class serial =
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    88
  fixes series :: "code_numeral => 'a cons"
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    89
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    90
definition cons1 :: "('a::serial => 'b) => 'b series"
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    91
where
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    92
  "cons1 f = apply (cons f) series"
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    93
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    94
definition cons2 :: "('a :: serial => 'b :: serial => 'c) => 'c series"
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    95
where
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    96
  "cons2 f = apply (apply (cons f) series) series"
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    97
  
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    98
instantiation unit :: serial
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    99
begin
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   100
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   101
definition
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   102
  "series = cons0 ()"
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   103
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   104
instance ..
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   105
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   106
end
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   107
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   108
instantiation bool :: serial
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   109
begin
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   110
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   111
definition
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   112
  "series = sum (cons0 True) (cons0 False)" 
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   113
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   114
instance ..
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   115
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   116
end
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   117
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   118
instantiation option :: (serial) serial
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   119
begin
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   120
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   121
definition
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   122
  "series = sum (cons0 None) (cons1 Some)"
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   123
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   124
instance ..
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   125
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   126
end
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   127
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   128
instantiation sum :: (serial, serial) serial
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   129
begin
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   130
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   131
definition
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   132
  "series = sum (cons1 Inl) (cons1 Inr)"
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   133
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   134
instance ..
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   135
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   136
end
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   137
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   138
instantiation list :: (serial) serial
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   139
begin
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   140
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   141
function series_list :: "'a list series"
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   142
where
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   143
  "series_list d = sum (cons []) (apply (apply (cons Cons) series) series_list) d"
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   144
by pat_completeness auto
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   145
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   146
termination sorry
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   147
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   148
instance ..
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   149
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   150
end
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   151
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   152
instantiation nat :: serial
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   153
begin
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   154
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   155
function series_nat :: "nat series"
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   156
where
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   157
  "series_nat d = sum (cons 0) (apply (cons Suc) series_nat) d"
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   158
by pat_completeness auto
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   159
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   160
termination sorry
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   161
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   162
instance ..
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   163
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   164
end
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   165
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   166
instantiation Enum.finite_1 :: serial
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   167
begin
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   168
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   169
definition series_finite_1 :: "Enum.finite_1 series"
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   170
where
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   171
  "series_finite_1 = cons (Enum.finite_1.a\<^isub>1 :: Enum.finite_1)"
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   172
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   173
instance ..
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   174
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   175
end
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   176
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   177
instantiation Enum.finite_2 :: serial
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   178
begin
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   179
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   180
definition series_finite_2 :: "Enum.finite_2 series"
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   181
where
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   182
  "series_finite_2 = sum (cons (Enum.finite_2.a\<^isub>1 :: Enum.finite_2)) (cons (Enum.finite_2.a\<^isub>2 :: Enum.finite_2))"
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   183
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   184
instance ..
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   185
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   186
end
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   187
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   188
instantiation Enum.finite_3 :: serial
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   189
begin
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   190
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   191
definition series_finite_3 :: "Enum.finite_3 series"
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   192
where
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   193
  "series_finite_3 = sum (cons (Enum.finite_3.a\<^isub>1 :: Enum.finite_3)) (sum (cons (Enum.finite_3.a\<^isub>2 :: Enum.finite_3)) (cons (Enum.finite_3.a\<^isub>3 :: Enum.finite_3)))"
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   194
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   195
instance ..
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   196
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   197
end
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   198
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   199
subsubsection {* class is_testable *}
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   200
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   201
text {* The class is_testable ensures that all necessary type instances are generated. *}
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   202
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   203
class is_testable
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   204
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   205
instance bool :: is_testable ..
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   206
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   207
instance "fun" :: ("{term_of, serial}", is_testable) is_testable ..
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   208
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   209
definition ensure_testable :: "'a :: is_testable => 'a :: is_testable"
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   210
where
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   211
  "ensure_testable f = f"
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   212
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   213
subsubsection {* Setting up the counterexample generator *}
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   214
  
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   215
use "Tools/LSC/lazysmallcheck.ML"
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   216
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   217
setup {* Lazysmallcheck.setup *}
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   218
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   219
end