src/LCF/fix.ML
author oheimb
Fri Jun 02 20:38:28 2000 +0200 (2000-06-02)
changeset 9028 8a1ec8f05f14
parent 3837 d7f033c74b38
child 17248 81bf91654e73
permissions -rw-r--r--
added HOL/Prolog
clasohm@1461
     1
(*  Title:      LCF/fix
lcp@660
     2
    ID:         $Id$
clasohm@1461
     3
    Author:     Tobias Nipkow
lcp@660
     4
    Copyright   1992  University of Cambridge
lcp@660
     5
lcp@660
     6
Fixedpoint theory
lcp@660
     7
*)
lcp@660
     8
clasohm@0
     9
signature FIX =
clasohm@0
    10
sig
clasohm@0
    11
  val adm_eq: thm
clasohm@0
    12
  val adm_not_eq_tr: thm
clasohm@0
    13
  val adm_not_not: thm
clasohm@0
    14
  val not_eq_TT: thm
clasohm@0
    15
  val not_eq_FF: thm
clasohm@0
    16
  val not_eq_UU: thm
clasohm@0
    17
  val induct2: thm
clasohm@0
    18
  val induct_tac: string -> int -> tactic
clasohm@0
    19
  val induct2_tac: string*string -> int -> tactic
clasohm@0
    20
end;
clasohm@0
    21
clasohm@0
    22
structure Fix:FIX =
clasohm@0
    23
struct
clasohm@0
    24
wenzelm@3837
    25
val adm_eq = prove_goal LCF.thy "adm(%x. t(x)=(u(x)::'a::cpo))"
clasohm@1461
    26
        (fn _ => [rewtac eq_def,
clasohm@1461
    27
                  REPEAT(rstac[adm_conj,adm_less]1)]);
clasohm@0
    28
clasohm@0
    29
val adm_not_not = prove_goal LCF.thy "adm(P) ==> adm(%x.~~P(x))"
clasohm@1461
    30
        (fn prems => [simp_tac (LCF_ss addsimps prems) 1]);
clasohm@0
    31
clasohm@0
    32
clasohm@0
    33
val tac = rtac tr_induct 1 THEN REPEAT(simp_tac LCF_ss 1);
clasohm@0
    34
clasohm@0
    35
val not_eq_TT = prove_goal LCF.thy "ALL p. ~p=TT <-> (p=FF | p=UU)"
lcp@660
    36
    (fn _ => [tac]) RS spec;
clasohm@0
    37
clasohm@0
    38
val not_eq_FF = prove_goal LCF.thy "ALL p. ~p=FF <-> (p=TT | p=UU)"
lcp@660
    39
    (fn _ => [tac]) RS spec;
clasohm@0
    40
clasohm@0
    41
val not_eq_UU = prove_goal LCF.thy "ALL p. ~p=UU <-> (p=TT | p=FF)"
lcp@660
    42
    (fn _ => [tac]) RS spec;
clasohm@0
    43
wenzelm@3837
    44
val adm_not_eq_tr = prove_goal LCF.thy "ALL p::tr. adm(%x. ~t(x)=p)"
lcp@660
    45
    (fn _ => [rtac tr_induct 1,
lcp@660
    46
    REPEAT(simp_tac (LCF_ss addsimps [not_eq_TT,not_eq_FF,not_eq_UU]) 1 THEN
clasohm@1461
    47
           REPEAT(rstac [adm_disj,adm_eq] 1))]) RS spec;
clasohm@0
    48
clasohm@0
    49
val adm_lemmas = [adm_not_free,adm_eq,adm_less,adm_not_less,adm_not_eq_tr,
clasohm@1461
    50
                  adm_conj,adm_disj,adm_imp,adm_all];
clasohm@0
    51
clasohm@0
    52
fun induct_tac v i = res_inst_tac[("f",v)] induct i THEN
clasohm@1461
    53
                     REPEAT(rstac adm_lemmas i);
clasohm@0
    54
clasohm@0
    55
clasohm@0
    56
val least_FIX = prove_goal LCF.thy "f(p) = p ==> FIX(f) << p"
clasohm@1461
    57
        (fn [prem] => [induct_tac "f" 1, rtac minimal 1, strip_tac 1,
clasohm@1461
    58
                        stac (prem RS sym) 1, etac less_ap_term 1]);
clasohm@0
    59
clasohm@0
    60
val lfp_is_FIX = prove_goal LCF.thy
clasohm@1461
    61
        "[| f(p) = p; ALL q. f(q)=q --> p << q |] ==> p = FIX(f)"
clasohm@1461
    62
        (fn [prem1,prem2] => [rtac less_anti_sym 1,
clasohm@1461
    63
                              rtac (prem2 RS spec RS mp) 1, rtac FIX_eq 1,
clasohm@1461
    64
                              rtac least_FIX 1, rtac prem1 1]);
clasohm@0
    65
clasohm@0
    66
val ffix = read_instantiate [("f","f::?'a=>?'a")] FIX_eq;
clasohm@0
    67
val gfix = read_instantiate [("f","g::?'a=>?'a")] FIX_eq;
clasohm@0
    68
val ss = LCF_ss addsimps [ffix,gfix];
clasohm@0
    69
clasohm@0
    70
val FIX_pair = prove_goal LCF.thy
clasohm@0
    71
  "<FIX(f),FIX(g)> = FIX(%p.<f(FST(p)),g(SND(p))>)"
clasohm@0
    72
  (fn _ => [rtac lfp_is_FIX 1, simp_tac ss 1,
clasohm@1461
    73
          strip_tac 1, simp_tac (LCF_ss addsimps [PROD_less]) 1,
clasohm@1461
    74
          rtac conjI 1, rtac least_FIX 1, etac subst 1, rtac (FST RS sym) 1,
clasohm@1461
    75
          rtac least_FIX 1, etac subst 1, rtac (SND RS sym) 1]);
clasohm@0
    76
clasohm@0
    77
val FIX_pair_conj = rewrite_rule (map mk_meta_eq [PROD_eq,FST,SND]) FIX_pair;
clasohm@0
    78
clasohm@0
    79
val FIX1 = FIX_pair_conj RS conjunct1;
clasohm@0
    80
val FIX2 = FIX_pair_conj RS conjunct2;
clasohm@0
    81
clasohm@0
    82
val induct2 = prove_goal LCF.thy
wenzelm@3837
    83
         "[| adm(%p. P(FST(p),SND(p))); P(UU::'a,UU::'b);\
clasohm@1461
    84
\            ALL x y. P(x,y) --> P(f(x),g(y)) |] ==> P(FIX(f),FIX(g))"
clasohm@1461
    85
        (fn prems => [EVERY1
clasohm@1461
    86
        [res_inst_tac [("f","f"),("g","g")] (standard(FIX1 RS ssubst)),
clasohm@1461
    87
         res_inst_tac [("f","f"),("g","g")] (standard(FIX2 RS ssubst)),
clasohm@1461
    88
         res_inst_tac [("f","%x. <f(FST(x)),g(SND(x))>")] induct,
clasohm@1461
    89
         rstac prems, simp_tac ss, rstac prems,
clasohm@1461
    90
         simp_tac (LCF_ss addsimps [expand_all_PROD]), rstac prems]]);
clasohm@0
    91
clasohm@0
    92
fun induct2_tac (f,g) i = res_inst_tac[("f",f),("g",g)] induct2 i THEN
clasohm@1461
    93
                     REPEAT(rstac adm_lemmas i);
clasohm@0
    94
clasohm@0
    95
end;
clasohm@0
    96
clasohm@0
    97
open Fix;