src/ZF/UNITY/ClientImpl.ML
author paulson
Thu, 12 Jun 2003 16:40:59 +0200
changeset 14057 57de6d68389e
parent 14053 4daa384f4fd7
child 14060 c0c4af41fa3b
permissions -rw-r--r--
x-symbols (mostly)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
14053
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
     1
(*  Title:      ZF/UNITY/Client.ML
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
     2
    ID:         $Id$
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
     3
    Author:     Sidi O Ehmety, Cambridge University Computer Laboratory
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
     4
    Copyright   2002  University of Cambridge
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
     5
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
     6
Distributed Resource Management System: the Client
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
     7
*)
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
     8
Addsimps [type_assumes, default_val_assumes];
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
     9
(* This part should be automated *)
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    10
14057
57de6d68389e x-symbols (mostly)
paulson
parents: 14053
diff changeset
    11
Goalw [state_def] "s \\<in> state ==> s`ask \\<in> list(nat)";
14053
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    12
by (dres_inst_tac [("a", "ask")] apply_type 1);
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    13
by Auto_tac;
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    14
qed "ask_value_type";
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    15
AddTCs [ask_value_type];
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    16
Addsimps [ask_value_type];
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    17
14057
57de6d68389e x-symbols (mostly)
paulson
parents: 14053
diff changeset
    18
Goalw [state_def] "s \\<in> state ==> s`giv \\<in> list(nat)";
14053
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    19
by (dres_inst_tac [("a", "giv")] apply_type 1);
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    20
by Auto_tac;
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    21
qed "giv_value_type";
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    22
AddTCs [giv_value_type];
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    23
Addsimps [giv_value_type];
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    24
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    25
Goalw [state_def]
14057
57de6d68389e x-symbols (mostly)
paulson
parents: 14053
diff changeset
    26
"s \\<in> state ==> s`rel \\<in> list(nat)";
14053
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    27
by (dres_inst_tac [("a", "rel")] apply_type 1);
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    28
by Auto_tac;
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    29
qed "rel_value_type";
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    30
AddTCs [rel_value_type];
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    31
Addsimps [rel_value_type];
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    32
14057
57de6d68389e x-symbols (mostly)
paulson
parents: 14053
diff changeset
    33
Goalw [state_def] "s \\<in> state ==> s`tok \\<in> nat";
14053
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    34
by (dres_inst_tac [("a", "tok")] apply_type 1);
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    35
by Auto_tac;
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    36
qed "tok_value_type";
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    37
AddTCs [tok_value_type];
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    38
Addsimps [tok_value_type];
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    39
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    40
(** The Client Program **)
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    41
14057
57de6d68389e x-symbols (mostly)
paulson
parents: 14053
diff changeset
    42
Goalw [client_prog_def] "client_prog \\<in> program";
14053
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    43
by (Simp_tac 1);
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    44
qed "client_type";
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    45
Addsimps [client_type];
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    46
AddTCs [client_type];
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    47
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    48
Addsimps [client_prog_def RS def_prg_Init, 
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    49
          client_prog_def RS def_prg_AllowedActs];
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    50
program_defs_ref := [client_prog_def];
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    51
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    52
Addsimps (map simp_of_act [client_rel_act_def, 
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    53
client_tok_act_def, client_ask_act_def]);
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    54
14057
57de6d68389e x-symbols (mostly)
paulson
parents: 14053
diff changeset
    55
Goal "\\<forall>G \\<in> program. (client_prog ok G) <-> \
57de6d68389e x-symbols (mostly)
paulson
parents: 14053
diff changeset
    56
\  (G \\<in> preserves(lift(rel)) & G \\<in> preserves(lift(ask)) & \
57de6d68389e x-symbols (mostly)
paulson
parents: 14053
diff changeset
    57
\   G \\<in> preserves(lift(tok)) &  client_prog \\<in> Allowed(G))";
14053
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    58
by (auto_tac (claset(), 
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    59
     simpset() addsimps [ok_iff_Allowed, client_prog_def RS def_prg_Allowed]));  
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    60
qed "client_prog_ok_iff";
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    61
14057
57de6d68389e x-symbols (mostly)
paulson
parents: 14053
diff changeset
    62
Goal "client_prog:(\\<Inter>x \\<in> var-{ask, rel, tok}. preserves(lift(x)))";
14053
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    63
by (rtac Inter_var_DiffI 1);
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    64
by (rtac ballI 2);
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    65
by (rtac preservesI 2);
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    66
by (constrains_tac 2);
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    67
by Auto_tac;
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    68
qed "client_prog_preserves";
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    69
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    70
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    71
(*Safety property 1: ask, rel are increasing : (24) *)
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    72
Goalw [guar_def]
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    73
"client_prog: program guarantees Incr(lift(ask)) Int Incr(lift(rel))";
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    74
by (auto_tac (claset() addSIs [increasing_imp_Increasing],
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    75
        simpset() addsimps [client_prog_ok_iff, increasing_def]));
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    76
by (ALLGOALS(constrains_tac));
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    77
by (ALLGOALS(thin_tac "mk_program(?u, ?v, ?w):Allowed(?x)"));
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    78
by (auto_tac (claset() addDs [ActsD], simpset()));
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    79
by (dres_inst_tac [("f", "lift(rel)")] preserves_imp_eq 2);
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    80
by (dres_inst_tac [("f", "lift(ask)")] preserves_imp_eq 1);
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    81
by (TRYALL(assume_tac));
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    82
by (ALLGOALS(dtac ActsD));
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    83
by (TRYALL(assume_tac));
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    84
by (ALLGOALS(Clarify_tac));
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    85
by (ALLGOALS(rotate_tac ~2));
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    86
by Auto_tac;
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    87
qed "client_prog_Increasing_ask_rel";
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    88
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    89
Addsimps [nth_append, append_one_prefix];
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    90
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    91
Goal  "0<NbT";
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    92
by (cut_facts_tac [NbT_pos] 1);
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    93
by (resolve_tac [Ord_0_lt] 1);
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    94
by Auto_tac;
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    95
qed "NbT_pos2";
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    96
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    97
(*Safety property 2: the client never requests too many tokens.
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    98
With no Substitution Axiom, we must prove the two invariants simultaneously. *)
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
    99
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   100
Goal 
14057
57de6d68389e x-symbols (mostly)
paulson
parents: 14053
diff changeset
   101
"[| client_prog ok G; G \\<in> program |]\
14053
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   102
\     ==> client_prog Join G :  \
14057
57de6d68389e x-symbols (mostly)
paulson
parents: 14053
diff changeset
   103
\             Always({s \\<in> state. s`tok le NbT}  Int  \
57de6d68389e x-symbols (mostly)
paulson
parents: 14053
diff changeset
   104
\                     {s \\<in> state. \\<forall>elt \\<in> set_of_list(s`ask). elt le NbT})";
14053
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   105
by (rotate_tac ~1 1);
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   106
by (auto_tac (claset(), simpset() addsimps [client_prog_ok_iff]));
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   107
by (rtac (invariantI RS stable_Join_Always2) 1);
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   108
by (ALLGOALS(Clarify_tac));
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   109
by (ALLGOALS(Asm_full_simp_tac)); 
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   110
by (rtac stable_Int 2);
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   111
by (dres_inst_tac [("f", "lift(ask)")] preserves_imp_stable 3);
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   112
by (dres_inst_tac [("f", "lift(tok)")] preserves_imp_stable 2);
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   113
by (REPEAT(Force_tac 2));
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   114
by (constrains_tac 1);
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   115
by (auto_tac (claset() addDs [ActsD], simpset()));
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   116
by (cut_facts_tac [NbT_pos] 1);
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   117
by (resolve_tac [NbT_pos2 RS mod_less_divisor] 1);
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   118
by (auto_tac (claset() addDs [ActsD, preserves_imp_eq], 
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   119
               simpset() addsimps [set_of_list_append]));
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   120
qed "ask_Bounded_lemma";
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   121
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   122
(* Export version, with no mention of tok in the postcondition, but
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   123
  unfortunately tok must be declared local.*)
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   124
Goal 
14057
57de6d68389e x-symbols (mostly)
paulson
parents: 14053
diff changeset
   125
"client_prog \\<in> program guarantees \
57de6d68389e x-symbols (mostly)
paulson
parents: 14053
diff changeset
   126
\            Always({s \\<in> state. \\<forall>elt \\<in> set_of_list(s`ask). elt le NbT})";
14053
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   127
by (rtac guaranteesI 1);
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   128
by (etac (ask_Bounded_lemma RS Always_weaken) 1);
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   129
by Auto_tac;
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   130
qed "client_prog_ask_Bounded";
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   131
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   132
(*** Towards proving the liveness property ***)
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   133
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   134
Goal 
14057
57de6d68389e x-symbols (mostly)
paulson
parents: 14053
diff changeset
   135
"client_prog \\<in> stable({s \\<in> state. <s`rel, s`giv>:prefix(nat)})";
14053
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   136
by (constrains_tac 1);
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   137
by Auto_tac;
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   138
qed "client_prog_stable_rel_le_giv";
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   139
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   140
Goal
14057
57de6d68389e x-symbols (mostly)
paulson
parents: 14053
diff changeset
   141
"[| client_prog Join G \\<in> Incr(lift(giv)); G \\<in> preserves(lift(rel)) |] \
57de6d68389e x-symbols (mostly)
paulson
parents: 14053
diff changeset
   142
\   ==> client_prog Join G \\<in> Stable({s \\<in> state. <s`rel, s`giv>:prefix(nat)})";
14053
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   143
by (rtac (client_prog_stable_rel_le_giv RS Increasing_preserves_Stable) 1);
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   144
by (auto_tac (claset(), simpset() addsimps [lift_def]));
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   145
qed "client_prog_Join_Stable_rel_le_giv";
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   146
14057
57de6d68389e x-symbols (mostly)
paulson
parents: 14053
diff changeset
   147
Goal "[| client_prog Join G \\<in> Incr(lift(giv)); G \\<in> preserves(lift(rel)) |] \
57de6d68389e x-symbols (mostly)
paulson
parents: 14053
diff changeset
   148
\   ==> client_prog Join G  \\<in> Always({s \\<in> state. <s`rel, s`giv>:prefix(nat)})";
14053
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   149
by (force_tac (claset() addSIs [AlwaysI, client_prog_Join_Stable_rel_le_giv], 
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   150
            simpset()) 1);
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   151
qed "client_prog_Join_Always_rel_le_giv";
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   152
14057
57de6d68389e x-symbols (mostly)
paulson
parents: 14053
diff changeset
   153
Goal "xs \\<in> list(A) ==> xs@[a]=xs --> False";
14053
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   154
by (etac list.induct 1);
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   155
by Auto_tac;
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   156
qed "list_app_lemma";
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   157
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   158
Goal "A == {<s, t>:state*state. P(s, t)} ==> A={<s, t>:state*state. P(s, t)}";
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   159
by Auto_tac;
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   160
qed "def_act_eq";
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   161
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   162
Goal "A={<s,t>:state*state. P(s, t)} ==> A<=state*state";
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   163
by Auto_tac;
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   164
qed "act_subset";
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   165
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   166
Goal 
14057
57de6d68389e x-symbols (mostly)
paulson
parents: 14053
diff changeset
   167
"client_prog \\<in> \
57de6d68389e x-symbols (mostly)
paulson
parents: 14053
diff changeset
   168
\ transient({s \\<in> state. s`rel = k & <k, h>:strict_prefix(nat) \
14053
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   169
\  & <h, s`giv>:prefix(nat) & h pfixGe s`ask})";
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   170
by (res_inst_tac [("act", "client_rel_act")] transientI 1);
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   171
by (simp_tac (simpset() addsimps 
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   172
                 [client_prog_def RS def_prg_Acts]) 1);
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   173
by (simp_tac (simpset() addsimps 
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   174
             [client_rel_act_def RS def_act_eq RS act_subset]) 1);
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   175
by (auto_tac (claset(),
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   176
              simpset() addsimps [client_prog_def RS def_prg_Acts,domain_def]));
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   177
by (resolve_tac [ReplaceI] 1);
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   178
by (res_inst_tac [("x", "x(rel:= x`rel @\
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   179
        \            [nth(length(x`rel), x`giv)])")] exI 1);
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   180
by (auto_tac (claset() addSIs [state_update_type, 
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   181
                               app_type, length_type, nth_type], 
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   182
              simpset()));
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   183
by Auto_tac;
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   184
by (blast_tac (claset() addIs [lt_trans2, prefix_length_le,
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   185
                               strict_prefix_length_lt]) 1);
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   186
by (blast_tac (claset() addIs [lt_trans2, prefix_length_le,
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   187
                               strict_prefix_length_lt]) 1);
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   188
by (full_simp_tac (simpset() addsimps [gen_prefix_iff_nth]) 1);
14057
57de6d68389e x-symbols (mostly)
paulson
parents: 14053
diff changeset
   189
by (ALLGOALS(subgoal_tac "h \\<in> list(nat)"));
14053
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   190
by (ALLGOALS(asm_simp_tac (simpset() addsimps [prefix_type RS subsetD RS SigmaD1])));
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   191
by (auto_tac (claset(), 
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   192
              simpset() addsimps [prefix_def, Ge_def]));
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   193
by (dtac strict_prefix_length_lt 1);
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   194
by (dres_inst_tac [("x", "length(x`rel)")] bspec 1);
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   195
by Auto_tac;
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   196
by (full_simp_tac (simpset() addsimps [gen_prefix_iff_nth]) 1);
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   197
by (auto_tac (claset(), simpset() addsimps [id_def, lam_def]));
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   198
qed "transient_lemma";
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   199
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   200
Goalw [strict_prefix_def,id_def, lam_def]
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   201
"<xs, ys>:strict_prefix(A) <->  <xs, ys>:prefix(A) & xs~=ys";
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   202
by (auto_tac (claset() addDs [prefix_type RS subsetD], simpset()));
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   203
qed "strict_prefix_is_prefix";
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   204
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   205
Goal 
14057
57de6d68389e x-symbols (mostly)
paulson
parents: 14053
diff changeset
   206
"[| client_prog Join G \\<in> Incr(lift(giv)); client_prog ok G; G \\<in> program |] \
57de6d68389e x-symbols (mostly)
paulson
parents: 14053
diff changeset
   207
\ ==> client_prog Join G \\<in> \
57de6d68389e x-symbols (mostly)
paulson
parents: 14053
diff changeset
   208
\ {s \\<in> state. s`rel = k & <k,h>:strict_prefix(nat) \
14053
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   209
\  & <h , s`giv>:prefix(nat) & h pfixGe s`ask}  \
14057
57de6d68389e x-symbols (mostly)
paulson
parents: 14053
diff changeset
   210
\       LeadsTo {s \\<in> state. <k, s`rel>:strict_prefix(nat) \
14053
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   211
\                         & <s`rel, s`giv>:prefix(nat) & \
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   212
\                                 <h, s`giv>:prefix(nat) & \
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   213
\               h pfixGe s`ask}";
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   214
by (rtac single_LeadsTo_I 1);
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   215
by (Asm_simp_tac 2);
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   216
by (ftac (client_prog_Increasing_ask_rel RS guaranteesD) 1);
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   217
by (rotate_tac 2 3);
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   218
by (auto_tac (claset(), simpset() addsimps [client_prog_ok_iff]));
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   219
by (rtac (transient_lemma RS Join_transient_I1 RS transient_imp_leadsTo RS 
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   220
          leadsTo_imp_LeadsTo RS PSP_Stable RS LeadsTo_weaken) 1);
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   221
by (rtac (Stable_Int RS Stable_Int RS Stable_Int) 1);
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   222
by (eres_inst_tac [("f", "lift(giv)"), ("a", "s`giv")] Increasing_imp_Stable 1);
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   223
by (Asm_simp_tac 1);
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   224
by (eres_inst_tac [("f", "lift(ask)"), ("a", "s`ask")] Increasing_imp_Stable 1);
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   225
by (Asm_simp_tac 1);
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   226
by (eres_inst_tac [("f", "lift(rel)"), ("a", "s`rel")] Increasing_imp_Stable 1);
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   227
by (Asm_simp_tac 1);
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   228
by (etac client_prog_Join_Stable_rel_le_giv 1);
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   229
by (Blast_tac 1);
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   230
by (Asm_simp_tac 1);
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   231
by (Asm_simp_tac 2);
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   232
by (blast_tac (claset() addIs [sym, strict_prefix_is_prefix RS iffD2, 
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   233
                               prefix_trans, prefix_imp_pfixGe, 
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   234
                               pfixGe_trans]) 2);
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   235
by (auto_tac (claset() addIs [strict_prefix_is_prefix RS iffD1 RS conjunct1, 
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   236
                               prefix_trans], simpset()));
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   237
qed "induct_lemma";
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   238
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   239
Goal 
14057
57de6d68389e x-symbols (mostly)
paulson
parents: 14053
diff changeset
   240
"[| client_prog Join G  \\<in> Incr(lift(giv)); client_prog ok G; G \\<in> program |] \
57de6d68389e x-symbols (mostly)
paulson
parents: 14053
diff changeset
   241
\ ==> client_prog Join G  \\<in> \
57de6d68389e x-symbols (mostly)
paulson
parents: 14053
diff changeset
   242
\    {s \\<in> state. <s`rel, h>:strict_prefix(nat) \
14053
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   243
\          & <h, s`giv>:prefix(nat) & h pfixGe s`ask}  \
14057
57de6d68389e x-symbols (mostly)
paulson
parents: 14053
diff changeset
   244
\                     LeadsTo {s \\<in> state. <h, s`rel>:prefix(nat)}";
57de6d68389e x-symbols (mostly)
paulson
parents: 14053
diff changeset
   245
by (res_inst_tac [("f", "\\<lambda>x \\<in> state. length(h) #- length(x`rel)")] 
14053
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   246
                                 LessThan_induct 1);
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   247
by (auto_tac (claset(), simpset() addsimps [vimage_def]));
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   248
by (rtac single_LeadsTo_I 1);
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   249
by (rtac (induct_lemma RS LeadsTo_weaken) 1);
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   250
by Auto_tac;
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   251
by (resolve_tac [imageI] 3);
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   252
by (resolve_tac [converseI] 3);
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   253
by (asm_simp_tac (simpset() addsimps [lam_def]) 3);
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   254
by (asm_simp_tac (simpset() addsimps [length_type]) 3);
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   255
by (etac swap 2);
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   256
by (resolve_tac [imageI] 2);
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   257
by (resolve_tac [converseI] 2);
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   258
by (asm_full_simp_tac (simpset() addsimps [lam_def]) 2);
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   259
by (REPEAT (dtac strict_prefix_length_lt 2));
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   260
by (asm_full_simp_tac (simpset() addsimps [length_type, lam_def]) 2);
14057
57de6d68389e x-symbols (mostly)
paulson
parents: 14053
diff changeset
   261
by (ALLGOALS(subgoal_tac "h \\<in> list(nat)"));
14053
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   262
by (ALLGOALS(asm_simp_tac (simpset() addsimps [prefix_type RS subsetD RS SigmaD1])));
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   263
by (dtac less_imp_succ_add 2);
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   264
by (dtac less_imp_succ_add 3);
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   265
by (ALLGOALS(Clarify_tac));
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   266
by (ALLGOALS(Asm_simp_tac));
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   267
by (etac (diff_le_self RS ltD) 2); 
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   268
by (asm_full_simp_tac (simpset() addsimps [length_type, lam_def]) 1);
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   269
by (auto_tac (claset() addIs [strict_prefix_is_prefix RS iffD2]
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   270
                        addDs [rotate_prems 2 common_prefix_linear,
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   271
                               prefix_type RS subsetD], simpset()));
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   272
qed "rel_progress_lemma";
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   273
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   274
Goal 
14057
57de6d68389e x-symbols (mostly)
paulson
parents: 14053
diff changeset
   275
"[| client_prog Join G \\<in> Incr(lift(giv)); client_prog ok G; G \\<in> program |] ==> \
57de6d68389e x-symbols (mostly)
paulson
parents: 14053
diff changeset
   276
\ client_prog Join G  \\<in> \
57de6d68389e x-symbols (mostly)
paulson
parents: 14053
diff changeset
   277
\  {s \\<in> state. <h, s`giv>:prefix(nat) & h pfixGe s`ask}  \
57de6d68389e x-symbols (mostly)
paulson
parents: 14053
diff changeset
   278
\              LeadsTo {s \\<in> state. <h, s`rel>:prefix(nat)}";
14053
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   279
by (rtac (client_prog_Join_Always_rel_le_giv RS Always_LeadsToI) 1);
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   280
by (rtac ([rel_progress_lemma, subset_refl RS subset_imp_LeadsTo] MRS 
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   281
    LeadsTo_Un RS LeadsTo_weaken_L) 3);
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   282
by Auto_tac;
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   283
by (auto_tac (claset() addIs [strict_prefix_is_prefix RS iffD2]
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   284
                        addDs [rotate_prems 3 common_prefix_linear,
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   285
                               prefix_type RS subsetD], simpset()));
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   286
by (rotate_tac ~1 1);
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   287
by (force_tac (claset(), simpset() addsimps [client_prog_ok_iff]) 1);
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   288
qed "progress_lemma";
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   289
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   290
(*Progress property: all tokens that are given will be released*)
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   291
Goal 
14057
57de6d68389e x-symbols (mostly)
paulson
parents: 14053
diff changeset
   292
"client_prog \\<in> Incr(lift(giv))  guarantees  \
57de6d68389e x-symbols (mostly)
paulson
parents: 14053
diff changeset
   293
\     (\\<Inter>h \\<in> list(nat). {s \\<in> state. <h, s`giv>:prefix(nat) &\
57de6d68389e x-symbols (mostly)
paulson
parents: 14053
diff changeset
   294
\             h pfixGe s`ask} LeadsTo {s \\<in> state. <h, s`rel>:prefix(nat)})";
14053
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   295
by (rtac guaranteesI 1);
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   296
by (Clarify_tac 1);
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   297
by (blast_tac (claset() addIs [progress_lemma]) 1);
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   298
by Auto_tac;
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   299
qed "client_prog_progress";
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   300
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   301
Goal "Allowed(client_prog) = \
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   302
\ preserves(lift(rel)) Int preserves(lift(ask)) Int preserves(lift(tok))";
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   303
by (cut_facts_tac [inst "v"  "lift(ask)" preserves_type] 1);
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   304
by (auto_tac (claset(), 
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   305
              simpset() addsimps [Allowed_def, 
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   306
               client_prog_def RS def_prg_Allowed, 
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   307
                  cons_Int_distrib, safety_prop_Acts_iff]));
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   308
qed "client_prog_Allowed";
4daa384f4fd7 Introduction of the theories UNITY/Merge, UNITY/ClientImpl
paulson
parents:
diff changeset
   309