src/HOL/Finite.ML
author clasohm
Wed Oct 04 13:10:03 1995 +0100 (1995-10-04)
changeset 1264 3eb91524b938
parent 923 ff1574a81019
child 1465 5d7a7e439cec
permissions -rw-r--r--
added local simpsets; removed IOA from 'make test'
clasohm@923
     1
(*  Title: 	HOL/Finite.thy
clasohm@923
     2
    ID:         $Id$
clasohm@923
     3
    Author: 	Lawrence C Paulson, Cambridge University Computer Laboratory
clasohm@923
     4
    Copyright   1994  University of Cambridge
clasohm@923
     5
clasohm@923
     6
Finite powerset operator
clasohm@923
     7
*)
clasohm@923
     8
clasohm@923
     9
open Finite;
clasohm@923
    10
clasohm@923
    11
goalw Finite.thy Fin.defs "!!A B. A<=B ==> Fin(A) <= Fin(B)";
clasohm@923
    12
br lfp_mono 1;
clasohm@923
    13
by (REPEAT (ares_tac basic_monos 1));
clasohm@923
    14
qed "Fin_mono";
clasohm@923
    15
clasohm@923
    16
goalw Finite.thy Fin.defs "Fin(A) <= Pow(A)";
clasohm@923
    17
by (fast_tac (set_cs addSIs [lfp_lowerbound]) 1);
clasohm@923
    18
qed "Fin_subset_Pow";
clasohm@923
    19
clasohm@923
    20
(* A : Fin(B) ==> A <= B *)
clasohm@923
    21
val FinD = Fin_subset_Pow RS subsetD RS PowD;
clasohm@923
    22
clasohm@923
    23
(*Discharging ~ x:y entails extra work*)
clasohm@923
    24
val major::prems = goal Finite.thy 
clasohm@923
    25
    "[| F:Fin(A);  P({}); \
clasohm@923
    26
\	!!F x. [| x:A;  F:Fin(A);  x~:F;  P(F) |] ==> P(insert x F) \
clasohm@923
    27
\    |] ==> P(F)";
clasohm@923
    28
by (rtac (major RS Fin.induct) 1);
clasohm@923
    29
by (excluded_middle_tac "a:b" 2);
clasohm@923
    30
by (etac (insert_absorb RS ssubst) 3 THEN assume_tac 3);   (*backtracking!*)
clasohm@923
    31
by (REPEAT (ares_tac prems 1));
clasohm@923
    32
qed "Fin_induct";
clasohm@923
    33
clasohm@923
    34
(** Simplification for Fin **)
clasohm@923
    35
clasohm@1264
    36
Addsimps Fin.intrs;
clasohm@923
    37
clasohm@923
    38
(*The union of two finite sets is finite*)
clasohm@923
    39
val major::prems = goal Finite.thy
clasohm@923
    40
    "[| F: Fin(A);  G: Fin(A) |] ==> F Un G : Fin(A)";
clasohm@923
    41
by (rtac (major RS Fin_induct) 1);
clasohm@1264
    42
by (ALLGOALS (asm_simp_tac (!simpset addsimps (prems @ [Un_insert_left]))));
clasohm@923
    43
qed "Fin_UnI";
clasohm@923
    44
clasohm@923
    45
(*Every subset of a finite set is finite*)
clasohm@923
    46
val [subs,fin] = goal Finite.thy "[| A<=B;  B: Fin(M) |] ==> A: Fin(M)";
clasohm@923
    47
by (EVERY1 [subgoal_tac "ALL C. C<=B --> C: Fin(M)",
clasohm@923
    48
	    rtac mp, etac spec,
clasohm@923
    49
	    rtac subs]);
clasohm@923
    50
by (rtac (fin RS Fin_induct) 1);
clasohm@1264
    51
by (simp_tac (!simpset addsimps [subset_Un_eq]) 1);
clasohm@923
    52
by (safe_tac (set_cs addSDs [subset_insert_iff RS iffD1]));
clasohm@923
    53
by (eres_inst_tac [("t","C")] (insert_Diff RS subst) 2);
clasohm@1264
    54
by (ALLGOALS Asm_simp_tac);
clasohm@923
    55
qed "Fin_subset";
clasohm@923
    56
clasohm@923
    57
(*The image of a finite set is finite*)
clasohm@923
    58
val major::_ = goal Finite.thy
clasohm@923
    59
    "F: Fin(A) ==> h``F : Fin(h``A)";
clasohm@923
    60
by (rtac (major RS Fin_induct) 1);
clasohm@1264
    61
by (Simp_tac 1);
clasohm@1264
    62
by (asm_simp_tac
clasohm@1264
    63
    (!simpset addsimps [image_eqI RS Fin.insertI, image_insert]) 1);
clasohm@923
    64
qed "Fin_imageI";
clasohm@923
    65
clasohm@923
    66
val major::prems = goal Finite.thy 
clasohm@923
    67
    "[| c: Fin(A);  b: Fin(A);  				\
clasohm@923
    68
\       P(b);       						\
clasohm@923
    69
\       !!(x::'a) y. [| x:A; y: Fin(A);  x:y;  P(y) |] ==> P(y-{x}) \
clasohm@923
    70
\    |] ==> c<=b --> P(b-c)";
clasohm@923
    71
by (rtac (major RS Fin_induct) 1);
clasohm@923
    72
by (rtac (Diff_insert RS ssubst) 2);
clasohm@923
    73
by (ALLGOALS (asm_simp_tac
clasohm@1264
    74
                (!simpset addsimps (prems@[Diff_subset RS Fin_subset]))));
clasohm@923
    75
qed "Fin_empty_induct_lemma";
clasohm@923
    76
clasohm@923
    77
val prems = goal Finite.thy 
clasohm@923
    78
    "[| b: Fin(A);  						\
clasohm@923
    79
\       P(b);        						\
clasohm@923
    80
\       !!x y. [| x:A; y: Fin(A);  x:y;  P(y) |] ==> P(y-{x}) \
clasohm@923
    81
\    |] ==> P({})";
clasohm@923
    82
by (rtac (Diff_cancel RS subst) 1);
clasohm@923
    83
by (rtac (Fin_empty_induct_lemma RS mp) 1);
clasohm@923
    84
by (REPEAT (ares_tac (subset_refl::prems) 1));
clasohm@923
    85
qed "Fin_empty_induct";