src/HOL/UNITY/Client.thy
author nipkow
Mon, 13 Mar 2000 12:51:10 +0100
changeset 8423 3c19160b6432
parent 8251 9be357df93d4
child 8931 ac2aac644b9f
permissions -rw-r--r--
exhaust_tac -> cases_tac
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5636
dd8f30780fa9 Addition of HOL/UNITY/Client
paulson
parents:
diff changeset
     1
(*  Title:      HOL/UNITY/Client.thy
dd8f30780fa9 Addition of HOL/UNITY/Client
paulson
parents:
diff changeset
     2
    ID:         $Id$
dd8f30780fa9 Addition of HOL/UNITY/Client
paulson
parents:
diff changeset
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
dd8f30780fa9 Addition of HOL/UNITY/Client
paulson
parents:
diff changeset
     4
    Copyright   1998  University of Cambridge
dd8f30780fa9 Addition of HOL/UNITY/Client
paulson
parents:
diff changeset
     5
dd8f30780fa9 Addition of HOL/UNITY/Client
paulson
parents:
diff changeset
     6
Distributed Resource Management System: the Client
dd8f30780fa9 Addition of HOL/UNITY/Client
paulson
parents:
diff changeset
     7
*)
dd8f30780fa9 Addition of HOL/UNITY/Client
paulson
parents:
diff changeset
     8
8251
9be357df93d4 New treatment of "guarantees" with polymorphic components and bijections.
paulson
parents: 8216
diff changeset
     9
Client = Rename + 
5636
dd8f30780fa9 Addition of HOL/UNITY/Client
paulson
parents:
diff changeset
    10
dd8f30780fa9 Addition of HOL/UNITY/Client
paulson
parents:
diff changeset
    11
consts
8216
e4b3192dfefa updated the Client example
paulson
parents: 7399
diff changeset
    12
  NbT :: nat       (*Maximum number of tokens*)
5636
dd8f30780fa9 Addition of HOL/UNITY/Client
paulson
parents:
diff changeset
    13
dd8f30780fa9 Addition of HOL/UNITY/Client
paulson
parents:
diff changeset
    14
types
dd8f30780fa9 Addition of HOL/UNITY/Client
paulson
parents:
diff changeset
    15
  tokbag = nat	   (*tokbags could be multisets...or any ordered type?*)
dd8f30780fa9 Addition of HOL/UNITY/Client
paulson
parents:
diff changeset
    16
dd8f30780fa9 Addition of HOL/UNITY/Client
paulson
parents:
diff changeset
    17
record state =
dd8f30780fa9 Addition of HOL/UNITY/Client
paulson
parents:
diff changeset
    18
  giv :: tokbag list   (*input history: tokens granted*)
dd8f30780fa9 Addition of HOL/UNITY/Client
paulson
parents:
diff changeset
    19
  ask :: tokbag list   (*output history: tokens requested*)
dd8f30780fa9 Addition of HOL/UNITY/Client
paulson
parents:
diff changeset
    20
  rel :: tokbag list   (*output history: tokens released*)
dd8f30780fa9 Addition of HOL/UNITY/Client
paulson
parents:
diff changeset
    21
  tok :: tokbag	       (*current token request*)
dd8f30780fa9 Addition of HOL/UNITY/Client
paulson
parents:
diff changeset
    22
8251
9be357df93d4 New treatment of "guarantees" with polymorphic components and bijections.
paulson
parents: 8216
diff changeset
    23
record 'a state_u =
9be357df93d4 New treatment of "guarantees" with polymorphic components and bijections.
paulson
parents: 8216
diff changeset
    24
  state +  
9be357df93d4 New treatment of "guarantees" with polymorphic components and bijections.
paulson
parents: 8216
diff changeset
    25
  extra :: 'a          (*new variables*)
9be357df93d4 New treatment of "guarantees" with polymorphic components and bijections.
paulson
parents: 8216
diff changeset
    26
5636
dd8f30780fa9 Addition of HOL/UNITY/Client
paulson
parents:
diff changeset
    27
dd8f30780fa9 Addition of HOL/UNITY/Client
paulson
parents:
diff changeset
    28
(*Array indexing is translated to list indexing as A[n] == A!(n-1). *)
dd8f30780fa9 Addition of HOL/UNITY/Client
paulson
parents:
diff changeset
    29
dd8f30780fa9 Addition of HOL/UNITY/Client
paulson
parents:
diff changeset
    30
constdefs
dd8f30780fa9 Addition of HOL/UNITY/Client
paulson
parents:
diff changeset
    31
  
dd8f30780fa9 Addition of HOL/UNITY/Client
paulson
parents:
diff changeset
    32
  (** Release some tokens **)
dd8f30780fa9 Addition of HOL/UNITY/Client
paulson
parents:
diff changeset
    33
  
8251
9be357df93d4 New treatment of "guarantees" with polymorphic components and bijections.
paulson
parents: 8216
diff changeset
    34
  rel_act :: "('a state_u * 'a state_u) set"
5636
dd8f30780fa9 Addition of HOL/UNITY/Client
paulson
parents:
diff changeset
    35
    "rel_act == {(s,s').
5804
8e0a4c4fd67b Revising the Client proof as suggested by Michel Charpentier. New lemmas
paulson
parents: 5648
diff changeset
    36
		  EX nrel. nrel = size (rel s) &
5636
dd8f30780fa9 Addition of HOL/UNITY/Client
paulson
parents:
diff changeset
    37
		           s' = s (| rel := rel s @ [giv s!nrel] |) &
5804
8e0a4c4fd67b Revising the Client proof as suggested by Michel Charpentier. New lemmas
paulson
parents: 5648
diff changeset
    38
		           nrel < size (giv s) &
5636
dd8f30780fa9 Addition of HOL/UNITY/Client
paulson
parents:
diff changeset
    39
		           ask s!nrel <= giv s!nrel}"
dd8f30780fa9 Addition of HOL/UNITY/Client
paulson
parents:
diff changeset
    40
dd8f30780fa9 Addition of HOL/UNITY/Client
paulson
parents:
diff changeset
    41
  (** Choose a new token requirement **)
dd8f30780fa9 Addition of HOL/UNITY/Client
paulson
parents:
diff changeset
    42
dd8f30780fa9 Addition of HOL/UNITY/Client
paulson
parents:
diff changeset
    43
  (** Including s'=s suppresses fairness, allowing the non-trivial part
dd8f30780fa9 Addition of HOL/UNITY/Client
paulson
parents:
diff changeset
    44
      of the action to be ignored **)
dd8f30780fa9 Addition of HOL/UNITY/Client
paulson
parents:
diff changeset
    45
8251
9be357df93d4 New treatment of "guarantees" with polymorphic components and bijections.
paulson
parents: 8216
diff changeset
    46
  tok_act :: "('a state_u * 'a state_u) set"
9be357df93d4 New treatment of "guarantees" with polymorphic components and bijections.
paulson
parents: 8216
diff changeset
    47
     "tok_act == {(s,s'). s'=s | s' = s (|tok := Suc (tok s mod NbT) |)}"
8216
e4b3192dfefa updated the Client example
paulson
parents: 7399
diff changeset
    48
  
8251
9be357df93d4 New treatment of "guarantees" with polymorphic components and bijections.
paulson
parents: 8216
diff changeset
    49
  ask_act :: "('a state_u * 'a state_u) set"
5636
dd8f30780fa9 Addition of HOL/UNITY/Client
paulson
parents:
diff changeset
    50
    "ask_act == {(s,s'). s'=s |
8216
e4b3192dfefa updated the Client example
paulson
parents: 7399
diff changeset
    51
		         (s' = s (|ask := ask s @ [tok s]|))}"
5636
dd8f30780fa9 Addition of HOL/UNITY/Client
paulson
parents:
diff changeset
    52
8251
9be357df93d4 New treatment of "guarantees" with polymorphic components and bijections.
paulson
parents: 8216
diff changeset
    53
  Client :: 'a state_u program
8216
e4b3192dfefa updated the Client example
paulson
parents: 7399
diff changeset
    54
    "Client == mk_program ({s. tok s : atMost NbT &
e4b3192dfefa updated the Client example
paulson
parents: 7399
diff changeset
    55
		               giv s = [] & ask s = [] & rel s = []},
e4b3192dfefa updated the Client example
paulson
parents: 7399
diff changeset
    56
			   {rel_act, tok_act, ask_act})"
5636
dd8f30780fa9 Addition of HOL/UNITY/Client
paulson
parents:
diff changeset
    57
8251
9be357df93d4 New treatment of "guarantees" with polymorphic components and bijections.
paulson
parents: 8216
diff changeset
    58
  (*Maybe want a special theory section to declare such maps*)
9be357df93d4 New treatment of "guarantees" with polymorphic components and bijections.
paulson
parents: 8216
diff changeset
    59
  non_extra :: 'a state_u => state
9be357df93d4 New treatment of "guarantees" with polymorphic components and bijections.
paulson
parents: 8216
diff changeset
    60
    "non_extra s == (|giv = giv s, ask = ask s, rel = rel s, tok = tok s|)"
9be357df93d4 New treatment of "guarantees" with polymorphic components and bijections.
paulson
parents: 8216
diff changeset
    61
9be357df93d4 New treatment of "guarantees" with polymorphic components and bijections.
paulson
parents: 8216
diff changeset
    62
  (*Renaming map to put a Client into the standard form*)
9be357df93d4 New treatment of "guarantees" with polymorphic components and bijections.
paulson
parents: 8216
diff changeset
    63
  client_map :: "'a state_u => state*'a"
9be357df93d4 New treatment of "guarantees" with polymorphic components and bijections.
paulson
parents: 8216
diff changeset
    64
    "client_map == funPair non_extra extra"
9be357df93d4 New treatment of "guarantees" with polymorphic components and bijections.
paulson
parents: 8216
diff changeset
    65
9be357df93d4 New treatment of "guarantees" with polymorphic components and bijections.
paulson
parents: 8216
diff changeset
    66
rules
9be357df93d4 New treatment of "guarantees" with polymorphic components and bijections.
paulson
parents: 8216
diff changeset
    67
  NbT_pos  "0 < NbT"
5636
dd8f30780fa9 Addition of HOL/UNITY/Client
paulson
parents:
diff changeset
    68
dd8f30780fa9 Addition of HOL/UNITY/Client
paulson
parents:
diff changeset
    69
end