src/ZF/ex/misc.ML
changeset 7 268f93ab3bc4
parent 0 a5a9c433f639
child 16 0b033d50ca1c
equal deleted inserted replaced
6:8ce8c4d13d4d 7:268f93ab3bc4
    60     "g: Y->X ==>   					\
    60     "g: Y->X ==>   					\
    61 \    g``(Y - f`` lfp(X, %W. X - g``(Y - f``W))) = 	\
    61 \    g``(Y - f`` lfp(X, %W. X - g``(Y - f``W))) = 	\
    62 \    X - lfp(X, %W. X - g``(Y - f``W)) ";
    62 \    X - lfp(X, %W. X - g``(Y - f``W)) ";
    63 by (res_inst_tac [("P", "%u. ?v = X-u")] 
    63 by (res_inst_tac [("P", "%u. ?v = X-u")] 
    64      (decomp_bnd_mono RS lfp_Tarski RS ssubst) 1);
    64      (decomp_bnd_mono RS lfp_Tarski RS ssubst) 1);
    65 by (SIMP_TAC (ZF_ss addrews [subset_refl, double_complement, Diff_subset,
    65 by (simp_tac (ZF_ss addsimps [subset_refl, double_complement, Diff_subset,
    66 			     gfun RS fun_is_rel RS image_subset]) 1);
    66 			     gfun RS fun_is_rel RS image_subset]) 1);
    67 val Banach_last_equation = result();
    67 val Banach_last_equation = result();
    68 
    68 
    69 val prems = goal SB_thy
    69 val prems = goal SB_thy
    70     "[| f: X->Y;  g: Y->X |] ==>   \
    70     "[| f: X->Y;  g: Y->X |] ==>   \
    95   R. Boyer et al.,
    95   R. Boyer et al.,
    96   Set Theory in First-Order Logic: Clauses for G\"odel's Axioms,
    96   Set Theory in First-Order Logic: Clauses for G\"odel's Axioms,
    97   JAR 2 (1986), 287-327 
    97   JAR 2 (1986), 287-327 
    98 *)
    98 *)
    99 
    99 
   100 val hom_ss =   (*collecting the relevant lemmas*)
   100 (*collecting the relevant lemmas*)
   101   ZF_ss addrews [comp_func,comp_func_apply,SigmaI,apply_type]
   101 val hom_ss = ZF_ss addsimps [comp_func,comp_func_apply,SigmaI,apply_funtype];
   102    	addcongs (mk_congs Perm.thy ["op O"]);
   102 
   103 
   103 (*The problem below is proving conditions of rewrites such as comp_func_apply;
   104 (*This version uses a super application of SIMP_TAC;  it is SLOW
   104   rewriting does not instantiate Vars; we must prove the conditions
   105   Expressing the goal by --> instead of ==> would make it slower still*)
   105   explicitly.*)
   106 val [hom_eq] = goal Perm.thy
   106 fun hom_tac hyps =
       
   107     resolve_tac (TrueI::refl::iff_refl::hyps) ORELSE' 
       
   108     (cut_facts_tac hyps THEN' fast_tac prop_cs);
       
   109 
       
   110 (*This version uses a super application of simp_tac*)
       
   111 goal Perm.thy
   107     "(ALL A f B g. hom(A,f,B,g) = \
   112     "(ALL A f B g. hom(A,f,B,g) = \
   108 \          {H: A->B. f:A*A->A & g:B*B->B & \
   113 \          {H: A->B. f:A*A->A & g:B*B->B & \
   109 \                    (ALL x:A. ALL y:A. H`(f`<x,y>) = g`<H`x,H`y>)}) ==> \
   114 \                    (ALL x:A. ALL y:A. H`(f`<x,y>) = g`<H`x,H`y>)}) --> \
   110 \    J : hom(A,f,B,g) & K : hom(B,g,C,h) -->  \
   115 \    J : hom(A,f,B,g) & K : hom(B,g,C,h) -->  \
   111 \    (K O J) : hom(A,f,C,h)";
   116 \    (K O J) : hom(A,f,C,h)";
   112 by (SIMP_TAC (hom_ss setauto K(fast_tac prop_cs) addrews [hom_eq]) 1);
   117 by (simp_tac (hom_ss setsolver hom_tac) 1);
       
   118 (*Also works but slower:
       
   119     by (asm_simp_tac (hom_ss setloop (K (safe_tac FOL_cs))) 1); *)
   113 val comp_homs = result();
   120 val comp_homs = result();
   114 
   121 
   115 (*This version uses meta-level rewriting, safe_tac and ASM_SIMP_TAC*)
   122 (*This version uses meta-level rewriting, safe_tac and asm_simp_tac*)
   116 val [hom_def] = goal Perm.thy
   123 val [hom_def] = goal Perm.thy
   117     "(!! A f B g. hom(A,f,B,g) == \
   124     "(!! A f B g. hom(A,f,B,g) == \
   118 \          {H: A->B. f:A*A->A & g:B*B->B & \
   125 \          {H: A->B. f:A*A->A & g:B*B->B & \
   119 \                    (ALL x:A. ALL y:A. H`(f`<x,y>) = g`<H`x,H`y>)}) ==> \
   126 \                    (ALL x:A. ALL y:A. H`(f`<x,y>) = g`<H`x,H`y>)}) ==> \
   120 \    J : hom(A,f,B,g) & K : hom(B,g,C,h) -->  \
   127 \    J : hom(A,f,B,g) & K : hom(B,g,C,h) -->  \
   121 \    (K O J) : hom(A,f,C,h)";
   128 \    (K O J) : hom(A,f,C,h)";
   122 by (rewtac hom_def);
   129 by (rewtac hom_def);
   123 by (safe_tac ZF_cs);
   130 by (safe_tac ZF_cs);
   124 by (ASM_SIMP_TAC hom_ss 1);
   131 by (asm_simp_tac hom_ss 1);
   125 by (ASM_SIMP_TAC hom_ss 1);
   132 by (asm_simp_tac hom_ss 1);
   126 val comp_homs = result();
   133 val comp_homs = result();
   127 
   134 
   128 
   135 
   129 (** A characterization of functions, suggested by Tobias Nipkow **)
   136 (** A characterization of functions, suggested by Tobias Nipkow **)
   130 
   137 
   208 \       (g O f O h): surj(C,C); 	\
   215 \       (g O f O h): surj(C,C); 	\
   209 \       f: A->B;  g: B->C;  h: C->A |] ==> h: bij(C,A)";
   216 \       f: A->B;  g: B->C;  h: C->A |] ==> h: bij(C,A)";
   210 by (REPEAT (resolve_tac (IntI :: pastre_facts prems) 1));
   217 by (REPEAT (resolve_tac (IntI :: pastre_facts prems) 1));
   211 val pastre6 = result();
   218 val pastre6 = result();
   212 
   219 
       
   220 (** Yet another example... **)
       
   221 
       
   222 goalw (merge_theories(Sum.thy,Perm.thy)) [bij_def,inj_def,surj_def]
       
   223     "(lam Z:Pow(A+B). <{x:A. Inl(x):Z}, {y:B. Inr(y):Z}>) \
       
   224 \    : bij(Pow(A+B), Pow(A)*Pow(B))";
       
   225 by (DO_GOAL
       
   226       [rtac IntI,
       
   227        DO_GOAL
       
   228 	 [rtac CollectI,
       
   229 	  fast_tac (ZF_cs addSIs [lam_type]),
       
   230 	  simp_tac ZF_ss,
       
   231 	  fast_tac (eq_cs addSEs [sumE]
       
   232 			  addEs  [equalityD1 RS subsetD RS CollectD2,
       
   233 				  equalityD2 RS subsetD RS CollectD2])],
       
   234        DO_GOAL
       
   235 	 [rtac CollectI,
       
   236 	  fast_tac (ZF_cs addSIs [lam_type]),
       
   237 	  simp_tac ZF_ss,
       
   238 	  K(safe_tac ZF_cs),
       
   239 	  res_inst_tac [("x", "{Inl(u). u: ?U} Un {Inr(v). v: ?V}")] bexI,
       
   240 	  DO_GOAL
       
   241 	    [res_inst_tac [("t", "Pair")] subst_context2,
       
   242 	    fast_tac (sum_cs addSIs [equalityI]),
       
   243 	    fast_tac (sum_cs addSIs [equalityI])],
       
   244 	  DO_GOAL [fast_tac sum_cs]]] 1);
       
   245 val Pow_bij = result();
       
   246 
   213 writeln"Reached end of file.";
   247 writeln"Reached end of file.";