src/HOL/UNITY/AllocBase.ML
author wenzelm
Wed Oct 18 23:42:18 2000 +0200 (2000-10-18)
changeset 10265 4e004b548049
parent 9747 043098ba5098
permissions -rw-r--r--
use Multiset from HOL/Library;
     1 (*  Title:      HOL/UNITY/AllocBase.ML
     2     ID:         $Id$
     3     Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
     4     Copyright   1998  University of Cambridge
     5 
     6 Basis declarations for Chandy and Charpentier's Allocator
     7 *)
     8 
     9 Goal "!!f :: nat=>nat. \
    10 \     (ALL i. i<n --> f i <= g i) --> \
    11 \     setsum f (lessThan n) <= setsum g (lessThan n)";
    12 by (induct_tac "n" 1);
    13 by (auto_tac (claset(), simpset() addsimps [lessThan_Suc]));
    14 by (dres_inst_tac [("x","n")] spec 1);
    15 by (arith_tac 1);
    16 qed_spec_mp "setsum_fun_mono";
    17 
    18 Goal "ALL xs. xs <= ys --> tokens xs <= tokens ys";
    19 by (induct_tac "ys" 1);
    20 by (auto_tac (claset(), simpset() addsimps [prefix_Cons]));
    21 qed_spec_mp "tokens_mono_prefix";
    22 
    23 Goalw [mono_def] "mono tokens";
    24 by (blast_tac (claset() addIs [tokens_mono_prefix]) 1);
    25 qed "mono_tokens";
    26 
    27 
    28 (** bag_of **)
    29 
    30 Goal "bag_of (l@l') = bag_of l + bag_of l'";
    31 by (induct_tac "l" 1);
    32  by (asm_simp_tac (simpset() addsimps (thms "plus_ac0")) 2);
    33 by (Simp_tac 1);
    34 qed "bag_of_append";
    35 Addsimps [bag_of_append];
    36 
    37 Goal "mono (bag_of :: 'a list => ('a::order) multiset)";
    38 by (rtac monoI 1); 
    39 by (rewtac prefix_def);
    40 by (etac genPrefix.induct 1);
    41 by Auto_tac;
    42 by (asm_full_simp_tac (simpset() addsimps [thm "union_le_mono"]) 1); 
    43 by (etac order_trans 1); 
    44 by (rtac (thm "union_upper1") 1); 
    45 qed "mono_bag_of";
    46 
    47 (** setsum **)
    48 
    49 Addcongs [setsum_cong];
    50 
    51 Goal "setsum (%i. {#if i<k then f i else g i#}) (A Int lessThan k) = \
    52 \     setsum (%i. {#f i#}) (A Int lessThan k)";
    53 by (rtac setsum_cong 1);
    54 by Auto_tac;  
    55 qed "bag_of_sublist_lemma";
    56 
    57 Goal "bag_of (sublist l A) = \
    58 \     setsum (%i. {# l!i #}) (A Int lessThan (length l))";
    59 by (rev_induct_tac "l" 1);
    60 by (Simp_tac 1);
    61 by (asm_simp_tac
    62     (simpset() addsimps [sublist_append, Int_insert_right, lessThan_Suc, 
    63                     nth_append, bag_of_sublist_lemma] @ thms "plus_ac0") 1);
    64 qed "bag_of_sublist";
    65 
    66 
    67 Goal "bag_of (sublist l (A Un B)) + bag_of (sublist l (A Int B)) = \
    68 \     bag_of (sublist l A) + bag_of (sublist l B)";
    69 by (subgoal_tac "A Int B Int {..length l(} = \
    70 \                (A Int {..length l(}) Int (B Int {..length l(})" 1);
    71 by (asm_simp_tac (simpset() addsimps [bag_of_sublist, Int_Un_distrib2, 
    72                                       setsum_Un_Int]) 1);
    73 by (Blast_tac 1);
    74 qed "bag_of_sublist_Un_Int";
    75 
    76 Goal "A Int B = {} \
    77 \     ==> bag_of (sublist l (A Un B)) = \
    78 \         bag_of (sublist l A) + bag_of (sublist l B)"; 
    79 by (asm_simp_tac (simpset() addsimps [bag_of_sublist_Un_Int RS sym]) 1);
    80 qed "bag_of_sublist_Un_disjoint";
    81 
    82 Goal "[| finite I; ALL i:I. ALL j:I. i~=j --> A i Int A j = {} |] \
    83 \     ==> bag_of (sublist l (UNION I A)) =  \
    84 \         setsum (%i. bag_of (sublist l (A i))) I";  
    85 by (asm_simp_tac (simpset() delsimps UN_simps addsimps (UN_simps RL [sym])
    86 			    addsimps [bag_of_sublist]) 1);
    87 by (stac setsum_UN_disjoint 1);
    88 by Auto_tac;  
    89 qed_spec_mp "bag_of_sublist_UN_disjoint";