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