src/Tools/quickcheck.ML
changeset 37910 555287ba8d8d
parent 37909 583543ad6ad1
child 37911 8f99e3880864
equal deleted inserted replaced
37909:583543ad6ad1 37910:555287ba8d8d
     4 Generic counterexample search engine.
     4 Generic counterexample search engine.
     5 *)
     5 *)
     6 
     6 
     7 signature QUICKCHECK =
     7 signature QUICKCHECK =
     8 sig
     8 sig
       
     9   val setup: theory -> theory
       
    10   (* configuration *)
     9   val auto: bool Unsynchronized.ref
    11   val auto: bool Unsynchronized.ref
    10   val timing : bool Unsynchronized.ref
    12   val timing : bool Unsynchronized.ref
    11   datatype report = Report of
    13   datatype report = Report of
    12     { iterations : int, raised_match_errors : int,
    14     { iterations : int, raised_match_errors : int,
    13       satisfied_assms : int list, positive_concl_tests : int }
    15       satisfied_assms : int list, positive_concl_tests : int }
       
    16   datatype test_params = Test_Params of
       
    17   { size: int, iterations: int, default_type: typ list, no_assms: bool, report: bool, quiet : bool};
       
    18   val test_params_of: theory -> test_params 
       
    19   val add_generator:
       
    20     string * (Proof.context -> bool -> term -> int -> term list option * (bool list * bool))
       
    21       -> theory -> theory
       
    22   (* testing terms and proof states *)
    14   val gen_test_term: Proof.context -> bool -> bool -> string option -> int -> int -> term ->
    23   val gen_test_term: Proof.context -> bool -> bool -> string option -> int -> int -> term ->
    15     (string * term) list option * ((string * int) list * ((int * report list) list) option)
    24     (string * term) list option * ((string * int) list * ((int * report list) list) option)
    16   val test_term: Proof.context -> bool -> string option -> int -> int -> term ->
    25   val test_term: Proof.context -> bool -> string option -> int -> int -> term ->
    17     (string * term) list option
    26     (string * term) list option
    18   val add_generator:
       
    19     string * (Proof.context -> bool -> term -> int -> term list option * (bool list * bool))
       
    20       -> theory -> theory
       
    21   val setup: theory -> theory
       
    22   val quickcheck: (string * string list) list -> int -> Proof.state -> (string * term) list option
    27   val quickcheck: (string * string list) list -> int -> Proof.state -> (string * term) list option
    23 end;
    28 end;
    24 
    29 
    25 structure Quickcheck : QUICKCHECK =
    30 structure Quickcheck : QUICKCHECK =
    26 struct
    31 struct
    89   val extend = I;
    94   val extend = I;
    90   fun merge ((generators1, params1), (generators2, params2)) : T =
    95   fun merge ((generators1, params1), (generators2, params2)) : T =
    91     (AList.merge (op =) (K true) (generators1, generators2),
    96     (AList.merge (op =) (K true) (generators1, generators2),
    92       merge_test_params (params1, params2));
    97       merge_test_params (params1, params2));
    93 );
    98 );
       
    99 
       
   100 val test_params_of = snd o Data.get;
    94 
   101 
    95 val add_generator = Data.map o apfst o AList.update (op =);
   102 val add_generator = Data.map o apfst o AList.update (op =);
    96 
   103 
    97 (* generating tests *)
   104 (* generating tests *)
    98 
   105