src/HOLCF/Pcpo.ML
author wenzelm
Thu Aug 27 20:46:36 1998 +0200 (1998-08-27)
changeset 5400 645f46a24c72
parent 4721 c8a8482a8124
child 9169 85a47aa21f74
permissions -rw-r--r--
made tutorial first;
     1 (*  Title:      HOLCF/pcpo.ML
     2     ID:         $Id$
     3     Author:     Franz Regensburger
     4     Copyright   1993 Technische Universitaet Muenchen
     5 
     6 Lemmas for pcpo.thy
     7 *)
     8  
     9 open Pcpo;
    10 
    11 
    12 (* ------------------------------------------------------------------------ *)
    13 (* derive the old rule minimal                                              *)
    14 (* ------------------------------------------------------------------------ *)
    15 
    16 qed_goalw "UU_least" thy [ UU_def ] "!z. UU << z"
    17 (fn prems => [ 
    18         (rtac (select_eq_Ex RS iffD2) 1),
    19         (rtac least 1)]);
    20 
    21 bind_thm("minimal",UU_least RS spec);
    22 
    23 (* ------------------------------------------------------------------------ *)
    24 (* in cpo's everthing equal to THE lub has lub properties for every chain  *)
    25 (* ------------------------------------------------------------------------ *)
    26 
    27 qed_goal "thelubE"  thy 
    28         "[| chain(S);lub(range(S)) = (l::'a::cpo)|] ==> range(S) <<| l "
    29 (fn prems =>
    30         [
    31         (cut_facts_tac prems 1), 
    32         (hyp_subst_tac 1),
    33         (rtac lubI 1),
    34         (etac cpo 1)
    35         ]);
    36 
    37 (* ------------------------------------------------------------------------ *)
    38 (* Properties of the lub                                                    *)
    39 (* ------------------------------------------------------------------------ *)
    40 
    41 
    42 bind_thm ("is_ub_thelub", cpo RS lubI RS is_ub_lub);
    43 (* chain(?S1) ==> ?S1(?x) << lub(range(?S1))                             *)
    44 
    45 bind_thm ("is_lub_thelub", cpo RS lubI RS is_lub_lub);
    46 (* [| chain(?S5); range(?S5) <| ?x1 |] ==> lub(range(?S5)) << ?x1        *)
    47 
    48 qed_goal "maxinch_is_thelub" thy "chain Y ==> \
    49 \       max_in_chain i Y = (lub(range(Y)) = ((Y i)::'a::cpo))" 
    50 (fn prems => 
    51         [
    52         cut_facts_tac prems 1,
    53         rtac iffI 1,
    54         fast_tac (HOL_cs addSIs [thelubI,lub_finch1]) 1,
    55         rewtac max_in_chain_def,
    56         safe_tac (HOL_cs addSIs [antisym_less]),
    57         fast_tac (HOL_cs addSEs [chain_mono3]) 1,
    58         dtac sym 1,
    59         fast_tac ((HOL_cs addSEs [is_ub_thelub]) addss simpset()) 1
    60         ]);
    61 
    62 
    63 (* ------------------------------------------------------------------------ *)
    64 (* the << relation between two chains is preserved by their lubs            *)
    65 (* ------------------------------------------------------------------------ *)
    66 
    67 qed_goal "lub_mono" thy 
    68         "[|chain(C1::(nat=>'a::cpo));chain(C2); ! k. C1(k) << C2(k)|]\
    69 \           ==> lub(range(C1)) << lub(range(C2))"
    70 (fn prems =>
    71         [
    72         (cut_facts_tac prems 1),
    73         (etac is_lub_thelub 1),
    74         (rtac ub_rangeI 1),
    75         (rtac allI 1),
    76         (rtac trans_less 1),
    77         (etac spec 1),
    78         (etac is_ub_thelub 1)
    79         ]);
    80 
    81 (* ------------------------------------------------------------------------ *)
    82 (* the = relation between two chains is preserved by their lubs            *)
    83 (* ------------------------------------------------------------------------ *)
    84 
    85 qed_goal "lub_equal" thy
    86 "[| chain(C1::(nat=>'a::cpo));chain(C2);!k. C1(k)=C2(k)|]\
    87 \       ==> lub(range(C1))=lub(range(C2))"
    88 (fn prems =>
    89         [
    90         (cut_facts_tac prems 1),
    91         (rtac antisym_less 1),
    92         (rtac lub_mono 1),
    93         (atac 1),
    94         (atac 1),
    95         (strip_tac 1),
    96         (rtac (antisym_less_inverse RS conjunct1) 1),
    97         (etac spec 1),
    98         (rtac lub_mono 1),
    99         (atac 1),
   100         (atac 1),
   101         (strip_tac 1),
   102         (rtac (antisym_less_inverse RS conjunct2) 1),
   103         (etac spec 1)
   104         ]);
   105 
   106 (* ------------------------------------------------------------------------ *)
   107 (* more results about mono and = of lubs of chains                          *)
   108 (* ------------------------------------------------------------------------ *)
   109 
   110 qed_goal "lub_mono2" thy 
   111 "[|? j.!i. j<i --> X(i::nat)=Y(i);chain(X::nat=>'a::cpo);chain(Y)|]\
   112 \ ==> lub(range(X))<<lub(range(Y))"
   113  (fn prems =>
   114         [
   115         (rtac  exE 1),
   116         (resolve_tac prems 1),
   117         (rtac is_lub_thelub 1),
   118         (resolve_tac prems 1),
   119         (rtac ub_rangeI 1),
   120         (strip_tac 1),
   121         (case_tac "x<i" 1),
   122         (res_inst_tac [("s","Y(i)"),("t","X(i)")] subst 1),
   123         (rtac sym 1),
   124         (Fast_tac 1),
   125         (rtac is_ub_thelub 1),
   126         (resolve_tac prems 1),
   127         (res_inst_tac [("y","X(Suc(x))")] trans_less 1),
   128         (rtac (chain_mono RS mp) 1),
   129         (resolve_tac prems 1),
   130         (rtac (not_less_eq RS subst) 1),
   131         (atac 1),
   132         (res_inst_tac [("s","Y(Suc(x))"),("t","X(Suc(x))")] subst 1),
   133         (rtac sym 1),
   134         (Asm_simp_tac 1),
   135         (rtac is_ub_thelub 1),
   136         (resolve_tac prems 1)
   137         ]);
   138 
   139 qed_goal "lub_equal2" thy 
   140 "[|? j.!i. j<i --> X(i)=Y(i);chain(X::nat=>'a::cpo);chain(Y)|]\
   141 \ ==> lub(range(X))=lub(range(Y))"
   142  (fn prems =>
   143         [
   144         (rtac antisym_less 1),
   145         (rtac lub_mono2 1),
   146         (REPEAT (resolve_tac prems 1)),
   147         (cut_facts_tac prems 1),
   148         (rtac lub_mono2 1),
   149         Safe_tac,
   150         (Step_tac 1),
   151         Safe_tac,
   152         (rtac sym 1),
   153         (Fast_tac 1)
   154         ]);
   155 
   156 qed_goal "lub_mono3" thy "[|chain(Y::nat=>'a::cpo);chain(X);\
   157 \! i. ? j. Y(i)<< X(j)|]==> lub(range(Y))<<lub(range(X))"
   158  (fn prems =>
   159         [
   160         (cut_facts_tac prems 1),
   161         (rtac is_lub_thelub 1),
   162         (atac 1),
   163         (rtac ub_rangeI 1),
   164         (strip_tac 1),
   165         (etac allE 1),
   166         (etac exE 1),
   167         (rtac trans_less 1),
   168         (rtac is_ub_thelub 2),
   169         (atac 2),
   170         (atac 1)
   171         ]);
   172 
   173 (* ------------------------------------------------------------------------ *)
   174 (* usefull lemmas about UU                                                  *)
   175 (* ------------------------------------------------------------------------ *)
   176 
   177 val eq_UU_sym = prove_goal thy "(UU = x) = (x = UU)" (fn _ => [
   178         Fast_tac 1]);
   179 
   180 qed_goal "eq_UU_iff" thy "(x=UU)=(x<<UU)"
   181  (fn prems =>
   182         [
   183         (rtac iffI 1),
   184         (hyp_subst_tac 1),
   185         (rtac refl_less 1),
   186         (rtac antisym_less 1),
   187         (atac 1),
   188         (rtac minimal 1)
   189         ]);
   190 
   191 qed_goal "UU_I" thy "x << UU ==> x = UU"
   192  (fn prems =>
   193         [
   194         (stac eq_UU_iff 1),
   195         (resolve_tac prems 1)
   196         ]);
   197 
   198 qed_goal "not_less2not_eq" thy "~(x::'a::po)<<y ==> ~x=y"
   199  (fn prems =>
   200         [
   201         (cut_facts_tac prems 1),
   202         (rtac classical2 1),
   203         (atac 1),
   204         (hyp_subst_tac 1),
   205         (rtac refl_less 1)
   206         ]);
   207 
   208 qed_goal "chain_UU_I" thy
   209         "[|chain(Y);lub(range(Y))=UU|] ==> ! i. Y(i)=UU"
   210  (fn prems =>
   211         [
   212         (cut_facts_tac prems 1),
   213         (rtac allI 1),
   214         (rtac antisym_less 1),
   215         (rtac minimal 2),
   216         (etac subst 1),
   217         (etac is_ub_thelub 1)
   218         ]);
   219 
   220 
   221 qed_goal "chain_UU_I_inverse" thy 
   222         "!i. Y(i::nat)=UU ==> lub(range(Y::(nat=>'a::pcpo)))=UU"
   223  (fn prems =>
   224         [
   225         (cut_facts_tac prems 1),
   226         (rtac lub_chain_maxelem 1),
   227         (rtac exI 1),
   228         (etac spec 1),
   229         (rtac allI 1),
   230         (rtac (antisym_less_inverse RS conjunct1) 1),
   231         (etac spec 1)
   232         ]);
   233 
   234 qed_goal "chain_UU_I_inverse2" thy 
   235         "~lub(range(Y::(nat=>'a::pcpo)))=UU ==> ? i.~ Y(i)=UU"
   236  (fn prems =>
   237         [
   238         (cut_facts_tac prems 1),
   239         (rtac (not_all RS iffD1) 1),
   240         (rtac swap 1),
   241         (rtac chain_UU_I_inverse 2),
   242         (etac notnotD 2),
   243         (atac 1)
   244         ]);
   245 
   246 
   247 qed_goal "notUU_I" thy "[| x<<y; ~x=UU |] ==> ~y=UU"
   248 (fn prems =>
   249         [
   250         (cut_facts_tac prems 1),
   251         (etac contrapos 1),
   252         (rtac UU_I 1),
   253         (hyp_subst_tac 1),
   254         (atac 1)
   255         ]);
   256 
   257 
   258 qed_goal "chain_mono2" thy 
   259 "[|? j.~Y(j)=UU;chain(Y::nat=>'a::pcpo)|]\
   260 \ ==> ? j.!i. j<i-->~Y(i)=UU"
   261  (fn prems =>
   262         [
   263         (cut_facts_tac prems 1),
   264         Safe_tac,
   265         (Step_tac 1),
   266         (strip_tac 1),
   267         (rtac notUU_I 1),
   268         (atac 2),
   269         (etac (chain_mono RS mp) 1),
   270         (atac 1)
   271         ]);
   272 
   273 (**************************************)
   274 (* some properties for chfin and flat *)
   275 (**************************************)
   276 
   277 (* ------------------------------------------------------------------------ *)
   278 (* flat types are chfin                                              *)
   279 (* ------------------------------------------------------------------------ *)
   280 
   281 qed_goalw "flat_imp_chfin" thy [max_in_chain_def]
   282         "!Y::nat=>'a::flat. chain Y-->(? n. max_in_chain n Y)"
   283  (fn _ =>
   284         [
   285         (strip_tac 1),
   286         (case_tac "!i. Y(i)=UU" 1),
   287         (res_inst_tac [("x","0")] exI 1),
   288 	(Asm_simp_tac 1),
   289  	(Asm_full_simp_tac 1),
   290  	(etac exE 1),
   291         (res_inst_tac [("x","i")] exI 1),
   292         (strip_tac 1),
   293         (dres_inst_tac [("x","i"),("y","j")] chain_mono 1),
   294         (etac (le_imp_less_or_eq RS disjE) 1),
   295 	Safe_tac,
   296 	(dtac (ax_flat RS spec RS spec RS mp) 1),
   297 	(Fast_tac 1)
   298         ]);
   299 
   300 (* flat subclass of chfin --> adm_flat not needed *)
   301 
   302 qed_goal "flat_eq" thy "(a::'a::flat) ~= UU ==> a << b = (a = b)" 
   303 (fn prems=>
   304 	[
   305         cut_facts_tac prems 1,
   306         safe_tac (HOL_cs addSIs [refl_less]),
   307 	dtac (ax_flat RS spec RS spec RS mp) 1,
   308 	fast_tac (HOL_cs addSIs [refl_less,ax_flat RS spec RS spec RS mp]) 1
   309 	]);
   310 
   311 qed_goal "chfin2finch" thy 
   312     "chain (Y::nat=>'a::chfin) ==> finite_chain Y"
   313 	(fn prems => 
   314 	[
   315 	cut_facts_tac prems 1,
   316 	fast_tac (HOL_cs addss 
   317 		 (simpset() addsimps [chfin,finite_chain_def])) 1
   318 	]);
   319 
   320 (* ------------------------------------------------------------------------ *)
   321 (* lemmata for improved admissibility introdution rule                      *)
   322 (* ------------------------------------------------------------------------ *)
   323 
   324 qed_goal "infinite_chain_adm_lemma" Porder.thy 
   325 "[|chain Y; !i. P (Y i); \
   326 \  (!!Y. [| chain Y; !i. P (Y i); ~ finite_chain Y |] ==> P (lub (range Y)))\
   327 \ |] ==> P (lub (range Y))"
   328  (fn prems => [
   329         cut_facts_tac prems 1,
   330         case_tac "finite_chain Y" 1,
   331          eresolve_tac prems 2, atac 2, atac 2,
   332         rewtac finite_chain_def,
   333         safe_tac HOL_cs,
   334         etac (lub_finch1 RS thelubI RS ssubst) 1, atac 1, etac spec 1]);
   335 
   336 qed_goal "increasing_chain_adm_lemma" Porder.thy 
   337 "[|chain Y; !i. P (Y i); \
   338 \  (!!Y. [| chain Y; !i. P (Y i); !i. ? j. i < j & Y i ~= Y j & Y i << Y j|]\
   339 \ ==> P (lub (range Y))) |] ==> P (lub (range Y))"
   340  (fn prems => [
   341         cut_facts_tac prems 1,
   342         etac infinite_chain_adm_lemma 1, atac 1, etac thin_rl 1,
   343         rewtac finite_chain_def,
   344         safe_tac HOL_cs,
   345         etac swap 1,
   346         rewtac max_in_chain_def,
   347         resolve_tac prems 1, atac 1, atac 1,
   348         fast_tac (HOL_cs addDs [le_imp_less_or_eq] 
   349                          addEs [chain_mono RS mp]) 1]);