src/HOL/UNITY/Traces.ML
author nipkow
Fri, 02 Oct 1998 14:28:39 +0200
changeset 5608 a82a038a3e7a
parent 5596 b29d18d8c4d2
child 5620 3ac11c4af76a
permissions -rw-r--r--
id <-> Id
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5111
8f4b72f0c15d Uncurried functions LeadsTo and reach
paulson
parents: 5069
diff changeset
     1
(*  Title:      HOL/UNITY/Traces
8f4b72f0c15d Uncurried functions LeadsTo and reach
paulson
parents: 5069
diff changeset
     2
    ID:         $Id$
8f4b72f0c15d Uncurried functions LeadsTo and reach
paulson
parents: 5069
diff changeset
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
8f4b72f0c15d Uncurried functions LeadsTo and reach
paulson
parents: 5069
diff changeset
     4
    Copyright   1998  University of Cambridge
8f4b72f0c15d Uncurried functions LeadsTo and reach
paulson
parents: 5069
diff changeset
     5
8f4b72f0c15d Uncurried functions LeadsTo and reach
paulson
parents: 5069
diff changeset
     6
Definitions of
8f4b72f0c15d Uncurried functions LeadsTo and reach
paulson
parents: 5069
diff changeset
     7
  * traces: the possible execution traces
8f4b72f0c15d Uncurried functions LeadsTo and reach
paulson
parents: 5069
diff changeset
     8
  * reachable: the set of reachable states
8f4b72f0c15d Uncurried functions LeadsTo and reach
paulson
parents: 5069
diff changeset
     9
8f4b72f0c15d Uncurried functions LeadsTo and reach
paulson
parents: 5069
diff changeset
    10
*)
8f4b72f0c15d Uncurried functions LeadsTo and reach
paulson
parents: 5069
diff changeset
    11
5596
b29d18d8c4d2 abstype of programs
paulson
parents: 5584
diff changeset
    12
b29d18d8c4d2 abstype of programs
paulson
parents: 5584
diff changeset
    13
(*** The abstract type of programs ***)
b29d18d8c4d2 abstype of programs
paulson
parents: 5584
diff changeset
    14
b29d18d8c4d2 abstype of programs
paulson
parents: 5584
diff changeset
    15
val rep_ss = simpset() addsimps 
b29d18d8c4d2 abstype of programs
paulson
parents: 5584
diff changeset
    16
                [Init_def, Acts_def, mk_program_def, Program_def, Rep_Program, 
b29d18d8c4d2 abstype of programs
paulson
parents: 5584
diff changeset
    17
		 Rep_Program_inverse, Abs_Program_inverse];
b29d18d8c4d2 abstype of programs
paulson
parents: 5584
diff changeset
    18
b29d18d8c4d2 abstype of programs
paulson
parents: 5584
diff changeset
    19
5608
a82a038a3e7a id <-> Id
nipkow
parents: 5596
diff changeset
    20
Goal "Id: Acts prg";
5596
b29d18d8c4d2 abstype of programs
paulson
parents: 5584
diff changeset
    21
by (cut_inst_tac [("x", "prg")] Rep_Program 1);
b29d18d8c4d2 abstype of programs
paulson
parents: 5584
diff changeset
    22
by (auto_tac (claset(), rep_ss));
5608
a82a038a3e7a id <-> Id
nipkow
parents: 5596
diff changeset
    23
qed "Id_in_Acts";
a82a038a3e7a id <-> Id
nipkow
parents: 5596
diff changeset
    24
AddIffs [Id_in_Acts];
5584
aad639e56d4e Now id:(Acts prg) is implicit
paulson
parents: 5426
diff changeset
    25
aad639e56d4e Now id:(Acts prg) is implicit
paulson
parents: 5426
diff changeset
    26
5596
b29d18d8c4d2 abstype of programs
paulson
parents: 5584
diff changeset
    27
Goal "Init (mk_program (init,acts)) = init";
b29d18d8c4d2 abstype of programs
paulson
parents: 5584
diff changeset
    28
by (auto_tac (claset(), rep_ss));
b29d18d8c4d2 abstype of programs
paulson
parents: 5584
diff changeset
    29
qed "Init_eq";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    30
5608
a82a038a3e7a id <-> Id
nipkow
parents: 5596
diff changeset
    31
Goal "Acts (mk_program (init,acts)) = insert Id acts";
5596
b29d18d8c4d2 abstype of programs
paulson
parents: 5584
diff changeset
    32
by (auto_tac (claset(), rep_ss));
5423
c57c87628bb4 two new thms
paulson
parents: 5313
diff changeset
    33
qed "Acts_eq";
c57c87628bb4 two new thms
paulson
parents: 5313
diff changeset
    34
5596
b29d18d8c4d2 abstype of programs
paulson
parents: 5584
diff changeset
    35
Addsimps [Acts_eq, Init_eq];
b29d18d8c4d2 abstype of programs
paulson
parents: 5584
diff changeset
    36
5423
c57c87628bb4 two new thms
paulson
parents: 5313
diff changeset
    37
5596
b29d18d8c4d2 abstype of programs
paulson
parents: 5584
diff changeset
    38
Goal "[| Init prg = Init prg'; Acts prg = Acts prg' |] ==> prg = prg'";
b29d18d8c4d2 abstype of programs
paulson
parents: 5584
diff changeset
    39
by (cut_inst_tac [("p", "Rep_Program prg")] surjective_pairing 1);
b29d18d8c4d2 abstype of programs
paulson
parents: 5584
diff changeset
    40
by (auto_tac (claset(), rep_ss));
b29d18d8c4d2 abstype of programs
paulson
parents: 5584
diff changeset
    41
by (dres_inst_tac [("f", "Abs_Program")] arg_cong 1);
b29d18d8c4d2 abstype of programs
paulson
parents: 5584
diff changeset
    42
by (full_simp_tac (rep_ss addsimps [surjective_pairing RS sym]) 1);
b29d18d8c4d2 abstype of programs
paulson
parents: 5584
diff changeset
    43
qed "program_equalityI";
5426
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5423
diff changeset
    44
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5423
diff changeset
    45
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5423
diff changeset
    46
(*** These three rules allow "lazy" definition expansion ***)
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5423
diff changeset
    47
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5423
diff changeset
    48
val [rew] = goal thy
5596
b29d18d8c4d2 abstype of programs
paulson
parents: 5584
diff changeset
    49
    "[| prg == mk_program (init,acts) |] \
5608
a82a038a3e7a id <-> Id
nipkow
parents: 5596
diff changeset
    50
\    ==> Init prg = init & Acts prg = insert Id acts";
5426
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5423
diff changeset
    51
by (rewtac rew);
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5423
diff changeset
    52
by Auto_tac;
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5423
diff changeset
    53
qed "def_prg_simps";
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5423
diff changeset
    54
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5423
diff changeset
    55
val [rew] = goal thy
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5423
diff changeset
    56
    "[| act == {(s,s'). P s s'} |] ==> ((s,s') : act) = P s s'";
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5423
diff changeset
    57
by (rewtac rew);
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5423
diff changeset
    58
by Auto_tac;
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5423
diff changeset
    59
qed "def_act_simp";
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5423
diff changeset
    60
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5423
diff changeset
    61
fun simp_of_act def = def RS def_act_simp;
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5423
diff changeset
    62
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5423
diff changeset
    63
val [rew] = goal thy
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5423
diff changeset
    64
    "[| A == B |] ==> (x : A) = (x : B)";
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5423
diff changeset
    65
by (rewtac rew);
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5423
diff changeset
    66
by Auto_tac;
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5423
diff changeset
    67
qed "def_set_simp";
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5423
diff changeset
    68
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5423
diff changeset
    69
fun simp_of_set def = def RS def_set_simp;
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5423
diff changeset
    70
5596
b29d18d8c4d2 abstype of programs
paulson
parents: 5584
diff changeset
    71
b29d18d8c4d2 abstype of programs
paulson
parents: 5584
diff changeset
    72
(*** traces and reachable ***)
b29d18d8c4d2 abstype of programs
paulson
parents: 5584
diff changeset
    73
b29d18d8c4d2 abstype of programs
paulson
parents: 5584
diff changeset
    74
Goal "reachable prg = {s. EX evs. (s,evs): traces (Init prg) (Acts prg)}";
b29d18d8c4d2 abstype of programs
paulson
parents: 5584
diff changeset
    75
by Safe_tac;
b29d18d8c4d2 abstype of programs
paulson
parents: 5584
diff changeset
    76
by (etac traces.induct 2);
b29d18d8c4d2 abstype of programs
paulson
parents: 5584
diff changeset
    77
by (etac reachable.induct 1);
b29d18d8c4d2 abstype of programs
paulson
parents: 5584
diff changeset
    78
by (ALLGOALS (blast_tac (claset() addIs (reachable.intrs @ traces.intrs))));
b29d18d8c4d2 abstype of programs
paulson
parents: 5584
diff changeset
    79
qed "reachable_equiv_traces";
b29d18d8c4d2 abstype of programs
paulson
parents: 5584
diff changeset
    80
b29d18d8c4d2 abstype of programs
paulson
parents: 5584
diff changeset
    81
Goal "acts <= Acts prg ==> stable acts (reachable prg)";
b29d18d8c4d2 abstype of programs
paulson
parents: 5584
diff changeset
    82
by (blast_tac (claset() addIs ([stableI, constrainsI] @ reachable.intrs)) 1);
b29d18d8c4d2 abstype of programs
paulson
parents: 5584
diff changeset
    83
qed "stable_reachable";