src/HOL/Finite.thy
changeset 5626 f67c34721486
parent 5616 497eeeace3fc
child 5782 7559f116cb10
equal deleted inserted replaced
5625:77e9ab9cd7b1 5626:f67c34721486
    16     insertI "A : Finites ==> insert a A : Finites"
    16     insertI "A : Finites ==> insert a A : Finites"
    17 
    17 
    18 syntax finite :: 'a set => bool
    18 syntax finite :: 'a set => bool
    19 translations  "finite A"  ==  "A : Finites"
    19 translations  "finite A"  ==  "A : Finites"
    20 
    20 
       
    21 (* This definition, although traditional, is ugly to work with
    21 constdefs
    22 constdefs
    22   card :: 'a set => nat
    23   card :: 'a set => nat
    23   "card A == LEAST n. ? f. A = {f i |i. i<n}"
    24   "card A == LEAST n. ? f. A = {f i |i. i<n}"
       
    25 Therefore we have switched to an inductive one:
       
    26 *)
       
    27 
       
    28 consts cardR :: "('a set * nat) set"
       
    29 
       
    30 inductive cardR
       
    31 intrs
       
    32   EmptyI  "({},0) : cardR"
       
    33   InsertI "[| (A,n) : cardR; a ~: A |] ==> (insert a A, Suc n) : cardR"
       
    34 
       
    35 constdefs
       
    36   card :: 'a set => nat
       
    37  "card A == @n. (A,n) : cardR"
    24 
    38 
    25 (*
    39 (*
    26 A "fold" functional for finite sets.  For n non-negative we have
    40 A "fold" functional for finite sets.  For n non-negative we have
    27     fold f e {x1,...,xn} = f x1 (... (f xn e))
    41     fold f e {x1,...,xn} = f x1 (... (f xn e))
    28 where f is at least left-commutative.
    42 where f is at least left-commutative.