src/HOL/Mirabelle/Tools/mirabelle_quickcheck.ML
author boehmes
Sat, 05 Sep 2009 11:45:57 +0200
changeset 32521 f20cc66b2c74
parent 32518 e3c4e337196c
child 32564 378528d2f7eb
permissions -rw-r--r--
added initialization and cleanup of actions, added option to suppress Isabelle output, sledgehammer action produces its own report (no need for additional perl script)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
32385
594890623c46 split actions from Mirabelle core (Mirabelle may thus be applied to basic theories in HOL)
boehmes
parents:
diff changeset
     1
(* Title:  mirabelle_quickcheck.ML
594890623c46 split actions from Mirabelle core (Mirabelle may thus be applied to basic theories in HOL)
boehmes
parents:
diff changeset
     2
   Author: Jasmin Blanchette and Sascha Boehme
594890623c46 split actions from Mirabelle core (Mirabelle may thus be applied to basic theories in HOL)
boehmes
parents:
diff changeset
     3
*)
594890623c46 split actions from Mirabelle core (Mirabelle may thus be applied to basic theories in HOL)
boehmes
parents:
diff changeset
     4
594890623c46 split actions from Mirabelle core (Mirabelle may thus be applied to basic theories in HOL)
boehmes
parents:
diff changeset
     5
structure Mirabelle_Quickcheck : MIRABELLE_ACTION =
594890623c46 split actions from Mirabelle core (Mirabelle may thus be applied to basic theories in HOL)
boehmes
parents:
diff changeset
     6
struct
594890623c46 split actions from Mirabelle core (Mirabelle may thus be applied to basic theories in HOL)
boehmes
parents:
diff changeset
     7
32521
f20cc66b2c74 added initialization and cleanup of actions,
boehmes
parents: 32518
diff changeset
     8
fun qc_tag id = "#" ^ string_of_int id ^ " quickcheck: "
f20cc66b2c74 added initialization and cleanup of actions,
boehmes
parents: 32518
diff changeset
     9
f20cc66b2c74 added initialization and cleanup of actions,
boehmes
parents: 32518
diff changeset
    10
fun init _ = I
f20cc66b2c74 added initialization and cleanup of actions,
boehmes
parents: 32518
diff changeset
    11
fun done _ _ = ()
f20cc66b2c74 added initialization and cleanup of actions,
boehmes
parents: 32518
diff changeset
    12
f20cc66b2c74 added initialization and cleanup of actions,
boehmes
parents: 32518
diff changeset
    13
fun run args id {pre, timeout, log, ...} =
32385
594890623c46 split actions from Mirabelle core (Mirabelle may thus be applied to basic theories in HOL)
boehmes
parents:
diff changeset
    14
  let
594890623c46 split actions from Mirabelle core (Mirabelle may thus be applied to basic theories in HOL)
boehmes
parents:
diff changeset
    15
    val has_valid_key = member (op =) ["iterations", "size", "generator"] o fst
32469
1ad7d4fc0954 Mirabelle: added preliminary documentation,
boehmes
parents: 32385
diff changeset
    16
    val quickcheck = Quickcheck.quickcheck (filter has_valid_key args) 1
32385
594890623c46 split actions from Mirabelle core (Mirabelle may thus be applied to basic theories in HOL)
boehmes
parents:
diff changeset
    17
  in
32497
922718ac81e4 removed errors overseen in previous changes
boehmes
parents: 32496
diff changeset
    18
    (case TimeLimit.timeLimit timeout quickcheck pre of
32521
f20cc66b2c74 added initialization and cleanup of actions,
boehmes
parents: 32518
diff changeset
    19
      NONE => log (qc_tag id ^ "no counterexample")
f20cc66b2c74 added initialization and cleanup of actions,
boehmes
parents: 32518
diff changeset
    20
    | SOME _ => log (qc_tag id ^ "counterexample found"))
32385
594890623c46 split actions from Mirabelle core (Mirabelle may thus be applied to basic theories in HOL)
boehmes
parents:
diff changeset
    21
  end
32521
f20cc66b2c74 added initialization and cleanup of actions,
boehmes
parents: 32518
diff changeset
    22
  handle TimeLimit.TimeOut => log (qc_tag id ^ "timeout")
f20cc66b2c74 added initialization and cleanup of actions,
boehmes
parents: 32518
diff changeset
    23
       | ERROR msg => log (qc_tag id ^ "error: " ^ msg)
32385
594890623c46 split actions from Mirabelle core (Mirabelle may thus be applied to basic theories in HOL)
boehmes
parents:
diff changeset
    24
32515
e7c0d3c0494a Mirabelle: actions are responsible for catching exceptions and producing suitable log messages (makes log message uniform),
boehmes
parents: 32498
diff changeset
    25
fun invoke args =
32521
f20cc66b2c74 added initialization and cleanup of actions,
boehmes
parents: 32518
diff changeset
    26
  Mirabelle.register (init, Mirabelle.catch qc_tag (run args), done)
32385
594890623c46 split actions from Mirabelle core (Mirabelle may thus be applied to basic theories in HOL)
boehmes
parents:
diff changeset
    27
594890623c46 split actions from Mirabelle core (Mirabelle may thus be applied to basic theories in HOL)
boehmes
parents:
diff changeset
    28
end