src/HOL/Tools/Predicate_Compile/predicate_compile_quickcheck.ML
author haftmann
Thu, 26 Aug 2010 20:51:17 +0200
changeset 39019 e46e7a9cb622
parent 38774 d0385f2764d8
child 39043 abe92b33ac9f
permissions -rw-r--r--
formerly unnamed infix impliciation now named HOL.implies
wenzelm@33264
     1
(*  Title:      HOL/Tools/Predicate_Compile/predicate_compile_quickcheck.ML
wenzelm@33264
     2
    Author:     Lukas Bulwahn, TU Muenchen
bulwahn@33242
     3
wenzelm@33264
     4
A quickcheck generator based on the predicate compiler.
bulwahn@33242
     5
*)
bulwahn@33242
     6
bulwahn@33242
     7
signature PREDICATE_COMPILE_QUICKCHECK =
bulwahn@33242
     8
sig
bulwahn@35324
     9
  (*val quickcheck : Proof.context -> term -> int -> term list option*)
bulwahn@33242
    10
  val test_ref :
bulwahn@34935
    11
    ((unit -> int -> int -> int * int -> term list DSequence.dseq * (int * int)) option) Unsynchronized.ref
bulwahn@36019
    12
  val new_test_ref :
bulwahn@36019
    13
    ((unit -> int -> int -> int * int -> int -> term list Lazy_Sequence.lazy_sequence) option) Unsynchronized.ref;
bulwahn@36019
    14
  val eval_random_ref :
bulwahn@36019
    15
    ((unit -> int -> int -> int -> int * int -> term list Predicate.pred) option) Unsynchronized.ref;
bulwahn@36019
    16
bulwahn@34935
    17
  val tracing : bool Unsynchronized.ref;
bulwahn@36019
    18
  val quiet : bool Unsynchronized.ref;
bulwahn@36019
    19
  val quickcheck_compile_term : Predicate_Compile_Aux.compilation -> bool -> bool -> int ->
bulwahn@35378
    20
    Proof.context -> bool -> term -> int -> term list option * (bool list * bool);
bulwahn@35324
    21
(*  val test_term : Proof.context -> bool -> int -> int -> int -> int -> term -> *)
bulwahn@35324
    22
  val nrandom : int Unsynchronized.ref;
bulwahn@35324
    23
  val debug : bool Unsynchronized.ref;
bulwahn@35324
    24
  val function_flattening : bool Unsynchronized.ref;
bulwahn@35324
    25
  val no_higher_order_predicate : string list Unsynchronized.ref;
bulwahn@33242
    26
end;
bulwahn@33242
    27
bulwahn@33242
    28
structure Predicate_Compile_Quickcheck : PREDICATE_COMPILE_QUICKCHECK =
bulwahn@33242
    29
struct
bulwahn@33242
    30
bulwahn@33249
    31
open Predicate_Compile_Aux;
bulwahn@33249
    32
bulwahn@33242
    33
val test_ref =
bulwahn@34935
    34
  Unsynchronized.ref (NONE : (unit -> int -> int -> int * int -> term list DSequence.dseq * (int * int)) option);
bulwahn@34935
    35
bulwahn@36019
    36
val new_test_ref =
bulwahn@36019
    37
  Unsynchronized.ref (NONE : (unit -> int -> int -> int * int -> int -> term list Lazy_Sequence.lazy_sequence) option)
bulwahn@36019
    38
bulwahn@36019
    39
val eval_random_ref =
bulwahn@36019
    40
  Unsynchronized.ref (NONE : (unit -> int -> int -> int -> int * int -> term list Predicate.pred) option);
bulwahn@36019
    41
bulwahn@36019
    42
bulwahn@34935
    43
val tracing = Unsynchronized.ref false;
bulwahn@33242
    44
bulwahn@35523
    45
val quiet = Unsynchronized.ref true;
bulwahn@35523
    46
bulwahn@33242
    47
val target = "Quickcheck"
bulwahn@33242
    48
bulwahn@36019
    49
val nrandom = Unsynchronized.ref 3;
bulwahn@35324
    50
bulwahn@35523
    51
val debug = Unsynchronized.ref false;
bulwahn@35324
    52
bulwahn@35324
    53
val function_flattening = Unsynchronized.ref true;
bulwahn@35324
    54
bulwahn@35524
    55
val no_higher_order_predicate = Unsynchronized.ref ([] : string list);
bulwahn@35324
    56
bulwahn@33249
    57
val options = Options {
bulwahn@33249
    58
  expected_modes = NONE,
bulwahn@33752
    59
  proposed_modes = NONE,
bulwahn@33651
    60
  proposed_names = [],
bulwahn@35324
    61
  show_steps = false,
bulwahn@35324
    62
  show_intermediate_results = false,
bulwahn@35324
    63
  show_proof_trace = false,
bulwahn@35324
    64
  show_modes = false,
bulwahn@35324
    65
  show_mode_inference = false,
bulwahn@35324
    66
  show_compilation = false,
bulwahn@35324
    67
  show_caught_failures = false,
bulwahn@35324
    68
  skip_proof = false,
bulwahn@35324
    69
  compilation = Random,
bulwahn@35324
    70
  inductify = true,
bulwahn@36256
    71
  specialise = true,
bulwahn@36256
    72
  detect_switches = false,
bulwahn@35324
    73
  function_flattening = true,
bulwahn@35324
    74
  fail_safe_function_flattening = false,
bulwahn@35324
    75
  no_higher_order_predicate = [],
bulwahn@36250
    76
  no_topmost_reordering = false
bulwahn@35324
    77
}
bulwahn@35324
    78
bulwahn@35324
    79
val debug_options = Options {
bulwahn@35324
    80
  expected_modes = NONE,
bulwahn@35324
    81
  proposed_modes = NONE,
bulwahn@35324
    82
  proposed_names = [],
bulwahn@33249
    83
  show_steps = true,
bulwahn@33249
    84
  show_intermediate_results = true,
bulwahn@33249
    85
  show_proof_trace = false,
bulwahn@35324
    86
  show_modes = true,
bulwahn@35324
    87
  show_mode_inference = true,
bulwahn@34935
    88
  show_compilation = false,
bulwahn@35324
    89
  show_caught_failures = true,
bulwahn@33249
    90
  skip_proof = false,
bulwahn@34935
    91
  compilation = Random,
bulwahn@35324
    92
  inductify = true,
bulwahn@36256
    93
  specialise = true,
bulwahn@36256
    94
  detect_switches = false,
bulwahn@35324
    95
  function_flattening = true,
bulwahn@35324
    96
  fail_safe_function_flattening = false,
bulwahn@35324
    97
  no_higher_order_predicate = [],
bulwahn@35324
    98
  no_topmost_reordering = true
bulwahn@33249
    99
}
bulwahn@33249
   100
bulwahn@35324
   101
bulwahn@35324
   102
fun set_function_flattening b
bulwahn@35324
   103
  (Options { expected_modes = e_m, proposed_modes = p_m, proposed_names = p_n, show_steps = s_s,
bulwahn@35324
   104
    show_intermediate_results = s_ir, show_proof_trace = s_pt, show_modes = s_m,
bulwahn@35324
   105
    show_mode_inference = s_mi, show_compilation = s_c, show_caught_failures = s_cf, skip_proof = s_p,
bulwahn@36256
   106
    compilation = c, inductify = i, specialise = sp, detect_switches = ds, function_flattening = f_f, 
bulwahn@35324
   107
    fail_safe_function_flattening = fs_ff, no_higher_order_predicate = no_ho,
bulwahn@35324
   108
    no_topmost_reordering = re}) =
bulwahn@35324
   109
  (Options { expected_modes = e_m, proposed_modes = p_m, proposed_names = p_n, show_steps = s_s,
bulwahn@35324
   110
    show_intermediate_results = s_ir, show_proof_trace = s_pt, show_modes = s_m,
bulwahn@35324
   111
    show_mode_inference = s_mi, show_compilation = s_c, show_caught_failures = s_cf, skip_proof = s_p,
bulwahn@36256
   112
    compilation = c, inductify = i, specialise = sp, detect_switches = ds, function_flattening = b,
bulwahn@35324
   113
    fail_safe_function_flattening = fs_ff, no_higher_order_predicate = no_ho,
bulwahn@35324
   114
    no_topmost_reordering = re})
bulwahn@35324
   115
bulwahn@35324
   116
fun set_fail_safe_function_flattening b
bulwahn@35324
   117
  (Options { expected_modes = e_m, proposed_modes = p_m, proposed_names = p_n, show_steps = s_s,
bulwahn@35324
   118
    show_intermediate_results = s_ir, show_proof_trace = s_pt, show_modes = s_m,
bulwahn@35324
   119
    show_mode_inference = s_mi, show_compilation = s_c, show_caught_failures = s_cf, skip_proof = s_p,
bulwahn@36256
   120
    compilation = c, inductify = i, specialise = sp, detect_switches = ds, function_flattening = f_f, 
bulwahn@35324
   121
    fail_safe_function_flattening = fs_ff, no_higher_order_predicate = no_ho,
bulwahn@35324
   122
    no_topmost_reordering = re}) =
bulwahn@35324
   123
  (Options { expected_modes = e_m, proposed_modes = p_m, proposed_names = p_n, show_steps = s_s,
bulwahn@35324
   124
    show_intermediate_results = s_ir, show_proof_trace = s_pt, show_modes = s_m,
bulwahn@35324
   125
    show_mode_inference = s_mi, show_compilation = s_c, show_caught_failures = s_cf, skip_proof = s_p,
bulwahn@36256
   126
    compilation = c, inductify = i, specialise = sp, detect_switches = ds, function_flattening = f_f,
bulwahn@35324
   127
    fail_safe_function_flattening = b, no_higher_order_predicate = no_ho,
bulwahn@35324
   128
    no_topmost_reordering = re})
bulwahn@35324
   129
bulwahn@35324
   130
fun set_no_higher_order_predicate ss
bulwahn@35324
   131
  (Options { expected_modes = e_m, proposed_modes = p_m, proposed_names = p_n, show_steps = s_s,
bulwahn@35324
   132
    show_intermediate_results = s_ir, show_proof_trace = s_pt, show_modes = s_m,
bulwahn@35324
   133
    show_mode_inference = s_mi, show_compilation = s_c, show_caught_failures = s_cf, skip_proof = s_p,
bulwahn@36256
   134
    compilation = c, inductify = i, specialise = sp, detect_switches = ds, function_flattening = f_f, 
bulwahn@35324
   135
    fail_safe_function_flattening = fs_ff, no_higher_order_predicate = no_ho,
bulwahn@35324
   136
    no_topmost_reordering = re}) =
bulwahn@35324
   137
  (Options { expected_modes = e_m, proposed_modes = p_m, proposed_names = p_n, show_steps = s_s,
bulwahn@35324
   138
    show_intermediate_results = s_ir, show_proof_trace = s_pt, show_modes = s_m,
bulwahn@35324
   139
    show_mode_inference = s_mi, show_compilation = s_c, show_caught_failures = s_cf, skip_proof = s_p,
bulwahn@36256
   140
    compilation = c, inductify = i, specialise = sp, detect_switches = ds, function_flattening = f_f,
bulwahn@35324
   141
    fail_safe_function_flattening = fs_ff, no_higher_order_predicate = ss, no_topmost_reordering = re})
bulwahn@35324
   142
bulwahn@35324
   143
bulwahn@35324
   144
fun get_options () = 
bulwahn@35324
   145
  set_no_higher_order_predicate (!no_higher_order_predicate)
bulwahn@35324
   146
    (set_function_flattening (!function_flattening)
bulwahn@35324
   147
      (if !debug then debug_options else options))
bulwahn@35324
   148
bulwahn@36046
   149
val mk_predT = Predicate_Compile_Aux.mk_predT PredicateCompFuns.compfuns
bulwahn@36046
   150
val mk_return' = Predicate_Compile_Aux.mk_single PredicateCompFuns.compfuns
bulwahn@36046
   151
val mk_bind' = Predicate_Compile_Aux.mk_bind PredicateCompFuns.compfuns
bulwahn@36019
   152
bulwahn@36046
   153
val mk_randompredT = Predicate_Compile_Aux.mk_predT RandomPredCompFuns.compfuns
bulwahn@36046
   154
val mk_return = Predicate_Compile_Aux.mk_single RandomPredCompFuns.compfuns
bulwahn@36046
   155
val mk_bind = Predicate_Compile_Aux.mk_bind RandomPredCompFuns.compfuns
bulwahn@33242
   156
bulwahn@36046
   157
val mk_new_randompredT = Predicate_Compile_Aux.mk_predT New_Pos_Random_Sequence_CompFuns.compfuns
bulwahn@36046
   158
val mk_new_return = Predicate_Compile_Aux.mk_single New_Pos_Random_Sequence_CompFuns.compfuns
bulwahn@36046
   159
val mk_new_bind = Predicate_Compile_Aux.mk_bind New_Pos_Random_Sequence_CompFuns.compfuns
bulwahn@36019
   160
bulwahn@33242
   161
fun mk_split_lambda [] t = Abs ("u", HOLogic.unitT, t)
bulwahn@33242
   162
  | mk_split_lambda [x] t = lambda x t
bulwahn@33242
   163
  | mk_split_lambda xs t =
bulwahn@33242
   164
  let
bulwahn@33242
   165
    fun mk_split_lambda' (x::y::[]) t = HOLogic.mk_split (lambda x (lambda y t))
bulwahn@33242
   166
      | mk_split_lambda' (x::xs) t = HOLogic.mk_split (lambda x (mk_split_lambda' xs t))
bulwahn@33242
   167
  in
bulwahn@33242
   168
    mk_split_lambda' xs t
bulwahn@33242
   169
  end;
bulwahn@33242
   170
haftmann@39019
   171
fun strip_imp_prems (Const(@{const_name HOL.implies}, _) $ A $ B) = A :: strip_imp_prems B
bulwahn@33242
   172
  | strip_imp_prems _ = [];
bulwahn@33242
   173
haftmann@39019
   174
fun strip_imp_concl (Const(@{const_name HOL.implies}, _) $ A $ B) = strip_imp_concl B
bulwahn@33242
   175
  | strip_imp_concl A = A : term;
bulwahn@33242
   176
bulwahn@33242
   177
fun strip_horn A = (strip_imp_prems A, strip_imp_concl A);
bulwahn@33242
   178
bulwahn@35324
   179
fun cpu_time description f =
bulwahn@33242
   180
  let
bulwahn@35324
   181
    val start = start_timing ()
bulwahn@35324
   182
    val result = Exn.capture f ()
bulwahn@35324
   183
    val time = Time.toMilliseconds (#cpu (end_timing start))
bulwahn@35324
   184
  in (Exn.release result, (description, time)) end
bulwahn@35324
   185
bulwahn@36019
   186
fun compile_term compilation options ctxt t =
bulwahn@35324
   187
  let
bulwahn@33242
   188
    val ctxt' = ProofContext.theory (Context.copy_thy) ctxt
bulwahn@33242
   189
    val thy = (ProofContext.theory_of ctxt') 
bulwahn@33242
   190
    val (vs, t') = strip_abs t
bulwahn@33242
   191
    val vs' = Variable.variant_frees ctxt' [] vs
bulwahn@33242
   192
    val t'' = subst_bounds (map Free (rev vs'), t')
bulwahn@33242
   193
    val (prems, concl) = strip_horn t''
bulwahn@33242
   194
    val constname = "pred_compile_quickcheck"
bulwahn@33242
   195
    val full_constname = Sign.full_bname thy constname
bulwahn@33242
   196
    val constT = map snd vs' ---> @{typ bool}
bulwahn@34935
   197
    val thy1 = Sign.add_consts_i [(Binding.name constname, constT, NoSyn)] thy
bulwahn@34935
   198
    val const = Const (full_constname, constT)
bulwahn@33242
   199
    val t = Logic.list_implies
bulwahn@35324
   200
      (map HOLogic.mk_Trueprop (prems @ [HOLogic.mk_not concl]),
bulwahn@33242
   201
       HOLogic.mk_Trueprop (list_comb (Const (full_constname, constT), map Free vs')))
bulwahn@34935
   202
    val tac = fn _ => Skip_Proof.cheat_tac thy1
wenzelm@36633
   203
    val intro = Goal.prove (ProofContext.init_global thy1) (map fst vs') [] t tac
bulwahn@35324
   204
    val thy2 = Context.theory_map (Predicate_Compile_Alternative_Defs.add_thm intro) thy1
bulwahn@36256
   205
    val (thy3, preproc_time) = cpu_time "predicate preprocessing"
bulwahn@35324
   206
        (fn () => Predicate_Compile.preprocess options const thy2)
bulwahn@35324
   207
    val (thy4, core_comp_time) = cpu_time "random_dseq core compilation"
bulwahn@36019
   208
        (fn () =>
bulwahn@36019
   209
          case compilation of
bulwahn@36019
   210
            Pos_Random_DSeq =>
bulwahn@36019
   211
              Predicate_Compile_Core.add_random_dseq_equations options [full_constname] thy3
bulwahn@36019
   212
          | New_Pos_Random_DSeq =>
bulwahn@36019
   213
              Predicate_Compile_Core.add_new_random_dseq_equations options [full_constname] thy3
bulwahn@36019
   214
          (*| Depth_Limited_Random =>
bulwahn@36019
   215
              Predicate_Compile_Core.add_depth_limited_random_equations options [full_constname] thy3*))
bulwahn@36256
   216
    (*val _ = Predicate_Compile_Core.print_all_modes compilation thy4*)
bulwahn@36256
   217
    val _ = Output.tracing ("Preprocessing time: " ^ string_of_int (snd preproc_time))
bulwahn@36256
   218
    val _ = Output.tracing ("Core compilation time: " ^ string_of_int (snd core_comp_time))
bulwahn@36996
   219
    val ctxt4 = ProofContext.init_global thy4
bulwahn@36996
   220
    val modes = Predicate_Compile_Core.modes_of compilation ctxt4 full_constname
bulwahn@34935
   221
    val output_mode = fold_rev (curry Fun) (map (K Output) (binder_types constT)) Bool
bulwahn@33242
   222
    val prog =
bulwahn@34935
   223
      if member eq_mode modes output_mode then
bulwahn@33242
   224
        let
bulwahn@36996
   225
          val name = Predicate_Compile_Core.function_name_of compilation ctxt4
bulwahn@36019
   226
            full_constname output_mode
bulwahn@36019
   227
          val T = 
bulwahn@36019
   228
            case compilation of
bulwahn@36019
   229
              Pos_Random_DSeq => mk_randompredT (HOLogic.mk_tupleT (map snd vs'))
bulwahn@36019
   230
            | New_Pos_Random_DSeq => mk_new_randompredT (HOLogic.mk_tupleT (map snd vs'))
bulwahn@36019
   231
            | Depth_Limited_Random =>
bulwahn@36019
   232
              [@{typ code_numeral}, @{typ code_numeral}, @{typ code_numeral},
bulwahn@36019
   233
              @{typ "code_numeral * code_numeral"}] ---> mk_predT (HOLogic.mk_tupleT (map snd vs'))
bulwahn@34935
   234
        in
bulwahn@34935
   235
          Const (name, T)
bulwahn@34935
   236
        end
bulwahn@35324
   237
      else error ("Predicate Compile Quickcheck failed: " ^ commas (map string_of_mode modes))
bulwahn@36019
   238
    val qc_term =
bulwahn@36019
   239
      case compilation of
bulwahn@36019
   240
          Pos_Random_DSeq => mk_bind (prog,
bulwahn@36019
   241
            mk_split_lambda (map Free vs') (mk_return (HOLogic.mk_list @{typ term}
bulwahn@36019
   242
            (map2 HOLogic.mk_term_of (map snd vs') (map Free vs')))))
bulwahn@36019
   243
        | New_Pos_Random_DSeq => mk_new_bind (prog,
bulwahn@36019
   244
            mk_split_lambda (map Free vs') (mk_new_return (HOLogic.mk_list @{typ term}
bulwahn@36019
   245
            (map2 HOLogic.mk_term_of (map snd vs') (map Free vs')))))
bulwahn@36019
   246
        | Depth_Limited_Random => fold_rev (curry absdummy)
bulwahn@36019
   247
            [@{typ code_numeral}, @{typ code_numeral}, @{typ code_numeral},
bulwahn@36019
   248
             @{typ "code_numeral * code_numeral"}]
bulwahn@36019
   249
            (mk_bind' (list_comb (prog, map Bound (3 downto 0)),
bulwahn@36019
   250
            mk_split_lambda (map Free vs') (mk_return' (HOLogic.mk_list @{typ term}
bulwahn@36019
   251
            (map2 HOLogic.mk_term_of (map snd vs') (map Free vs'))))))
bulwahn@36019
   252
    val prog =
bulwahn@36019
   253
      case compilation of
bulwahn@36019
   254
        Pos_Random_DSeq =>
bulwahn@36019
   255
          let
bulwahn@36019
   256
            val compiled_term =
bulwahn@36019
   257
              Code_Eval.eval (SOME target) ("Predicate_Compile_Quickcheck.test_ref", test_ref)
bulwahn@36019
   258
                (fn proc => fn g => fn n => fn size => fn s => g n size s |>> (DSequence.map o map) proc)
bulwahn@36019
   259
                thy4 qc_term []
bulwahn@36019
   260
          in
bulwahn@36019
   261
            (fn size => fn nrandom => fn depth =>
bulwahn@36019
   262
              Option.map fst (DSequence.yield
bulwahn@36019
   263
                (compiled_term nrandom size |> Random_Engine.run) depth true))
bulwahn@36019
   264
          end
bulwahn@36019
   265
      | New_Pos_Random_DSeq =>
bulwahn@36019
   266
          let
bulwahn@36019
   267
            val compiled_term =
bulwahn@36019
   268
              Code_Eval.eval (SOME target)
bulwahn@36019
   269
                ("Predicate_Compile_Quickcheck.new_test_ref", new_test_ref)
bulwahn@36019
   270
                (fn proc => fn g => fn nrandom => fn size => fn s => fn depth =>
haftmann@36533
   271
                  g nrandom size s depth |> (Lazy_Sequence.mapa o map) proc)
bulwahn@36019
   272
                  thy4 qc_term []
bulwahn@36019
   273
          in
bulwahn@36019
   274
            fn size => fn nrandom => fn depth => Option.map fst (Lazy_Sequence.yield 
bulwahn@36019
   275
               (
bulwahn@36019
   276
               let
bulwahn@36019
   277
                 val seed = Random_Engine.next_seed ()
bulwahn@36019
   278
               in compiled_term nrandom size seed depth end))
bulwahn@36019
   279
          end
bulwahn@36019
   280
      | Depth_Limited_Random =>
bulwahn@36019
   281
          let
bulwahn@36019
   282
            val compiled_term = Code_Eval.eval (SOME target)
bulwahn@36019
   283
              ("Predicate_Compile_Quickcheck.eval_random_ref", eval_random_ref)
bulwahn@36019
   284
                (fn proc => fn g => fn depth => fn nrandom => fn size => fn seed =>
bulwahn@36019
   285
                  g depth nrandom size seed |> (Predicate.map o map) proc)
bulwahn@36019
   286
                thy4 qc_term []
bulwahn@36019
   287
          in
bulwahn@36019
   288
            fn size => fn nrandom => fn depth => Option.map fst (Predicate.yield 
bulwahn@36019
   289
              (compiled_term depth nrandom size (Random_Engine.run (fn s => (s, s)))))
bulwahn@36019
   290
          end
bulwahn@33242
   291
  in
bulwahn@36019
   292
    prog
bulwahn@35324
   293
  end
bulwahn@35324
   294
bulwahn@35324
   295
fun try_upto quiet f i =
bulwahn@35324
   296
  let
bulwahn@35324
   297
    fun try' j =
bulwahn@35324
   298
      if j <= i then
bulwahn@35324
   299
        let
bulwahn@35380
   300
          val _ = if quiet then () else priority ("Executing depth " ^ string_of_int j)
bulwahn@35324
   301
        in
bulwahn@35324
   302
          case f j handle Match => (if quiet then ()
bulwahn@35324
   303
             else warning "Exception Match raised during quickcheck"; NONE)
bulwahn@35324
   304
          of NONE => try' (j + 1) | SOME q => SOME q
bulwahn@35324
   305
        end
bulwahn@35324
   306
      else
bulwahn@35324
   307
        NONE
bulwahn@35324
   308
  in
bulwahn@35324
   309
    try' 0
bulwahn@35324
   310
  end
bulwahn@35324
   311
bulwahn@35324
   312
(* quickcheck interface functions *)
bulwahn@35324
   313
bulwahn@36019
   314
fun compile_term' compilation options depth ctxt report t =
bulwahn@35324
   315
  let
bulwahn@36019
   316
    val c = compile_term compilation options ctxt t
bulwahn@35378
   317
    val dummy_report = ([], false)
bulwahn@35324
   318
  in
bulwahn@35523
   319
    fn size => (try_upto (!quiet) (c size (!nrandom)) depth, dummy_report)
bulwahn@35324
   320
  end
bulwahn@35324
   321
bulwahn@36019
   322
fun quickcheck_compile_term compilation function_flattening fail_safe_function_flattening depth =
bulwahn@35324
   323
  let
bulwahn@35324
   324
     val options =
bulwahn@35324
   325
       set_fail_safe_function_flattening fail_safe_function_flattening
bulwahn@35324
   326
         (set_function_flattening function_flattening (get_options ()))
bulwahn@35324
   327
  in
bulwahn@36019
   328
    compile_term' compilation options depth
bulwahn@33242
   329
  end
bulwahn@33242
   330
bulwahn@33242
   331
end;