src/HOL/Tools/Predicate_Compile/predicate_compile_compilations.ML
author wenzelm
Sat, 05 Mar 2016 17:01:45 +0100
changeset 62519 a564458f94db
parent 55437 3fd63b92ea3b
child 69593 3dda49e08b9d
permissions -rw-r--r--
tuned signature -- clarified modules;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
36046
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
     1
(*  Title:      HOL/Tools/Predicate_Compile/predicate_compile_compilations.ML
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
     2
    Author:     Lukas Bulwahn, TU Muenchen
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
     3
41941
f823f7fae9a2 tuned headers;
wenzelm
parents: 40051
diff changeset
     4
Structures for different compilations of the predicate compiler.
36046
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
     5
*)
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
     6
55437
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
     7
structure Predicate_Comp_Funs =  (* FIXME proper signature *)
36046
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
     8
struct
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
     9
45461
130c90bb80b4 using more conventional names for monad plus operations
bulwahn
parents: 45450
diff changeset
    10
fun mk_monadT T = Type (@{type_name Predicate.pred}, [T])
36046
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
    11
45461
130c90bb80b4 using more conventional names for monad plus operations
bulwahn
parents: 45450
diff changeset
    12
fun dest_monadT (Type (@{type_name Predicate.pred}, [T])) = T
55437
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
    13
  | dest_monadT T = raise TYPE ("dest_monadT", [T], [])
36046
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
    14
55437
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
    15
fun mk_empty T = Const (@{const_name Orderings.bot}, mk_monadT T)
36046
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
    16
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
    17
fun mk_single t =
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
    18
  let val T = fastype_of t
55437
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
    19
  in Const(@{const_name Predicate.single}, T --> mk_monadT T) $ t end
36046
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
    20
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
    21
fun mk_bind (x, f) =
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
    22
  let val T as Type ("fun", [_, U]) = fastype_of f
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
    23
  in
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
    24
    Const (@{const_name Predicate.bind}, fastype_of x --> T --> U) $ x $ f
55437
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
    25
  end
36046
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
    26
55437
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
    27
val mk_plus = HOLogic.mk_binop @{const_name sup}
36046
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
    28
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
    29
fun mk_if cond = Const (@{const_name Predicate.if_pred},
55437
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
    30
  HOLogic.boolT --> mk_monadT HOLogic.unitT) $ cond
36046
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
    31
36049
0ce5b7a5c2fd adding iterate_upto interface in compilations and iterate_upto functions in Isabelle theories for arithmetic setup of the predicate compiler
bulwahn
parents: 36046
diff changeset
    32
fun mk_iterate_upto T (f, from, to) =
46664
1f6c140f9c72 moved predicate relations and conversion rules between set and predicate relations from Predicate.thy to Relation.thy; moved Predicate.thy upwards in theory hierarchy
haftmann
parents: 46638
diff changeset
    33
  list_comb (Const (@{const_name Predicate.iterate_upto},
51143
0a2371e7ced3 two target language numeral types: integer and natural, as replacement for code_numeral;
haftmann
parents: 51126
diff changeset
    34
      [@{typ natural} --> T, @{typ natural}, @{typ natural}] ---> mk_monadT T),
36049
0ce5b7a5c2fd adding iterate_upto interface in compilations and iterate_upto functions in Isabelle theories for arithmetic setup of the predicate compiler
bulwahn
parents: 36046
diff changeset
    35
    [f, from, to])
0ce5b7a5c2fd adding iterate_upto interface in compilations and iterate_upto functions in Isabelle theories for arithmetic setup of the predicate compiler
bulwahn
parents: 36046
diff changeset
    36
36046
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
    37
fun mk_not t =
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
    38
  let
45461
130c90bb80b4 using more conventional names for monad plus operations
bulwahn
parents: 45450
diff changeset
    39
    val T = mk_monadT HOLogic.unitT
36046
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
    40
  in Const (@{const_name Predicate.not_pred}, T --> T) $ t end
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
    41
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
    42
fun mk_Enum f =
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
    43
  let val T as Type ("fun", [T', _]) = fastype_of f
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
    44
  in
45461
130c90bb80b4 using more conventional names for monad plus operations
bulwahn
parents: 45450
diff changeset
    45
    Const (@{const_name Predicate.Pred}, T --> mk_monadT T') $ f    
36046
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
    46
  end;
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
    47
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
    48
fun mk_Eval (f, x) =
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
    49
  let
45461
130c90bb80b4 using more conventional names for monad plus operations
bulwahn
parents: 45450
diff changeset
    50
    val T = dest_monadT (fastype_of f)
36046
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
    51
  in
45461
130c90bb80b4 using more conventional names for monad plus operations
bulwahn
parents: 45450
diff changeset
    52
    Const (@{const_name Predicate.eval}, mk_monadT T --> T --> HOLogic.boolT) $ f $ x
55437
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
    53
  end
36046
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
    54
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
    55
fun dest_Eval (Const (@{const_name Predicate.eval}, _) $ f $ x) = (f, x)
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
    56
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
    57
fun mk_map T1 T2 tf tp = Const (@{const_name Predicate.map},
55437
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
    58
  (T1 --> T2) --> mk_monadT T1 --> mk_monadT T2) $ tf $ tp
36046
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
    59
55437
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
    60
val compfuns =
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
    61
  Predicate_Compile_Aux.CompilationFuns
45461
130c90bb80b4 using more conventional names for monad plus operations
bulwahn
parents: 45450
diff changeset
    62
    {mk_monadT = mk_monadT, dest_monadT = dest_monadT, mk_empty = mk_empty,
130c90bb80b4 using more conventional names for monad plus operations
bulwahn
parents: 45450
diff changeset
    63
    mk_single = mk_single, mk_bind = mk_bind, mk_plus = mk_plus, mk_if = mk_if,
55437
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
    64
    mk_iterate_upto = mk_iterate_upto, mk_not = mk_not, mk_map = mk_map}
36046
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
    65
55437
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
    66
end
36046
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
    67
55437
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
    68
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
    69
structure CPS_Comp_Funs =  (* FIXME proper signature *)
45450
dc2236b19a3d adding CPS compilation to predicate compiler;
bulwahn
parents: 41941
diff changeset
    70
struct
dc2236b19a3d adding CPS compilation to predicate compiler;
bulwahn
parents: 41941
diff changeset
    71
55437
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
    72
fun mk_monadT T =
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
    73
  (T --> @{typ "Code_Evaluation.term list option"}) --> @{typ "Code_Evaluation.term list option"}
45450
dc2236b19a3d adding CPS compilation to predicate compiler;
bulwahn
parents: 41941
diff changeset
    74
55437
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
    75
fun dest_monadT
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
    76
      (Type ("fun", [Type ("fun", [T, @{typ "term list option"}]), @{typ "term list option"}])) = T
45461
130c90bb80b4 using more conventional names for monad plus operations
bulwahn
parents: 45450
diff changeset
    77
  | dest_monadT T = raise TYPE ("dest_monadT", [T], []);
45450
dc2236b19a3d adding CPS compilation to predicate compiler;
bulwahn
parents: 41941
diff changeset
    78
55437
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
    79
fun mk_empty T = Const (@{const_name Quickcheck_Exhaustive.cps_empty}, mk_monadT T)
45450
dc2236b19a3d adding CPS compilation to predicate compiler;
bulwahn
parents: 41941
diff changeset
    80
dc2236b19a3d adding CPS compilation to predicate compiler;
bulwahn
parents: 41941
diff changeset
    81
fun mk_single t =
dc2236b19a3d adding CPS compilation to predicate compiler;
bulwahn
parents: 41941
diff changeset
    82
  let val T = fastype_of t
55437
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
    83
  in Const(@{const_name Quickcheck_Exhaustive.cps_single}, T --> mk_monadT T) $ t end
45450
dc2236b19a3d adding CPS compilation to predicate compiler;
bulwahn
parents: 41941
diff changeset
    84
dc2236b19a3d adding CPS compilation to predicate compiler;
bulwahn
parents: 41941
diff changeset
    85
fun mk_bind (x, f) =
dc2236b19a3d adding CPS compilation to predicate compiler;
bulwahn
parents: 41941
diff changeset
    86
  let val T as Type ("fun", [_, U]) = fastype_of f
dc2236b19a3d adding CPS compilation to predicate compiler;
bulwahn
parents: 41941
diff changeset
    87
  in
dc2236b19a3d adding CPS compilation to predicate compiler;
bulwahn
parents: 41941
diff changeset
    88
    Const (@{const_name Quickcheck_Exhaustive.cps_bind}, fastype_of x --> T --> U) $ x $ f
55437
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
    89
  end
45450
dc2236b19a3d adding CPS compilation to predicate compiler;
bulwahn
parents: 41941
diff changeset
    90
55437
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
    91
val mk_plus = HOLogic.mk_binop @{const_name Quickcheck_Exhaustive.cps_plus}
45450
dc2236b19a3d adding CPS compilation to predicate compiler;
bulwahn
parents: 41941
diff changeset
    92
dc2236b19a3d adding CPS compilation to predicate compiler;
bulwahn
parents: 41941
diff changeset
    93
fun mk_if cond = Const (@{const_name Quickcheck_Exhaustive.cps_if},
55437
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
    94
  HOLogic.boolT --> mk_monadT HOLogic.unitT) $ cond
45450
dc2236b19a3d adding CPS compilation to predicate compiler;
bulwahn
parents: 41941
diff changeset
    95
50056
72efd6b4038d dropped dead code
haftmann
parents: 46664
diff changeset
    96
fun mk_iterate_upto _ _ = error "not implemented yet"
45450
dc2236b19a3d adding CPS compilation to predicate compiler;
bulwahn
parents: 41941
diff changeset
    97
dc2236b19a3d adding CPS compilation to predicate compiler;
bulwahn
parents: 41941
diff changeset
    98
fun mk_not t =
dc2236b19a3d adding CPS compilation to predicate compiler;
bulwahn
parents: 41941
diff changeset
    99
  let
45461
130c90bb80b4 using more conventional names for monad plus operations
bulwahn
parents: 45450
diff changeset
   100
    val T = mk_monadT HOLogic.unitT
45450
dc2236b19a3d adding CPS compilation to predicate compiler;
bulwahn
parents: 41941
diff changeset
   101
  in Const (@{const_name Quickcheck_Exhaustive.cps_not}, T --> T) $ t end
dc2236b19a3d adding CPS compilation to predicate compiler;
bulwahn
parents: 41941
diff changeset
   102
50056
72efd6b4038d dropped dead code
haftmann
parents: 46664
diff changeset
   103
fun mk_Enum _ = error "not implemented"
45450
dc2236b19a3d adding CPS compilation to predicate compiler;
bulwahn
parents: 41941
diff changeset
   104
50056
72efd6b4038d dropped dead code
haftmann
parents: 46664
diff changeset
   105
fun mk_Eval _ = error "not implemented"
45450
dc2236b19a3d adding CPS compilation to predicate compiler;
bulwahn
parents: 41941
diff changeset
   106
50056
72efd6b4038d dropped dead code
haftmann
parents: 46664
diff changeset
   107
fun dest_Eval _ = error "not implemented"
45450
dc2236b19a3d adding CPS compilation to predicate compiler;
bulwahn
parents: 41941
diff changeset
   108
50056
72efd6b4038d dropped dead code
haftmann
parents: 46664
diff changeset
   109
fun mk_map _ _ _ _ = error "not implemented"
45450
dc2236b19a3d adding CPS compilation to predicate compiler;
bulwahn
parents: 41941
diff changeset
   110
55437
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   111
val compfuns =
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   112
  Predicate_Compile_Aux.CompilationFuns
45461
130c90bb80b4 using more conventional names for monad plus operations
bulwahn
parents: 45450
diff changeset
   113
    {mk_monadT = mk_monadT, dest_monadT = dest_monadT, mk_empty = mk_empty,
130c90bb80b4 using more conventional names for monad plus operations
bulwahn
parents: 45450
diff changeset
   114
    mk_single = mk_single, mk_bind = mk_bind, mk_plus = mk_plus, mk_if = mk_if,
45450
dc2236b19a3d adding CPS compilation to predicate compiler;
bulwahn
parents: 41941
diff changeset
   115
    mk_iterate_upto = mk_iterate_upto, mk_not = mk_not, mk_map = mk_map};
dc2236b19a3d adding CPS compilation to predicate compiler;
bulwahn
parents: 41941
diff changeset
   116
55437
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   117
end
45450
dc2236b19a3d adding CPS compilation to predicate compiler;
bulwahn
parents: 41941
diff changeset
   118
55437
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   119
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   120
structure Pos_Bounded_CPS_Comp_Funs =  (* FIXME proper signature *)
45450
dc2236b19a3d adding CPS compilation to predicate compiler;
bulwahn
parents: 41941
diff changeset
   121
struct
dc2236b19a3d adding CPS compilation to predicate compiler;
bulwahn
parents: 41941
diff changeset
   122
45750
17100f4ce0b5 adding genuine flag to predicate_compile_quickcheck and prolog_quickcheck (cf. 5e46c225370e);
bulwahn
parents: 45461
diff changeset
   123
val resultT = @{typ "(bool * Code_Evaluation.term list) option"}
51143
0a2371e7ced3 two target language numeral types: integer and natural, as replacement for code_numeral;
haftmann
parents: 51126
diff changeset
   124
fun mk_monadT T = (T --> resultT) --> @{typ "natural"} --> resultT
45450
dc2236b19a3d adding CPS compilation to predicate compiler;
bulwahn
parents: 41941
diff changeset
   125
45750
17100f4ce0b5 adding genuine flag to predicate_compile_quickcheck and prolog_quickcheck (cf. 5e46c225370e);
bulwahn
parents: 45461
diff changeset
   126
fun dest_monadT (Type ("fun", [Type ("fun", [T, @{typ "(bool * term list) option"}]),
51143
0a2371e7ced3 two target language numeral types: integer and natural, as replacement for code_numeral;
haftmann
parents: 51126
diff changeset
   127
  @{typ "natural => (bool * term list) option"}])) = T
55437
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   128
  | dest_monadT T = raise TYPE ("dest_monadT", [T], [])
45450
dc2236b19a3d adding CPS compilation to predicate compiler;
bulwahn
parents: 41941
diff changeset
   129
55437
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   130
fun mk_empty T = Const (@{const_name Quickcheck_Exhaustive.pos_bound_cps_empty}, mk_monadT T)
45450
dc2236b19a3d adding CPS compilation to predicate compiler;
bulwahn
parents: 41941
diff changeset
   131
dc2236b19a3d adding CPS compilation to predicate compiler;
bulwahn
parents: 41941
diff changeset
   132
fun mk_single t =
dc2236b19a3d adding CPS compilation to predicate compiler;
bulwahn
parents: 41941
diff changeset
   133
  let val T = fastype_of t
55437
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   134
  in Const(@{const_name Quickcheck_Exhaustive.pos_bound_cps_single}, T --> mk_monadT T) $ t end
45450
dc2236b19a3d adding CPS compilation to predicate compiler;
bulwahn
parents: 41941
diff changeset
   135
dc2236b19a3d adding CPS compilation to predicate compiler;
bulwahn
parents: 41941
diff changeset
   136
fun mk_bind (x, f) =
dc2236b19a3d adding CPS compilation to predicate compiler;
bulwahn
parents: 41941
diff changeset
   137
  let val T as Type ("fun", [_, U]) = fastype_of f
dc2236b19a3d adding CPS compilation to predicate compiler;
bulwahn
parents: 41941
diff changeset
   138
  in
dc2236b19a3d adding CPS compilation to predicate compiler;
bulwahn
parents: 41941
diff changeset
   139
    Const (@{const_name Quickcheck_Exhaustive.pos_bound_cps_bind}, fastype_of x --> T --> U) $ x $ f
dc2236b19a3d adding CPS compilation to predicate compiler;
bulwahn
parents: 41941
diff changeset
   140
  end;
dc2236b19a3d adding CPS compilation to predicate compiler;
bulwahn
parents: 41941
diff changeset
   141
55437
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   142
val mk_plus = HOLogic.mk_binop @{const_name Quickcheck_Exhaustive.pos_bound_cps_plus}
45450
dc2236b19a3d adding CPS compilation to predicate compiler;
bulwahn
parents: 41941
diff changeset
   143
55437
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   144
fun mk_if cond =
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   145
  Const (@{const_name Quickcheck_Exhaustive.pos_bound_cps_if},
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   146
    HOLogic.boolT --> mk_monadT HOLogic.unitT) $ cond
45450
dc2236b19a3d adding CPS compilation to predicate compiler;
bulwahn
parents: 41941
diff changeset
   147
50056
72efd6b4038d dropped dead code
haftmann
parents: 46664
diff changeset
   148
fun mk_iterate_upto _ _ = error "not implemented yet"
45450
dc2236b19a3d adding CPS compilation to predicate compiler;
bulwahn
parents: 41941
diff changeset
   149
dc2236b19a3d adding CPS compilation to predicate compiler;
bulwahn
parents: 41941
diff changeset
   150
fun mk_not t =
dc2236b19a3d adding CPS compilation to predicate compiler;
bulwahn
parents: 41941
diff changeset
   151
  let
dc2236b19a3d adding CPS compilation to predicate compiler;
bulwahn
parents: 41941
diff changeset
   152
    val nT = @{typ "(unit Quickcheck_Exhaustive.unknown =>
51143
0a2371e7ced3 two target language numeral types: integer and natural, as replacement for code_numeral;
haftmann
parents: 51126
diff changeset
   153
      Code_Evaluation.term list Quickcheck_Exhaustive.three_valued) => natural =>
45450
dc2236b19a3d adding CPS compilation to predicate compiler;
bulwahn
parents: 41941
diff changeset
   154
      Code_Evaluation.term list Quickcheck_Exhaustive.three_valued"}
45461
130c90bb80b4 using more conventional names for monad plus operations
bulwahn
parents: 45450
diff changeset
   155
    val T = mk_monadT HOLogic.unitT
45450
dc2236b19a3d adding CPS compilation to predicate compiler;
bulwahn
parents: 41941
diff changeset
   156
  in Const (@{const_name Quickcheck_Exhaustive.pos_bound_cps_not}, nT --> T) $ t end
dc2236b19a3d adding CPS compilation to predicate compiler;
bulwahn
parents: 41941
diff changeset
   157
50056
72efd6b4038d dropped dead code
haftmann
parents: 46664
diff changeset
   158
fun mk_Enum _ = error "not implemented"
45450
dc2236b19a3d adding CPS compilation to predicate compiler;
bulwahn
parents: 41941
diff changeset
   159
50056
72efd6b4038d dropped dead code
haftmann
parents: 46664
diff changeset
   160
fun mk_Eval _ = error "not implemented"
45450
dc2236b19a3d adding CPS compilation to predicate compiler;
bulwahn
parents: 41941
diff changeset
   161
50056
72efd6b4038d dropped dead code
haftmann
parents: 46664
diff changeset
   162
fun dest_Eval _ = error "not implemented"
45450
dc2236b19a3d adding CPS compilation to predicate compiler;
bulwahn
parents: 41941
diff changeset
   163
50056
72efd6b4038d dropped dead code
haftmann
parents: 46664
diff changeset
   164
fun mk_map _ _ _ _ = error "not implemented"
45450
dc2236b19a3d adding CPS compilation to predicate compiler;
bulwahn
parents: 41941
diff changeset
   165
55437
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   166
val compfuns =
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   167
  Predicate_Compile_Aux.CompilationFuns
45461
130c90bb80b4 using more conventional names for monad plus operations
bulwahn
parents: 45450
diff changeset
   168
    {mk_monadT = mk_monadT, dest_monadT = dest_monadT, mk_empty = mk_empty,
130c90bb80b4 using more conventional names for monad plus operations
bulwahn
parents: 45450
diff changeset
   169
    mk_single = mk_single, mk_bind = mk_bind, mk_plus = mk_plus, mk_if = mk_if,
45450
dc2236b19a3d adding CPS compilation to predicate compiler;
bulwahn
parents: 41941
diff changeset
   170
    mk_iterate_upto = mk_iterate_upto, mk_not = mk_not, mk_map = mk_map};
dc2236b19a3d adding CPS compilation to predicate compiler;
bulwahn
parents: 41941
diff changeset
   171
55437
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   172
end
45450
dc2236b19a3d adding CPS compilation to predicate compiler;
bulwahn
parents: 41941
diff changeset
   173
55437
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   174
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   175
structure Neg_Bounded_CPS_Comp_Funs =  (* FIXME proper signature *)
45450
dc2236b19a3d adding CPS compilation to predicate compiler;
bulwahn
parents: 41941
diff changeset
   176
struct
dc2236b19a3d adding CPS compilation to predicate compiler;
bulwahn
parents: 41941
diff changeset
   177
45461
130c90bb80b4 using more conventional names for monad plus operations
bulwahn
parents: 45450
diff changeset
   178
fun mk_monadT T =
45450
dc2236b19a3d adding CPS compilation to predicate compiler;
bulwahn
parents: 41941
diff changeset
   179
  (Type (@{type_name "Quickcheck_Exhaustive.unknown"}, [T])
dc2236b19a3d adding CPS compilation to predicate compiler;
bulwahn
parents: 41941
diff changeset
   180
    --> @{typ "Code_Evaluation.term list Quickcheck_Exhaustive.three_valued"})
51143
0a2371e7ced3 two target language numeral types: integer and natural, as replacement for code_numeral;
haftmann
parents: 51126
diff changeset
   181
    --> @{typ "natural => Code_Evaluation.term list Quickcheck_Exhaustive.three_valued"}
45450
dc2236b19a3d adding CPS compilation to predicate compiler;
bulwahn
parents: 41941
diff changeset
   182
55437
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   183
fun dest_monadT
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   184
    (Type ("fun", [Type ("fun", [Type (@{type_name "Quickcheck_Exhaustive.unknown"}, [T]),
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   185
      @{typ "term list Quickcheck_Exhaustive.three_valued"}]),
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   186
      @{typ "natural => term list Quickcheck_Exhaustive.three_valued"}])) = T
45461
130c90bb80b4 using more conventional names for monad plus operations
bulwahn
parents: 45450
diff changeset
   187
  | dest_monadT T = raise TYPE ("dest_monadT", [T], []);
45450
dc2236b19a3d adding CPS compilation to predicate compiler;
bulwahn
parents: 41941
diff changeset
   188
55437
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   189
fun mk_empty T = Const (@{const_name Quickcheck_Exhaustive.neg_bound_cps_empty}, mk_monadT T)
45450
dc2236b19a3d adding CPS compilation to predicate compiler;
bulwahn
parents: 41941
diff changeset
   190
dc2236b19a3d adding CPS compilation to predicate compiler;
bulwahn
parents: 41941
diff changeset
   191
fun mk_single t =
dc2236b19a3d adding CPS compilation to predicate compiler;
bulwahn
parents: 41941
diff changeset
   192
  let val T = fastype_of t
55437
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   193
  in Const(@{const_name Quickcheck_Exhaustive.neg_bound_cps_single}, T --> mk_monadT T) $ t end
45450
dc2236b19a3d adding CPS compilation to predicate compiler;
bulwahn
parents: 41941
diff changeset
   194
dc2236b19a3d adding CPS compilation to predicate compiler;
bulwahn
parents: 41941
diff changeset
   195
fun mk_bind (x, f) =
dc2236b19a3d adding CPS compilation to predicate compiler;
bulwahn
parents: 41941
diff changeset
   196
  let val T as Type ("fun", [_, U]) = fastype_of f
dc2236b19a3d adding CPS compilation to predicate compiler;
bulwahn
parents: 41941
diff changeset
   197
  in
dc2236b19a3d adding CPS compilation to predicate compiler;
bulwahn
parents: 41941
diff changeset
   198
    Const (@{const_name Quickcheck_Exhaustive.neg_bound_cps_bind}, fastype_of x --> T --> U) $ x $ f
dc2236b19a3d adding CPS compilation to predicate compiler;
bulwahn
parents: 41941
diff changeset
   199
  end;
dc2236b19a3d adding CPS compilation to predicate compiler;
bulwahn
parents: 41941
diff changeset
   200
55437
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   201
val mk_plus = HOLogic.mk_binop @{const_name Quickcheck_Exhaustive.neg_bound_cps_plus}
45450
dc2236b19a3d adding CPS compilation to predicate compiler;
bulwahn
parents: 41941
diff changeset
   202
dc2236b19a3d adding CPS compilation to predicate compiler;
bulwahn
parents: 41941
diff changeset
   203
fun mk_if cond = Const (@{const_name Quickcheck_Exhaustive.neg_bound_cps_if},
55437
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   204
  HOLogic.boolT --> mk_monadT HOLogic.unitT) $ cond
45450
dc2236b19a3d adding CPS compilation to predicate compiler;
bulwahn
parents: 41941
diff changeset
   205
50056
72efd6b4038d dropped dead code
haftmann
parents: 46664
diff changeset
   206
fun mk_iterate_upto _ _ = error "not implemented"
45450
dc2236b19a3d adding CPS compilation to predicate compiler;
bulwahn
parents: 41941
diff changeset
   207
dc2236b19a3d adding CPS compilation to predicate compiler;
bulwahn
parents: 41941
diff changeset
   208
fun mk_not t =
dc2236b19a3d adding CPS compilation to predicate compiler;
bulwahn
parents: 41941
diff changeset
   209
  let
45461
130c90bb80b4 using more conventional names for monad plus operations
bulwahn
parents: 45450
diff changeset
   210
    val T = mk_monadT HOLogic.unitT
45750
17100f4ce0b5 adding genuine flag to predicate_compile_quickcheck and prolog_quickcheck (cf. 5e46c225370e);
bulwahn
parents: 45461
diff changeset
   211
    val pT = @{typ "(unit => (bool * Code_Evaluation.term list) option)"}
51143
0a2371e7ced3 two target language numeral types: integer and natural, as replacement for code_numeral;
haftmann
parents: 51126
diff changeset
   212
      --> @{typ "natural => (bool * Code_Evaluation.term list) option"}
45450
dc2236b19a3d adding CPS compilation to predicate compiler;
bulwahn
parents: 41941
diff changeset
   213
  in Const (@{const_name Quickcheck_Exhaustive.neg_bound_cps_not}, pT --> T) $ t end
dc2236b19a3d adding CPS compilation to predicate compiler;
bulwahn
parents: 41941
diff changeset
   214
50056
72efd6b4038d dropped dead code
haftmann
parents: 46664
diff changeset
   215
fun mk_Enum _ = error "not implemented"
45450
dc2236b19a3d adding CPS compilation to predicate compiler;
bulwahn
parents: 41941
diff changeset
   216
50056
72efd6b4038d dropped dead code
haftmann
parents: 46664
diff changeset
   217
fun mk_Eval _ = error "not implemented"
45450
dc2236b19a3d adding CPS compilation to predicate compiler;
bulwahn
parents: 41941
diff changeset
   218
50056
72efd6b4038d dropped dead code
haftmann
parents: 46664
diff changeset
   219
fun dest_Eval _ = error "not implemented"
45450
dc2236b19a3d adding CPS compilation to predicate compiler;
bulwahn
parents: 41941
diff changeset
   220
50056
72efd6b4038d dropped dead code
haftmann
parents: 46664
diff changeset
   221
fun mk_map _ _ _ _  = error "not implemented"
45450
dc2236b19a3d adding CPS compilation to predicate compiler;
bulwahn
parents: 41941
diff changeset
   222
55437
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   223
val compfuns =
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   224
  Predicate_Compile_Aux.CompilationFuns
45461
130c90bb80b4 using more conventional names for monad plus operations
bulwahn
parents: 45450
diff changeset
   225
    {mk_monadT = mk_monadT, dest_monadT = dest_monadT, mk_empty = mk_empty,
130c90bb80b4 using more conventional names for monad plus operations
bulwahn
parents: 45450
diff changeset
   226
    mk_single = mk_single, mk_bind = mk_bind, mk_plus = mk_plus, mk_if = mk_if,
45450
dc2236b19a3d adding CPS compilation to predicate compiler;
bulwahn
parents: 41941
diff changeset
   227
    mk_iterate_upto = mk_iterate_upto, mk_not = mk_not, mk_map = mk_map};
dc2236b19a3d adding CPS compilation to predicate compiler;
bulwahn
parents: 41941
diff changeset
   228
dc2236b19a3d adding CPS compilation to predicate compiler;
bulwahn
parents: 41941
diff changeset
   229
end;
dc2236b19a3d adding CPS compilation to predicate compiler;
bulwahn
parents: 41941
diff changeset
   230
dc2236b19a3d adding CPS compilation to predicate compiler;
bulwahn
parents: 41941
diff changeset
   231
55437
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   232
structure RandomPredCompFuns =  (* FIXME proper signature *)
36046
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   233
struct
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   234
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   235
fun mk_randompredT T =
45461
130c90bb80b4 using more conventional names for monad plus operations
bulwahn
parents: 45450
diff changeset
   236
  @{typ Random.seed} --> HOLogic.mk_prodT (Predicate_Comp_Funs.mk_monadT T, @{typ Random.seed})
36046
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   237
37678
0040bafffdef "prod" and "sum" replace "*" and "+" respectively
haftmann
parents: 36049
diff changeset
   238
fun dest_randompredT (Type ("fun", [@{typ Random.seed}, Type (@{type_name Product_Type.prod},
51126
df86080de4cb reform of predicate compiler / quickcheck theories:
haftmann
parents: 50056
diff changeset
   239
  [Type (@{type_name Predicate.pred}, [T]), @{typ Random.seed}])])) = T
55437
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   240
  | dest_randompredT T = raise TYPE ("dest_randompredT", [T], [])
36046
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   241
51126
df86080de4cb reform of predicate compiler / quickcheck theories:
haftmann
parents: 50056
diff changeset
   242
fun mk_empty T = Const(@{const_name Random_Pred.empty}, mk_randompredT T)
36046
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   243
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   244
fun mk_single t =
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   245
  let               
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   246
    val T = fastype_of t
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   247
  in
51126
df86080de4cb reform of predicate compiler / quickcheck theories:
haftmann
parents: 50056
diff changeset
   248
    Const (@{const_name Random_Pred.single}, T --> mk_randompredT T) $ t
55437
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   249
  end
36046
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   250
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   251
fun mk_bind (x, f) =
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   252
  let
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   253
    val T as (Type ("fun", [_, U])) = fastype_of f
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   254
  in
51126
df86080de4cb reform of predicate compiler / quickcheck theories:
haftmann
parents: 50056
diff changeset
   255
    Const (@{const_name Random_Pred.bind}, fastype_of x --> T --> U) $ x $ f
36046
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   256
  end
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   257
51126
df86080de4cb reform of predicate compiler / quickcheck theories:
haftmann
parents: 50056
diff changeset
   258
val mk_plus = HOLogic.mk_binop @{const_name Random_Pred.union}
36046
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   259
51126
df86080de4cb reform of predicate compiler / quickcheck theories:
haftmann
parents: 50056
diff changeset
   260
fun mk_if cond = Const (@{const_name Random_Pred.if_randompred},
36046
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   261
  HOLogic.boolT --> mk_randompredT HOLogic.unitT) $ cond;
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   262
36049
0ce5b7a5c2fd adding iterate_upto interface in compilations and iterate_upto functions in Isabelle theories for arithmetic setup of the predicate compiler
bulwahn
parents: 36046
diff changeset
   263
fun mk_iterate_upto T (f, from, to) =
51126
df86080de4cb reform of predicate compiler / quickcheck theories:
haftmann
parents: 50056
diff changeset
   264
  list_comb (Const (@{const_name Random_Pred.iterate_upto},
51143
0a2371e7ced3 two target language numeral types: integer and natural, as replacement for code_numeral;
haftmann
parents: 51126
diff changeset
   265
      [@{typ natural} --> T, @{typ natural}, @{typ natural}] ---> mk_randompredT T),
36049
0ce5b7a5c2fd adding iterate_upto interface in compilations and iterate_upto functions in Isabelle theories for arithmetic setup of the predicate compiler
bulwahn
parents: 36046
diff changeset
   266
    [f, from, to])
0ce5b7a5c2fd adding iterate_upto interface in compilations and iterate_upto functions in Isabelle theories for arithmetic setup of the predicate compiler
bulwahn
parents: 36046
diff changeset
   267
36046
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   268
fun mk_not t =
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   269
  let
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   270
    val T = mk_randompredT HOLogic.unitT
51126
df86080de4cb reform of predicate compiler / quickcheck theories:
haftmann
parents: 50056
diff changeset
   271
  in Const (@{const_name Random_Pred.not_randompred}, T --> T) $ t end
36046
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   272
51126
df86080de4cb reform of predicate compiler / quickcheck theories:
haftmann
parents: 50056
diff changeset
   273
fun mk_map T1 T2 tf tp = Const (@{const_name Random_Pred.map},
36046
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   274
  (T1 --> T2) --> mk_randompredT T1 --> mk_randompredT T2) $ tf $ tp
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   275
55437
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   276
val compfuns =
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   277
  Predicate_Compile_Aux.CompilationFuns
45461
130c90bb80b4 using more conventional names for monad plus operations
bulwahn
parents: 45450
diff changeset
   278
    {mk_monadT = mk_randompredT, dest_monadT = dest_randompredT,
130c90bb80b4 using more conventional names for monad plus operations
bulwahn
parents: 45450
diff changeset
   279
    mk_empty = mk_empty, mk_single = mk_single, mk_bind = mk_bind, mk_plus = mk_plus, mk_if = mk_if,
36049
0ce5b7a5c2fd adding iterate_upto interface in compilations and iterate_upto functions in Isabelle theories for arithmetic setup of the predicate compiler
bulwahn
parents: 36046
diff changeset
   280
    mk_iterate_upto = mk_iterate_upto, mk_not = mk_not, mk_map = mk_map};
36046
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   281
55437
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   282
end
36046
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   283
55437
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   284
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   285
structure DSequence_CompFuns =  (* FIXME proper signature *)
36046
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   286
struct
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   287
51143
0a2371e7ced3 two target language numeral types: integer and natural, as replacement for code_numeral;
haftmann
parents: 51126
diff changeset
   288
fun mk_dseqT T = Type ("fun", [@{typ natural}, Type ("fun", [@{typ bool},
36046
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   289
  Type (@{type_name Option.option}, [Type  (@{type_name Lazy_Sequence.lazy_sequence}, [T])])])])
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   290
51143
0a2371e7ced3 two target language numeral types: integer and natural, as replacement for code_numeral;
haftmann
parents: 51126
diff changeset
   291
fun dest_dseqT (Type ("fun", [@{typ natural}, Type ("fun", [@{typ bool},
36046
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   292
  Type (@{type_name Option.option}, [Type (@{type_name Lazy_Sequence.lazy_sequence}, [T])])])])) = T
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   293
  | dest_dseqT T = raise TYPE ("dest_dseqT", [T], []);
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   294
51126
df86080de4cb reform of predicate compiler / quickcheck theories:
haftmann
parents: 50056
diff changeset
   295
fun mk_empty T = Const (@{const_name Limited_Sequence.empty}, mk_dseqT T);
36046
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   296
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   297
fun mk_single t =
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   298
  let val T = fastype_of t
51126
df86080de4cb reform of predicate compiler / quickcheck theories:
haftmann
parents: 50056
diff changeset
   299
  in Const(@{const_name Limited_Sequence.single}, T --> mk_dseqT T) $ t end;
36046
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   300
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   301
fun mk_bind (x, f) =
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   302
  let val T as Type ("fun", [_, U]) = fastype_of f
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   303
  in
51126
df86080de4cb reform of predicate compiler / quickcheck theories:
haftmann
parents: 50056
diff changeset
   304
    Const (@{const_name Limited_Sequence.bind}, fastype_of x --> T --> U) $ x $ f
36046
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   305
  end;
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   306
51126
df86080de4cb reform of predicate compiler / quickcheck theories:
haftmann
parents: 50056
diff changeset
   307
val mk_plus = HOLogic.mk_binop @{const_name Limited_Sequence.union};
36046
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   308
51126
df86080de4cb reform of predicate compiler / quickcheck theories:
haftmann
parents: 50056
diff changeset
   309
fun mk_if cond = Const (@{const_name Limited_Sequence.if_seq},
36046
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   310
  HOLogic.boolT --> mk_dseqT HOLogic.unitT) $ cond;
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   311
50056
72efd6b4038d dropped dead code
haftmann
parents: 46664
diff changeset
   312
fun mk_iterate_upto _ _ = raise Fail "No iterate_upto compilation"
36049
0ce5b7a5c2fd adding iterate_upto interface in compilations and iterate_upto functions in Isabelle theories for arithmetic setup of the predicate compiler
bulwahn
parents: 36046
diff changeset
   313
36046
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   314
fun mk_not t = let val T = mk_dseqT HOLogic.unitT
51126
df86080de4cb reform of predicate compiler / quickcheck theories:
haftmann
parents: 50056
diff changeset
   315
  in Const (@{const_name Limited_Sequence.not_seq}, T --> T) $ t end
36046
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   316
51126
df86080de4cb reform of predicate compiler / quickcheck theories:
haftmann
parents: 50056
diff changeset
   317
fun mk_map T1 T2 tf tp = Const (@{const_name Limited_Sequence.map},
36046
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   318
  (T1 --> T2) --> mk_dseqT T1 --> mk_dseqT T2) $ tf $ tp
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   319
55437
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   320
val compfuns =
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   321
  Predicate_Compile_Aux.CompilationFuns
45461
130c90bb80b4 using more conventional names for monad plus operations
bulwahn
parents: 45450
diff changeset
   322
    {mk_monadT = mk_dseqT, dest_monadT = dest_dseqT,
130c90bb80b4 using more conventional names for monad plus operations
bulwahn
parents: 45450
diff changeset
   323
    mk_empty = mk_empty, mk_single = mk_single, mk_bind = mk_bind, mk_plus = mk_plus, mk_if = mk_if,
36049
0ce5b7a5c2fd adding iterate_upto interface in compilations and iterate_upto functions in Isabelle theories for arithmetic setup of the predicate compiler
bulwahn
parents: 36046
diff changeset
   324
    mk_iterate_upto = mk_iterate_upto, mk_not = mk_not, mk_map = mk_map}
36046
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   325
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   326
end;
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   327
55437
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   328
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   329
structure New_Pos_DSequence_CompFuns =  (* FIXME proper signature *)
40051
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   330
struct
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   331
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   332
fun mk_pos_dseqT T =
55437
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   333
  @{typ natural} --> Type (@{type_name Lazy_Sequence.lazy_sequence}, [T])
40051
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   334
55437
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   335
fun dest_pos_dseqT
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   336
      (Type ("fun", [@{typ natural}, Type (@{type_name Lazy_Sequence.lazy_sequence}, [T])])) = T
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   337
  | dest_pos_dseqT T = raise TYPE ("dest_pos_dseqT", [T], [])
40051
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   338
55437
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   339
fun mk_empty T = Const (@{const_name Limited_Sequence.pos_empty}, mk_pos_dseqT T)
40051
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   340
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   341
fun mk_single t =
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   342
  let
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   343
    val T = fastype_of t
55437
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   344
  in Const(@{const_name Limited_Sequence.pos_single}, T --> mk_pos_dseqT T) $ t end
40051
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   345
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   346
fun mk_bind (x, f) =
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   347
  let
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   348
    val T as Type ("fun", [_, U]) = fastype_of f
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   349
  in
51126
df86080de4cb reform of predicate compiler / quickcheck theories:
haftmann
parents: 50056
diff changeset
   350
    Const (@{const_name Limited_Sequence.pos_bind}, fastype_of x --> T --> U) $ x $ f
55437
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   351
  end
40051
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   352
  
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   353
fun mk_decr_bind (x, f) =
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   354
  let
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   355
    val T as Type ("fun", [_, U]) = fastype_of f
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   356
  in
51126
df86080de4cb reform of predicate compiler / quickcheck theories:
haftmann
parents: 50056
diff changeset
   357
    Const (@{const_name Limited_Sequence.pos_decr_bind}, fastype_of x --> T --> U) $ x $ f
55437
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   358
  end
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   359
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   360
val mk_plus = HOLogic.mk_binop @{const_name Limited_Sequence.pos_union}
40051
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   361
55437
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   362
fun mk_if cond =
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   363
  Const (@{const_name Limited_Sequence.pos_if_seq},
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   364
    HOLogic.boolT --> mk_pos_dseqT HOLogic.unitT) $ cond
40051
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   365
50056
72efd6b4038d dropped dead code
haftmann
parents: 46664
diff changeset
   366
fun mk_iterate_upto _ _ = raise Fail "No iterate_upto compilation"
40051
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   367
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   368
fun mk_not t =
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   369
  let
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   370
    val pT = mk_pos_dseqT HOLogic.unitT
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   371
    val nT =
51143
0a2371e7ced3 two target language numeral types: integer and natural, as replacement for code_numeral;
haftmann
parents: 51126
diff changeset
   372
      @{typ natural} --> Type (@{type_name Lazy_Sequence.lazy_sequence},
40051
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   373
        [Type (@{type_name Option.option}, [@{typ unit}])])
51126
df86080de4cb reform of predicate compiler / quickcheck theories:
haftmann
parents: 50056
diff changeset
   374
  in Const (@{const_name Limited_Sequence.pos_not_seq}, nT --> pT) $ t end
40051
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   375
55437
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   376
fun mk_map T1 T2 tf tp =
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   377
  Const (@{const_name Limited_Sequence.pos_map},
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   378
    (T1 --> T2) --> mk_pos_dseqT T1 --> mk_pos_dseqT T2) $ tf $ tp
40051
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   379
55437
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   380
val depth_limited_compfuns =
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   381
  Predicate_Compile_Aux.CompilationFuns
45461
130c90bb80b4 using more conventional names for monad plus operations
bulwahn
parents: 45450
diff changeset
   382
    {mk_monadT = mk_pos_dseqT, dest_monadT = dest_pos_dseqT,
130c90bb80b4 using more conventional names for monad plus operations
bulwahn
parents: 45450
diff changeset
   383
    mk_empty = mk_empty, mk_single = mk_single, mk_bind = mk_decr_bind, mk_plus = mk_plus, mk_if = mk_if,
40051
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   384
    mk_iterate_upto = mk_iterate_upto, mk_not = mk_not, mk_map = mk_map}
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   385
55437
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   386
val depth_unlimited_compfuns =
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   387
  Predicate_Compile_Aux.CompilationFuns
45461
130c90bb80b4 using more conventional names for monad plus operations
bulwahn
parents: 45450
diff changeset
   388
    {mk_monadT = mk_pos_dseqT, dest_monadT = dest_pos_dseqT,
130c90bb80b4 using more conventional names for monad plus operations
bulwahn
parents: 45450
diff changeset
   389
    mk_empty = mk_empty, mk_single = mk_single, mk_bind = mk_bind, mk_plus = mk_plus, mk_if = mk_if,
40051
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   390
    mk_iterate_upto = mk_iterate_upto, mk_not = mk_not, mk_map = mk_map}
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   391
55437
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   392
end
40051
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   393
55437
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   394
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   395
structure New_Neg_DSequence_CompFuns =  (* FIXME proper signature *)
40051
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   396
struct
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   397
51143
0a2371e7ced3 two target language numeral types: integer and natural, as replacement for code_numeral;
haftmann
parents: 51126
diff changeset
   398
fun mk_neg_dseqT T = @{typ natural} -->
40051
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   399
  Type (@{type_name Lazy_Sequence.lazy_sequence}, [Type (@{type_name Option.option}, [T])])
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   400
55437
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   401
fun dest_neg_dseqT
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   402
    (Type ("fun", [@{typ natural},
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   403
      Type (@{type_name Lazy_Sequence.lazy_sequence}, [Type (@{type_name Option.option}, [T])])])) =
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   404
      T
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   405
  | dest_neg_dseqT T = raise TYPE ("dest_neg_dseqT", [T], [])
40051
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   406
55437
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   407
fun mk_empty T = Const (@{const_name Limited_Sequence.neg_empty}, mk_neg_dseqT T)
40051
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   408
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   409
fun mk_single t =
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   410
  let
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   411
    val T = fastype_of t
55437
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   412
  in Const(@{const_name Limited_Sequence.neg_single}, T --> mk_neg_dseqT T) $ t end
40051
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   413
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   414
fun mk_bind (x, f) =
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   415
  let
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   416
    val T as Type ("fun", [_, U]) = fastype_of f
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   417
  in
51126
df86080de4cb reform of predicate compiler / quickcheck theories:
haftmann
parents: 50056
diff changeset
   418
    Const (@{const_name Limited_Sequence.neg_bind}, fastype_of x --> T --> U) $ x $ f
55437
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   419
  end
40051
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   420
  
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   421
fun mk_decr_bind (x, f) =
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   422
  let
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   423
    val T as Type ("fun", [_, U]) = fastype_of f
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   424
  in
51126
df86080de4cb reform of predicate compiler / quickcheck theories:
haftmann
parents: 50056
diff changeset
   425
    Const (@{const_name Limited_Sequence.neg_decr_bind}, fastype_of x --> T --> U) $ x $ f
55437
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   426
  end
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   427
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   428
val mk_plus = HOLogic.mk_binop @{const_name Limited_Sequence.neg_union}
40051
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   429
55437
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   430
fun mk_if cond =
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   431
  Const (@{const_name Limited_Sequence.neg_if_seq},
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   432
    HOLogic.boolT --> mk_neg_dseqT HOLogic.unitT) $ cond
40051
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   433
50056
72efd6b4038d dropped dead code
haftmann
parents: 46664
diff changeset
   434
fun mk_iterate_upto _ _ = raise Fail "No iterate_upto compilation"
40051
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   435
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   436
fun mk_not t =
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   437
  let
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   438
    val nT = mk_neg_dseqT HOLogic.unitT
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   439
    val pT =
51143
0a2371e7ced3 two target language numeral types: integer and natural, as replacement for code_numeral;
haftmann
parents: 51126
diff changeset
   440
      @{typ natural} --> Type (@{type_name Lazy_Sequence.lazy_sequence},
40051
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   441
        [@{typ unit}])
51126
df86080de4cb reform of predicate compiler / quickcheck theories:
haftmann
parents: 50056
diff changeset
   442
  in Const (@{const_name Limited_Sequence.neg_not_seq}, pT --> nT) $ t end
40051
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   443
55437
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   444
fun mk_map T1 T2 tf tp =
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   445
  Const (@{const_name Limited_Sequence.neg_map},
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   446
    (T1 --> T2) --> mk_neg_dseqT T1 --> mk_neg_dseqT T2) $ tf $ tp
40051
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   447
55437
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   448
val depth_limited_compfuns =
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   449
  Predicate_Compile_Aux.CompilationFuns
45461
130c90bb80b4 using more conventional names for monad plus operations
bulwahn
parents: 45450
diff changeset
   450
    {mk_monadT = mk_neg_dseqT, dest_monadT = dest_neg_dseqT,
130c90bb80b4 using more conventional names for monad plus operations
bulwahn
parents: 45450
diff changeset
   451
    mk_empty = mk_empty, mk_single = mk_single, mk_bind = mk_decr_bind, mk_plus = mk_plus, mk_if = mk_if,
40051
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   452
    mk_iterate_upto = mk_iterate_upto, mk_not = mk_not, mk_map = mk_map}
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   453
55437
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   454
val depth_unlimited_compfuns =
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   455
  Predicate_Compile_Aux.CompilationFuns
45461
130c90bb80b4 using more conventional names for monad plus operations
bulwahn
parents: 45450
diff changeset
   456
    {mk_monadT = mk_neg_dseqT, dest_monadT = dest_neg_dseqT,
130c90bb80b4 using more conventional names for monad plus operations
bulwahn
parents: 45450
diff changeset
   457
    mk_empty = mk_empty, mk_single = mk_single, mk_bind = mk_bind, mk_plus = mk_plus, mk_if = mk_if,
40051
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   458
    mk_iterate_upto = mk_iterate_upto, mk_not = mk_not, mk_map = mk_map}
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   459
55437
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   460
end
40051
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   461
55437
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   462
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   463
structure New_Pos_Random_Sequence_CompFuns =  (* FIXME proper signature *)
36046
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   464
struct
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   465
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   466
fun mk_pos_random_dseqT T =
51143
0a2371e7ced3 two target language numeral types: integer and natural, as replacement for code_numeral;
haftmann
parents: 51126
diff changeset
   467
  @{typ natural} --> @{typ natural} --> @{typ Random.seed} -->
0a2371e7ced3 two target language numeral types: integer and natural, as replacement for code_numeral;
haftmann
parents: 51126
diff changeset
   468
    @{typ natural} --> Type (@{type_name Lazy_Sequence.lazy_sequence}, [T])
36046
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   469
55437
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   470
fun dest_pos_random_dseqT
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   471
    (Type ("fun", [@{typ natural}, Type ("fun", [@{typ natural},
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   472
      Type ("fun", [@{typ Random.seed}, Type ("fun", [@{typ natural},
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   473
      Type (@{type_name Lazy_Sequence.lazy_sequence}, [T])])])])])) = T
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   474
  | dest_pos_random_dseqT T = raise TYPE ("dest_random_dseqT", [T], [])
36046
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   475
55437
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   476
fun mk_empty T = Const (@{const_name Random_Sequence.pos_empty}, mk_pos_random_dseqT T)
36046
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   477
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   478
fun mk_single t =
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   479
  let
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   480
    val T = fastype_of t
55437
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   481
  in Const(@{const_name Random_Sequence.pos_single}, T --> mk_pos_random_dseqT T) $ t end
36046
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   482
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   483
fun mk_bind (x, f) =
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   484
  let
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   485
    val T as Type ("fun", [_, U]) = fastype_of f
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   486
  in
51126
df86080de4cb reform of predicate compiler / quickcheck theories:
haftmann
parents: 50056
diff changeset
   487
    Const (@{const_name Random_Sequence.pos_bind}, fastype_of x --> T --> U) $ x $ f
55437
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   488
  end
40051
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   489
40049
75d9f57123d6 adding decreasing bind and non-decreasing bind; depth-limited and depth-unlimited compilation possible
bulwahn
parents: 39648
diff changeset
   490
fun mk_decr_bind (x, f) =
75d9f57123d6 adding decreasing bind and non-decreasing bind; depth-limited and depth-unlimited compilation possible
bulwahn
parents: 39648
diff changeset
   491
  let
75d9f57123d6 adding decreasing bind and non-decreasing bind; depth-limited and depth-unlimited compilation possible
bulwahn
parents: 39648
diff changeset
   492
    val T as Type ("fun", [_, U]) = fastype_of f
75d9f57123d6 adding decreasing bind and non-decreasing bind; depth-limited and depth-unlimited compilation possible
bulwahn
parents: 39648
diff changeset
   493
  in
51126
df86080de4cb reform of predicate compiler / quickcheck theories:
haftmann
parents: 50056
diff changeset
   494
    Const (@{const_name Random_Sequence.pos_decr_bind}, fastype_of x --> T --> U) $ x $ f
55437
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   495
  end
36046
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   496
51126
df86080de4cb reform of predicate compiler / quickcheck theories:
haftmann
parents: 50056
diff changeset
   497
val mk_plus = HOLogic.mk_binop @{const_name Random_Sequence.pos_union};
36046
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   498
51126
df86080de4cb reform of predicate compiler / quickcheck theories:
haftmann
parents: 50056
diff changeset
   499
fun mk_if cond = Const (@{const_name Random_Sequence.pos_if_random_dseq},
36046
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   500
  HOLogic.boolT --> mk_pos_random_dseqT HOLogic.unitT) $ cond;
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   501
36049
0ce5b7a5c2fd adding iterate_upto interface in compilations and iterate_upto functions in Isabelle theories for arithmetic setup of the predicate compiler
bulwahn
parents: 36046
diff changeset
   502
fun mk_iterate_upto T (f, from, to) =
51126
df86080de4cb reform of predicate compiler / quickcheck theories:
haftmann
parents: 50056
diff changeset
   503
  list_comb (Const (@{const_name Random_Sequence.pos_iterate_upto},
51143
0a2371e7ced3 two target language numeral types: integer and natural, as replacement for code_numeral;
haftmann
parents: 51126
diff changeset
   504
      [@{typ natural} --> T, @{typ natural}, @{typ natural}]
36049
0ce5b7a5c2fd adding iterate_upto interface in compilations and iterate_upto functions in Isabelle theories for arithmetic setup of the predicate compiler
bulwahn
parents: 36046
diff changeset
   505
        ---> mk_pos_random_dseqT T),
0ce5b7a5c2fd adding iterate_upto interface in compilations and iterate_upto functions in Isabelle theories for arithmetic setup of the predicate compiler
bulwahn
parents: 36046
diff changeset
   506
    [f, from, to])
0ce5b7a5c2fd adding iterate_upto interface in compilations and iterate_upto functions in Isabelle theories for arithmetic setup of the predicate compiler
bulwahn
parents: 36046
diff changeset
   507
36046
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   508
fun mk_not t =
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   509
  let
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   510
    val pT = mk_pos_random_dseqT HOLogic.unitT
51143
0a2371e7ced3 two target language numeral types: integer and natural, as replacement for code_numeral;
haftmann
parents: 51126
diff changeset
   511
    val nT = @{typ natural} --> @{typ natural} --> @{typ Random.seed} -->
0a2371e7ced3 two target language numeral types: integer and natural, as replacement for code_numeral;
haftmann
parents: 51126
diff changeset
   512
      @{typ natural} --> Type (@{type_name Lazy_Sequence.lazy_sequence},
36046
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   513
        [Type (@{type_name Option.option}, [@{typ unit}])])
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   514
51126
df86080de4cb reform of predicate compiler / quickcheck theories:
haftmann
parents: 50056
diff changeset
   515
  in Const (@{const_name Random_Sequence.pos_not_random_dseq}, nT --> pT) $ t end
36046
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   516
55437
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   517
fun mk_map T1 T2 tf tp =
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   518
  Const (@{const_name Random_Sequence.pos_map},
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   519
    (T1 --> T2) --> mk_pos_random_dseqT T1 --> mk_pos_random_dseqT T2) $ tf $ tp
36046
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   520
55437
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   521
val depth_limited_compfuns =
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   522
  Predicate_Compile_Aux.CompilationFuns
45461
130c90bb80b4 using more conventional names for monad plus operations
bulwahn
parents: 45450
diff changeset
   523
    {mk_monadT = mk_pos_random_dseqT, dest_monadT = dest_pos_random_dseqT,
130c90bb80b4 using more conventional names for monad plus operations
bulwahn
parents: 45450
diff changeset
   524
    mk_empty = mk_empty, mk_single = mk_single, mk_bind = mk_decr_bind, mk_plus = mk_plus, mk_if = mk_if,
40049
75d9f57123d6 adding decreasing bind and non-decreasing bind; depth-limited and depth-unlimited compilation possible
bulwahn
parents: 39648
diff changeset
   525
    mk_iterate_upto = mk_iterate_upto, mk_not = mk_not, mk_map = mk_map}
75d9f57123d6 adding decreasing bind and non-decreasing bind; depth-limited and depth-unlimited compilation possible
bulwahn
parents: 39648
diff changeset
   526
55437
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   527
val depth_unlimited_compfuns =
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   528
  Predicate_Compile_Aux.CompilationFuns
45461
130c90bb80b4 using more conventional names for monad plus operations
bulwahn
parents: 45450
diff changeset
   529
    {mk_monadT = mk_pos_random_dseqT, dest_monadT = dest_pos_random_dseqT,
130c90bb80b4 using more conventional names for monad plus operations
bulwahn
parents: 45450
diff changeset
   530
    mk_empty = mk_empty, mk_single = mk_single, mk_bind = mk_bind, mk_plus = mk_plus, mk_if = mk_if,
36049
0ce5b7a5c2fd adding iterate_upto interface in compilations and iterate_upto functions in Isabelle theories for arithmetic setup of the predicate compiler
bulwahn
parents: 36046
diff changeset
   531
    mk_iterate_upto = mk_iterate_upto, mk_not = mk_not, mk_map = mk_map}
55437
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   532
36046
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   533
end;
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   534
55437
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   535
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   536
structure New_Neg_Random_Sequence_CompFuns =  (* FIXME proper signature *)
36046
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   537
struct
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   538
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   539
fun mk_neg_random_dseqT T =
55437
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   540
  @{typ natural} --> @{typ natural} --> @{typ Random.seed} -->
51143
0a2371e7ced3 two target language numeral types: integer and natural, as replacement for code_numeral;
haftmann
parents: 51126
diff changeset
   541
    @{typ natural} --> 
36046
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   542
    Type (@{type_name Lazy_Sequence.lazy_sequence}, [Type (@{type_name Option.option}, [T])])
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   543
55437
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   544
fun dest_neg_random_dseqT
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   545
    (Type ("fun", [@{typ natural}, Type ("fun", [@{typ natural},
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   546
      Type ("fun", [@{typ Random.seed}, Type ("fun", [@{typ natural},
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   547
        Type (@{type_name Lazy_Sequence.lazy_sequence},
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   548
          [Type (@{type_name Option.option}, [T])])])])])])) = T
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   549
  | dest_neg_random_dseqT T = raise TYPE ("dest_random_dseqT", [T], [])
36046
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   550
55437
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   551
fun mk_empty T = Const (@{const_name Random_Sequence.neg_empty}, mk_neg_random_dseqT T)
36046
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   552
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   553
fun mk_single t =
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   554
  let
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   555
    val T = fastype_of t
55437
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   556
  in Const(@{const_name Random_Sequence.neg_single}, T --> mk_neg_random_dseqT T) $ t end
36046
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   557
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   558
fun mk_bind (x, f) =
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   559
  let
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   560
    val T as Type ("fun", [_, U]) = fastype_of f
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   561
  in
51126
df86080de4cb reform of predicate compiler / quickcheck theories:
haftmann
parents: 50056
diff changeset
   562
    Const (@{const_name Random_Sequence.neg_bind}, fastype_of x --> T --> U) $ x $ f
55437
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   563
  end
36046
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   564
40049
75d9f57123d6 adding decreasing bind and non-decreasing bind; depth-limited and depth-unlimited compilation possible
bulwahn
parents: 39648
diff changeset
   565
fun mk_decr_bind (x, f) =
75d9f57123d6 adding decreasing bind and non-decreasing bind; depth-limited and depth-unlimited compilation possible
bulwahn
parents: 39648
diff changeset
   566
  let
75d9f57123d6 adding decreasing bind and non-decreasing bind; depth-limited and depth-unlimited compilation possible
bulwahn
parents: 39648
diff changeset
   567
    val T as Type ("fun", [_, U]) = fastype_of f
75d9f57123d6 adding decreasing bind and non-decreasing bind; depth-limited and depth-unlimited compilation possible
bulwahn
parents: 39648
diff changeset
   568
  in
51126
df86080de4cb reform of predicate compiler / quickcheck theories:
haftmann
parents: 50056
diff changeset
   569
    Const (@{const_name Random_Sequence.neg_decr_bind}, fastype_of x --> T --> U) $ x $ f
55437
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   570
  end
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   571
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   572
val mk_plus = HOLogic.mk_binop @{const_name Random_Sequence.neg_union}
40049
75d9f57123d6 adding decreasing bind and non-decreasing bind; depth-limited and depth-unlimited compilation possible
bulwahn
parents: 39648
diff changeset
   573
55437
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   574
fun mk_if cond =
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   575
  Const (@{const_name Random_Sequence.neg_if_random_dseq},
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   576
    HOLogic.boolT --> mk_neg_random_dseqT HOLogic.unitT) $ cond
36046
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   577
36049
0ce5b7a5c2fd adding iterate_upto interface in compilations and iterate_upto functions in Isabelle theories for arithmetic setup of the predicate compiler
bulwahn
parents: 36046
diff changeset
   578
fun mk_iterate_upto T (f, from, to) =
51126
df86080de4cb reform of predicate compiler / quickcheck theories:
haftmann
parents: 50056
diff changeset
   579
  list_comb (Const (@{const_name Random_Sequence.neg_iterate_upto},
51143
0a2371e7ced3 two target language numeral types: integer and natural, as replacement for code_numeral;
haftmann
parents: 51126
diff changeset
   580
      [@{typ natural} --> T, @{typ natural}, @{typ natural}]
36049
0ce5b7a5c2fd adding iterate_upto interface in compilations and iterate_upto functions in Isabelle theories for arithmetic setup of the predicate compiler
bulwahn
parents: 36046
diff changeset
   581
        ---> mk_neg_random_dseqT T),
0ce5b7a5c2fd adding iterate_upto interface in compilations and iterate_upto functions in Isabelle theories for arithmetic setup of the predicate compiler
bulwahn
parents: 36046
diff changeset
   582
    [f, from, to])
0ce5b7a5c2fd adding iterate_upto interface in compilations and iterate_upto functions in Isabelle theories for arithmetic setup of the predicate compiler
bulwahn
parents: 36046
diff changeset
   583
36046
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   584
fun mk_not t =
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   585
  let
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   586
    val nT = mk_neg_random_dseqT HOLogic.unitT
51143
0a2371e7ced3 two target language numeral types: integer and natural, as replacement for code_numeral;
haftmann
parents: 51126
diff changeset
   587
    val pT = @{typ natural} --> @{typ natural} --> @{typ Random.seed} -->
0a2371e7ced3 two target language numeral types: integer and natural, as replacement for code_numeral;
haftmann
parents: 51126
diff changeset
   588
    @{typ natural} --> Type (@{type_name Lazy_Sequence.lazy_sequence}, [@{typ unit}])
51126
df86080de4cb reform of predicate compiler / quickcheck theories:
haftmann
parents: 50056
diff changeset
   589
  in Const (@{const_name Random_Sequence.neg_not_random_dseq}, pT --> nT) $ t end
36046
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   590
55437
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   591
fun mk_map T1 T2 tf tp =
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   592
  Const (@{const_name Random_Sequence.neg_map},
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   593
    (T1 --> T2) --> mk_neg_random_dseqT T1 --> mk_neg_random_dseqT T2) $ tf $ tp
36046
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   594
55437
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   595
val depth_limited_compfuns =
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   596
  Predicate_Compile_Aux.CompilationFuns
45461
130c90bb80b4 using more conventional names for monad plus operations
bulwahn
parents: 45450
diff changeset
   597
    {mk_monadT = mk_neg_random_dseqT, dest_monadT = dest_neg_random_dseqT,
130c90bb80b4 using more conventional names for monad plus operations
bulwahn
parents: 45450
diff changeset
   598
    mk_empty = mk_empty, mk_single = mk_single, mk_bind = mk_decr_bind, mk_plus = mk_plus, mk_if = mk_if,
40049
75d9f57123d6 adding decreasing bind and non-decreasing bind; depth-limited and depth-unlimited compilation possible
bulwahn
parents: 39648
diff changeset
   599
    mk_iterate_upto = mk_iterate_upto, mk_not = mk_not, mk_map = mk_map}
75d9f57123d6 adding decreasing bind and non-decreasing bind; depth-limited and depth-unlimited compilation possible
bulwahn
parents: 39648
diff changeset
   600
55437
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   601
val depth_unlimited_compfuns =
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   602
  Predicate_Compile_Aux.CompilationFuns
45461
130c90bb80b4 using more conventional names for monad plus operations
bulwahn
parents: 45450
diff changeset
   603
    {mk_monadT = mk_neg_random_dseqT, dest_monadT = dest_neg_random_dseqT,
130c90bb80b4 using more conventional names for monad plus operations
bulwahn
parents: 45450
diff changeset
   604
    mk_empty = mk_empty, mk_single = mk_single, mk_bind = mk_bind, mk_plus = mk_plus, mk_if = mk_if,
36049
0ce5b7a5c2fd adding iterate_upto interface in compilations and iterate_upto functions in Isabelle theories for arithmetic setup of the predicate compiler
bulwahn
parents: 36046
diff changeset
   605
    mk_iterate_upto = mk_iterate_upto, mk_not = mk_not, mk_map = mk_map}
36046
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   606
55437
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   607
end
36046
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   608
55437
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   609
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   610
structure Random_Sequence_CompFuns =  (* FIXME proper signature *)
36046
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   611
struct
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   612
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   613
fun mk_random_dseqT T =
51143
0a2371e7ced3 two target language numeral types: integer and natural, as replacement for code_numeral;
haftmann
parents: 51126
diff changeset
   614
  @{typ natural} --> @{typ natural} --> @{typ Random.seed} -->
36046
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   615
    HOLogic.mk_prodT (DSequence_CompFuns.mk_dseqT T, @{typ Random.seed})
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   616
55437
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   617
fun dest_random_dseqT
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   618
    (Type ("fun", [@{typ natural}, Type ("fun", [@{typ natural},
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   619
      Type ("fun", [@{typ Random.seed},
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   620
      Type (@{type_name Product_Type.prod}, [T, @{typ Random.seed}])])])])) =
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   621
      DSequence_CompFuns.dest_dseqT T
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   622
  | dest_random_dseqT T = raise TYPE ("dest_random_dseqT", [T], [])
36046
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   623
55437
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   624
fun mk_empty T = Const (@{const_name Random_Sequence.empty}, mk_random_dseqT T)
36046
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   625
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   626
fun mk_single t =
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   627
  let
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   628
    val T = fastype_of t
55437
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   629
  in Const(@{const_name Random_Sequence.single}, T --> mk_random_dseqT T) $ t end
36046
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   630
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   631
fun mk_bind (x, f) =
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   632
  let
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   633
    val T as Type ("fun", [_, U]) = fastype_of f
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   634
  in
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   635
    Const (@{const_name Random_Sequence.bind}, fastype_of x --> T --> U) $ x $ f
55437
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   636
  end
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   637
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   638
val mk_plus = HOLogic.mk_binop @{const_name Random_Sequence.union}
36046
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   639
55437
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   640
fun mk_if cond =
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   641
  Const (@{const_name Random_Sequence.if_random_dseq},
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   642
    HOLogic.boolT --> mk_random_dseqT HOLogic.unitT) $ cond
36046
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   643
50056
72efd6b4038d dropped dead code
haftmann
parents: 46664
diff changeset
   644
fun mk_iterate_upto _ _ = raise Fail "No iterate_upto compilation"
36049
0ce5b7a5c2fd adding iterate_upto interface in compilations and iterate_upto functions in Isabelle theories for arithmetic setup of the predicate compiler
bulwahn
parents: 36046
diff changeset
   645
36046
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   646
fun mk_not t =
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   647
  let
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   648
    val T = mk_random_dseqT HOLogic.unitT
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   649
  in Const (@{const_name Random_Sequence.not_random_dseq}, T --> T) $ t end
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   650
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   651
fun mk_map T1 T2 tf tp = Const (@{const_name Random_Sequence.map},
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   652
  (T1 --> T2) --> mk_random_dseqT T1 --> mk_random_dseqT T2) $ tf $ tp
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   653
55437
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   654
val compfuns =
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   655
  Predicate_Compile_Aux.CompilationFuns
45461
130c90bb80b4 using more conventional names for monad plus operations
bulwahn
parents: 45450
diff changeset
   656
    {mk_monadT = mk_random_dseqT, dest_monadT = dest_random_dseqT,
130c90bb80b4 using more conventional names for monad plus operations
bulwahn
parents: 45450
diff changeset
   657
    mk_empty = mk_empty, mk_single = mk_single, mk_bind = mk_bind, mk_plus = mk_plus, mk_if = mk_if,
36049
0ce5b7a5c2fd adding iterate_upto interface in compilations and iterate_upto functions in Isabelle theories for arithmetic setup of the predicate compiler
bulwahn
parents: 36046
diff changeset
   658
    mk_iterate_upto = mk_iterate_upto, mk_not = mk_not, mk_map = mk_map}
36046
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   659
55437
3fd63b92ea3b tuned whitespace;
wenzelm
parents: 51143
diff changeset
   660
end
36046
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   661