src/HOL/UNITY/Lift.ML
author paulson
Fri, 07 May 1999 10:50:28 +0200
changeset 6614 2d47dee036b5
parent 6570 a7d7985050a9
child 6676 62d1e642da30
permissions -rw-r--r--
tidied
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff changeset
     1
(*  Title:      HOL/UNITY/Lift
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff changeset
     2
    ID:         $Id$
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff changeset
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff changeset
     4
    Copyright   1998  University of Cambridge
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff changeset
     5
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff changeset
     6
The Lift-Control Example
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff changeset
     7
*)
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff changeset
     8
5426
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
     9
(*split_all_tac causes a big blow-up*)
5706
21706a735c8d record_split_name;
wenzelm
parents: 5701
diff changeset
    10
claset_ref() := claset() delSWrapper record_split_name;
5426
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
    11
5563
228b92552d1f Now uses integers instead of naturals
paulson
parents: 5490
diff changeset
    12
Goal "[| x ~: A;  y : A |] ==> x ~= y";
228b92552d1f Now uses integers instead of naturals
paulson
parents: 5490
diff changeset
    13
by (Blast_tac 1);
228b92552d1f Now uses integers instead of naturals
paulson
parents: 5490
diff changeset
    14
qed "not_mem_distinct";
228b92552d1f Now uses integers instead of naturals
paulson
parents: 5490
diff changeset
    15
228b92552d1f Now uses integers instead of naturals
paulson
parents: 5490
diff changeset
    16
fun distinct_tac i =
228b92552d1f Now uses integers instead of naturals
paulson
parents: 5490
diff changeset
    17
    dtac zle_neq_implies_zless i THEN
228b92552d1f Now uses integers instead of naturals
paulson
parents: 5490
diff changeset
    18
    eresolve_tac [not_mem_distinct, not_mem_distinct RS not_sym] i THEN
228b92552d1f Now uses integers instead of naturals
paulson
parents: 5490
diff changeset
    19
    assume_tac i;
228b92552d1f Now uses integers instead of naturals
paulson
parents: 5490
diff changeset
    20
5426
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
    21
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
    22
(** Rules to move "metric n s" out of the assumptions, for case splitting **)
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
    23
val mov_metric1 = read_instantiate_sg (sign_of thy) 
5596
b29d18d8c4d2 abstype of programs
paulson
parents: 5583
diff changeset
    24
                   [("P", "?x < metric ?n ?s")] rev_mp;
5426
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
    25
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
    26
val mov_metric2 = read_instantiate_sg (sign_of thy) 
5596
b29d18d8c4d2 abstype of programs
paulson
parents: 5583
diff changeset
    27
                   [("P", "?x = metric ?n ?s")] rev_mp;
5426
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
    28
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
    29
val mov_metric3 = read_instantiate_sg (sign_of thy) 
5596
b29d18d8c4d2 abstype of programs
paulson
parents: 5583
diff changeset
    30
                   [("P", "~ (?x < metric ?n ?s)")] rev_mp;
5426
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
    31
5563
228b92552d1f Now uses integers instead of naturals
paulson
parents: 5490
diff changeset
    32
val mov_metric4 = read_instantiate_sg (sign_of thy) 
5596
b29d18d8c4d2 abstype of programs
paulson
parents: 5583
diff changeset
    33
                   [("P", "(?x <= metric ?n ?s)")] rev_mp;
5563
228b92552d1f Now uses integers instead of naturals
paulson
parents: 5490
diff changeset
    34
5426
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
    35
(*The order in which they are applied seems to be critical...*)
5563
228b92552d1f Now uses integers instead of naturals
paulson
parents: 5490
diff changeset
    36
val mov_metrics = [mov_metric2, mov_metric3, mov_metric1, mov_metric4];
5426
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
    37
6139
26abad27b03c simplified thanks to the arithmetic prover
paulson
parents: 6132
diff changeset
    38
val metric_simps = [metric_def, vimage_def];
5563
228b92552d1f Now uses integers instead of naturals
paulson
parents: 5490
diff changeset
    39
5340
d75c03cf77b5 Misc changes
paulson
parents: 5320
diff changeset
    40
5648
fe887910e32e specifications as sets of programs
paulson
parents: 5596
diff changeset
    41
Addsimps [Lprg_def RS def_prg_Init];
fe887910e32e specifications as sets of programs
paulson
parents: 5596
diff changeset
    42
program_defs_ref := [Lprg_def];
5426
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
    43
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
    44
Addsimps (map simp_of_act
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
    45
	  [request_act_def, open_act_def, close_act_def,
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
    46
	   req_up_def, req_down_def, move_up_def, move_down_def,
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
    47
	   button_press_def]);
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
    48
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff changeset
    49
val always_defs = [above_def, below_def, queueing_def, 
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff changeset
    50
		   goingup_def, goingdown_def, ready_def];
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff changeset
    51
5426
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
    52
Addsimps (map simp_of_set always_defs);
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff changeset
    53
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff changeset
    54
5583
d2377657f8ef modified proof for new simproc
paulson
parents: 5563
diff changeset
    55
val LeadsTo_Trans_Un' = rotate_prems 1 LeadsTo_Trans_Un;
6614
paulson
parents: 6570
diff changeset
    56
(* [| Lprg: B LeadsTo C; Lprg: A LeadsTo B |] ==> Lprg: (A Un B) LeadsTo C *)
5357
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
    57
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
    58
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff changeset
    59
(*Simplification for records*)
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff changeset
    60
Addsimps (thms"state.update_defs");
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff changeset
    61
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff changeset
    62
Addsimps [bounded_def, open_stop_def, open_move_def, stop_floor_def,
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff changeset
    63
	  moving_up_def, moving_down_def];
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff changeset
    64
5357
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
    65
AddIffs [Min_le_Max];
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff changeset
    66
5320
79b326bceafb now trans_tac is part of the claset...
paulson
parents: 5313
diff changeset
    67
6570
a7d7985050a9 Invariant -> Always and other tidying
paulson
parents: 6536
diff changeset
    68
Goal "Lprg : Always open_stop";
a7d7985050a9 Invariant -> Always and other tidying
paulson
parents: 6536
diff changeset
    69
by (rtac AlwaysI 1);
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff changeset
    70
by (Force_tac 1);
5426
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
    71
by (constrains_tac 1);
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff changeset
    72
qed "open_stop";
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff changeset
    73
6570
a7d7985050a9 Invariant -> Always and other tidying
paulson
parents: 6536
diff changeset
    74
Goal "Lprg : Always stop_floor";
a7d7985050a9 Invariant -> Always and other tidying
paulson
parents: 6536
diff changeset
    75
by (rtac AlwaysI 1);
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff changeset
    76
by (Force_tac 1);
5426
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
    77
by (constrains_tac 1);
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff changeset
    78
qed "stop_floor";
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff changeset
    79
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
    80
(*This one needs open_stop, which was proved above*)
6570
a7d7985050a9 Invariant -> Always and other tidying
paulson
parents: 6536
diff changeset
    81
Goal "Lprg : Always open_move";
a7d7985050a9 Invariant -> Always and other tidying
paulson
parents: 6536
diff changeset
    82
by (rtac AlwaysI 1);
a7d7985050a9 Invariant -> Always and other tidying
paulson
parents: 6536
diff changeset
    83
by (rtac (open_stop RS Always_ConstrainsI RS StableI) 2);
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff changeset
    84
by (Force_tac 1);
5426
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
    85
by (constrains_tac 1);
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff changeset
    86
qed "open_move";
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff changeset
    87
6570
a7d7985050a9 Invariant -> Always and other tidying
paulson
parents: 6536
diff changeset
    88
Goal "Lprg : Always moving_up";
a7d7985050a9 Invariant -> Always and other tidying
paulson
parents: 6536
diff changeset
    89
by (rtac AlwaysI 1);
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff changeset
    90
by (Force_tac 1);
5426
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
    91
by (constrains_tac 1);
5563
228b92552d1f Now uses integers instead of naturals
paulson
parents: 5490
diff changeset
    92
by (blast_tac (claset() addDs [zle_imp_zless_or_eq]) 1);
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff changeset
    93
qed "moving_up";
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff changeset
    94
6570
a7d7985050a9 Invariant -> Always and other tidying
paulson
parents: 6536
diff changeset
    95
Goal "Lprg : Always moving_down";
a7d7985050a9 Invariant -> Always and other tidying
paulson
parents: 6536
diff changeset
    96
by (rtac AlwaysI 1);
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff changeset
    97
by (Force_tac 1);
5426
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
    98
by (constrains_tac 1);
5563
228b92552d1f Now uses integers instead of naturals
paulson
parents: 5490
diff changeset
    99
by (blast_tac (claset() addDs [zle_imp_zless_or_eq]) 1);
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff changeset
   100
qed "moving_down";
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff changeset
   101
6570
a7d7985050a9 Invariant -> Always and other tidying
paulson
parents: 6536
diff changeset
   102
Goal "Lprg : Always bounded";
a7d7985050a9 Invariant -> Always and other tidying
paulson
parents: 6536
diff changeset
   103
by (rtac AlwaysI 1);
a7d7985050a9 Invariant -> Always and other tidying
paulson
parents: 6536
diff changeset
   104
by (rtac (Always_Int_rule [moving_up, moving_down] RS Always_StableI) 2);
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff changeset
   105
by (Force_tac 1);
5426
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
   106
by (constrains_tac 1);
5563
228b92552d1f Now uses integers instead of naturals
paulson
parents: 5490
diff changeset
   107
by (ALLGOALS Clarify_tac);
228b92552d1f Now uses integers instead of naturals
paulson
parents: 5490
diff changeset
   108
by (REPEAT_FIRST distinct_tac);
6161
paulson
parents: 6139
diff changeset
   109
by Auto_tac;
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff changeset
   110
qed "bounded";
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff changeset
   111
5320
79b326bceafb now trans_tac is part of the claset...
paulson
parents: 5313
diff changeset
   112
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff changeset
   113
5320
79b326bceafb now trans_tac is part of the claset...
paulson
parents: 5313
diff changeset
   114
(*** Progress ***)
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff changeset
   115
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff changeset
   116
5320
79b326bceafb now trans_tac is part of the claset...
paulson
parents: 5313
diff changeset
   117
val abbrev_defs = [moving_def, stopped_def, 
5340
d75c03cf77b5 Misc changes
paulson
parents: 5320
diff changeset
   118
		   opened_def, closed_def, atFloor_def, Req_def];
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff changeset
   119
5426
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
   120
Addsimps (map simp_of_set abbrev_defs);
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff changeset
   121
5340
d75c03cf77b5 Misc changes
paulson
parents: 5320
diff changeset
   122
d75c03cf77b5 Misc changes
paulson
parents: 5320
diff changeset
   123
(** The HUG'93 paper mistakenly omits the Req n from these! **)
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff changeset
   124
5357
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   125
(** Lift_1 **)
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   126
6536
281d44905cab made many specification operators infix
paulson
parents: 6161
diff changeset
   127
Goal "Lprg : (stopped Int atFloor n) LeadsTo (opened Int atFloor n)";
5340
d75c03cf77b5 Misc changes
paulson
parents: 5320
diff changeset
   128
by (cut_facts_tac [stop_floor] 1);
5426
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
   129
by (ensures_tac "open_act" 1);
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
   130
qed "E_thm01";  (*lem_lift_1_5*)
5340
d75c03cf77b5 Misc changes
paulson
parents: 5320
diff changeset
   131
6536
281d44905cab made many specification operators infix
paulson
parents: 6161
diff changeset
   132
Goal "Lprg : (Req n Int stopped - atFloor n) LeadsTo \
6139
26abad27b03c simplified thanks to the arithmetic prover
paulson
parents: 6132
diff changeset
   133
\                    (Req n Int opened - atFloor n)";
5340
d75c03cf77b5 Misc changes
paulson
parents: 5320
diff changeset
   134
by (cut_facts_tac [stop_floor] 1);
5426
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
   135
by (ensures_tac "open_act" 1);
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
   136
qed "E_thm02";  (*lem_lift_1_1*)
5340
d75c03cf77b5 Misc changes
paulson
parents: 5320
diff changeset
   137
6536
281d44905cab made many specification operators infix
paulson
parents: 6161
diff changeset
   138
Goal "Lprg : (Req n Int opened - atFloor n) LeadsTo \
6139
26abad27b03c simplified thanks to the arithmetic prover
paulson
parents: 6132
diff changeset
   139
\                    (Req n Int closed - (atFloor n - queueing))";
5426
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
   140
by (ensures_tac "close_act" 1);
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
   141
qed "E_thm03";  (*lem_lift_1_2*)
5340
d75c03cf77b5 Misc changes
paulson
parents: 5320
diff changeset
   142
6536
281d44905cab made many specification operators infix
paulson
parents: 6161
diff changeset
   143
Goal "Lprg : (Req n Int closed Int (atFloor n - queueing))  \
281d44905cab made many specification operators infix
paulson
parents: 6161
diff changeset
   144
\            LeadsTo (opened Int atFloor n)";
5426
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
   145
by (ensures_tac "open_act" 1);
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
   146
qed "E_thm04";  (*lem_lift_1_7*)
5340
d75c03cf77b5 Misc changes
paulson
parents: 5320
diff changeset
   147
d75c03cf77b5 Misc changes
paulson
parents: 5320
diff changeset
   148
5357
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   149
(** Lift 2.  Statements of thm05a and thm05b were wrong! **)
5340
d75c03cf77b5 Misc changes
paulson
parents: 5320
diff changeset
   150
d75c03cf77b5 Misc changes
paulson
parents: 5320
diff changeset
   151
Open_locale "floor"; 
d75c03cf77b5 Misc changes
paulson
parents: 5320
diff changeset
   152
5357
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   153
val Min_le_n = thm "Min_le_n";
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   154
val n_le_Max = thm "n_le_Max";
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   155
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   156
AddIffs [Min_le_n, n_le_Max];
5340
d75c03cf77b5 Misc changes
paulson
parents: 5320
diff changeset
   157
5563
228b92552d1f Now uses integers instead of naturals
paulson
parents: 5490
diff changeset
   158
val le_MinD = Min_le_n RS zle_anti_sym;
228b92552d1f Now uses integers instead of naturals
paulson
parents: 5490
diff changeset
   159
val Max_leD = n_le_Max RSN (2,zle_anti_sym);
5357
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   160
5563
228b92552d1f Now uses integers instead of naturals
paulson
parents: 5490
diff changeset
   161
AddSDs [le_MinD, zleI RS le_MinD,
228b92552d1f Now uses integers instead of naturals
paulson
parents: 5490
diff changeset
   162
	Max_leD, zleI RS Max_leD];
5357
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   163
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   164
(*lem_lift_2_0 
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   165
  NOT an ensures property, but a mere inclusion;
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   166
  don't know why script lift_2.uni says ENSURES*)
6536
281d44905cab made many specification operators infix
paulson
parents: 6161
diff changeset
   167
Goal "Lprg : (Req n Int closed - (atFloor n - queueing))   \
281d44905cab made many specification operators infix
paulson
parents: 6161
diff changeset
   168
\            LeadsTo ((closed Int goingup Int Req n)  Un \
6139
26abad27b03c simplified thanks to the arithmetic prover
paulson
parents: 6132
diff changeset
   169
\                     (closed Int goingdown Int Req n))";
5426
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
   170
by (rtac subset_imp_LeadsTo 1);
5563
228b92552d1f Now uses integers instead of naturals
paulson
parents: 5490
diff changeset
   171
by (auto_tac (claset() addSEs [int_neqE], simpset()));
5340
d75c03cf77b5 Misc changes
paulson
parents: 5320
diff changeset
   172
qed "E_thm05c";
d75c03cf77b5 Misc changes
paulson
parents: 5320
diff changeset
   173
5357
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   174
(*lift_2*)
6536
281d44905cab made many specification operators infix
paulson
parents: 6161
diff changeset
   175
Goal "Lprg : (Req n Int closed - (atFloor n - queueing))   \
281d44905cab made many specification operators infix
paulson
parents: 6161
diff changeset
   176
\            LeadsTo (moving Int Req n)";
5426
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
   177
by (rtac ([E_thm05c, LeadsTo_Un] MRS LeadsTo_Trans) 1);
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
   178
by (ensures_tac "req_down" 2);
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
   179
by (ensures_tac "req_up" 1);
5424
771a68a468cc modified proofs for new constrains_tac and ensures_tac
paulson
parents: 5410
diff changeset
   180
by Auto_tac;
5340
d75c03cf77b5 Misc changes
paulson
parents: 5320
diff changeset
   181
qed "lift_2";
d75c03cf77b5 Misc changes
paulson
parents: 5320
diff changeset
   182
d75c03cf77b5 Misc changes
paulson
parents: 5320
diff changeset
   183
5357
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   184
(** Towards lift_4 ***)
5563
228b92552d1f Now uses integers instead of naturals
paulson
parents: 5490
diff changeset
   185
 
5357
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   186
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   187
(*lem_lift_4_1 *)
5563
228b92552d1f Now uses integers instead of naturals
paulson
parents: 5490
diff changeset
   188
Goal "#0 < N ==> \
6536
281d44905cab made many specification operators infix
paulson
parents: 6161
diff changeset
   189
\     Lprg : (moving Int Req n Int {s. metric n s = N} Int \
281d44905cab made many specification operators infix
paulson
parents: 6161
diff changeset
   190
\             {s. floor s ~: req s} Int {s. up s})   \
281d44905cab made many specification operators infix
paulson
parents: 6161
diff changeset
   191
\            LeadsTo \
6139
26abad27b03c simplified thanks to the arithmetic prover
paulson
parents: 6132
diff changeset
   192
\              (moving Int Req n Int {s. metric n s < N})";
5357
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   193
by (cut_facts_tac [moving_up] 1);
5426
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
   194
by (ensures_tac "move_up" 1);
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
   195
by Safe_tac;
5357
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   196
(*this step consolidates two formulae to the goal  metric n s' <= metric n s*)
5563
228b92552d1f Now uses integers instead of naturals
paulson
parents: 5490
diff changeset
   197
by (etac (zleI RS zle_anti_sym RS sym) 1);
5426
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
   198
by (REPEAT_FIRST (eresolve_tac mov_metrics));
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
   199
by (REPEAT_FIRST distinct_tac);
5563
228b92552d1f Now uses integers instead of naturals
paulson
parents: 5490
diff changeset
   200
(** LEVEL 6 **)
5583
d2377657f8ef modified proof for new simproc
paulson
parents: 5563
diff changeset
   201
by (ALLGOALS (asm_simp_tac (simpset() addsimps 
d2377657f8ef modified proof for new simproc
paulson
parents: 5563
diff changeset
   202
			    [zle_def] @ metric_simps @ zcompare_rls)));
5357
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   203
qed "E_thm12a";
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   204
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   205
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   206
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   207
(*lem_lift_4_3 *)
5563
228b92552d1f Now uses integers instead of naturals
paulson
parents: 5490
diff changeset
   208
Goal "#0 < N ==> \
6536
281d44905cab made many specification operators infix
paulson
parents: 6161
diff changeset
   209
\     Lprg : (moving Int Req n Int {s. metric n s = N} Int \
281d44905cab made many specification operators infix
paulson
parents: 6161
diff changeset
   210
\             {s. floor s ~: req s} - {s. up s})   \
281d44905cab made many specification operators infix
paulson
parents: 6161
diff changeset
   211
\            LeadsTo (moving Int Req n Int {s. metric n s < N})";
5357
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   212
by (cut_facts_tac [moving_down] 1);
5426
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
   213
by (ensures_tac "move_down" 1);
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
   214
by Safe_tac;
5357
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   215
(*this step consolidates two formulae to the goal  metric n s' <= metric n s*)
5563
228b92552d1f Now uses integers instead of naturals
paulson
parents: 5490
diff changeset
   216
by (etac (zleI RS zle_anti_sym RS sym) 1);
5426
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
   217
by (REPEAT_FIRST (eresolve_tac mov_metrics));
5563
228b92552d1f Now uses integers instead of naturals
paulson
parents: 5490
diff changeset
   218
by (REPEAT_FIRST distinct_tac);
228b92552d1f Now uses integers instead of naturals
paulson
parents: 5490
diff changeset
   219
(** LEVEL 6 **)
6139
26abad27b03c simplified thanks to the arithmetic prover
paulson
parents: 6132
diff changeset
   220
by (ALLGOALS (asm_simp_tac (simpset() addsimps metric_simps @ zcompare_rls)));
5357
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   221
qed "E_thm12b";
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   222
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   223
(*lift_4*)
6536
281d44905cab made many specification operators infix
paulson
parents: 6161
diff changeset
   224
Goal "#0<N ==> Lprg : (moving Int Req n Int {s. metric n s = N} Int \
281d44905cab made many specification operators infix
paulson
parents: 6161
diff changeset
   225
\                           {s. floor s ~: req s}) LeadsTo     \
5563
228b92552d1f Now uses integers instead of naturals
paulson
parents: 5490
diff changeset
   226
\                          (moving Int Req n Int {s. metric n s < N})";
5426
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
   227
by (rtac ([subset_imp_LeadsTo, LeadsTo_Un] MRS LeadsTo_Trans) 1);
5583
d2377657f8ef modified proof for new simproc
paulson
parents: 5563
diff changeset
   228
by (etac E_thm12b 3);
d2377657f8ef modified proof for new simproc
paulson
parents: 5563
diff changeset
   229
by (etac E_thm12a 2);
5357
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   230
by (Blast_tac 1);
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   231
qed "lift_4";
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   232
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   233
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   234
(** towards lift_5 **)
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   235
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   236
(*lem_lift_5_3*)
5563
228b92552d1f Now uses integers instead of naturals
paulson
parents: 5490
diff changeset
   237
Goal "#0<N   \
6536
281d44905cab made many specification operators infix
paulson
parents: 6161
diff changeset
   238
\     ==> Lprg : (closed Int Req n Int {s. metric n s = N} Int goingup) LeadsTo \
5563
228b92552d1f Now uses integers instead of naturals
paulson
parents: 5490
diff changeset
   239
\                      (moving Int Req n Int {s. metric n s < N})";
5357
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   240
by (cut_facts_tac [bounded] 1);
5426
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
   241
by (ensures_tac "req_up" 1);
5424
771a68a468cc modified proofs for new constrains_tac and ensures_tac
paulson
parents: 5410
diff changeset
   242
by Auto_tac;
5426
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
   243
by (REPEAT_FIRST (eresolve_tac mov_metrics));
6139
26abad27b03c simplified thanks to the arithmetic prover
paulson
parents: 6132
diff changeset
   244
by (ALLGOALS (asm_simp_tac (simpset() addsimps metric_simps @ zcompare_rls)));
6128
2acc5d36610c More arith refinements.
nipkow
parents: 6061
diff changeset
   245
by (Blast_tac 1);
5357
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   246
qed "E_thm16a";
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   247
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   248
(*lem_lift_5_1 has ~goingup instead of goingdown*)
5563
228b92552d1f Now uses integers instead of naturals
paulson
parents: 5490
diff changeset
   249
Goal "#0<N ==>   \
6536
281d44905cab made many specification operators infix
paulson
parents: 6161
diff changeset
   250
\     Lprg : (closed Int Req n Int {s. metric n s = N} Int goingdown) LeadsTo \
5563
228b92552d1f Now uses integers instead of naturals
paulson
parents: 5490
diff changeset
   251
\                  (moving Int Req n Int {s. metric n s < N})";
5357
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   252
by (cut_facts_tac [bounded] 1);
5426
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
   253
by (ensures_tac "req_down" 1);
5424
771a68a468cc modified proofs for new constrains_tac and ensures_tac
paulson
parents: 5410
diff changeset
   254
by Auto_tac;
5426
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
   255
by (REPEAT_FIRST (eresolve_tac mov_metrics));
6139
26abad27b03c simplified thanks to the arithmetic prover
paulson
parents: 6132
diff changeset
   256
by (ALLGOALS (asm_simp_tac (simpset() addsimps metric_simps @ zcompare_rls)));
6128
2acc5d36610c More arith refinements.
nipkow
parents: 6061
diff changeset
   257
by (Blast_tac 1);
5357
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   258
qed "E_thm16b";
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   259
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   260
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   261
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   262
(*lem_lift_5_0 proves an intersection involving ~goingup and goingup,
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   263
  i.e. the trivial disjunction, leading to an asymmetrical proof.*)
5563
228b92552d1f Now uses integers instead of naturals
paulson
parents: 5490
diff changeset
   264
Goal "#0<N ==> Req n Int {s. metric n s = N} <= goingup Un goingdown";
228b92552d1f Now uses integers instead of naturals
paulson
parents: 5490
diff changeset
   265
by (asm_simp_tac (simpset() addsimps metric_simps) 1);
5758
27a2b36efd95 corrected auto_tac (applications of unsafe wrappers)
oheimb
parents: 5706
diff changeset
   266
by (force_tac (claset() delrules [impCE] addEs [impCE], 
6139
26abad27b03c simplified thanks to the arithmetic prover
paulson
parents: 6132
diff changeset
   267
	       simpset() addsimps conj_comms) 1);
5357
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   268
qed "E_thm16c";
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   269
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   270
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   271
(*lift_5*)
6536
281d44905cab made many specification operators infix
paulson
parents: 6161
diff changeset
   272
Goal "#0<N ==> Lprg : (closed Int Req n Int {s. metric n s = N}) LeadsTo   \
5563
228b92552d1f Now uses integers instead of naturals
paulson
parents: 5490
diff changeset
   273
\                          (moving Int Req n Int {s. metric n s < N})";
5426
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
   274
by (rtac ([subset_imp_LeadsTo, LeadsTo_Un] MRS LeadsTo_Trans) 1);
5583
d2377657f8ef modified proof for new simproc
paulson
parents: 5563
diff changeset
   275
by (etac E_thm16b 3);
d2377657f8ef modified proof for new simproc
paulson
parents: 5563
diff changeset
   276
by (etac E_thm16a 2);
5426
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
   277
by (dtac E_thm16c 1);
5357
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   278
by (Blast_tac 1);
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   279
qed "lift_5";
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   280
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   281
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   282
(** towards lift_3 **)
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   283
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   284
(*lemma used to prove lem_lift_3_1*)
5563
228b92552d1f Now uses integers instead of naturals
paulson
parents: 5490
diff changeset
   285
Goal "[| metric n s = #0;  Min <= floor s;  floor s <= Max |] ==> floor s = n";
5426
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
   286
by (etac rev_mp 1);
5563
228b92552d1f Now uses integers instead of naturals
paulson
parents: 5490
diff changeset
   287
(*force simplification of "metric..." while in conclusion part*)
228b92552d1f Now uses integers instead of naturals
paulson
parents: 5490
diff changeset
   288
by (asm_simp_tac (simpset() addsimps metric_simps) 1);
5357
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   289
qed "metric_eq_0D";
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   290
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   291
AddDs [metric_eq_0D];
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   292
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   293
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   294
(*lem_lift_3_1*)
6536
281d44905cab made many specification operators infix
paulson
parents: 6161
diff changeset
   295
Goal "Lprg : (moving Int Req n Int {s. metric n s = #0}) LeadsTo   \
5357
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   296
\                  (stopped Int atFloor n)";
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   297
by (cut_facts_tac [bounded] 1);
5426
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
   298
by (ensures_tac "request_act" 1);
5424
771a68a468cc modified proofs for new constrains_tac and ensures_tac
paulson
parents: 5410
diff changeset
   299
by Auto_tac;
5357
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   300
qed "E_thm11";
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   301
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   302
(*lem_lift_3_5*)
6536
281d44905cab made many specification operators infix
paulson
parents: 6161
diff changeset
   303
Goal
281d44905cab made many specification operators infix
paulson
parents: 6161
diff changeset
   304
  "Lprg : (moving Int Req n Int {s. metric n s = N} Int {s. floor s : req s}) \
281d44905cab made many specification operators infix
paulson
parents: 6161
diff changeset
   305
\ LeadsTo (stopped Int Req n Int {s. metric n s = N} Int {s. floor s : req s})";
5426
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
   306
by (ensures_tac "request_act" 1);
5424
771a68a468cc modified proofs for new constrains_tac and ensures_tac
paulson
parents: 5410
diff changeset
   307
by (auto_tac (claset(), simpset() addsimps metric_simps));
5357
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   308
qed "E_thm13";
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   309
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   310
(*lem_lift_3_6*)
5563
228b92552d1f Now uses integers instead of naturals
paulson
parents: 5490
diff changeset
   311
Goal "#0 < N ==> \
6536
281d44905cab made many specification operators infix
paulson
parents: 6161
diff changeset
   312
\     Lprg : \
5563
228b92552d1f Now uses integers instead of naturals
paulson
parents: 5490
diff changeset
   313
\       (stopped Int Req n Int {s. metric n s = N} Int {s. floor s : req s}) \
6536
281d44905cab made many specification operators infix
paulson
parents: 6161
diff changeset
   314
\       LeadsTo (opened Int Req n Int {s. metric n s = N})";
5426
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
   315
by (ensures_tac "open_act" 1);
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
   316
by (REPEAT_FIRST (eresolve_tac mov_metrics));
5424
771a68a468cc modified proofs for new constrains_tac and ensures_tac
paulson
parents: 5410
diff changeset
   317
by (auto_tac (claset(), simpset() addsimps metric_simps));
5357
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   318
qed "E_thm14";
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   319
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   320
(*lem_lift_3_7*)
6536
281d44905cab made many specification operators infix
paulson
parents: 6161
diff changeset
   321
Goal "Lprg : (opened Int Req n Int {s. metric n s = N})  \
281d44905cab made many specification operators infix
paulson
parents: 6161
diff changeset
   322
\            LeadsTo (closed Int Req n Int {s. metric n s = N})";
5426
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
   323
by (ensures_tac "close_act" 1);
5424
771a68a468cc modified proofs for new constrains_tac and ensures_tac
paulson
parents: 5410
diff changeset
   324
by (auto_tac (claset(), simpset() addsimps metric_simps));
5357
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   325
qed "E_thm15";
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   326
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   327
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   328
(** the final steps **)
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   329
5563
228b92552d1f Now uses integers instead of naturals
paulson
parents: 5490
diff changeset
   330
Goal "#0 < N ==> \
6536
281d44905cab made many specification operators infix
paulson
parents: 6161
diff changeset
   331
\     Lprg : \
5563
228b92552d1f Now uses integers instead of naturals
paulson
parents: 5490
diff changeset
   332
\       (moving Int Req n Int {s. metric n s = N} Int {s. floor s : req s})   \
6536
281d44905cab made many specification operators infix
paulson
parents: 6161
diff changeset
   333
\       LeadsTo (moving Int Req n Int {s. metric n s < N})";
5479
5a5dfb0f0d7d fixed PROOF FAILED
paulson
parents: 5426
diff changeset
   334
by (blast_tac (claset() addSIs [E_thm13, E_thm14, E_thm15, lift_5]
5a5dfb0f0d7d fixed PROOF FAILED
paulson
parents: 5426
diff changeset
   335
	                addIs [LeadsTo_Trans]) 1);
5357
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   336
qed "lift_3_Req";
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   337
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   338
5563
228b92552d1f Now uses integers instead of naturals
paulson
parents: 5490
diff changeset
   339
228b92552d1f Now uses integers instead of naturals
paulson
parents: 5490
diff changeset
   340
(*Now we observe that our integer metric is really a natural number*)
6570
a7d7985050a9 Invariant -> Always and other tidying
paulson
parents: 6536
diff changeset
   341
Goal "Lprg : Always {s. #0 <= metric n s}";
a7d7985050a9 Invariant -> Always and other tidying
paulson
parents: 6536
diff changeset
   342
by (rtac (bounded RS Always_weaken) 1);
5563
228b92552d1f Now uses integers instead of naturals
paulson
parents: 5490
diff changeset
   343
by (simp_tac (simpset() addsimps metric_simps @ zcompare_rls) 1);
228b92552d1f Now uses integers instead of naturals
paulson
parents: 5490
diff changeset
   344
by (auto_tac (claset(),
228b92552d1f Now uses integers instead of naturals
paulson
parents: 5490
diff changeset
   345
	      simpset() addsimps [zless_iff_Suc_zadd, zle_iff_zadd]));
228b92552d1f Now uses integers instead of naturals
paulson
parents: 5490
diff changeset
   346
by (REPEAT_FIRST (etac ssubst));
5583
d2377657f8ef modified proof for new simproc
paulson
parents: 5563
diff changeset
   347
by (auto_tac (claset(), simpset() addsimps [zadd_int]));
6570
a7d7985050a9 Invariant -> Always and other tidying
paulson
parents: 6536
diff changeset
   348
qed "Always_nonneg";
5563
228b92552d1f Now uses integers instead of naturals
paulson
parents: 5490
diff changeset
   349
6570
a7d7985050a9 Invariant -> Always and other tidying
paulson
parents: 6536
diff changeset
   350
val R_thm11 = [Always_nonneg, E_thm11] MRS Always_LeadsTo_weaken;
5563
228b92552d1f Now uses integers instead of naturals
paulson
parents: 5490
diff changeset
   351
6536
281d44905cab made many specification operators infix
paulson
parents: 6161
diff changeset
   352
Goal "Lprg : (moving Int Req n) LeadsTo (stopped Int atFloor n)";
6570
a7d7985050a9 Invariant -> Always and other tidying
paulson
parents: 6536
diff changeset
   353
by (rtac (Always_nonneg RS integ_0_le_induct) 1);
5563
228b92552d1f Now uses integers instead of naturals
paulson
parents: 5490
diff changeset
   354
by (case_tac "#0 < z" 1);
228b92552d1f Now uses integers instead of naturals
paulson
parents: 5490
diff changeset
   355
(*If z <= #0 then actually z = #0*)
228b92552d1f Now uses integers instead of naturals
paulson
parents: 5490
diff changeset
   356
by (fold_tac [zle_def]);
228b92552d1f Now uses integers instead of naturals
paulson
parents: 5490
diff changeset
   357
by (force_tac (claset() addIs [R_thm11, zle_anti_sym], simpset()) 2);
5426
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
   358
by (rtac ([asm_rl, Un_upper1] MRS LeadsTo_weaken_R) 1);
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
   359
by (rtac ([subset_imp_LeadsTo, LeadsTo_Un] MRS LeadsTo_Trans) 1);
5583
d2377657f8ef modified proof for new simproc
paulson
parents: 5563
diff changeset
   360
by (rtac lift_3_Req 3);
d2377657f8ef modified proof for new simproc
paulson
parents: 5563
diff changeset
   361
by (rtac lift_4 2);
5426
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
   362
by Auto_tac;
5357
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   363
qed "lift_3";
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   364
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   365
6536
281d44905cab made many specification operators infix
paulson
parents: 6161
diff changeset
   366
Goal "Lprg : (Req n) LeadsTo (opened Int atFloor n)";
5426
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
   367
by (rtac LeadsTo_Trans 1);
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
   368
by (rtac (E_thm04 RS LeadsTo_Un) 2);
5583
d2377657f8ef modified proof for new simproc
paulson
parents: 5563
diff changeset
   369
by (rtac LeadsTo_Un_post 2);
5426
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
   370
by (rtac (E_thm01 RS LeadsTo_Trans_Un') 2);
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
   371
by (rtac (lift_3 RS LeadsTo_Trans_Un') 2);
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
   372
by (rtac (lift_2 RS LeadsTo_Trans_Un') 2);
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
   373
by (rtac (E_thm03 RS LeadsTo_Trans_Un') 2);
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
   374
by (rtac E_thm02 2);
6570
a7d7985050a9 Invariant -> Always and other tidying
paulson
parents: 6536
diff changeset
   375
by (rtac (open_move RS Always_LeadsToI) 1);
a7d7985050a9 Invariant -> Always and other tidying
paulson
parents: 6536
diff changeset
   376
by (rtac (open_stop RS Always_LeadsToI) 1);
5426
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
   377
by (rtac subset_imp_LeadsTo 1);
5340
d75c03cf77b5 Misc changes
paulson
parents: 5320
diff changeset
   378
by (Clarify_tac 1);
5484
e9430ed7e8d6 Extra steps at end to make it run faster
paulson
parents: 5479
diff changeset
   379
(*The case split is not essential but makes Blast_tac much faster.
e9430ed7e8d6 Extra steps at end to make it run faster
paulson
parents: 5479
diff changeset
   380
  Must also be careful to prevent simplification from looping*)
e9430ed7e8d6 Extra steps at end to make it run faster
paulson
parents: 5479
diff changeset
   381
by (case_tac "open x" 1);
e9430ed7e8d6 Extra steps at end to make it run faster
paulson
parents: 5479
diff changeset
   382
by (ALLGOALS (rotate_tac ~1));
e9430ed7e8d6 Extra steps at end to make it run faster
paulson
parents: 5479
diff changeset
   383
by (ALLGOALS Asm_full_simp_tac);
5426
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
   384
by (Blast_tac 1);
5340
d75c03cf77b5 Misc changes
paulson
parents: 5320
diff changeset
   385
qed "lift_1";
d75c03cf77b5 Misc changes
paulson
parents: 5320
diff changeset
   386
6024
cb87f103d114 new Close_locale synatx
paulson
parents: 5783
diff changeset
   387
Close_locale "floor";