src/HOL/UNITY/Common.ML
author wenzelm
Mon, 22 Jun 1998 17:26:46 +0200
changeset 5069 3ea049f7979d
parent 4776 1f9362e769c1
child 5111 8f4b72f0c15d
permissions -rw-r--r--
isatool fixgoal;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
     1
(*  Title:      HOL/UNITY/Common
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
     2
    ID:         $Id$
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
     4
    Copyright   1998  University of Cambridge
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
     5
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
     6
Common Meeting Time example from Misra (1994)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
     7
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
     8
The state is identified with the one variable in existence.
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
     9
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    10
From Misra, "A Logic for Concurrent Programming" (1994), sections 5.1 and 13.1.
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    11
*)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    12
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    13
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    14
open Common;
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    15
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    16
(*Misra's property CMT4: t exceeds no common meeting time*)
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
    17
Goal
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    18
  "!!Acts. [| ALL m. constrains Acts {m} (maxfg m); n: common |] \
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    19
\           ==> stable Acts (atMost n)";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    20
by (dres_inst_tac [("P", "%t. t<=n")] elimination_sing 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    21
by (asm_full_simp_tac
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    22
    (simpset() addsimps [atMost_def, stable_def, common_def, maxfg_def,
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    23
			 constrains_def, le_max_iff_disj]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    24
by (Clarify_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    25
by (dtac bspec 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    26
by (assume_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    27
by (blast_tac (claset() addSEs [subsetCE]
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    28
			addIs [order_eq_refl, fmono, gmono, le_trans]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    29
qed "common_stable";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    30
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
    31
Goal
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    32
  "!!Acts. [| ALL m. constrains Acts {m} (maxfg m); n: common |] \
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    33
\           ==> reachable {0} Acts <= atMost n";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    34
by (rtac strongest_invariant 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    35
by (asm_simp_tac (simpset() addsimps [common_stable]) 2);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    36
by (simp_tac (simpset() addsimps [atMost_def]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    37
qed "common_invariant";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    38
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    39
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    40
(*** Some programs that implement the safety property above ***)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    41
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    42
(*This one is just Skip*)
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
    43
Goal "constrains {id} {m} (maxfg m)";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    44
by (simp_tac (simpset() addsimps [constrains_def, maxfg_def, le_max_iff_disj,
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    45
				  fasc, gasc]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    46
result();
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    47
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    48
(*This one is  t := ftime t || t := gtime t    really needs Skip too*)
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
    49
Goal "constrains {range(%t.(t,ftime t)), range(%t.(t,gtime t))} \
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    50
\                    {m} (maxfg m)";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    51
by (simp_tac (simpset() addsimps [constrains_def, maxfg_def, 
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    52
				  le_max_iff_disj]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    53
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    54
result();
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    55
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    56
(*This one is  t := max (ftime t) (gtime t)    really needs Skip too*)
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
    57
Goal "constrains {range(%t.(t, max (ftime t) (gtime t)))} \
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    58
\                    {m} (maxfg m)";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    59
by (simp_tac (simpset() addsimps [constrains_def, maxfg_def]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    60
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    61
result();
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    62
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    63
(*This one is  t := t+1 if t <max (ftime t) (gtime t) *)
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
    64
Goalw [constrains_def, maxfg_def] 
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    65
    "constrains { {(t, Suc t) | t. t < max (ftime t) (gtime t)} } \
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    66
\               {m} (maxfg m)";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    67
by (blast_tac (claset() addIs [Suc_leI]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    68
result();
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    69
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    70
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    71
(*It remans to prove that they satisfy CMT3': t does not decrease,
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    72
  and that CMT3' implies that t stops changing once common(t) holds.*)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    73
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    74
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    75
(*** Progress under weak fairness ***)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    76
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    77
Addsimps [atMost_Int_atLeast];
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    78
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
    79
Goal
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    80
    "!!Acts. [| ALL m. constrains Acts {m} (maxfg m); \
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    81
\               ALL m: lessThan n. leadsTo Acts {m} (greaterThan m); \
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    82
\               n: common;  id: Acts |]  \
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    83
\            ==> leadsTo Acts (atMost n) common";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    84
by (rtac leadsTo_weaken_R 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    85
by (res_inst_tac [("f","%x. x"), ("l", "n")] greaterThan_bounded_induct 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    86
by (ALLGOALS Asm_simp_tac);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    87
by (rtac subset_refl 2);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    88
by (blast_tac (claset() addDs [PSP_stable2] 
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    89
                        addIs [common_stable, leadsTo_weaken_R]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    90
val lemma = result();
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    91
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    92
(*The "ALL m: Compl common" form echoes CMT6.*)
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
    93
Goal
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    94
    "!!Acts. [| ALL m. constrains Acts {m} (maxfg m); \
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    95
\               ALL m: Compl common. leadsTo Acts {m} (greaterThan m); \
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    96
\               n: common;  id: Acts |]  \
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    97
\            ==> leadsTo Acts (atMost (LEAST n. n: common)) common";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    98
by (rtac lemma 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    99
by (ALLGOALS Asm_simp_tac);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   100
by (etac LeastI 2);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   101
by (blast_tac (claset() addSDs [not_less_Least]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   102
qed "leadsTo_common";