IOA/example/Multiset.thy
changeset 156 fd1be45b64bf
child 168 44ff2275d44f
equal deleted inserted replaced
155:722bf1319be5 156:fd1be45b64bf
       
     1 Multiset = Arith + "Lemmas" +
       
     2 
       
     3 types
       
     4 
       
     5   'a multiset
       
     6 
       
     7 arities
       
     8 
       
     9   multiset :: (term) term
       
    10 
       
    11 consts
       
    12 
       
    13   "{|}"  :: "'a multiset"                        ("{|}")
       
    14   addm   :: "['a multiset, 'a] => 'a multiset"
       
    15   delm   :: "['a multiset, 'a] => 'a multiset"
       
    16   countm :: "['a multiset, 'a => bool] => nat"
       
    17   count  :: "['a multiset, 'a] => nat"
       
    18 
       
    19 rules
       
    20 
       
    21 delm_empty_def
       
    22   "delm({|},x) = {|}" 
       
    23 
       
    24 delm_nonempty_def
       
    25   "delm(addm(M,x),y) == if(x=y,M,addm(delm(M,y),x))"
       
    26 
       
    27 countm_empty_def
       
    28    "countm({|},P) == 0"
       
    29 
       
    30 countm_nonempty_def
       
    31    "countm(addm(M,x),P) == countm(M,P) + if(P(x), Suc(0), 0)"
       
    32 
       
    33 count_def
       
    34    "count(M,x) == countm(M, %y.y = x)"
       
    35 
       
    36 induction
       
    37    "[| P({|}); !!M x. P(M) ==> P(addm(M,x)) |] ==> P(M)"
       
    38 
       
    39 end