|
8928
|
1 |
(* Title: HOL/UNITY/AllocBase
|
|
|
2 |
ID: $Id$
|
|
|
3 |
Author: Lawrence C Paulson, Cambridge University Computer Laboratory
|
|
|
4 |
Copyright 1998 University of Cambridge
|
|
|
5 |
|
|
|
6 |
Common declarations for Chandy and Charpentier's Allocator
|
|
8989
|
7 |
|
|
|
8 |
with_path "../Induct" time_use_thy "AllocBase";
|
|
8928
|
9 |
*)
|
|
|
10 |
|
|
8989
|
11 |
AllocBase = Rename + Follows + MultisetOrder +
|
|
8928
|
12 |
|
|
|
13 |
consts
|
|
|
14 |
NbT :: nat (*Number of tokens in system*)
|
|
|
15 |
Nclients :: nat (*Number of clients*)
|
|
|
16 |
|
|
|
17 |
rules
|
|
|
18 |
NbT_pos "0 < NbT"
|
|
|
19 |
|
|
|
20 |
(*This function merely sums the elements of a list*)
|
|
|
21 |
consts tokens :: nat list => nat
|
|
|
22 |
primrec
|
|
|
23 |
"tokens [] = 0"
|
|
|
24 |
"tokens (x#xs) = x + tokens xs"
|
|
|
25 |
|
|
8974
|
26 |
(*Or could be setsum...(lessThan n)*)
|
|
|
27 |
consts sum_below :: "[nat=>'a, nat] => ('a::plus_ac0)"
|
|
|
28 |
primrec
|
|
|
29 |
sum_below_0 "sum_below f 0 = 0"
|
|
|
30 |
sum_below_Suc "sum_below f (Suc n) = f(n) + sum_below f n"
|
|
|
31 |
|
|
8989
|
32 |
constdefs sublist :: "['a list, nat set] => 'a list"
|
|
|
33 |
"sublist l A == map fst (filter (%p. snd p : A) (zip l [0..size l(]))"
|
|
|
34 |
|
|
8928
|
35 |
end
|