5417
|
1 |
(* Title: HOL/FoldSet
|
|
2 |
ID: $Id$
|
|
3 |
Author: Lawrence C Paulson
|
|
4 |
Copyright 1998 University of Cambridge
|
|
5 |
|
|
6 |
A "fold" functional for finite sets. For n non-negative we have
|
|
7 |
fold f e {x1,...,xn} = f x1 (... (f xn e))
|
|
8 |
where f is an associative-commutative function and e is its identity.
|
|
9 |
*)
|
|
10 |
|
|
11 |
FoldSet = Finite +
|
|
12 |
|
|
13 |
consts foldSet :: "[['a,'a] => 'a, 'a] => ('a set * 'a) set"
|
|
14 |
|
|
15 |
inductive "foldSet f e"
|
|
16 |
intrs
|
|
17 |
emptyI "({}, e) : foldSet f e"
|
|
18 |
|
|
19 |
insertI "[| x ~: A; (A,y) : foldSet f e |]
|
|
20 |
==> (insert x A, f x y) : foldSet f e"
|
|
21 |
|
|
22 |
constdefs fold :: "[['a,'a] => 'a, 'a, 'a set] => 'a"
|
|
23 |
"fold f e A == @x. (A,x) : foldSet f e"
|
|
24 |
|
|
25 |
locale ACI =
|
|
26 |
fixes
|
|
27 |
f :: ['a,'a] => 'a
|
|
28 |
e :: 'a
|
|
29 |
assumes
|
|
30 |
ident "!! x. f x e = x"
|
|
31 |
commute "!! x y. f x y = f y x"
|
|
32 |
assoc "!! x y z. f (f x y) z = f x (f y z)"
|
|
33 |
defines
|
|
34 |
(*nothing*)
|
|
35 |
end
|
|
36 |
|
|
37 |
|