src/HOL/Modelcheck/EindhovenSyn.thy
author Cezary Kaliszyk <kaliszyk@in.tum.de>
Mon, 26 Apr 2010 15:14:14 +0200
changeset 36352 f71978e47cd5
parent 35010 d6e492cea6e4
child 37146 f652333bbf8e
permissions -rw-r--r--
add bounded_lattice_bot and bounded_lattice_top type classes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6466
2eba94dc5951 added modelchecker mucke besides modelchecker eindhoven;
mueller
parents:
diff changeset
     1
(*  Title:      HOL/Modelcheck/EindhovenSyn.thy
2eba94dc5951 added modelchecker mucke besides modelchecker eindhoven;
mueller
parents:
diff changeset
     2
    Author:     Olaf Mueller, Jan Philipps, Robert Sandner
2eba94dc5951 added modelchecker mucke besides modelchecker eindhoven;
mueller
parents:
diff changeset
     3
    Copyright   1997  TU Muenchen
2eba94dc5951 added modelchecker mucke besides modelchecker eindhoven;
mueller
parents:
diff changeset
     4
*)
2eba94dc5951 added modelchecker mucke besides modelchecker eindhoven;
mueller
parents:
diff changeset
     5
17272
c63e5220ed77 converted to Isar theory format;
wenzelm
parents: 7295
diff changeset
     6
theory EindhovenSyn
c63e5220ed77 converted to Isar theory format;
wenzelm
parents: 7295
diff changeset
     7
imports MuCalculus
c63e5220ed77 converted to Isar theory format;
wenzelm
parents: 7295
diff changeset
     8
begin
6466
2eba94dc5951 added modelchecker mucke besides modelchecker eindhoven;
mueller
parents:
diff changeset
     9
2eba94dc5951 added modelchecker mucke besides modelchecker eindhoven;
mueller
parents:
diff changeset
    10
syntax (Eindhoven output)
17272
c63e5220ed77 converted to Isar theory format;
wenzelm
parents: 7295
diff changeset
    11
  True          :: bool                                 ("TRUE")
c63e5220ed77 converted to Isar theory format;
wenzelm
parents: 7295
diff changeset
    12
  False         :: bool                                 ("FALSE")
6466
2eba94dc5951 added modelchecker mucke besides modelchecker eindhoven;
mueller
parents:
diff changeset
    13
17272
c63e5220ed77 converted to Isar theory format;
wenzelm
parents: 7295
diff changeset
    14
  Not           :: "bool => bool"                       ("NOT _" [40] 40)
c63e5220ed77 converted to Isar theory format;
wenzelm
parents: 7295
diff changeset
    15
  "op &"        :: "[bool, bool] => bool"               (infixr "AND" 35)
c63e5220ed77 converted to Isar theory format;
wenzelm
parents: 7295
diff changeset
    16
  "op |"        :: "[bool, bool] => bool"               (infixr "OR" 30)
6466
2eba94dc5951 added modelchecker mucke besides modelchecker eindhoven;
mueller
parents:
diff changeset
    17
21524
7843e2fd14a9 updated (binder) syntax/notation;
wenzelm
parents: 17272
diff changeset
    18
  All_binder    :: "[idts, bool] => bool"               ("'((3A _./ _)')" [0, 10] 10)
7843e2fd14a9 updated (binder) syntax/notation;
wenzelm
parents: 17272
diff changeset
    19
  Ex_binder     :: "[idts, bool] => bool"               ("'((3E _./ _)')" [0, 10] 10)
17272
c63e5220ed77 converted to Isar theory format;
wenzelm
parents: 7295
diff changeset
    20
   "_lambda"    :: "[pttrns, 'a] => 'b"                 ("(3L _./ _)" 10)
c63e5220ed77 converted to Isar theory format;
wenzelm
parents: 7295
diff changeset
    21
c63e5220ed77 converted to Isar theory format;
wenzelm
parents: 7295
diff changeset
    22
  "_idts"       :: "[idt, idts] => idts"                ("_,/_" [1, 0] 0)
c63e5220ed77 converted to Isar theory format;
wenzelm
parents: 7295
diff changeset
    23
  "_pattern"    :: "[pttrn, patterns] => pttrn"         ("_,/_" [1, 0] 0)
c63e5220ed77 converted to Isar theory format;
wenzelm
parents: 7295
diff changeset
    24
c63e5220ed77 converted to Isar theory format;
wenzelm
parents: 7295
diff changeset
    25
  "Mu "         :: "[idts, 'a pred] => 'a pred"         ("(3[mu _./ _])" 1000)
c63e5220ed77 converted to Isar theory format;
wenzelm
parents: 7295
diff changeset
    26
  "Nu "         :: "[idts, 'a pred] => 'a pred"         ("(3[nu _./ _])" 1000)
c63e5220ed77 converted to Isar theory format;
wenzelm
parents: 7295
diff changeset
    27
c63e5220ed77 converted to Isar theory format;
wenzelm
parents: 7295
diff changeset
    28
ML {*
32740
9dd0a2f83429 explicit indication of Unsynchronized.ref;
wenzelm
parents: 32010
diff changeset
    29
  val trace_eindhoven = Unsynchronized.ref false;
17272
c63e5220ed77 converted to Isar theory format;
wenzelm
parents: 7295
diff changeset
    30
*}
6466
2eba94dc5951 added modelchecker mucke besides modelchecker eindhoven;
mueller
parents:
diff changeset
    31
28290
4cc2b6046258 simplified oracle interface;
wenzelm
parents: 28263
diff changeset
    32
oracle mc_eindhoven_oracle =
17272
c63e5220ed77 converted to Isar theory format;
wenzelm
parents: 7295
diff changeset
    33
{*
c63e5220ed77 converted to Isar theory format;
wenzelm
parents: 7295
diff changeset
    34
let
26939
1035c89b4c02 moved global pretty/string_of functions from Sign to Syntax;
wenzelm
parents: 26342
diff changeset
    35
  val eindhoven_term = PrintMode.setmp ["Eindhoven"] o Syntax.string_of_term_global;
6466
2eba94dc5951 added modelchecker mucke besides modelchecker eindhoven;
mueller
parents:
diff changeset
    36
17272
c63e5220ed77 converted to Isar theory format;
wenzelm
parents: 7295
diff changeset
    37
  fun call_mc s =
c63e5220ed77 converted to Isar theory format;
wenzelm
parents: 7295
diff changeset
    38
    let
c63e5220ed77 converted to Isar theory format;
wenzelm
parents: 7295
diff changeset
    39
      val eindhoven_home = getenv "EINDHOVEN_HOME";
c63e5220ed77 converted to Isar theory format;
wenzelm
parents: 7295
diff changeset
    40
      val pmu =
c63e5220ed77 converted to Isar theory format;
wenzelm
parents: 7295
diff changeset
    41
        if eindhoven_home = "" then error "Environment variable EINDHOVEN_HOME not set"
c63e5220ed77 converted to Isar theory format;
wenzelm
parents: 7295
diff changeset
    42
        else eindhoven_home ^ "/pmu";
35010
d6e492cea6e4 renamed system/system_out to bash/bash_output -- to emphasized that this is really GNU bash, not some undefined POSIX sh;
wenzelm
parents: 32740
diff changeset
    43
    in #1 (bash_output ("echo \"" ^ s ^ "\" | " ^ pmu ^ " -w")) end;
17272
c63e5220ed77 converted to Isar theory format;
wenzelm
parents: 7295
diff changeset
    44
in
28290
4cc2b6046258 simplified oracle interface;
wenzelm
parents: 28263
diff changeset
    45
  fn cgoal =>
17272
c63e5220ed77 converted to Isar theory format;
wenzelm
parents: 7295
diff changeset
    46
    let
28290
4cc2b6046258 simplified oracle interface;
wenzelm
parents: 28263
diff changeset
    47
      val thy = Thm.theory_of_cterm cgoal;
4cc2b6046258 simplified oracle interface;
wenzelm
parents: 28263
diff changeset
    48
      val goal = Thm.term_of cgoal;
17272
c63e5220ed77 converted to Isar theory format;
wenzelm
parents: 7295
diff changeset
    49
      val s = eindhoven_term thy goal;
c63e5220ed77 converted to Isar theory format;
wenzelm
parents: 7295
diff changeset
    50
      val debug = tracing ("MC debugger: " ^ s);
c63e5220ed77 converted to Isar theory format;
wenzelm
parents: 7295
diff changeset
    51
      val result = call_mc s;
c63e5220ed77 converted to Isar theory format;
wenzelm
parents: 7295
diff changeset
    52
    in
c63e5220ed77 converted to Isar theory format;
wenzelm
parents: 7295
diff changeset
    53
      if ! trace_eindhoven then writeln (cat_lines [s, "----", result]) else ();
c63e5220ed77 converted to Isar theory format;
wenzelm
parents: 7295
diff changeset
    54
      (case result of
28290
4cc2b6046258 simplified oracle interface;
wenzelm
parents: 28263
diff changeset
    55
        "TRUE\n"  => cgoal |
17272
c63e5220ed77 converted to Isar theory format;
wenzelm
parents: 7295
diff changeset
    56
        "FALSE\n" => error "MC oracle yields FALSE" |
c63e5220ed77 converted to Isar theory format;
wenzelm
parents: 7295
diff changeset
    57
      _ => error ("MC syntax error: " ^ result))
c63e5220ed77 converted to Isar theory format;
wenzelm
parents: 7295
diff changeset
    58
    end
c63e5220ed77 converted to Isar theory format;
wenzelm
parents: 7295
diff changeset
    59
end
c63e5220ed77 converted to Isar theory format;
wenzelm
parents: 7295
diff changeset
    60
*}
6466
2eba94dc5951 added modelchecker mucke besides modelchecker eindhoven;
mueller
parents:
diff changeset
    61
22819
a7b425bb668c removed legacy ML files;
wenzelm
parents: 21524
diff changeset
    62
ML {*
a7b425bb668c removed legacy ML files;
wenzelm
parents: 21524
diff changeset
    63
fun mc_eindhoven_tac i state = SUBGOAL (fn (goal, _) =>
a7b425bb668c removed legacy ML files;
wenzelm
parents: 21524
diff changeset
    64
  let
a7b425bb668c removed legacy ML files;
wenzelm
parents: 21524
diff changeset
    65
    val thy = Thm.theory_of_thm state;
28290
4cc2b6046258 simplified oracle interface;
wenzelm
parents: 28263
diff changeset
    66
    val assertion = mc_eindhoven_oracle (Thm.cterm_of thy (Logic.strip_imp_concl goal));
22819
a7b425bb668c removed legacy ML files;
wenzelm
parents: 21524
diff changeset
    67
  in cut_facts_tac [assertion] i THEN atac i end) i state;
a7b425bb668c removed legacy ML files;
wenzelm
parents: 21524
diff changeset
    68
a7b425bb668c removed legacy ML files;
wenzelm
parents: 21524
diff changeset
    69
val pair_eta_expand = Thm.symmetric (mk_meta_eq (thm "split_eta"));
a7b425bb668c removed legacy ML files;
wenzelm
parents: 21524
diff changeset
    70
a7b425bb668c removed legacy ML files;
wenzelm
parents: 21524
diff changeset
    71
val pair_eta_expand_proc =
32010
cb1a1c94b4cd more antiquotations;
wenzelm
parents: 28290
diff changeset
    72
  Simplifier.simproc @{theory} "pair_eta_expand" ["f::'a*'b=>'c"]
22819
a7b425bb668c removed legacy ML files;
wenzelm
parents: 21524
diff changeset
    73
  (fn _ => fn _ => fn t => case t of Abs _ => SOME pair_eta_expand | _ => NONE);
a7b425bb668c removed legacy ML files;
wenzelm
parents: 21524
diff changeset
    74
a7b425bb668c removed legacy ML files;
wenzelm
parents: 21524
diff changeset
    75
val Eindhoven_ss =
26342
0f65fa163304 more antiquotations;
wenzelm
parents: 26225
diff changeset
    76
  @{simpset} addsimprocs [pair_eta_expand_proc] addsimps [Let_def];
22819
a7b425bb668c removed legacy ML files;
wenzelm
parents: 21524
diff changeset
    77
*}
a7b425bb668c removed legacy ML files;
wenzelm
parents: 21524
diff changeset
    78
6466
2eba94dc5951 added modelchecker mucke besides modelchecker eindhoven;
mueller
parents:
diff changeset
    79
end