src/HOL/Modelcheck/EindhovenSyn.thy
author wenzelm
Wed Mar 19 22:50:42 2008 +0100 (2008-03-19)
changeset 26342 0f65fa163304
parent 26225 3bfc71022dea
child 26939 1035c89b4c02
permissions -rw-r--r--
more antiquotations;
mueller@6466
     1
(*  Title:      HOL/Modelcheck/EindhovenSyn.thy
mueller@6466
     2
    ID:         $Id$
mueller@6466
     3
    Author:     Olaf Mueller, Jan Philipps, Robert Sandner
mueller@6466
     4
    Copyright   1997  TU Muenchen
mueller@6466
     5
*)
mueller@6466
     6
wenzelm@17272
     7
theory EindhovenSyn
wenzelm@17272
     8
imports MuCalculus
wenzelm@17272
     9
begin
mueller@6466
    10
mueller@6466
    11
syntax (Eindhoven output)
wenzelm@17272
    12
  True          :: bool                                 ("TRUE")
wenzelm@17272
    13
  False         :: bool                                 ("FALSE")
mueller@6466
    14
wenzelm@17272
    15
  Not           :: "bool => bool"                       ("NOT _" [40] 40)
wenzelm@17272
    16
  "op &"        :: "[bool, bool] => bool"               (infixr "AND" 35)
wenzelm@17272
    17
  "op |"        :: "[bool, bool] => bool"               (infixr "OR" 30)
mueller@6466
    18
wenzelm@21524
    19
  All_binder    :: "[idts, bool] => bool"               ("'((3A _./ _)')" [0, 10] 10)
wenzelm@21524
    20
  Ex_binder     :: "[idts, bool] => bool"               ("'((3E _./ _)')" [0, 10] 10)
wenzelm@17272
    21
   "_lambda"    :: "[pttrns, 'a] => 'b"                 ("(3L _./ _)" 10)
wenzelm@17272
    22
wenzelm@17272
    23
  "_idts"       :: "[idt, idts] => idts"                ("_,/_" [1, 0] 0)
wenzelm@17272
    24
  "_pattern"    :: "[pttrn, patterns] => pttrn"         ("_,/_" [1, 0] 0)
wenzelm@17272
    25
wenzelm@17272
    26
  "Mu "         :: "[idts, 'a pred] => 'a pred"         ("(3[mu _./ _])" 1000)
wenzelm@17272
    27
  "Nu "         :: "[idts, 'a pred] => 'a pred"         ("(3[nu _./ _])" 1000)
wenzelm@17272
    28
wenzelm@17272
    29
ML {*
wenzelm@17272
    30
  val trace_eindhoven = ref false;
wenzelm@17272
    31
*}
mueller@6466
    32
wenzelm@17272
    33
oracle mc_eindhoven_oracle ("term") =
wenzelm@17272
    34
{*
wenzelm@17272
    35
let
wenzelm@24634
    36
  val eindhoven_term = PrintMode.setmp ["Eindhoven"] o Sign.string_of_term;
mueller@6466
    37
wenzelm@17272
    38
  fun call_mc s =
wenzelm@17272
    39
    let
wenzelm@17272
    40
      val eindhoven_home = getenv "EINDHOVEN_HOME";
wenzelm@17272
    41
      val pmu =
wenzelm@17272
    42
        if eindhoven_home = "" then error "Environment variable EINDHOVEN_HOME not set"
wenzelm@17272
    43
        else eindhoven_home ^ "/pmu";
wenzelm@26225
    44
    in #1 (system_out ("echo \"" ^ s ^ "\" | " ^ pmu ^ " -w")) end;
wenzelm@17272
    45
in
wenzelm@17272
    46
  fn thy => fn goal =>
wenzelm@17272
    47
    let
wenzelm@17272
    48
      val s = eindhoven_term thy goal;
wenzelm@17272
    49
      val debug = tracing ("MC debugger: " ^ s);
wenzelm@17272
    50
      val result = call_mc s;
wenzelm@17272
    51
    in
wenzelm@17272
    52
      if ! trace_eindhoven then writeln (cat_lines [s, "----", result]) else ();
wenzelm@17272
    53
      (case result of
wenzelm@17272
    54
        "TRUE\n"  => goal |
wenzelm@17272
    55
        "FALSE\n" => error "MC oracle yields FALSE" |
wenzelm@17272
    56
      _ => error ("MC syntax error: " ^ result))
wenzelm@17272
    57
    end
wenzelm@17272
    58
end
wenzelm@17272
    59
*}
mueller@6466
    60
wenzelm@22819
    61
ML {*
wenzelm@22819
    62
fun mc_eindhoven_tac i state = SUBGOAL (fn (goal, _) =>
wenzelm@22819
    63
  let
wenzelm@22819
    64
    val thy = Thm.theory_of_thm state;
wenzelm@22819
    65
    val assertion = mc_eindhoven_oracle thy (Logic.strip_imp_concl goal);
wenzelm@22819
    66
  in cut_facts_tac [assertion] i THEN atac i end) i state;
wenzelm@22819
    67
wenzelm@22819
    68
val pair_eta_expand = Thm.symmetric (mk_meta_eq (thm "split_eta"));
wenzelm@22819
    69
wenzelm@22819
    70
val pair_eta_expand_proc =
wenzelm@22819
    71
  Simplifier.simproc (the_context ()) "pair_eta_expand" ["f::'a*'b=>'c"]
wenzelm@22819
    72
  (fn _ => fn _ => fn t => case t of Abs _ => SOME pair_eta_expand | _ => NONE);
wenzelm@22819
    73
wenzelm@22819
    74
val Eindhoven_ss =
wenzelm@26342
    75
  @{simpset} addsimprocs [pair_eta_expand_proc] addsimps [Let_def];
wenzelm@22819
    76
wenzelm@22819
    77
(*check if user has pmu installed*)
wenzelm@22819
    78
fun eindhoven_enabled () = getenv "EINDHOVEN_HOME" <> "";
wenzelm@22819
    79
fun if_eindhoven_enabled f x = if eindhoven_enabled () then f x else ();
wenzelm@22819
    80
*}
wenzelm@22819
    81
mueller@6466
    82
end