src/HOL/Tools/Predicate_Compile/predicate_compile_compilations.ML
author blanchet
Wed, 15 Dec 2010 18:10:32 +0100
changeset 41171 043f8dc3b51f
parent 40051 b6acda4d1c29
child 41941 f823f7fae9a2
permissions -rw-r--r--
facilitate debugging
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
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
     4
Structures for different compilations of the predicate compiler
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
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
     7
structure PredicateCompFuns =
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
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
    10
fun mk_predT T = Type (@{type_name Predicate.pred}, [T])
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
    11
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
    12
fun dest_predT (Type (@{type_name Predicate.pred}, [T])) = T
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
    13
  | dest_predT T = raise TYPE ("dest_predT", [T], []);
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
    14
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
    15
fun mk_bot T = Const (@{const_name Orderings.bot}, mk_predT T);
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
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
    19
  in Const(@{const_name Predicate.single}, T --> mk_predT T) $ t end;
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
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
    27
val mk_sup = HOLogic.mk_binop @{const_name sup};
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},
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
    30
  HOLogic.boolT --> mk_predT HOLogic.unitT) $ cond;
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) =
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
    33
  list_comb (Const (@{const_name Code_Numeral.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
    34
      [@{typ code_numeral} --> T, @{typ code_numeral}, @{typ code_numeral}] ---> mk_predT 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
    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
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
    39
    val T = mk_predT HOLogic.unitT
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
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
    45
    Const (@{const_name Predicate.Pred}, T --> mk_predT T') $ f    
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
39648
655307cb8489 rewriting function mk_Eval_of in predicate compiler
bulwahn
parents: 37678
diff changeset
    50
    val T = dest_predT (fastype_of f)
36046
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
    51
  in
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
    52
    Const (@{const_name Predicate.eval}, mk_predT T --> T --> HOLogic.boolT) $ f $ x
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},
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
    58
  (T1 --> T2) --> mk_predT T1 --> mk_predT T2) $ tf $ tp;
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
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
    61
    {mk_predT = mk_predT, dest_predT = dest_predT, mk_bot = mk_bot,
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
    62
    mk_single = mk_single, mk_bind = mk_bind, mk_sup = mk_sup, mk_if = mk_if,
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
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
    67
structure RandomPredCompFuns =
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
    68
struct
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
    69
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
    70
fun mk_randompredT T =
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
    71
  @{typ Random.seed} --> HOLogic.mk_prodT (PredicateCompFuns.mk_predT T, @{typ Random.seed})
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
    72
37678
0040bafffdef "prod" and "sum" replace "*" and "+" respectively
haftmann
parents: 36049
diff changeset
    73
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
    74
  [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
    75
  | dest_randompredT T = raise TYPE ("dest_randompredT", [T], []);
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
    76
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
    77
fun mk_bot T = Const(@{const_name Quickcheck.empty}, mk_randompredT T)
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
    78
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
    79
fun mk_single t =
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
    80
  let               
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
    81
    val T = fastype_of t
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
    82
  in
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
    83
    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
    84
  end;
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
    85
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
    86
fun mk_bind (x, f) =
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
    87
  let
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
    88
    val T as (Type ("fun", [_, U])) = fastype_of f
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
    89
  in
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
    90
    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
    91
  end
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
    92
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
    93
val mk_sup = HOLogic.mk_binop @{const_name Quickcheck.union}
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
    94
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
    95
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
    96
  HOLogic.boolT --> mk_randompredT HOLogic.unitT) $ cond;
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
    97
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
    98
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
    99
  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
   100
      [@{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
   101
    [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
   102
36046
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   103
fun mk_not t =
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   104
  let
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   105
    val T = mk_randompredT HOLogic.unitT
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   106
  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
   107
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   108
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
   109
  (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
   110
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   111
val compfuns = Predicate_Compile_Aux.CompilationFuns
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   112
    {mk_predT = mk_randompredT, dest_predT = dest_randompredT,
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   113
    mk_bot = mk_bot, mk_single = mk_single, mk_bind = mk_bind, mk_sup = mk_sup, 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
   114
    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
   115
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   116
end;
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   117
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   118
structure DSequence_CompFuns =
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   119
struct
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   120
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   121
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
   122
  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
   123
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   124
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
   125
  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
   126
  | dest_dseqT T = raise TYPE ("dest_dseqT", [T], []);
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   127
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   128
fun mk_bot T = Const (@{const_name DSequence.empty}, mk_dseqT T);
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   129
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   130
fun mk_single t =
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   131
  let val T = fastype_of t
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   132
  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
   133
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   134
fun mk_bind (x, f) =
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   135
  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
   136
  in
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   137
    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
   138
  end;
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   139
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   140
val mk_sup = HOLogic.mk_binop @{const_name DSequence.union};
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   141
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   142
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
   143
  HOLogic.boolT --> mk_dseqT HOLogic.unitT) $ cond;
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   144
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
   145
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
   146
36046
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   147
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
   148
  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
   149
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   150
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
   151
  (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
   152
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   153
val compfuns = Predicate_Compile_Aux.CompilationFuns
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   154
    {mk_predT = mk_dseqT, dest_predT = dest_dseqT,
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   155
    mk_bot = mk_bot, mk_single = mk_single, mk_bind = mk_bind, mk_sup = mk_sup, 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
   156
    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
   157
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   158
end;
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   159
40051
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   160
structure DSequence_CompFuns =
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   161
struct
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   162
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   163
fun mk_dseqT T = Type ("fun", [@{typ code_numeral}, Type ("fun", [@{typ bool},
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   164
  Type (@{type_name Option.option}, [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
   165
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   166
fun dest_dseqT (Type ("fun", [@{typ code_numeral}, Type ("fun", [@{typ bool},
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   167
  Type (@{type_name Option.option}, [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
   168
  | dest_dseqT T = raise TYPE ("dest_dseqT", [T], []);
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   169
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   170
fun mk_bot T = Const (@{const_name DSequence.empty}, mk_dseqT T);
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   171
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   172
fun mk_single t =
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   173
  let 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
   174
  in Const(@{const_name DSequence.single}, T --> mk_dseqT T) $ t end;
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   175
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   176
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
   177
  let 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
   178
  in
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   179
    Const (@{const_name DSequence.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
   180
  end;
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   181
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   182
val mk_sup = HOLogic.mk_binop @{const_name DSequence.union};
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   183
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   184
fun mk_if cond = Const (@{const_name DSequence.if_seq},
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   185
  HOLogic.boolT --> mk_dseqT HOLogic.unitT) $ cond;
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   186
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   187
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
   188
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   189
fun mk_not t = let val T = mk_dseqT HOLogic.unitT
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   190
  in Const (@{const_name DSequence.not_seq}, T --> T) $ t end
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   191
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   192
fun mk_map T1 T2 tf tp = Const (@{const_name DSequence.map},
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   193
  (T1 --> T2) --> mk_dseqT T1 --> mk_dseqT T2) $ tf $ tp
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   194
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   195
val compfuns = Predicate_Compile_Aux.CompilationFuns
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   196
    {mk_predT = mk_dseqT, dest_predT = dest_dseqT,
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   197
    mk_bot = mk_bot, mk_single = mk_single, mk_bind = mk_bind, mk_sup = mk_sup, mk_if = mk_if,
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   198
    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
   199
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   200
end;
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   201
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   202
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
   203
struct
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   204
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   205
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
   206
    @{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
   207
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   208
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
   209
    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
   210
  | 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
   211
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   212
fun mk_bot T = Const (@{const_name New_DSequence.pos_empty}, mk_pos_dseqT T);
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   213
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   214
fun mk_single t =
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   215
  let
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   216
    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
   217
  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
   218
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   219
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
   220
  let
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   221
    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
   222
  in
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   223
    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
   224
  end;
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   225
  
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   226
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
   227
  let
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   228
    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
   229
  in
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   230
    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
   231
  end;
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   232
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   233
val mk_sup = HOLogic.mk_binop @{const_name New_DSequence.pos_union};
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   234
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   235
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
   236
  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
   237
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   238
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
   239
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   240
fun mk_not t =
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   241
  let
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   242
    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
   243
    val nT =
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   244
      @{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
   245
        [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
   246
  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
   247
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   248
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
   249
  (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
   250
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   251
val depth_limited_compfuns = Predicate_Compile_Aux.CompilationFuns
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   252
    {mk_predT = mk_pos_dseqT, dest_predT = dest_pos_dseqT,
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   253
    mk_bot = mk_bot, mk_single = mk_single, mk_bind = mk_decr_bind, mk_sup = mk_sup, mk_if = mk_if,
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   254
    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
   255
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   256
val depth_unlimited_compfuns = Predicate_Compile_Aux.CompilationFuns
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   257
    {mk_predT = mk_pos_dseqT, dest_predT = dest_pos_dseqT,
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   258
    mk_bot = mk_bot, mk_single = mk_single, mk_bind = mk_bind, mk_sup = mk_sup, mk_if = mk_if,
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   259
    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
   260
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   261
end;
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   262
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   263
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
   264
struct
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   265
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   266
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
   267
  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
   268
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   269
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
   270
    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
   271
  | 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
   272
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   273
fun mk_bot T = Const (@{const_name New_DSequence.neg_empty}, mk_neg_dseqT T);
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   274
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   275
fun mk_single t =
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   276
  let
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   277
    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
   278
  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
   279
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   280
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
   281
  let
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   282
    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
   283
  in
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   284
    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
   285
  end;
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   286
  
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   287
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
   288
  let
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   289
    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
   290
  in
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   291
    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
   292
  end;
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   293
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   294
val mk_sup = HOLogic.mk_binop @{const_name New_DSequence.neg_union};
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   295
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   296
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
   297
  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
   298
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   299
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
   300
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   301
fun mk_not t =
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   302
  let
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   303
    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
   304
    val pT =
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   305
      @{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
   306
        [@{typ unit}])
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   307
  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
   308
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   309
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
   310
  (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
   311
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   312
val depth_limited_compfuns = Predicate_Compile_Aux.CompilationFuns
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   313
    {mk_predT = mk_neg_dseqT, dest_predT = dest_neg_dseqT,
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   314
    mk_bot = mk_bot, mk_single = mk_single, mk_bind = mk_decr_bind, mk_sup = mk_sup, mk_if = mk_if,
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   315
    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
   316
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   317
val depth_unlimited_compfuns = Predicate_Compile_Aux.CompilationFuns
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   318
    {mk_predT = mk_neg_dseqT, dest_predT = dest_neg_dseqT,
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   319
    mk_bot = mk_bot, mk_single = mk_single, mk_bind = mk_bind, mk_sup = mk_sup, mk_if = mk_if,
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   320
    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
   321
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   322
end;
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   323
36046
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   324
structure New_Pos_Random_Sequence_CompFuns =
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   325
struct
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   326
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   327
fun mk_pos_random_dseqT T =
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   328
  @{typ code_numeral} --> @{typ code_numeral} --> @{typ Random.seed} -->
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   329
    @{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
   330
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   331
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
   332
    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
   333
    Type (@{type_name Lazy_Sequence.lazy_sequence}, [T])])])])])) = T
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   334
  | 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
   335
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   336
fun mk_bot T = Const (@{const_name New_Random_Sequence.pos_empty}, mk_pos_random_dseqT T);
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   337
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   338
fun mk_single t =
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   339
  let
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   340
    val T = fastype_of t
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   341
  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
   342
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   343
fun mk_bind (x, f) =
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   344
  let
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   345
    val T as Type ("fun", [_, U]) = fastype_of f
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   346
  in
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   347
    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
   348
  end;
40051
b6acda4d1c29 added generator_dseq compilation for a sound depth-limited compilation with small value generators
bulwahn
parents: 40049
diff changeset
   349
40049
75d9f57123d6 adding decreasing bind and non-decreasing bind; depth-limited and depth-unlimited compilation possible
bulwahn
parents: 39648
diff changeset
   350
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
   351
  let
75d9f57123d6 adding decreasing bind and non-decreasing bind; depth-limited and depth-unlimited compilation possible
bulwahn
parents: 39648
diff changeset
   352
    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
   353
  in
75d9f57123d6 adding decreasing bind and non-decreasing bind; depth-limited and depth-unlimited compilation possible
bulwahn
parents: 39648
diff changeset
   354
    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
   355
  end;
36046
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   356
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   357
val mk_sup = HOLogic.mk_binop @{const_name New_Random_Sequence.pos_union};
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   358
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   359
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
   360
  HOLogic.boolT --> mk_pos_random_dseqT HOLogic.unitT) $ cond;
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   361
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
   362
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
   363
  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
   364
      [@{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
   365
        ---> 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
   366
    [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
   367
36046
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   368
fun mk_not t =
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   369
  let
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   370
    val pT = mk_pos_random_dseqT HOLogic.unitT
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   371
    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
   372
      @{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
   373
        [Type (@{type_name Option.option}, [@{typ unit}])])
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   374
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   375
  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
   376
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   377
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
   378
  (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
   379
40049
75d9f57123d6 adding decreasing bind and non-decreasing bind; depth-limited and depth-unlimited compilation possible
bulwahn
parents: 39648
diff changeset
   380
val depth_limited_compfuns = Predicate_Compile_Aux.CompilationFuns
75d9f57123d6 adding decreasing bind and non-decreasing bind; depth-limited and depth-unlimited compilation possible
bulwahn
parents: 39648
diff changeset
   381
    {mk_predT = mk_pos_random_dseqT, dest_predT = dest_pos_random_dseqT,
75d9f57123d6 adding decreasing bind and non-decreasing bind; depth-limited and depth-unlimited compilation possible
bulwahn
parents: 39648
diff changeset
   382
    mk_bot = mk_bot, mk_single = mk_single, mk_bind = mk_decr_bind, mk_sup = mk_sup, mk_if = mk_if,
75d9f57123d6 adding decreasing bind and non-decreasing bind; depth-limited and depth-unlimited compilation possible
bulwahn
parents: 39648
diff changeset
   383
    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
   384
75d9f57123d6 adding decreasing bind and non-decreasing bind; depth-limited and depth-unlimited compilation possible
bulwahn
parents: 39648
diff changeset
   385
val depth_unlimited_compfuns = Predicate_Compile_Aux.CompilationFuns
36046
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   386
    {mk_predT = mk_pos_random_dseqT, dest_predT = dest_pos_random_dseqT,
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   387
    mk_bot = mk_bot, mk_single = mk_single, mk_bind = mk_bind, mk_sup = mk_sup, 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
   388
    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
   389
end;
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   390
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   391
structure New_Neg_Random_Sequence_CompFuns =
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   392
struct
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   393
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   394
fun mk_neg_random_dseqT T =
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   395
   @{typ code_numeral} --> @{typ code_numeral} --> @{typ Random.seed} -->
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   396
    @{typ code_numeral} --> 
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   397
    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
   398
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   399
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
   400
    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
   401
      Type (@{type_name Lazy_Sequence.lazy_sequence},
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   402
        [Type (@{type_name Option.option}, [T])])])])])])) = T
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   403
  | 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
   404
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   405
fun mk_bot T = Const (@{const_name New_Random_Sequence.neg_empty}, mk_neg_random_dseqT T);
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   406
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   407
fun mk_single t =
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   408
  let
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   409
    val T = fastype_of t
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   410
  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
   411
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   412
fun mk_bind (x, f) =
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   413
  let
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   414
    val T as Type ("fun", [_, U]) = fastype_of f
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   415
  in
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   416
    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
   417
  end;
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   418
40049
75d9f57123d6 adding decreasing bind and non-decreasing bind; depth-limited and depth-unlimited compilation possible
bulwahn
parents: 39648
diff changeset
   419
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
   420
  let
75d9f57123d6 adding decreasing bind and non-decreasing bind; depth-limited and depth-unlimited compilation possible
bulwahn
parents: 39648
diff changeset
   421
    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
   422
  in
75d9f57123d6 adding decreasing bind and non-decreasing bind; depth-limited and depth-unlimited compilation possible
bulwahn
parents: 39648
diff changeset
   423
    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
   424
  end;
75d9f57123d6 adding decreasing bind and non-decreasing bind; depth-limited and depth-unlimited compilation possible
bulwahn
parents: 39648
diff changeset
   425
36046
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   426
val mk_sup = HOLogic.mk_binop @{const_name New_Random_Sequence.neg_union};
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   427
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   428
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
   429
  HOLogic.boolT --> mk_neg_random_dseqT HOLogic.unitT) $ cond;
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   430
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
   431
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
   432
  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
   433
      [@{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
   434
        ---> 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
   435
    [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
   436
36046
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   437
fun mk_not t =
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   438
  let
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   439
    val nT = mk_neg_random_dseqT HOLogic.unitT
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   440
    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
   441
    @{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
   442
  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
   443
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   444
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
   445
  (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
   446
40049
75d9f57123d6 adding decreasing bind and non-decreasing bind; depth-limited and depth-unlimited compilation possible
bulwahn
parents: 39648
diff changeset
   447
val depth_limited_compfuns = Predicate_Compile_Aux.CompilationFuns
75d9f57123d6 adding decreasing bind and non-decreasing bind; depth-limited and depth-unlimited compilation possible
bulwahn
parents: 39648
diff changeset
   448
    {mk_predT = mk_neg_random_dseqT, dest_predT = dest_neg_random_dseqT,
75d9f57123d6 adding decreasing bind and non-decreasing bind; depth-limited and depth-unlimited compilation possible
bulwahn
parents: 39648
diff changeset
   449
    mk_bot = mk_bot, mk_single = mk_single, mk_bind = mk_decr_bind, mk_sup = mk_sup, mk_if = mk_if,
75d9f57123d6 adding decreasing bind and non-decreasing bind; depth-limited and depth-unlimited compilation possible
bulwahn
parents: 39648
diff changeset
   450
    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
   451
75d9f57123d6 adding decreasing bind and non-decreasing bind; depth-limited and depth-unlimited compilation possible
bulwahn
parents: 39648
diff changeset
   452
val depth_unlimited_compfuns = Predicate_Compile_Aux.CompilationFuns
36046
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   453
    {mk_predT = mk_neg_random_dseqT, dest_predT = dest_neg_random_dseqT,
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   454
    mk_bot = mk_bot, mk_single = mk_single, mk_bind = mk_bind, mk_sup = mk_sup, 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
   455
    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
   456
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   457
end;
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   458
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   459
structure Random_Sequence_CompFuns =
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   460
struct
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   461
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   462
fun mk_random_dseqT T =
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   463
  @{typ code_numeral} --> @{typ code_numeral} --> @{typ Random.seed} -->
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   464
    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
   465
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   466
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
   467
  Type ("fun", [@{typ Random.seed},
37678
0040bafffdef "prod" and "sum" replace "*" and "+" respectively
haftmann
parents: 36049
diff changeset
   468
  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
   469
  | 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
   470
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   471
fun mk_bot T = Const (@{const_name Random_Sequence.empty}, mk_random_dseqT T);
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   472
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   473
fun mk_single t =
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   474
  let
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   475
    val T = fastype_of t
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   476
  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
   477
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   478
fun mk_bind (x, f) =
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   479
  let
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   480
    val T as Type ("fun", [_, U]) = fastype_of f
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   481
  in
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   482
    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
   483
  end;
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   484
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   485
val mk_sup = HOLogic.mk_binop @{const_name Random_Sequence.union};
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
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
   488
  HOLogic.boolT --> mk_random_dseqT HOLogic.unitT) $ cond;
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   489
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
   490
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
   491
36046
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   492
fun mk_not t =
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   493
  let
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   494
    val T = mk_random_dseqT HOLogic.unitT
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   495
  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
   496
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   497
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
   498
  (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
   499
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   500
val compfuns = Predicate_Compile_Aux.CompilationFuns
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   501
    {mk_predT = mk_random_dseqT, dest_predT = dest_random_dseqT,
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   502
    mk_bot = mk_bot, mk_single = mk_single, mk_bind = mk_bind, mk_sup = mk_sup, 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
   503
    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
   504
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   505
end;
c3946372f556 putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
diff changeset
   506