src/HOL/Library/LSC.thy
author bulwahn
Fri, 11 Mar 2011 10:37:37 +0100
changeset 41908 3bd9a21366d2
parent 41905 e2611bc96022
child 41909 383bbdad1650
permissions -rw-r--r--
changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
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
41908
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
    12
subsubsection {* Type code_int for Haskell's Int type *}
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
    13
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
    14
typedef (open) code_int = "UNIV \<Colon> int set"
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
    15
  morphisms int_of of_int by rule
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
    16
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
    17
lemma int_of_inject [simp]:
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
    18
  "int_of k = int_of l \<longleftrightarrow> k = l"
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
    19
  by (rule int_of_inject)
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
    20
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
    21
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
    22
instantiation code_int :: "{zero, one, minus, linorder}"
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
    23
begin
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
    24
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
    25
definition [simp, code del]:
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
    26
  "0 = of_int 0"
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
    27
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
    28
definition [simp, code del]:
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
    29
  "1 = of_int 1"
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
    30
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
    31
definition [simp, code del]:
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
    32
  "n - m = of_int (int_of n - int_of m)"
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
    33
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
    34
definition [simp, code del]:
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
    35
  "n \<le> m \<longleftrightarrow> int_of n \<le> int_of m"
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
    36
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
    37
definition [simp, code del]:
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
    38
  "n < m \<longleftrightarrow> int_of n < int_of m"
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
    39
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
    40
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
    41
instance proof qed (auto)
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
    42
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
    43
end
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
    44
(*
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
    45
lemma zero_code_int_code [code, code_unfold]:
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
    46
  "(0\<Colon>code_int) = Numeral0"
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
    47
  by (simp add: number_of_code_numeral_def Pls_def)
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
    48
lemma [code_post]: "Numeral0 = (0\<Colon>code_numeral)"
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
    49
  using zero_code_numeral_code ..
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
    50
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
    51
lemma one_code_numeral_code [code, code_unfold]:
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
    52
  "(1\<Colon>code_int) = Numeral1"
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
    53
  by (simp add: number_of_code_numeral_def Pls_def Bit1_def)
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
    54
lemma [code_post]: "Numeral1 = (1\<Colon>code_int)"
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
    55
  using one_code_numeral_code ..
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
    56
*)
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
    57
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
    58
code_const "0 \<Colon> code_int"
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
    59
  (Haskell "0")
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
    60
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
    61
code_const "1 \<Colon> code_int"
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
    62
  (Haskell "1")
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
    63
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
    64
code_const "minus \<Colon> code_int \<Rightarrow> code_int \<Rightarrow> code_int"
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
    65
  (Haskell "(_/ -/ _)")
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
    66
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
    67
code_const "op \<le> \<Colon> code_int \<Rightarrow> code_int \<Rightarrow> bool"
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
    68
  (Haskell infix 4 "<=")
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
    69
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
    70
code_const "op < \<Colon> code_int \<Rightarrow> code_int \<Rightarrow> bool"
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
    71
  (Haskell infix 4 "<")
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
    72
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
    73
code_type code_int
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
    74
  (Haskell "Int")
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
    75
41905
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    76
subsubsection {* LSC's deep representation of types of terms *}
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    77
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    78
datatype type = SumOfProd "type list list"
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    79
41908
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
    80
datatype "term" = Var "code_int list" type | Ctr code_int "term list"
41905
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    81
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    82
datatype 'a cons = C type "(term list => 'a) list"
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    83
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    84
subsubsection {* auxilary functions for LSC *}
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    85
41908
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
    86
consts nth :: "'a list => code_int => 'a"
41905
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    87
41908
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
    88
code_const nth ("Haskell" infixl 9  "!!")
41905
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    89
41908
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
    90
consts error :: "char list => 'a"
41905
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    91
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    92
code_const error ("Haskell" "error")
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    93
41908
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
    94
consts toEnum :: "code_int => char"
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
    95
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
    96
code_const toEnum ("Haskell" "toEnum")
41905
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    97
41908
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
    98
consts map_index :: "(code_int * 'a => 'b) => 'a list => 'b list"  
41905
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
    99
41908
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
   100
consts split_At :: "code_int => 'a list => 'a list * 'a list"
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
   101
 
41905
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   102
subsubsection {* LSC's basic operations *}
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   103
41908
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
   104
type_synonym 'a series = "code_int => 'a cons"
41905
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   105
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   106
definition empty :: "'a series"
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   107
where
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   108
  "empty d = C (SumOfProd []) []"
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   109
  
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   110
definition cons :: "'a => 'a series"
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   111
where
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   112
  "cons a d = (C (SumOfProd [[]]) [(%_. a)])"
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   113
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   114
fun conv :: "(term list => 'a) list => term => 'a"
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   115
where
41908
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
   116
  "conv cs (Var p _) = error (Char Nibble0 Nibble0 # map toEnum p)"
41905
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   117
| "conv cs (Ctr i xs) = (nth cs i) xs"
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   118
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   119
fun nonEmpty :: "type => bool"
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   120
where
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   121
  "nonEmpty (SumOfProd ps) = (\<not> (List.null ps))"
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   122
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   123
definition "apply" :: "('a => 'b) series => 'a series => 'b series"
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   124
where
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   125
  "apply f a d =
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   126
     (case f d of C (SumOfProd ps) cfs =>
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   127
       case a (d - 1) of C ta cas =>
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   128
       let
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   129
         shallow = (d > 0 \<and> nonEmpty ta);
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   130
         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
   131
       in C (SumOfProd [ta # p. shallow, p <- ps]) cs)"
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   132
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   133
definition sum :: "'a series => 'a series => 'a series"
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   134
where
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   135
  "sum a b d =
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   136
    (case a d of C (SumOfProd ssa) ca => 
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   137
      case b d of C (SumOfProd ssb) cb =>
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   138
      C (SumOfProd (ssa @ ssb)) (ca @ cb))"
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   139
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   140
definition cons0 :: "'a => 'a series"
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   141
where
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   142
  "cons0 f = cons f"
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   143
41908
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
   144
type_synonym pos = "code_int list"
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
   145
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
   146
subsubsection {* Term refinement *}
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
   147
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
   148
definition new :: "pos => type list list => term list"
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
   149
where
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
   150
  "new p ps = map_index (%(c, ts). Ctr c (map_index (%(i, t). Var (p @ [i]) t) ts)) ps"
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
   151
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
   152
fun refine :: "term => pos => term list" and refineList :: "term list => pos => (term list) list"
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
   153
where
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
   154
  "refine (Var p (SumOfProd ss)) [] = new p ss"
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
   155
| "refine (Ctr c xs) p = map (Ctr c) (refineList xs p)"
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
   156
| "refineList xs (i # is) = (let (ls, xrs) = split_At i xs in (case xrs of x#rs => [ls @ y # rs. y <- refine x is]))"
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
   157
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
   158
text {* Find total instantiations of a partial value *}
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
   159
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
   160
function total :: "term => term list"
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
   161
where
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
   162
  "total (Ctr c xs) = [Ctr c ys. ys <- map total xs]"
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
   163
| "total (Var p (SumOfProd ss)) = [y. x <- new p ss, y <- total x]"
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
   164
by pat_completeness auto
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
   165
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
   166
termination sorry
41905
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   167
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   168
subsubsection {* LSC's type class for enumeration *}
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   169
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   170
class serial =
41908
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
   171
  fixes series :: "code_int => 'a cons"
41905
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   172
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   173
definition cons1 :: "('a::serial => 'b) => 'b series"
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   174
where
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   175
  "cons1 f = apply (cons f) series"
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   176
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   177
definition cons2 :: "('a :: serial => 'b :: serial => 'c) => 'c series"
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   178
where
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   179
  "cons2 f = apply (apply (cons f) series) series"
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   180
  
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   181
instantiation unit :: serial
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   182
begin
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   183
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   184
definition
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   185
  "series = cons0 ()"
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   186
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   187
instance ..
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   188
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   189
end
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   190
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   191
instantiation bool :: serial
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   192
begin
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   193
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   194
definition
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   195
  "series = sum (cons0 True) (cons0 False)" 
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   196
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   197
instance ..
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   198
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   199
end
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   200
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   201
instantiation option :: (serial) serial
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   202
begin
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   203
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   204
definition
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   205
  "series = sum (cons0 None) (cons1 Some)"
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 ..
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   208
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   209
end
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   210
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   211
instantiation sum :: (serial, serial) serial
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   212
begin
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   213
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   214
definition
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   215
  "series = sum (cons1 Inl) (cons1 Inr)"
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   216
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   217
instance ..
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
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   220
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   221
instantiation list :: (serial) serial
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   222
begin
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   223
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   224
function series_list :: "'a list series"
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   225
where
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   226
  "series_list d = sum (cons []) (apply (apply (cons Cons) series) series_list) d"
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   227
by pat_completeness auto
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   228
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   229
termination sorry
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   230
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   231
instance ..
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   232
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   233
end
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   234
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   235
instantiation nat :: serial
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   236
begin
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   237
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   238
function series_nat :: "nat series"
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   239
where
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   240
  "series_nat d = sum (cons 0) (apply (cons Suc) series_nat) d"
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   241
by pat_completeness auto
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   242
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   243
termination sorry
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   244
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   245
instance ..
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   246
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   247
end
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   248
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   249
instantiation Enum.finite_1 :: serial
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   250
begin
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   251
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   252
definition series_finite_1 :: "Enum.finite_1 series"
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   253
where
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   254
  "series_finite_1 = cons (Enum.finite_1.a\<^isub>1 :: Enum.finite_1)"
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   255
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   256
instance ..
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   257
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   258
end
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   259
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   260
instantiation Enum.finite_2 :: serial
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   261
begin
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   262
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   263
definition series_finite_2 :: "Enum.finite_2 series"
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   264
where
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   265
  "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
   266
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   267
instance ..
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   268
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   269
end
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   270
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   271
instantiation Enum.finite_3 :: serial
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   272
begin
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   273
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   274
definition series_finite_3 :: "Enum.finite_3 series"
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   275
where
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   276
  "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
   277
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   278
instance ..
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   279
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   280
end
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   281
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   282
subsubsection {* class is_testable *}
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   283
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   284
text {* The class is_testable ensures that all necessary type instances are generated. *}
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   285
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   286
class is_testable
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   287
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   288
instance bool :: is_testable ..
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   289
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   290
instance "fun" :: ("{term_of, serial}", is_testable) is_testable ..
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   291
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   292
definition ensure_testable :: "'a :: is_testable => 'a :: is_testable"
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   293
where
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   294
  "ensure_testable f = f"
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   295
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   296
subsubsection {* Setting up the counterexample generator *}
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   297
  
41908
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
   298
use "~~/src/HOL/Tools/LSC/lazysmallcheck.ML"
41905
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   299
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   300
setup {* Lazysmallcheck.setup *}
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   301
41908
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
   302
hide_const (open) empty
3bd9a21366d2 changing invocation of ghc from interactive mode to compilation increases the performance of lazysmallcheck by a factor of twenty; changing Integer type to Int reduces by another 50 percent
bulwahn
parents: 41905
diff changeset
   303
41905
e2611bc96022 adding files for prototype of lazysmallcheck
bulwahn
parents:
diff changeset
   304
end