src/HOL/ex/Sorting.ML
changeset 3919 c036caebfc75
parent 3842 b55686a7b22c
child 4069 d6d06a03a2e9
equal deleted inserted replaced
3918:94e0fdcb7b91 3919:c036caebfc75
     6 Some general lemmas
     6 Some general lemmas
     7 *)
     7 *)
     8 
     8 
     9 goal Sorting.thy "!x. mset (xs@ys) x = mset xs x + mset ys x";
     9 goal Sorting.thy "!x. mset (xs@ys) x = mset xs x + mset ys x";
    10 by (list.induct_tac "xs" 1);
    10 by (list.induct_tac "xs" 1);
    11 by (ALLGOALS(asm_simp_tac (!simpset setloop (split_tac [expand_if]))));
    11 by (ALLGOALS(asm_simp_tac (!simpset addsplits [expand_if])));
    12 qed "mset_append";
    12 qed "mset_append";
    13 
    13 
    14 goal Sorting.thy "!x. mset [x:xs. ~p(x)] x + mset [x:xs. p(x)] x = \
    14 goal Sorting.thy "!x. mset [x:xs. ~p(x)] x + mset [x:xs. p(x)] x = \
    15 \                     mset xs x";
    15 \                     mset xs x";
    16 by (list.induct_tac "xs" 1);
    16 by (list.induct_tac "xs" 1);
    17 by (ALLGOALS(asm_simp_tac (!simpset setloop (split_tac [expand_if]))));
    17 by (ALLGOALS(asm_simp_tac (!simpset addsplits [expand_if])));
    18 qed "mset_compl_add";
    18 qed "mset_compl_add";
    19 
    19 
    20 Addsimps [mset_append, mset_compl_add];
    20 Addsimps [mset_append, mset_compl_add];
    21 
    21 
    22 goal Sorting.thy "set xs = {x. mset xs x ~= 0}";
    22 goal Sorting.thy "set xs = {x. mset xs x ~= 0}";
    23 by (list.induct_tac "xs" 1);
    23 by (list.induct_tac "xs" 1);
    24 by (ALLGOALS(asm_simp_tac (!simpset setloop (split_tac [expand_if]))));
    24 by (ALLGOALS(asm_simp_tac (!simpset addsplits [expand_if])));
    25 by (Fast_tac 1);
    25 by (Fast_tac 1);
    26 qed "set_via_mset";
    26 qed "set_via_mset";
    27 
    27 
    28 (* Equivalence of two definitions of `sorted' *)
    28 (* Equivalence of two definitions of `sorted' *)
    29 
    29 
    30 val prems = goalw Sorting.thy [transf_def]
    30 val prems = goalw Sorting.thy [transf_def]
    31   "transf(le) ==> sorted1 le xs = sorted le xs";
    31   "transf(le) ==> sorted1 le xs = sorted le xs";
    32 by (list.induct_tac "xs" 1);
    32 by (list.induct_tac "xs" 1);
    33 by (ALLGOALS(asm_simp_tac (!simpset setloop (split_tac [expand_list_case]))));
    33 by (ALLGOALS(asm_simp_tac (!simpset addsplits [expand_list_case])));
    34 by (cut_facts_tac prems 1);
    34 by (cut_facts_tac prems 1);
    35 by (Fast_tac 1);
    35 by (Fast_tac 1);
    36 qed "sorted1_is_sorted";
    36 qed "sorted1_is_sorted";