src/HOL/ex/InSort.ML
changeset 3919 c036caebfc75
parent 3647 a64c8fbcd98f
child 4089 96fba19bcbe2
equal deleted inserted replaced
3918:94e0fdcb7b91 3919:c036caebfc75
     7 *)
     7 *)
     8 
     8 
     9 goal thy "!y. mset(ins f x xs) y = mset (x#xs) y";
     9 goal thy "!y. mset(ins f x xs) y = mset (x#xs) y";
    10 by (list.induct_tac "xs" 1);
    10 by (list.induct_tac "xs" 1);
    11 by (Asm_simp_tac 1);
    11 by (Asm_simp_tac 1);
    12 by (asm_simp_tac (!simpset setloop (split_tac [expand_if])) 1);
    12 by (asm_simp_tac (!simpset addsplits [expand_if]) 1);
    13 qed "mset_ins";
    13 qed "mset_ins";
    14 Addsimps [mset_ins];
    14 Addsimps [mset_ins];
    15 
    15 
    16 goal thy "!x. mset(insort f xs) x = mset xs x";
    16 goal thy "!x. mset(insort f xs) x = mset xs x";
    17 by (list.induct_tac "xs" 1);
    17 by (list.induct_tac "xs" 1);
    18 by (ALLGOALS Asm_simp_tac);
    18 by (ALLGOALS Asm_simp_tac);
    19 qed "insort_permutes";
    19 qed "insort_permutes";
    20 
    20 
    21 goal thy "set(ins f x xs) = insert x (set xs)";
    21 goal thy "set(ins f x xs) = insert x (set xs)";
    22 by (asm_simp_tac (!simpset addsimps [set_via_mset]
    22 by (asm_simp_tac (!simpset addsimps [set_via_mset]
    23                            setloop (split_tac [expand_if])) 1);
    23                            addsplits [expand_if]) 1);
    24 by (Fast_tac 1);
    24 by (Fast_tac 1);
    25 qed "set_ins";
    25 qed "set_ins";
    26 Addsimps [set_ins];
    26 Addsimps [set_ins];
    27 
    27 
    28 val prems = goalw InSort.thy [total_def,transf_def]
    28 val prems = goalw InSort.thy [total_def,transf_def]
    29   "[| total(f); transf(f) |] ==>  sorted f (ins f x xs) = sorted f xs";
    29   "[| total(f); transf(f) |] ==>  sorted f (ins f x xs) = sorted f xs";
    30 by (list.induct_tac "xs" 1);
    30 by (list.induct_tac "xs" 1);
    31 by (ALLGOALS(asm_simp_tac (!simpset setloop (split_tac [expand_if]))));
    31 by (ALLGOALS(asm_simp_tac (!simpset addsplits [expand_if])));
    32 by (cut_facts_tac prems 1);
    32 by (cut_facts_tac prems 1);
    33 by (Fast_tac 1);
    33 by (Fast_tac 1);
    34 qed "sorted_ins";
    34 qed "sorted_ins";
    35 Addsimps [sorted_ins];
    35 Addsimps [sorted_ins];
    36 
    36