src/HOLCF/Fix.ML
changeset 3460 5d71eed16fbe
parent 3326 930c9bed5a09
child 3652 4c484f03079c
equal deleted inserted replaced
3459:112cbb8301dc 3460:5d71eed16fbe
   445 
   445 
   446 (* ------------------------------------------------------------------------ *)
   446 (* ------------------------------------------------------------------------ *)
   447 (* access to definitions                                                    *)
   447 (* access to definitions                                                    *)
   448 (* ------------------------------------------------------------------------ *)
   448 (* ------------------------------------------------------------------------ *)
   449 
   449 
   450 qed_goalw "adm_def2" thy [adm_def]
   450 qed_goalw "admI" thy [adm_def]
   451         "adm(P) = (!Y. is_chain(Y) --> (!i.P(Y(i))) --> P(lub(range(Y))))"
   451         "(!!Y. [| is_chain(Y); !i.P(Y(i)) |] ==> P(lub(range(Y)))) ==> adm(P)"
   452  (fn prems =>
   452  (fn prems => [fast_tac (HOL_cs addIs prems) 1]);
   453         [
   453 
   454         (rtac refl 1)
   454 qed_goalw "admD" thy [adm_def]
   455         ]);
   455         "!!P. [| adm(P); is_chain(Y); !i.P(Y(i)) |] ==> P(lub(range(Y)))"
       
   456  (fn prems => [fast_tac HOL_cs 1]);
   456 
   457 
   457 qed_goalw "admw_def2" thy [admw_def]
   458 qed_goalw "admw_def2" thy [admw_def]
   458         "admw(P) = (!F.(!n.P(iterate n F UU)) -->\
   459         "admw(P) = (!F.(!n.P(iterate n F UU)) -->\
   459 \                        P (lub(range(%i.iterate i F UU))))"
   460 \                        P (lub(range(%i.iterate i F UU))))"
   460  (fn prems =>
   461  (fn prems =>
   464 
   465 
   465 (* ------------------------------------------------------------------------ *)
   466 (* ------------------------------------------------------------------------ *)
   466 (* an admissible formula is also weak admissible                            *)
   467 (* an admissible formula is also weak admissible                            *)
   467 (* ------------------------------------------------------------------------ *)
   468 (* ------------------------------------------------------------------------ *)
   468 
   469 
   469 qed_goalw "adm_impl_admw"  thy [admw_def] "adm(P)==>admw(P)"
   470 qed_goalw "adm_impl_admw"  thy [admw_def] "!!P. adm(P)==>admw(P)"
   470  (fn prems =>
   471  (fn prems =>
   471         [
   472         [
   472         (cut_facts_tac prems 1),
   473         (strip_tac 1),
   473         (strip_tac 1),
   474         (etac admD 1),
   474         (rtac (adm_def2 RS iffD1 RS spec RS mp RS mp) 1),
       
   475         (atac 1),
       
   476         (rtac is_chain_iterate 1),
   475         (rtac is_chain_iterate 1),
   477         (atac 1)
   476         (atac 1)
   478         ]);
   477         ]);
   479 
   478 
   480 (* ------------------------------------------------------------------------ *)
   479 (* ------------------------------------------------------------------------ *)
   485 "[| adm(P);P(UU);!!x. P(x) ==> P(F`x)|] ==> P(fix`F)"
   484 "[| adm(P);P(UU);!!x. P(x) ==> P(F`x)|] ==> P(fix`F)"
   486  (fn prems =>
   485  (fn prems =>
   487         [
   486         [
   488         (cut_facts_tac prems 1),
   487         (cut_facts_tac prems 1),
   489         (stac fix_def2 1),
   488         (stac fix_def2 1),
   490         (rtac (adm_def2 RS iffD1 RS spec RS mp RS mp) 1),
   489         (etac admD 1),
   491         (atac 1),
       
   492         (rtac is_chain_iterate 1),
   490         (rtac is_chain_iterate 1),
   493         (rtac allI 1),
   491         (rtac allI 1),
   494         (nat_ind_tac "i" 1),
   492         (nat_ind_tac "i" 1),
   495         (stac iterate_0 1),
   493         (stac iterate_0 1),
   496         (atac 1),
   494         (atac 1),
   567 
   565 
   568 (* ------------------------------------------------------------------------ *)
   566 (* ------------------------------------------------------------------------ *)
   569 (* improved admisibility introduction                                       *)
   567 (* improved admisibility introduction                                       *)
   570 (* ------------------------------------------------------------------------ *)
   568 (* ------------------------------------------------------------------------ *)
   571 
   569 
   572 qed_goalw "admI" thy [adm_def]
   570 qed_goalw "admI2" thy [adm_def]
   573  "(!!Y. [| is_chain Y; !i. P (Y i); !i. ? j. i < j & Y i ~= Y j & Y i << Y j |]\
   571  "(!!Y. [| is_chain Y; !i. P (Y i); !i. ? j. i < j & Y i ~= Y j & Y i << Y j |]\
   574 \ ==> P(lub (range Y))) ==> adm P" 
   572 \ ==> P(lub (range Y))) ==> adm P" 
   575  (fn prems => [
   573  (fn prems => [
   576         strip_tac 1,
   574         strip_tac 1,
   577         etac increasing_chain_adm_lemma 1, atac 1,
   575         etac increasing_chain_adm_lemma 1, atac 1,
   599         (cut_facts_tac prems 1),
   597         (cut_facts_tac prems 1),
   600         (etac (cont2mono RS ch2ch_monofun) 1),
   598         (etac (cont2mono RS ch2ch_monofun) 1),
   601         (atac 1),
   599         (atac 1),
   602         (atac 1)
   600         (atac 1)
   603         ]);
   601         ]);
       
   602 Addsimps [adm_less];
   604 
   603 
   605 qed_goal "adm_conj"  thy  
   604 qed_goal "adm_conj"  thy  
   606         "[| adm P; adm Q |] ==> adm(%x. P x & Q x)"
   605         "!!P. [| adm P; adm Q |] ==> adm(%x. P x & Q x)"
   607  (fn prems =>
   606  (fn prems => [fast_tac (HOL_cs addEs [admD] addIs [admI]) 1]);
   608         [
   607 Addsimps [adm_conj];
   609         (cut_facts_tac prems 1),
       
   610         (rtac (adm_def2 RS iffD2) 1),
       
   611         (strip_tac 1),
       
   612         (rtac conjI 1),
       
   613         (rtac (adm_def2 RS iffD1 RS spec RS mp RS mp) 1),
       
   614         (atac 1),
       
   615         (atac 1),
       
   616         (fast_tac HOL_cs 1),
       
   617         (rtac (adm_def2 RS iffD1 RS spec RS mp RS mp) 1),
       
   618         (atac 1),
       
   619         (atac 1),
       
   620         (fast_tac HOL_cs 1)
       
   621         ]);
       
   622 
       
   623 qed_goal "adm_cong"  thy  
       
   624         "(!x. P x = Q x) ==> adm P = adm Q "
       
   625  (fn prems =>
       
   626         [
       
   627         (cut_facts_tac prems 1),
       
   628         (res_inst_tac [("s","P"),("t","Q")] subst 1),
       
   629         (rtac refl 2),
       
   630         (rtac ext 1),
       
   631         (etac spec 1)
       
   632         ]);
       
   633 
   608 
   634 qed_goalw "adm_not_free"  thy [adm_def] "adm(%x.t)"
   609 qed_goalw "adm_not_free"  thy [adm_def] "adm(%x.t)"
   635  (fn prems =>
   610  (fn prems => [fast_tac HOL_cs 1]);
   636         [
   611 Addsimps [adm_not_free];
   637         (fast_tac HOL_cs 1)
       
   638         ]);
       
   639 
   612 
   640 qed_goalw "adm_not_less"  thy [adm_def]
   613 qed_goalw "adm_not_less"  thy [adm_def]
   641         "cont t ==> adm(%x.~ (t x) << u)"
   614         "!!t. cont t ==> adm(%x.~ (t x) << u)"
   642  (fn prems =>
   615  (fn prems =>
   643         [
   616         [
   644         (cut_facts_tac prems 1),
       
   645         (strip_tac 1),
   617         (strip_tac 1),
   646         (rtac contrapos 1),
   618         (rtac contrapos 1),
   647         (etac spec 1),
   619         (etac spec 1),
   648         (rtac trans_less 1),
   620         (rtac trans_less 1),
   649         (atac 2),
   621         (atac 2),
   650         (etac (cont2mono RS monofun_fun_arg) 1),
   622         (etac (cont2mono RS monofun_fun_arg) 1),
   651         (rtac is_ub_thelub 1),
   623         (rtac is_ub_thelub 1),
   652         (atac 1)
   624         (atac 1)
   653         ]);
   625         ]);
   654 
   626 
   655 qed_goal "adm_all"  thy  
   627 qed_goal "adm_all" thy  
   656         " !y.adm(P y) ==> adm(%x.!y.P y x)"
   628         "!!P. !y.adm(P y) ==> adm(%x.!y.P y x)"
   657  (fn prems =>
   629  (fn prems => [fast_tac (HOL_cs addIs [admI] addEs [admD]) 1]);
   658         [
       
   659         (cut_facts_tac prems 1),
       
   660         (rtac (adm_def2 RS iffD2) 1),
       
   661         (strip_tac 1),
       
   662         (rtac (adm_def2 RS iffD1 RS spec RS mp RS mp) 1),
       
   663         (etac spec 1),
       
   664         (atac 1),
       
   665         (rtac allI 1),
       
   666         (dtac spec 1),
       
   667         (etac spec 1)
       
   668         ]);
       
   669 
   630 
   670 bind_thm ("adm_all2", allI RS adm_all);
   631 bind_thm ("adm_all2", allI RS adm_all);
   671 
   632 
   672 qed_goal "adm_subst"  thy  
   633 qed_goal "adm_subst"  thy  
   673         "[|cont t; adm P|] ==> adm(%x. P (t x))"
   634         "!!P. [|cont t; adm P|] ==> adm(%x. P (t x))"
   674  (fn prems =>
   635  (fn prems =>
   675         [
   636         [
   676         (cut_facts_tac prems 1),
   637         (rtac admI 1),
   677         (rtac (adm_def2 RS iffD2) 1),
       
   678         (strip_tac 1),
       
   679         (stac (cont2contlub RS contlubE RS spec RS mp) 1),
   638         (stac (cont2contlub RS contlubE RS spec RS mp) 1),
   680         (atac 1),
   639         (atac 1),
   681         (atac 1),
   640         (atac 1),
   682         (rtac (adm_def2 RS iffD1 RS spec RS mp RS mp) 1),
   641         (etac admD 1),
   683         (atac 1),
   642         (etac (cont2mono RS ch2ch_monofun) 1),
   684         (rtac (cont2mono RS ch2ch_monofun) 1),
       
   685         (atac 1),
       
   686         (atac 1),
   643         (atac 1),
   687         (atac 1)
   644         (atac 1)
   688         ]);
   645         ]);
   689 
   646 
   690 qed_goal "adm_UU_not_less"  thy "adm(%x.~ UU << t(x))"
   647 qed_goal "adm_UU_not_less"  thy "adm(%x.~ UU << t(x))"
   691  (fn prems =>
   648  (fn prems => [Simp_tac 1]);
   692         [
       
   693         (res_inst_tac [("P2","%x.False")] (adm_cong RS iffD1) 1),
       
   694         (Asm_simp_tac 1),
       
   695         (rtac adm_not_free 1)
       
   696         ]);
       
   697 
   649 
   698 qed_goalw "adm_not_UU"  thy [adm_def] 
   650 qed_goalw "adm_not_UU"  thy [adm_def] 
   699         "cont(t)==> adm(%x.~ (t x) = UU)"
   651         "!!t. cont(t)==> adm(%x.~ (t x) = UU)"
   700  (fn prems =>
   652  (fn prems =>
   701         [
   653         [
   702         (cut_facts_tac prems 1),
       
   703         (strip_tac 1),
   654         (strip_tac 1),
   704         (rtac contrapos 1),
   655         (rtac contrapos 1),
   705         (etac spec 1),
   656         (etac spec 1),
   706         (rtac (chain_UU_I RS spec) 1),
   657         (rtac (chain_UU_I RS spec) 1),
   707         (rtac (cont2mono RS ch2ch_monofun) 1),
   658         (rtac (cont2mono RS ch2ch_monofun) 1),
   712         (atac 1),
   663         (atac 1),
   713         (atac 1)
   664         (atac 1)
   714         ]);
   665         ]);
   715 
   666 
   716 qed_goal "adm_eq"  thy 
   667 qed_goal "adm_eq"  thy 
   717         "[|cont u ; cont v|]==> adm(%x. u x = v x)"
   668         "!!u. [|cont u ; cont v|]==> adm(%x. u x = v x)"
   718  (fn prems =>
   669  (fn prems => [asm_simp_tac (!simpset addsimps [po_eq_conv]) 1]);
   719         [
   670 
   720         (rtac (adm_cong RS iffD1) 1),
       
   721         (rtac allI 1),
       
   722         (rtac iffI 1),
       
   723         (rtac antisym_less 1),
       
   724         (rtac antisym_less_inverse 3),
       
   725         (atac 3),
       
   726         (etac conjunct1 1),
       
   727         (etac conjunct2 1),
       
   728         (rtac adm_conj 1),
       
   729         (rtac adm_less 1),
       
   730         (resolve_tac prems 1),
       
   731         (resolve_tac prems 1),
       
   732         (rtac adm_less 1),
       
   733         (resolve_tac prems 1),
       
   734         (resolve_tac prems 1)
       
   735         ]);
       
   736 
   671 
   737 
   672 
   738 (* ------------------------------------------------------------------------ *)
   673 (* ------------------------------------------------------------------------ *)
   739 (* admissibility for disjunction is hard to prove. It takes 10 Lemmas       *)
   674 (* admissibility for disjunction is hard to prove. It takes 10 Lemmas       *)
   740 (* ------------------------------------------------------------------------ *)
   675 (* ------------------------------------------------------------------------ *)
   750         ]);
   685         ]);
   751 
   686 
   752   val adm_disj_lemma2 = prove_goal thy  
   687   val adm_disj_lemma2 = prove_goal thy  
   753   "!!Q. [| adm(Q); ? X.is_chain(X) & (!n.Q(X(n))) &\
   688   "!!Q. [| adm(Q); ? X.is_chain(X) & (!n.Q(X(n))) &\
   754   \   lub(range(Y))=lub(range(X))|] ==> Q(lub(range(Y)))"
   689   \   lub(range(Y))=lub(range(X))|] ==> Q(lub(range(Y)))"
   755  (fn _ => [fast_tac (!claset addEs [adm_def2 RS iffD1 RS spec RS mp RS mp]
   690  (fn _ => [fast_tac (!claset addEs [admD] addss !simpset) 1]);
   756                              addss !simpset) 1]);
       
   757 
   691 
   758   val adm_disj_lemma3 = prove_goalw thy [is_chain]
   692   val adm_disj_lemma3 = prove_goalw thy [is_chain]
   759   "!!Q. is_chain(Y) ==> is_chain(%m. if m < Suc i then Y(Suc i) else Y m)"
   693   "!!Q. is_chain(Y) ==> is_chain(%m. if m < Suc i then Y(Suc i) else Y m)"
   760  (fn _ =>
   694  (fn _ =>
   761         [
   695         [
   914         (etac adm_disj_lemma10 1),
   848         (etac adm_disj_lemma10 1),
   915         (atac 1)
   849         (atac 1)
   916         ]);
   850         ]);
   917 
   851 
   918 val adm_disj = prove_goal thy  
   852 val adm_disj = prove_goal thy  
   919         "[| adm P; adm Q |] ==> adm(%x.P x | Q x)"
   853         "!!P. [| adm P; adm Q |] ==> adm(%x.P x | Q x)"
   920  (fn prems =>
   854  (fn prems =>
   921         [
   855         [
   922         (cut_facts_tac prems 1),
   856         (rtac admI 1),
   923         (rtac (adm_def2 RS iffD2) 1),
       
   924         (strip_tac 1),
       
   925         (rtac (adm_disj_lemma1 RS disjE) 1),
   857         (rtac (adm_disj_lemma1 RS disjE) 1),
   926         (atac 1),
   858         (atac 1),
   927         (rtac disjI2 1),
   859         (rtac disjI2 1),
   928         (etac adm_disj_lemma12 1),
   860         (etac adm_disj_lemma12 1),
   929         (atac 1),
   861         (atac 1),
   938 
   870 
   939 bind_thm("adm_lemma11",adm_lemma11);
   871 bind_thm("adm_lemma11",adm_lemma11);
   940 bind_thm("adm_disj",adm_disj);
   872 bind_thm("adm_disj",adm_disj);
   941 
   873 
   942 qed_goal "adm_imp"  thy  
   874 qed_goal "adm_imp"  thy  
   943         "[| adm(%x.~(P x)); adm Q |] ==> adm(%x.P x --> Q x)"
   875         "!!P. [| adm(%x.~(P x)); adm Q |] ==> adm(%x.P x --> Q x)"
   944  (fn prems =>
   876  (fn prems =>
   945         [
   877         [
   946         (cut_facts_tac prems 1),
   878         subgoal_tac "(%x.P x --> Q x) = (%x. ~P x | Q x)" 1,
   947         (res_inst_tac [("P2","%x.~(P x)|Q x")] (adm_cong RS iffD1) 1),
   879         (Asm_simp_tac 1),
   948         (fast_tac HOL_cs 1),
   880         (etac adm_disj 1),
   949         (rtac adm_disj 1),
   881         (atac 1),
   950         (atac 1),
   882         (rtac ext 1),
   951         (atac 1)
   883         (fast_tac HOL_cs 1)
   952         ]);
   884         ]);
       
   885 
       
   886 goal Fix.thy "!! P. [| adm (%x. P x --> Q x); adm (%x.Q x --> P x) |] \
       
   887 \           ==> adm (%x. P x = Q x)";
       
   888 by(subgoal_tac "(%x.P x = Q x) = (%x. (P x --> Q x) & (Q x --> P x))" 1);
       
   889 by (Asm_simp_tac 1);
       
   890 by (rtac ext 1);
       
   891 by (fast_tac HOL_cs 1);
       
   892 qed"adm_iff";
       
   893 
   953 
   894 
   954 qed_goal "adm_not_conj"  thy  
   895 qed_goal "adm_not_conj"  thy  
   955 "[| adm (%x. ~ P x); adm (%x. ~ Q x) |] ==> adm (%x. ~ (P x & Q x))"(fn prems=>[
   896 "[| adm (%x. ~ P x); adm (%x. ~ Q x) |] ==> adm (%x. ~ (P x & Q x))"(fn prems=>[
   956         cut_facts_tac prems 1,
   897         cut_facts_tac prems 1,
   957         subgoal_tac 
   898         subgoal_tac 
   961         etac ssubst 1,
   902         etac ssubst 1,
   962         etac adm_disj 1,
   903         etac adm_disj 1,
   963         atac 1]);
   904         atac 1]);
   964 
   905 
   965 val adm_lemmas = [adm_imp,adm_disj,adm_eq,adm_not_UU,adm_UU_not_less,
   906 val adm_lemmas = [adm_imp,adm_disj,adm_eq,adm_not_UU,adm_UU_not_less,
   966         adm_all2,adm_not_less,adm_not_free,adm_not_conj,adm_conj,adm_less];
   907         adm_all2,adm_not_less,adm_not_free,adm_not_conj,adm_conj,adm_less,
       
   908         adm_iff];
   967 
   909 
   968 Addsimps adm_lemmas;
   910 Addsimps adm_lemmas;
   969