src/HOL/Lfp.ML
author nipkow
Tue, 09 May 1995 22:10:08 +0200
changeset 1114 c8dfb56a7e95
parent 923 ff1574a81019
child 1125 13a3df2adbe5
permissions -rw-r--r--
Prod is now a parent of Lfp. Added thm induct2 to Lfp. Changed the way patterns in abstractions are pretty printed. It has become simpler now but fails if split has more than one argument because then the ast-translation does not match.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     1
(*  Title: 	HOL/lfp.ML
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     2
    ID:         $Id$
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     3
    Author: 	Lawrence C Paulson, Cambridge University Computer Laboratory
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     4
    Copyright   1992  University of Cambridge
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     5
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     6
For lfp.thy.  The Knaster-Tarski Theorem
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     7
*)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     8
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     9
open Lfp;
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    10
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    11
(*** Proof of Knaster-Tarski Theorem ***)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    12
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    13
(* lfp(f) is the greatest lower bound of {u. f(u) <= u} *)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    14
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    15
val prems = goalw Lfp.thy [lfp_def] "[| f(A) <= A |] ==> lfp(f) <= A";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    16
by (rtac (CollectI RS Inter_lower) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    17
by (resolve_tac prems 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    18
qed "lfp_lowerbound";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    19
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    20
val prems = goalw Lfp.thy [lfp_def]
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    21
    "[| !!u. f(u) <= u ==> A<=u |] ==> A <= lfp(f)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    22
by (REPEAT (ares_tac ([Inter_greatest]@prems) 1));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    23
by (etac CollectD 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    24
qed "lfp_greatest";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    25
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    26
val [mono] = goal Lfp.thy "mono(f) ==> f(lfp(f)) <= lfp(f)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    27
by (EVERY1 [rtac lfp_greatest, rtac subset_trans,
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    28
	    rtac (mono RS monoD), rtac lfp_lowerbound, atac, atac]);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    29
qed "lfp_lemma2";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    30
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    31
val [mono] = goal Lfp.thy "mono(f) ==> lfp(f) <= f(lfp(f))";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    32
by (EVERY1 [rtac lfp_lowerbound, rtac (mono RS monoD), 
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    33
	    rtac lfp_lemma2, rtac mono]);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    34
qed "lfp_lemma3";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    35
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    36
val [mono] = goal Lfp.thy "mono(f) ==> lfp(f) = f(lfp(f))";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    37
by (REPEAT (resolve_tac [equalityI,lfp_lemma2,lfp_lemma3,mono] 1));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    38
qed "lfp_Tarski";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    39
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    40
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    41
(*** General induction rule for least fixed points ***)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    42
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    43
val [lfp,mono,indhyp] = goal Lfp.thy
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    44
    "[| a: lfp(f);  mono(f);  				\
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    45
\       !!x. [| x: f(lfp(f) Int {x.P(x)}) |] ==> P(x) 	\
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    46
\    |] ==> P(a)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    47
by (res_inst_tac [("a","a")] (Int_lower2 RS subsetD RS CollectD) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    48
by (rtac (lfp RSN (2, lfp_lowerbound RS subsetD)) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    49
by (EVERY1 [rtac Int_greatest, rtac subset_trans, 
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    50
	    rtac (Int_lower1 RS (mono RS monoD)),
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    51
	    rtac (mono RS lfp_lemma2),
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    52
	    rtac (CollectI RS subsetI), rtac indhyp, atac]);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    53
qed "induct";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    54
1114
c8dfb56a7e95 Prod is now a parent of Lfp.
nipkow
parents: 923
diff changeset
    55
val major::prems = goal Lfp.thy
c8dfb56a7e95 Prod is now a parent of Lfp.
nipkow
parents: 923
diff changeset
    56
  "[| (a,b) : lfp f; mono f; \
c8dfb56a7e95 Prod is now a parent of Lfp.
nipkow
parents: 923
diff changeset
    57
\     !!a b. (a,b) : f(lfp f Int Collect(split P)) ==> P a b |] ==> P a b";
c8dfb56a7e95 Prod is now a parent of Lfp.
nipkow
parents: 923
diff changeset
    58
by(res_inst_tac [("c1","P")] (split RS subst) 1);
c8dfb56a7e95 Prod is now a parent of Lfp.
nipkow
parents: 923
diff changeset
    59
br (major RS induct) 1;
c8dfb56a7e95 Prod is now a parent of Lfp.
nipkow
parents: 923
diff changeset
    60
brs prems 1;
c8dfb56a7e95 Prod is now a parent of Lfp.
nipkow
parents: 923
diff changeset
    61
by(res_inst_tac[("p","x")]PairE 1);
c8dfb56a7e95 Prod is now a parent of Lfp.
nipkow
parents: 923
diff changeset
    62
by(hyp_subst_tac 1);
c8dfb56a7e95 Prod is now a parent of Lfp.
nipkow
parents: 923
diff changeset
    63
by(asm_simp_tac (prod_ss addsimps prems) 1);
c8dfb56a7e95 Prod is now a parent of Lfp.
nipkow
parents: 923
diff changeset
    64
qed"induct2";
c8dfb56a7e95 Prod is now a parent of Lfp.
nipkow
parents: 923
diff changeset
    65
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    66
(** Definition forms of lfp_Tarski and induct, to control unfolding **)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    67
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    68
val [rew,mono] = goal Lfp.thy "[| h==lfp(f);  mono(f) |] ==> h = f(h)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    69
by (rewtac rew);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    70
by (rtac (mono RS lfp_Tarski) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    71
qed "def_lfp_Tarski";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    72
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    73
val rew::prems = goal Lfp.thy
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    74
    "[| A == lfp(f);  mono(f);   a:A;  			\
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    75
\       !!x. [| x: f(A Int {x.P(x)}) |] ==> P(x) 	\
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    76
\    |] ==> P(a)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    77
by (EVERY1 [rtac induct,	(*backtracking to force correct induction*)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    78
	    REPEAT1 o (ares_tac (map (rewrite_rule [rew]) prems))]);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    79
qed "def_induct";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    80
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    81
(*Monotonicity of lfp!*)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    82
val [prem] = goal Lfp.thy "[| !!Z. f(Z)<=g(Z) |] ==> lfp(f) <= lfp(g)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    83
br (lfp_lowerbound RS lfp_greatest) 1;
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    84
be (prem RS subset_trans) 1;
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    85
qed "lfp_mono";