src/HOL/ex/Set_Comprehension_Pointfree_Tests.thy
author bulwahn
Sun, 14 Oct 2012 19:16:33 +0200
changeset 50866 4d33963962fa
parent 50781 65318db3087b
child 50868 875ed58b3b65
permissions -rw-r--r--
adding further test cases to check new functionality of the simproc; strengthened test cases to check the success of the simproc more faithfully
     1 (*  Title:      HOL/ex/Set_Comprehension_Pointfree_Tests.thy
     2     Author:     Lukas Bulwahn, Rafal Kolanski
     3     Copyright   2012 TU Muenchen
     4 *)
     5 
     6 header {* Tests for the set comprehension to pointfree simproc *}
     7 
     8 theory Set_Comprehension_Pointfree_Tests
     9 imports Main
    10 begin
    11 
    12 lemma
    13   "finite (UNIV::'a set) ==> finite {p. EX x::'a. p = (x, x)}"
    14   by simp
    15 
    16 lemma
    17   "finite A ==> finite B ==> finite {f a b| a b. a : A \<and> b : B}"
    18   by simp
    19   
    20 lemma
    21   "finite B ==> finite A' ==> finite {f a b| a b. a : A \<and> a : A' \<and> b : B}"
    22   by simp
    23 
    24 lemma
    25   "finite A ==> finite B ==> finite {f a b| a b. a : A \<and> b : B \<and> b : B'}"
    26   by simp
    27 
    28 lemma
    29   "finite A ==> finite B ==> finite C ==> finite {f a b c| a b c. a : A \<and> b : B \<and> c : C}"
    30   by simp
    31 
    32 lemma
    33   "finite A ==> finite B ==> finite C ==> finite D ==>
    34      finite {f a b c d| a b c d. a : A \<and> b : B \<and> c : C \<and> d : D}"
    35   by simp
    36 
    37 lemma
    38   "finite A ==> finite B ==> finite C ==> finite D ==> finite E ==>
    39     finite {f a b c d e | a b c d e. a : A \<and> b : B \<and> c : C \<and> d : D \<and> e : E}"
    40   by simp
    41 
    42 lemma (* check arbitrary ordering *)
    43   "finite A ==> finite B ==> finite C ==> finite D ==> finite E \<Longrightarrow>
    44     finite {f a d c b e | e b c d a. b : B \<and> a : A \<and> e : E' \<and> c : C \<and> d : D \<and> e : E \<and> b : B'}"
    45   by simp
    46 
    47 lemma
    48   "\<lbrakk> finite A ; finite B ; finite C ; finite D \<rbrakk>
    49   \<Longrightarrow> finite ({f a b c d| a b c d. a : A \<and> b : B \<and> c : C \<and> d : D})"
    50   by simp
    51 
    52 lemma
    53   "finite ((\<lambda>(a,b,c,d). f a b c d) ` (A \<times> B \<times> C \<times> D))
    54   \<Longrightarrow> finite ({f a b c d| a b c d. a : A \<and> b : B \<and> c : C \<and> d : D})"
    55   by simp
    56 
    57 lemma
    58   "finite S ==> finite {s'. EX s:S. s' = f a e s}"
    59   by simp
    60 
    61 lemma
    62   "finite A ==> finite B ==> finite {f a b| a b. a : A \<and> b : B \<and> a \<notin> Z}"
    63   by simp
    64 
    65 lemma
    66   "finite A ==> finite B ==> finite R ==> finite {f a b x y| a b x y. a : A \<and> b : B \<and> (x,y) \<in> R}"
    67 by simp
    68 
    69 lemma
    70   "finite A ==> finite B ==> finite R ==> finite {f a b x y| a b x y. a : A \<and> (x,y) \<in> R \<and> b : B}"
    71 by simp
    72 
    73 lemma
    74   "finite A ==> finite B ==> finite R ==> finite {f a (x, b) y| y b x a. a : A \<and> (x,y) \<in> R \<and> b : B}"
    75 by simp
    76 
    77 lemma
    78   "finite A ==> finite AA ==> finite B ==> finite {f a b| a b. (a : A \<or> a : AA) \<and> b : B \<and> a \<notin> Z}"
    79 by simp
    80 
    81 lemma
    82   "finite A1 ==> finite A2 ==> finite A3 ==> finite A4 ==> finite A5 ==> finite B ==>
    83      finite {f a b c | a b c. ((a : A1 \<and> a : A2) \<or> (a : A3 \<and> (a : A4 \<or> a : A5))) \<and> b : B \<and> a \<notin> Z}"
    84 apply simp
    85 oops
    86 
    87 schematic_lemma (* check interaction with schematics *)
    88   "finite {x :: ?'A \<Rightarrow> ?'B \<Rightarrow> bool. \<exists>a b. x = Pair_Rep a b}
    89    = finite ((\<lambda>(b :: ?'B, a:: ?'A). Pair_Rep a b) ` (UNIV \<times> UNIV))"
    90   by simp
    91 
    92 lemma
    93   assumes "finite S" shows "finite {(a,b,c,d). ([a, b], [c, d]) : S}"
    94 proof -
    95   have eq: "{(a,b,c,d). ([a, b], [c, d]) : S} = ((%(a, b, c, d). ([a, b], [c, d])) -` S)"
    96    unfolding vimage_def by (auto split: prod.split)  (* to be proved with the simproc *)
    97   from `finite S` show ?thesis
    98     unfolding eq by (auto intro!: finite_vimageI simp add: inj_on_def)
    99     (* to be automated with further rules and automation *)
   100 qed
   101 
   102 end