src/LCF/lcf.ML
author paulson
Mon Dec 07 18:26:25 1998 +0100 (1998-12-07)
changeset 6019 0e55c2fb2ebb
parent 0 a5a9c433f639
permissions -rw-r--r--
tidying
clasohm@0
     1
(*  Title: 	LCF/lcf.ML
clasohm@0
     2
    ID:         $Id$
clasohm@0
     3
    Author: 	Tobias Nipkow
clasohm@0
     4
    Copyright   1992  University of Cambridge
clasohm@0
     5
clasohm@0
     6
For lcf.thy.  Basic lemmas about LCF
clasohm@0
     7
*)
clasohm@0
     8
clasohm@0
     9
open LCF;
clasohm@0
    10
clasohm@0
    11
signature LCF_LEMMAS =
clasohm@0
    12
sig
clasohm@0
    13
  val ap_term: thm
clasohm@0
    14
  val ap_thm: thm
clasohm@0
    15
  val COND_cases: thm
clasohm@0
    16
  val COND_cases_iff: thm
clasohm@0
    17
  val Contrapos: thm
clasohm@0
    18
  val cong: thm
clasohm@0
    19
  val ext: thm
clasohm@0
    20
  val eq_imp_less1: thm
clasohm@0
    21
  val eq_imp_less2: thm
clasohm@0
    22
  val less_anti_sym: thm
clasohm@0
    23
  val less_ap_term: thm
clasohm@0
    24
  val less_ap_thm: thm
clasohm@0
    25
  val less_refl: thm
clasohm@0
    26
  val less_UU: thm
clasohm@0
    27
  val not_UU_eq_TT: thm
clasohm@0
    28
  val not_UU_eq_FF: thm
clasohm@0
    29
  val not_TT_eq_UU: thm
clasohm@0
    30
  val not_TT_eq_FF: thm
clasohm@0
    31
  val not_FF_eq_UU: thm
clasohm@0
    32
  val not_FF_eq_TT: thm
clasohm@0
    33
  val rstac: thm list -> int -> tactic
clasohm@0
    34
  val stac: thm -> int -> tactic
clasohm@0
    35
  val sstac: thm list -> int -> tactic
clasohm@0
    36
  val strip_tac: int -> tactic
clasohm@0
    37
  val tr_induct: thm
clasohm@0
    38
  val UU_abs: thm
clasohm@0
    39
  val UU_app: thm
clasohm@0
    40
end;
clasohm@0
    41
clasohm@0
    42
clasohm@0
    43
structure LCF_Lemmas : LCF_LEMMAS =
clasohm@0
    44
clasohm@0
    45
struct
clasohm@0
    46
clasohm@0
    47
(* Standard abbreviations *)
clasohm@0
    48
clasohm@0
    49
val rstac = resolve_tac;
clasohm@0
    50
fun stac th = rtac(th RS sym RS subst);
clasohm@0
    51
fun sstac ths = EVERY' (map stac ths);
clasohm@0
    52
clasohm@0
    53
fun strip_tac i = REPEAT(rstac [impI,allI] i); 
clasohm@0
    54
clasohm@0
    55
val eq_imp_less1 = prove_goal thy "x=y ==> x << y"
clasohm@0
    56
	(fn prems => [rtac (rewrite_rule[eq_def](hd prems) RS conjunct1) 1]);
clasohm@0
    57
clasohm@0
    58
val eq_imp_less2 = prove_goal thy "x=y ==> y << x"
clasohm@0
    59
	(fn prems => [rtac (rewrite_rule[eq_def](hd prems) RS conjunct2) 1]);
clasohm@0
    60
clasohm@0
    61
val less_refl = refl RS eq_imp_less1;
clasohm@0
    62
clasohm@0
    63
val less_anti_sym = prove_goal thy "[| x << y; y << x |] ==> x=y"
clasohm@0
    64
	(fn prems => [rewrite_goals_tac[eq_def],
clasohm@0
    65
		      REPEAT(rstac(conjI::prems)1)]);
clasohm@0
    66
clasohm@0
    67
val ext = prove_goal thy
clasohm@0
    68
	"(!!x::'a::cpo. f(x)=g(x)::'b::cpo) ==> (%x.f(x))=(%x.g(x))"
clasohm@0
    69
	(fn [prem] => [REPEAT(rstac[less_anti_sym, less_ext, allI,
clasohm@0
    70
				    prem RS eq_imp_less1,
clasohm@0
    71
				    prem RS eq_imp_less2]1)]);
clasohm@0
    72
clasohm@0
    73
val cong = prove_goal thy "[| f=g; x=y |] ==> f(x)=g(y)"
clasohm@0
    74
	(fn prems => [cut_facts_tac prems 1, etac subst 1, etac subst 1,
clasohm@0
    75
		      rtac refl 1]);
clasohm@0
    76
clasohm@0
    77
val less_ap_term = less_refl RS mono;
clasohm@0
    78
val less_ap_thm = less_refl RSN (2,mono);
clasohm@0
    79
val ap_term = refl RS cong;
clasohm@0
    80
val ap_thm = refl RSN (2,cong);
clasohm@0
    81
clasohm@0
    82
val UU_abs = prove_goal thy "(%x::'a::cpo.UU) = UU"
clasohm@0
    83
	(fn _ => [rtac less_anti_sym 1, rtac minimal 2,
clasohm@0
    84
		  rtac less_ext 1, rtac allI 1, rtac minimal 1]);
clasohm@0
    85
clasohm@0
    86
val UU_app = UU_abs RS sym RS ap_thm;
clasohm@0
    87
clasohm@0
    88
val less_UU = prove_goal thy "x << UU ==> x=UU"
clasohm@0
    89
	(fn prems=> [rtac less_anti_sym 1,rstac prems 1,rtac minimal 1]);
clasohm@0
    90
clasohm@0
    91
clasohm@0
    92
val tr_induct = prove_goal thy "[| P(UU); P(TT); P(FF) |] ==> ALL b.P(b)"
clasohm@0
    93
	(fn prems => [rtac allI 1, rtac mp 1,
clasohm@0
    94
		      res_inst_tac[("p","b")]tr_cases 2,
clasohm@0
    95
		      fast_tac (FOL_cs addIs prems) 1]);
clasohm@0
    96
clasohm@0
    97
clasohm@0
    98
val Contrapos = prove_goal thy "(A ==> B) ==> (~B ==> ~A)"
clasohm@0
    99
	(fn prems => [rtac notI 1, rtac notE 1, rstac prems 1,
clasohm@0
   100
		      rstac prems 1, atac 1]);
clasohm@0
   101
clasohm@0
   102
val not_less_imp_not_eq1 = eq_imp_less1 COMP Contrapos;
clasohm@0
   103
val not_less_imp_not_eq2 = eq_imp_less2 COMP Contrapos;
clasohm@0
   104
clasohm@0
   105
val not_UU_eq_TT = not_TT_less_UU RS not_less_imp_not_eq2;
clasohm@0
   106
val not_UU_eq_FF = not_FF_less_UU RS not_less_imp_not_eq2;
clasohm@0
   107
val not_TT_eq_UU = not_TT_less_UU RS not_less_imp_not_eq1;
clasohm@0
   108
val not_TT_eq_FF = not_TT_less_FF RS not_less_imp_not_eq1;
clasohm@0
   109
val not_FF_eq_UU = not_FF_less_UU RS not_less_imp_not_eq1;
clasohm@0
   110
val not_FF_eq_TT = not_FF_less_TT RS not_less_imp_not_eq1;
clasohm@0
   111
clasohm@0
   112
clasohm@0
   113
val COND_cases_iff = (prove_goal thy
clasohm@0
   114
  "ALL b. P(b=>x|y) <-> (b=UU-->P(UU)) & (b=TT-->P(x)) & (b=FF-->P(y))"
clasohm@0
   115
	(fn _ => [cut_facts_tac [not_UU_eq_TT,not_UU_eq_FF,not_TT_eq_UU,
clasohm@0
   116
				 not_TT_eq_FF,not_FF_eq_UU,not_FF_eq_TT]1,
clasohm@0
   117
		  rtac tr_induct 1, stac COND_UU 1, stac COND_TT 2,
clasohm@0
   118
		  stac COND_FF 3, REPEAT(fast_tac FOL_cs 1)]))  RS spec;
clasohm@0
   119
clasohm@0
   120
val lemma = prove_goal thy "A<->B ==> B ==> A"
clasohm@0
   121
	(fn prems => [cut_facts_tac prems 1, rewrite_goals_tac [iff_def],
clasohm@0
   122
		      fast_tac FOL_cs 1]);
clasohm@0
   123
clasohm@0
   124
val COND_cases = conjI RSN (2,conjI RS (COND_cases_iff RS lemma));
clasohm@0
   125
clasohm@0
   126
end;
clasohm@0
   127
clasohm@0
   128
open LCF_Lemmas;
clasohm@0
   129