src/HOL/Modelcheck/EindhovenSyn.thy
author wenzelm
Thu Sep 18 19:39:44 2008 +0200 (2008-09-18)
changeset 28290 4cc2b6046258
parent 28263 69eaa97e7e96
child 32010 cb1a1c94b4cd
permissions -rw-r--r--
simplified oracle interface;
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@28290
    33
oracle mc_eindhoven_oracle =
wenzelm@17272
    34
{*
wenzelm@17272
    35
let
wenzelm@26939
    36
  val eindhoven_term = PrintMode.setmp ["Eindhoven"] o Syntax.string_of_term_global;
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@28290
    46
  fn cgoal =>
wenzelm@17272
    47
    let
wenzelm@28290
    48
      val thy = Thm.theory_of_cterm cgoal;
wenzelm@28290
    49
      val goal = Thm.term_of cgoal;
wenzelm@17272
    50
      val s = eindhoven_term thy goal;
wenzelm@17272
    51
      val debug = tracing ("MC debugger: " ^ s);
wenzelm@17272
    52
      val result = call_mc s;
wenzelm@17272
    53
    in
wenzelm@17272
    54
      if ! trace_eindhoven then writeln (cat_lines [s, "----", result]) else ();
wenzelm@17272
    55
      (case result of
wenzelm@28290
    56
        "TRUE\n"  => cgoal |
wenzelm@17272
    57
        "FALSE\n" => error "MC oracle yields FALSE" |
wenzelm@17272
    58
      _ => error ("MC syntax error: " ^ result))
wenzelm@17272
    59
    end
wenzelm@17272
    60
end
wenzelm@17272
    61
*}
mueller@6466
    62
wenzelm@22819
    63
ML {*
wenzelm@22819
    64
fun mc_eindhoven_tac i state = SUBGOAL (fn (goal, _) =>
wenzelm@22819
    65
  let
wenzelm@22819
    66
    val thy = Thm.theory_of_thm state;
wenzelm@28290
    67
    val assertion = mc_eindhoven_oracle (Thm.cterm_of thy (Logic.strip_imp_concl goal));
wenzelm@22819
    68
  in cut_facts_tac [assertion] i THEN atac i end) i state;
wenzelm@22819
    69
wenzelm@22819
    70
val pair_eta_expand = Thm.symmetric (mk_meta_eq (thm "split_eta"));
wenzelm@22819
    71
wenzelm@22819
    72
val pair_eta_expand_proc =
wenzelm@22819
    73
  Simplifier.simproc (the_context ()) "pair_eta_expand" ["f::'a*'b=>'c"]
wenzelm@22819
    74
  (fn _ => fn _ => fn t => case t of Abs _ => SOME pair_eta_expand | _ => NONE);
wenzelm@22819
    75
wenzelm@22819
    76
val Eindhoven_ss =
wenzelm@26342
    77
  @{simpset} addsimprocs [pair_eta_expand_proc] addsimps [Let_def];
wenzelm@22819
    78
*}
wenzelm@22819
    79
mueller@6466
    80
end