| author | wenzelm | 
| Mon, 13 Mar 2000 13:24:12 +0100 | |
| changeset 8436 | 8a87fa482baf | 
| parent 8423 | 3c19160b6432 | 
| child 8442 | 96023903c2df | 
| permissions | -rw-r--r-- | 
| 7513 | 1 | (* Title: HOL/UNITY/TimerArray.thy | 
| 2 | ID: $Id$ | |
| 3 | Author: Lawrence C Paulson, Cambridge University Computer Laboratory | |
| 4 | Copyright 1998 University of Cambridge | |
| 5 | ||
| 6 | A trivial example of reasoning about an array of processes | |
| 7 | *) | |
| 8 | ||
| 9 | Addsimps [Timer_def RS def_prg_Init]; | |
| 10 | program_defs_ref := [Timer_def]; | |
| 11 | ||
| 8251 
9be357df93d4
New treatment of "guarantees" with polymorphic components and bijections.
 paulson parents: 
8041diff
changeset | 12 | Addsimps [count_def, decr_def]; | 
| 7513 | 13 | |
| 14 | (*Demonstrates induction, but not used in the following proof*) | |
| 8251 
9be357df93d4
New treatment of "guarantees" with polymorphic components and bijections.
 paulson parents: 
8041diff
changeset | 15 | Goal "Timer : UNIV leadsTo {s. count s = 0}";
 | 
| 
9be357df93d4
New treatment of "guarantees" with polymorphic components and bijections.
 paulson parents: 
8041diff
changeset | 16 | by (res_inst_tac [("f", "count")] lessThan_induct 1);
 | 
| 7513 | 17 | by (Simp_tac 1); | 
| 8423 | 18 | by (cases_tac "m" 1); | 
| 8251 
9be357df93d4
New treatment of "guarantees" with polymorphic components and bijections.
 paulson parents: 
8041diff
changeset | 19 | by (force_tac (claset() addSIs [subset_imp_leadsTo], simpset()) 1); | 
| 7537 | 20 | by (ensures_tac "decr" 1); | 
| 7513 | 21 | qed "Timer_leadsTo_zero"; | 
| 22 | ||
| 8251 
9be357df93d4
New treatment of "guarantees" with polymorphic components and bijections.
 paulson parents: 
8041diff
changeset | 23 | Goal "Timer : preserves snd"; | 
| 
9be357df93d4
New treatment of "guarantees" with polymorphic components and bijections.
 paulson parents: 
8041diff
changeset | 24 | by (rtac preservesI 1); | 
| 
9be357df93d4
New treatment of "guarantees" with polymorphic components and bijections.
 paulson parents: 
8041diff
changeset | 25 | by (constrains_tac 1); | 
| 
9be357df93d4
New treatment of "guarantees" with polymorphic components and bijections.
 paulson parents: 
8041diff
changeset | 26 | qed "Timer_preserves_snd"; | 
| 
9be357df93d4
New treatment of "guarantees" with polymorphic components and bijections.
 paulson parents: 
8041diff
changeset | 27 | AddIffs [Timer_preserves_snd]; | 
| 
9be357df93d4
New treatment of "guarantees" with polymorphic components and bijections.
 paulson parents: 
8041diff
changeset | 28 | |
| 
9be357df93d4
New treatment of "guarantees" with polymorphic components and bijections.
 paulson parents: 
8041diff
changeset | 29 | |
| 
9be357df93d4
New treatment of "guarantees" with polymorphic components and bijections.
 paulson parents: 
8041diff
changeset | 30 | Goal "finite I \ | 
| 
9be357df93d4
New treatment of "guarantees" with polymorphic components and bijections.
 paulson parents: 
8041diff
changeset | 31 | \     ==> (plam i: I. Timer) : UNIV leadsTo {(s,uu). ALL i:I. s i = 0}";
 | 
| 
9be357df93d4
New treatment of "guarantees" with polymorphic components and bijections.
 paulson parents: 
8041diff
changeset | 32 | by (eres_inst_tac [("A'1", "%i. lift_set i ({0} Times UNIV)")]
 | 
| 7513 | 33 | (finite_stable_completion RS leadsTo_weaken) 1); | 
| 34 | by Auto_tac; | |
| 8251 
9be357df93d4
New treatment of "guarantees" with polymorphic components and bijections.
 paulson parents: 
8041diff
changeset | 35 | (*Safety property, already reduced to the single Timer case*) | 
| 7537 | 36 | by (constrains_tac 2); | 
| 8251 
9be357df93d4
New treatment of "guarantees" with polymorphic components and bijections.
 paulson parents: 
8041diff
changeset | 37 | (*Progress property for the array of Timers*) | 
| 
9be357df93d4
New treatment of "guarantees" with polymorphic components and bijections.
 paulson parents: 
8041diff
changeset | 38 | by (res_inst_tac [("f", "sub i o fst")] lessThan_induct 1);
 | 
| 8423 | 39 | by (cases_tac "m" 1); | 
| 8251 
9be357df93d4
New treatment of "guarantees" with polymorphic components and bijections.
 paulson parents: 
8041diff
changeset | 40 | (*Annoying need to massage the conditions to have the form (... Times UNIV)*) | 
| 7513 | 41 | by (auto_tac (claset() addIs [subset_imp_leadsTo], | 
| 8251 
9be357df93d4
New treatment of "guarantees" with polymorphic components and bijections.
 paulson parents: 
8041diff
changeset | 42 | simpset() addsimps [insert_absorb, lessThan_Suc RS sym, | 
| 
9be357df93d4
New treatment of "guarantees" with polymorphic components and bijections.
 paulson parents: 
8041diff
changeset | 43 | lift_set_Un_distrib RS sym, | 
| 
9be357df93d4
New treatment of "guarantees" with polymorphic components and bijections.
 paulson parents: 
8041diff
changeset | 44 | Times_Un_distrib1 RS sym, | 
| 
9be357df93d4
New treatment of "guarantees" with polymorphic components and bijections.
 paulson parents: 
8041diff
changeset | 45 | Times_Diff_distrib1 RS sym])); | 
| 7513 | 46 | by (rename_tac "n" 1); | 
| 7537 | 47 | by (rtac PLam_leadsTo_Basis 1); | 
| 7513 | 48 | by (auto_tac (claset(), simpset() addsimps [lessThan_Suc RS sym])); | 
| 49 | by (constrains_tac 1); | |
| 8041 | 50 | by (res_inst_tac [("act", "decr")] transientI 1);
 | 
| 7513 | 51 | by (auto_tac (claset(), simpset() addsimps [Timer_def])); | 
| 52 | qed "TimerArray_leadsTo_zero"; |