src/HOL/UNITY/Lift.ML
author paulson
Fri, 11 Sep 1998 18:09:54 +0200
changeset 5484 e9430ed7e8d6
parent 5479 5a5dfb0f0d7d
child 5486 d98a55f581c5
permissions -rw-r--r--
Extra steps at end to make it run faster
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
5340
d75c03cf77b5 Misc changes
paulson
parents: 5320
diff changeset
     9
5426
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
    10
(*split_all_tac causes a big blow-up*)
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
    11
claset_ref() := claset() delSWrapper "split_all_tac";
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
    12
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
    13
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
    14
(** 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
    15
val mov_metric1 = read_instantiate_sg (sign_of thy) 
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
    16
                 [("P", "?x < metric ?n ?s")] rev_mp;
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
    17
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
    18
val mov_metric2 = read_instantiate_sg (sign_of thy) 
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
    19
                 [("P", "?x = metric ?n ?s")] rev_mp;
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
    20
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
    21
val mov_metric3 = read_instantiate_sg (sign_of thy) 
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
    22
                 [("P", "~ (?x < metric ?n ?s)")] rev_mp;
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
    23
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
    24
(*The order in which they are applied seems to be critical...*)
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
    25
val mov_metrics = [mov_metric2, mov_metric3, mov_metric1];
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
    26
5357
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
    27
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
    28
val Suc_lessD_contra = Suc_lessD COMP rev_contrapos;
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
    29
val Suc_lessD_contra' = less_not_sym RS Suc_lessD_contra;
5340
d75c03cf77b5 Misc changes
paulson
parents: 5320
diff changeset
    30
5426
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
    31
Addsimps [Lprg_def RS def_prg_simps];
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
    32
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
    33
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
    34
	  [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
    35
	   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
    36
	   button_press_def]);
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
    37
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff changeset
    38
val always_defs = [above_def, below_def, queueing_def, 
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff changeset
    39
		   goingup_def, goingdown_def, ready_def];
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff changeset
    40
5426
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
    41
Addsimps (map simp_of_set always_defs);
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff changeset
    42
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff changeset
    43
Goalw [Lprg_def] "id : Acts Lprg";
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff changeset
    44
by (Simp_tac 1);
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff changeset
    45
qed "id_in_Acts";
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff changeset
    46
AddIffs [id_in_Acts];
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff changeset
    47
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff changeset
    48
5357
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
    49
val LeadsTo_Un_post' = id_in_Acts RS LeadsTo_Un_post
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
    50
and LeadsTo_Trans_Un' = rotate_prems 1 (id_in_Acts RS LeadsTo_Trans_Un);
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
    51
(* [| LeadsTo Lprg B C; LeadsTo Lprg A B |] ==> LeadsTo Lprg (A Un B) C *)
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
    52
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
    53
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
    54
val metric_simps =
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
    55
    [metric_def, vimage_def, 
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
    56
     not_less_less_Suc_eq, less_not_sym RS not_less_less_Suc_eq,
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
    57
     Suc_lessD_contra, Suc_lessD_contra',
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
    58
     less_not_refl2, less_not_refl3];
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
    59
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
    60
5426
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
    61
(*Hoping to be faster than
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
    62
    asm_simp_tac (simpset() addsimps metric_simps
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
    63
  but sometimes it's slower*)
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
    64
val metric_simp_tac = 
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
    65
    asm_simp_tac (simpset() addsimps [metric_def, vimage_def]) THEN'
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
    66
    asm_simp_tac (simpset() addsimps metric_simps);
5357
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
    67
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff changeset
    68
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff changeset
    69
(*Simplification for records*)
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff changeset
    70
Addsimps (thms"state.update_defs");
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff changeset
    71
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff changeset
    72
Addsimps [Suc_le_eq];
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff changeset
    73
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff changeset
    74
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
    75
	  moving_up_def, moving_down_def];
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff changeset
    76
5357
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
    77
AddIffs [Min_le_Max];
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff changeset
    78
5320
79b326bceafb now trans_tac is part of the claset...
paulson
parents: 5313
diff changeset
    79
79b326bceafb now trans_tac is part of the claset...
paulson
parents: 5313
diff changeset
    80
val nat_exhaust_le_pred = 
79b326bceafb now trans_tac is part of the claset...
paulson
parents: 5313
diff changeset
    81
    read_instantiate_sg (sign_of thy) [("P", "?m <= ?y-1")] nat.exhaust;
79b326bceafb now trans_tac is part of the claset...
paulson
parents: 5313
diff changeset
    82
79b326bceafb now trans_tac is part of the claset...
paulson
parents: 5313
diff changeset
    83
val nat_exhaust_pred_le = 
79b326bceafb now trans_tac is part of the claset...
paulson
parents: 5313
diff changeset
    84
    read_instantiate_sg (sign_of thy) [("P", "?y-1 <= ?m")] nat.exhaust;
79b326bceafb now trans_tac is part of the claset...
paulson
parents: 5313
diff changeset
    85
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff changeset
    86
Goal "m < n ==> m <= n-1";
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff changeset
    87
by (asm_simp_tac (simpset() addsimps [gr_implies_gr0 RS le_pred_eq]) 1);
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff changeset
    88
qed "less_imp_le_pred";
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff changeset
    89
5426
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
    90
Goal "Invariant Lprg open_stop";
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
    91
by (rtac InvariantI 1);
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff changeset
    92
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
    93
by (constrains_tac 1);
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff changeset
    94
qed "open_stop";
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff changeset
    95
5426
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
    96
Goal "Invariant Lprg stop_floor";
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
    97
by (rtac InvariantI 1);
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff changeset
    98
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
    99
by (constrains_tac 1);
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff changeset
   100
qed "stop_floor";
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff changeset
   101
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   102
(*This one needs open_stop, which was proved above*)
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   103
Goal "Invariant Lprg open_move";
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   104
by (rtac InvariantI 1);
5426
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
   105
by (rtac (open_stop RS Invariant_ConstrainsI RS StableI) 2);
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff changeset
   106
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
   107
by (constrains_tac 1);
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff changeset
   108
qed "open_move";
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff changeset
   109
5426
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
   110
Goal "Invariant Lprg moving_up";
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   111
by (rtac InvariantI 1);
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff changeset
   112
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
   113
by (constrains_tac 1);
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff changeset
   114
by (blast_tac (claset() addDs [le_imp_less_or_eq]) 1);
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff changeset
   115
qed "moving_up";
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff changeset
   116
5426
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
   117
Goal "Invariant Lprg moving_down";
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   118
by (rtac InvariantI 1);
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff changeset
   119
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
   120
by (constrains_tac 1);
5424
771a68a468cc modified proofs for new constrains_tac and ensures_tac
paulson
parents: 5410
diff changeset
   121
by Safe_tac;
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff changeset
   122
by (dres_inst_tac [("m","f")] le_imp_less_or_eq 3);
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff changeset
   123
by (auto_tac (claset(),
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff changeset
   124
	      simpset() addsimps [gr_implies_gr0 RS le_pred_eq]));
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff changeset
   125
qed "moving_down";
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff changeset
   126
5320
79b326bceafb now trans_tac is part of the claset...
paulson
parents: 5313
diff changeset
   127
Goal "Invariant Lprg bounded";
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   128
by (rtac InvariantI 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 (rtac (Invariant_Int_rule [moving_up, moving_down] RS Invariant_StableI) 2);
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff changeset
   130
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
   131
by (constrains_tac 1);
5424
771a68a468cc modified proofs for new constrains_tac and ensures_tac
paulson
parents: 5410
diff changeset
   132
by Safe_tac;
5320
79b326bceafb now trans_tac is part of the claset...
paulson
parents: 5313
diff changeset
   133
by (TRYALL (resolve_tac [nat_exhaust_le_pred, nat_exhaust_pred_le]));
79b326bceafb now trans_tac is part of the claset...
paulson
parents: 5313
diff changeset
   134
by (auto_tac (claset(), simpset() addsimps [less_Suc_eq]));
79b326bceafb now trans_tac is part of the claset...
paulson
parents: 5313
diff changeset
   135
by (auto_tac (claset(), simpset() addsimps [less_Suc_eq, le_eq_less_or_eq]));
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff changeset
   136
qed "bounded";
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff changeset
   137
5320
79b326bceafb now trans_tac is part of the claset...
paulson
parents: 5313
diff changeset
   138
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff changeset
   139
5320
79b326bceafb now trans_tac is part of the claset...
paulson
parents: 5313
diff changeset
   140
(*** Progress ***)
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff changeset
   141
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff changeset
   142
5320
79b326bceafb now trans_tac is part of the claset...
paulson
parents: 5313
diff changeset
   143
val abbrev_defs = [moving_def, stopped_def, 
5340
d75c03cf77b5 Misc changes
paulson
parents: 5320
diff changeset
   144
		   opened_def, closed_def, atFloor_def, Req_def];
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff changeset
   145
5426
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
   146
Addsimps (map simp_of_set abbrev_defs);
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff changeset
   147
5340
d75c03cf77b5 Misc changes
paulson
parents: 5320
diff changeset
   148
d75c03cf77b5 Misc changes
paulson
parents: 5320
diff changeset
   149
(** 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
   150
5357
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   151
(** Lift_1 **)
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   152
5320
79b326bceafb now trans_tac is part of the claset...
paulson
parents: 5313
diff changeset
   153
Goal "LeadsTo Lprg (stopped Int atFloor n) (opened Int atFloor n)";
5340
d75c03cf77b5 Misc changes
paulson
parents: 5320
diff changeset
   154
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
   155
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
   156
qed "E_thm01";  (*lem_lift_1_5*)
5340
d75c03cf77b5 Misc changes
paulson
parents: 5320
diff changeset
   157
d75c03cf77b5 Misc changes
paulson
parents: 5320
diff changeset
   158
Goal "LeadsTo Lprg (Req n Int stopped - atFloor n) \
d75c03cf77b5 Misc changes
paulson
parents: 5320
diff changeset
   159
\                  (Req n Int opened - atFloor n)";
d75c03cf77b5 Misc changes
paulson
parents: 5320
diff changeset
   160
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
   161
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
   162
qed "E_thm02";  (*lem_lift_1_1*)
5340
d75c03cf77b5 Misc changes
paulson
parents: 5320
diff changeset
   163
d75c03cf77b5 Misc changes
paulson
parents: 5320
diff changeset
   164
Goal "LeadsTo Lprg (Req n Int opened - atFloor n) \
d75c03cf77b5 Misc changes
paulson
parents: 5320
diff changeset
   165
\                  (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
   166
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
   167
qed "E_thm03";  (*lem_lift_1_2*)
5340
d75c03cf77b5 Misc changes
paulson
parents: 5320
diff changeset
   168
d75c03cf77b5 Misc changes
paulson
parents: 5320
diff changeset
   169
Goal "LeadsTo Lprg (Req n Int closed Int (atFloor n - queueing)) \
d75c03cf77b5 Misc changes
paulson
parents: 5320
diff changeset
   170
\                  (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
   171
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
   172
qed "E_thm04";  (*lem_lift_1_7*)
5340
d75c03cf77b5 Misc changes
paulson
parents: 5320
diff changeset
   173
d75c03cf77b5 Misc changes
paulson
parents: 5320
diff changeset
   174
5357
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   175
(** Lift 2.  Statements of thm05a and thm05b were wrong! **)
5340
d75c03cf77b5 Misc changes
paulson
parents: 5320
diff changeset
   176
d75c03cf77b5 Misc changes
paulson
parents: 5320
diff changeset
   177
Open_locale "floor"; 
d75c03cf77b5 Misc changes
paulson
parents: 5320
diff changeset
   178
5357
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   179
val Min_le_n = thm "Min_le_n";
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   180
val n_le_Max = thm "n_le_Max";
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   181
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   182
AddIffs [Min_le_n, n_le_Max];
5340
d75c03cf77b5 Misc changes
paulson
parents: 5320
diff changeset
   183
5357
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   184
val le_MinD = Min_le_n RS le_anti_sym;
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   185
val Max_leD = n_le_Max RSN (2,le_anti_sym);
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   186
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   187
AddSDs [le_MinD, leI RS le_MinD,
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   188
	Max_leD, leI RS Max_leD];
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   189
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   190
(*lem_lift_2_0 
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   191
  NOT an ensures property, but a mere inclusion;
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   192
  don't know why script lift_2.uni says ENSURES*)
5340
d75c03cf77b5 Misc changes
paulson
parents: 5320
diff changeset
   193
Goal "LeadsTo Lprg (Req n Int closed - (atFloor n - queueing))   \
d75c03cf77b5 Misc changes
paulson
parents: 5320
diff changeset
   194
\                  ((closed Int goingup Int Req n)  Un \
d75c03cf77b5 Misc changes
paulson
parents: 5320
diff changeset
   195
\                   (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
   196
by (rtac subset_imp_LeadsTo 1);
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
   197
by (auto_tac (claset() addSEs [nat_neqE], simpset()));
5340
d75c03cf77b5 Misc changes
paulson
parents: 5320
diff changeset
   198
qed "E_thm05c";
d75c03cf77b5 Misc changes
paulson
parents: 5320
diff changeset
   199
5357
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   200
(*lift_2*)
5340
d75c03cf77b5 Misc changes
paulson
parents: 5320
diff changeset
   201
Goal "LeadsTo Lprg (Req n Int closed - (atFloor n - queueing))   \
d75c03cf77b5 Misc changes
paulson
parents: 5320
diff changeset
   202
\                  (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
   203
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
   204
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
   205
by (ensures_tac "req_up" 1);
5424
771a68a468cc modified proofs for new constrains_tac and ensures_tac
paulson
parents: 5410
diff changeset
   206
by Auto_tac;
5340
d75c03cf77b5 Misc changes
paulson
parents: 5320
diff changeset
   207
qed "lift_2";
d75c03cf77b5 Misc changes
paulson
parents: 5320
diff changeset
   208
d75c03cf77b5 Misc changes
paulson
parents: 5320
diff changeset
   209
5357
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   210
(** Towards lift_4 ***)
5340
d75c03cf77b5 Misc changes
paulson
parents: 5320
diff changeset
   211
5357
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   212
Goal "[| x ~: A;  y : A |] ==> x ~= y";
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   213
by (Blast_tac 1);
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   214
qed "not_mem_distinct";
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   215
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   216
fun distinct_tac i =
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   217
    dtac le_neq_implies_less i THEN
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   218
    eresolve_tac [not_mem_distinct, not_mem_distinct RS not_sym] i THEN
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   219
    assume_tac i;
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   220
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   221
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   222
(*lem_lift_4_1 *)
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   223
Goal "0 < N ==> \
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   224
\     LeadsTo Lprg \
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   225
\       (moving Int Req n Int (metric n -`` {N}) Int \
5426
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
   226
\         {s. floor s ~: req s} Int {s. up s})   \
5357
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   227
\       (moving Int Req n Int (metric n -`` lessThan N))";
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   228
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
   229
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
   230
by Safe_tac;
5357
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   231
(*this step consolidates two formulae to the goal  metric n s' <= metric n s*)
5426
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
   232
by (etac (leI RS le_anti_sym RS sym) 1);
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
   233
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
   234
by (REPEAT_FIRST distinct_tac);
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
   235
by (ALLGOALS metric_simp_tac);
5357
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   236
by (auto_tac
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   237
    (claset() addEs [diff_Suc_less_diff RS less_not_refl3 RSN (2, rev_notE)]
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   238
	      addIs [diff_Suc_less_diff], 
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   239
     simpset()));
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   240
qed "E_thm12a";
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   241
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   242
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   243
(*This rule helps eliminate occurrences of  (floor s - 1) *)
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   244
val less_floor_imp = read_instantiate_sg (sign_of thy) 
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   245
                 [("n", "floor ?s")] less_eq_Suc_add RS exE;
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   246
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   247
(*lem_lift_4_3 *)
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   248
Goal "0 < N ==> \
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   249
\     LeadsTo Lprg \
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   250
\       (moving Int Req n Int (metric n -`` {N}) Int \
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   251
\        {s. floor s ~: req s} - {s. up s})   \
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   252
\       (moving Int Req n Int (metric n -`` lessThan N))";
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   253
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
   254
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
   255
by Safe_tac;
5357
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   256
by (ALLGOALS distinct_tac);
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   257
by (ALLGOALS (etac less_floor_imp THEN' Clarify_tac THEN' Asm_full_simp_tac));
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   258
(*this step consolidates two formulae to the goal  metric n s' <= metric n s*)
5426
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
   259
by (etac (leI RS le_anti_sym RS sym) 1);
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
   260
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
   261
by (ALLGOALS metric_simp_tac);
5357
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   262
by (auto_tac
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   263
    (claset() addEs [diff_less_Suc_diff RS less_not_refl3 RSN (2, rev_notE)]
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   264
              addIs [diff_le_Suc_diff, diff_less_Suc_diff],
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   265
	      simpset() addsimps [trans_le_add1]));
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   266
qed "E_thm12b";
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   267
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   268
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   269
(*lift_4*)
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   270
Goal "0<N ==> LeadsTo Lprg (moving Int Req n Int (metric n -`` {N}) Int \
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   271
\                           {s. floor s ~: req s})     \
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   272
\                          (moving Int Req n Int (metric n -`` lessThan N))";
5426
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
   273
by (rtac ([subset_imp_LeadsTo, LeadsTo_Un] MRS LeadsTo_Trans) 1);
5357
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   274
by (etac E_thm12b 4);
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   275
by (etac E_thm12a 3);
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   276
by (rtac id_in_Acts 2);
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   277
by (Blast_tac 1);
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   278
qed "lift_4";
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   279
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   280
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   281
(** towards lift_5 **)
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   282
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   283
(*lem_lift_5_3*)
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   284
Goal "0<N   \
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   285
\     ==> LeadsTo Lprg (closed Int Req n Int (metric n -`` {N}) Int goingup) \
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   286
\                      (moving Int Req n Int (metric n -`` lessThan N))";
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   287
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
   288
by (ensures_tac "req_up" 1);
5424
771a68a468cc modified proofs for new constrains_tac and ensures_tac
paulson
parents: 5410
diff changeset
   289
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
   290
by (REPEAT_FIRST (eresolve_tac mov_metrics));
5357
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   291
by (ALLGOALS (asm_simp_tac (simpset() addsimps metric_simps)));
5426
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
   292
     (*faster than metric_simp_tac or than using just metric_def*)
5357
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   293
by (auto_tac (claset() addIs [diff_Suc_less_diff], 
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   294
	      simpset() addsimps [arith1, arith2]));
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   295
qed "E_thm16a";
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   296
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   297
    (*arith1 comes from
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   298
     1. !!s i.
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   299
	   [| n : req s; stop s; ~ open s; move s; floor s < i; i <= Max;
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   300
	      i : req s; ALL i. i < floor s --> Min <= i --> i ~: req s;
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   301
	      ~ n < Suc (floor s); ~ n < floor s; ~ up s; floor s < n;
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   302
	      Suc (floor s) < n; 0 < floor s - Min |]
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   303
	   ==> n - Suc (floor s) < floor s - Min + (n - Min)
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   304
    *)
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   305
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   306
    (*arith2 comes from
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   307
     2. !!s i.
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   308
	   [| Min <= floor s; ...
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   309
	      n : req s; stop s; ~ open s; move s; floor s < i; i <= Max;
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   310
	      i : req s; ALL i. i < floor s --> Min <= i --> i ~: req s;
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   311
	      ~ n < floor s; ~ up s; floor s < n; ~ n < Suc (floor s);
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   312
	      Suc (floor s) < n; Min < n |]
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   313
	   ==> n - Suc (floor s) < floor s - Min + (n - Min)
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   314
    *)
5340
d75c03cf77b5 Misc changes
paulson
parents: 5320
diff changeset
   315
5357
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   316
(*lem_lift_5_1 has ~goingup instead of goingdown*)
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   317
Goal "0<N ==>   \
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   318
\     LeadsTo Lprg (closed Int Req n Int (metric n -`` {N}) Int goingdown) \
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   319
\                  (moving Int Req n Int (metric n -`` lessThan N))";
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   320
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
   321
by (ensures_tac "req_down" 1);
5424
771a68a468cc modified proofs for new constrains_tac and ensures_tac
paulson
parents: 5410
diff changeset
   322
by Auto_tac;
5357
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   323
by (ALLGOALS (etac less_floor_imp THEN' Clarify_tac THEN' 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
   324
by (REPEAT_FIRST (eresolve_tac mov_metrics));
5357
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   325
by (ALLGOALS (asm_simp_tac (simpset() addsimps metric_simps)));
5426
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
   326
     (*faster and better than metric_simp_tac *)
5357
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   327
by (auto_tac (claset() addIs [diff_Suc_less_diff, diff_less_Suc_diff], 
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   328
	      simpset() addsimps [trans_le_add1, arith3, arith4]));
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   329
qed "E_thm16b";
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   330
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   331
    (*arith3 comes from
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   332
     1. !!s i x.
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   333
	   [| floor s = Suc (i + x); Min <= Suc (i + x); stop s; i + x < Max;
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   334
	      ~ open s; n : req s; move s; Min <= i; i : req s;
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   335
	      ALL ia. ia <= Max --> Suc (i + x) < ia --> ia ~: req s;
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   336
	      ~ Suc (i + x) < n; ~ i + x < n; n ~= i + x; up s; n < i + x;
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   337
	      Suc (i + x) < Max |]
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   338
	   ==> i + x - n < Max - Suc (i + x) + (Max - n)
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   339
    *)
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   340
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   341
    (*arith4 comes from
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   342
     2. !!s i x.
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   343
	   [| floor s = Suc (i + x); Min <= Suc (i + x); stop s; i + x < Max;
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   344
	      ~ open s; n : req s; move s; Min <= i; i : req s;
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   345
	      ALL ia. ia <= Max --> Suc (i + x) < ia --> ia ~: req s;
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   346
	      ~ Suc (i + x) < n; ~ i + x < n; n ~= i + x; up s; n < i + x;
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   347
	      n < Max |]
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   348
	   ==> i + x - n < Max - Suc (i + x) + (Max - n)
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   349
    *)
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   350
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   351
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   352
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   353
(*lem_lift_5_0 proves an intersection involving ~goingup and goingup,
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   354
  i.e. the trivial disjunction, leading to an asymmetrical proof.*)
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   355
Goal "0<N ==> Req n Int (metric n -``{N}) <= goingup Un goingdown";
5426
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
   356
by (asm_simp_tac
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
   357
    (simpset() addsimps (always_defs@abbrev_defs@[metric_def,vimage_def])) 1);
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
   358
by (auto_tac (claset(), simpset() addsimps metric_simps));
5357
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   359
qed "E_thm16c";
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   360
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   361
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   362
(*lift_5*)
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   363
Goal "0<N ==> LeadsTo Lprg (closed Int Req n Int (metric n -`` {N}))   \
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   364
\                          (moving Int Req n Int (metric n -`` lessThan N))";
5426
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
   365
by (rtac ([subset_imp_LeadsTo, LeadsTo_Un] MRS LeadsTo_Trans) 1);
5357
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   366
by (etac E_thm16b 4);
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   367
by (etac E_thm16a 3);
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   368
by (rtac id_in_Acts 2);
5426
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
   369
by (dtac E_thm16c 1);
5357
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   370
by (Blast_tac 1);
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   371
qed "lift_5";
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   372
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   373
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   374
(** towards lift_3 **)
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   375
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   376
(*lemma used to prove lem_lift_3_1*)
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   377
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
   378
by (etac rev_mp 1);
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
   379
  (*MUCH faster than metric_simps*)
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
   380
by (asm_simp_tac (simpset() addsimps [metric_def]) 1);
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
   381
by (auto_tac (claset(), simpset() addsimps metric_simps));
5357
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   382
qed "metric_eq_0D";
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   383
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   384
AddDs [metric_eq_0D];
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   385
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   386
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   387
(*lem_lift_3_1*)
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   388
Goal "LeadsTo Lprg (moving Int Req n Int (metric n -`` {0}))   \
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   389
\                  (stopped Int atFloor n)";
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   390
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
   391
by (ensures_tac "request_act" 1);
5424
771a68a468cc modified proofs for new constrains_tac and ensures_tac
paulson
parents: 5410
diff changeset
   392
by Auto_tac;
5357
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   393
qed "E_thm11";
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   394
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   395
(*lem_lift_3_5*)
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   396
Goal "LeadsTo Lprg \
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   397
\       (moving Int Req n Int (metric n -`` {N}) Int {s. floor s : req s})   \
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   398
\       (stopped Int Req n Int (metric n -`` {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
   399
by (ensures_tac "request_act" 1);
5424
771a68a468cc modified proofs for new constrains_tac and ensures_tac
paulson
parents: 5410
diff changeset
   400
by (auto_tac (claset(), simpset() addsimps metric_simps));
5357
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   401
qed "E_thm13";
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   402
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   403
(*lem_lift_3_6*)
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   404
Goal "0 < N ==> \
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   405
\     LeadsTo Lprg \
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   406
\       (stopped Int Req n Int (metric n -`` {N}) Int {s. floor s : req s}) \
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   407
\       (opened Int Req n Int (metric n -`` {N}))";
5426
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
   408
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
   409
by (REPEAT_FIRST (eresolve_tac mov_metrics));
5424
771a68a468cc modified proofs for new constrains_tac and ensures_tac
paulson
parents: 5410
diff changeset
   410
by (auto_tac (claset(), simpset() addsimps metric_simps));
5357
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   411
qed "E_thm14";
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   412
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   413
(*lem_lift_3_7*)
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   414
Goal "LeadsTo Lprg \
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   415
\       (opened Int Req n Int (metric n -`` {N}))  \
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   416
\       (closed Int Req n Int (metric n -`` {N}))";
5426
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
   417
by (ensures_tac "close_act" 1);
5424
771a68a468cc modified proofs for new constrains_tac and ensures_tac
paulson
parents: 5410
diff changeset
   418
by (auto_tac (claset(), simpset() addsimps metric_simps));
5357
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   419
qed "E_thm15";
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   420
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   421
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   422
(** the final steps **)
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   423
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   424
Goal "0 < N ==> \
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   425
\     LeadsTo Lprg \
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   426
\       (moving Int Req n Int (metric n -`` {N}) Int {s. floor s : req s})   \
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   427
\       (moving Int Req n Int (metric n -`` lessThan N))";
5479
5a5dfb0f0d7d fixed PROOF FAILED
paulson
parents: 5426
diff changeset
   428
by (blast_tac (claset() addSIs [E_thm13, E_thm14, E_thm15, lift_5]
5a5dfb0f0d7d fixed PROOF FAILED
paulson
parents: 5426
diff changeset
   429
	                addIs [LeadsTo_Trans]) 1);
5357
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   430
qed "lift_3_Req";
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   431
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   432
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   433
Goal "LeadsTo Lprg (moving Int Req n) (stopped 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
   434
by (rtac (allI RS LessThan_induct) 1);
5357
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   435
by (exhaust_tac "m" 1);
5426
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
   436
by Auto_tac;
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
   437
by (rtac E_thm11 1);
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
   438
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
   439
by (rtac ([subset_imp_LeadsTo, 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
   440
by (rtac lift_3_Req 4);
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
   441
by (rtac lift_4 3);
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
   442
by Auto_tac;
5357
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   443
qed "lift_3";
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   444
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   445
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   446
Goal "LeadsTo Lprg (Req n) (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
   447
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
   448
by (rtac (E_thm04 RS LeadsTo_Un) 2);
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
   449
by (rtac LeadsTo_Un_post' 2);
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
   450
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
   451
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
   452
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
   453
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
   454
by (rtac E_thm02 2);
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
   455
by (rtac (open_move RS Invariant_LeadsToI) 1);
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
   456
by (rtac (open_stop RS Invariant_LeadsToI) 1);
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5424
diff changeset
   457
by (rtac subset_imp_LeadsTo 1);
5340
d75c03cf77b5 Misc changes
paulson
parents: 5320
diff changeset
   458
by (rtac id_in_Acts 2);
d75c03cf77b5 Misc changes
paulson
parents: 5320
diff changeset
   459
by (Clarify_tac 1);
5484
e9430ed7e8d6 Extra steps at end to make it run faster
paulson
parents: 5479
diff changeset
   460
(*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
   461
  Must also be careful to prevent simplification from looping*)
e9430ed7e8d6 Extra steps at end to make it run faster
paulson
parents: 5479
diff changeset
   462
by (case_tac "open x" 1);
e9430ed7e8d6 Extra steps at end to make it run faster
paulson
parents: 5479
diff changeset
   463
by (ALLGOALS (rotate_tac ~1));
e9430ed7e8d6 Extra steps at end to make it run faster
paulson
parents: 5479
diff changeset
   464
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
   465
by (Blast_tac 1);
5340
d75c03cf77b5 Misc changes
paulson
parents: 5320
diff changeset
   466
qed "lift_1";
d75c03cf77b5 Misc changes
paulson
parents: 5320
diff changeset
   467
5357
6efb2b87610c New theory Lift
paulson
parents: 5340
diff changeset
   468
Close_locale;