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