src/HOLCF/Tr.ML
author wenzelm
Thu Aug 27 20:46:36 1998 +0200 (1998-08-27)
changeset 5400 645f46a24c72
parent 5143 b94cd208f073
child 7654 57c4cea8b137
permissions -rw-r--r--
made tutorial first;
slotosch@2640
     1
(*  Title:      HOLCF/Tr.ML
slotosch@2640
     2
    ID:         $Id$
slotosch@2640
     3
    Author:     Franz Regensburger
slotosch@2640
     4
    Copyright   1993 Technische Universitaet Muenchen
slotosch@2640
     5
slotosch@2640
     6
Lemmas for Tr.thy
slotosch@2640
     7
*)
slotosch@2640
     8
slotosch@2640
     9
open Tr;
slotosch@2640
    10
slotosch@2640
    11
(* ------------------------------------------------------------------------ *)
slotosch@2640
    12
(* Exhaustion and Elimination for type one                                  *)
slotosch@2640
    13
(* ------------------------------------------------------------------------ *)
slotosch@2640
    14
qed_goalw "Exh_tr" thy [FF_def,TT_def] "t=UU | t = TT | t = FF"
slotosch@2640
    15
 (fn prems =>
slotosch@2640
    16
        [
slotosch@2640
    17
	(lift.induct_tac "t" 1),
slotosch@2640
    18
	(fast_tac HOL_cs 1),
wenzelm@4098
    19
	(fast_tac (HOL_cs addss simpset()) 1)
slotosch@2640
    20
	]);
slotosch@2640
    21
slotosch@2640
    22
qed_goal "trE" thy
slotosch@2640
    23
        "[| p=UU ==> Q; p = TT ==>Q; p = FF ==>Q|] ==>Q"
slotosch@2640
    24
 (fn prems =>
slotosch@2640
    25
        [
slotosch@2640
    26
        (rtac (Exh_tr RS disjE) 1),
slotosch@2640
    27
        (eresolve_tac prems 1),
slotosch@2640
    28
        (etac disjE 1),
slotosch@2640
    29
        (eresolve_tac prems 1),
slotosch@2640
    30
        (eresolve_tac prems 1)
slotosch@2640
    31
        ]);
slotosch@2640
    32
slotosch@2640
    33
(* ------------------------------------------------------------------------ *) 
slotosch@2640
    34
(* tactic for tr-thms with case split                                       *)
slotosch@2640
    35
(* ------------------------------------------------------------------------ *)
slotosch@2640
    36
slotosch@2640
    37
val tr_defs = [andalso_def,orelse_def,neg_def,ifte_def,TT_def,FF_def];
slotosch@2640
    38
slotosch@2640
    39
fun prover t =  prove_goal thy t
slotosch@2640
    40
 (fn prems =>
slotosch@2640
    41
        [
slotosch@2640
    42
        (res_inst_tac [("p","y")] trE 1),
wenzelm@4098
    43
	(REPEAT(asm_simp_tac (simpset() addsimps 
slotosch@2640
    44
		[o_def,flift1_def,flift2_def,inst_lift_po]@tr_defs) 1))
slotosch@2640
    45
	]);
slotosch@2640
    46
slotosch@2640
    47
(* ------------------------------------------------------------------------ *) 
slotosch@2640
    48
(* distinctness for type tr                                                 *) 
slotosch@2640
    49
(* ------------------------------------------------------------------------ *)
slotosch@2640
    50
slotosch@2640
    51
val dist_less_tr = map prover [
slotosch@2640
    52
			"~TT << UU",
slotosch@2640
    53
			"~FF << UU",
slotosch@2640
    54
			"~TT << FF",
slotosch@2640
    55
			"~FF << TT"
slotosch@2640
    56
                        ];
slotosch@2640
    57
slotosch@2640
    58
val dist_eq_tr = map prover ["TT~=UU","FF~=UU","TT~=FF"];
slotosch@2640
    59
val dist_eq_tr = dist_eq_tr @ (map (fn thm => (thm RS not_sym)) dist_eq_tr);
slotosch@2640
    60
slotosch@2640
    61
(* ------------------------------------------------------------------------ *) 
slotosch@2640
    62
(* lemmas about andalso, orelse, neg and if                                 *) 
slotosch@2640
    63
(* ------------------------------------------------------------------------ *)
slotosch@2640
    64
slotosch@2640
    65
val andalso_thms = map prover [
slotosch@2640
    66
                        "(TT andalso y) = y",
slotosch@2640
    67
                        "(FF andalso y) = FF",
slotosch@2640
    68
                        "(UU andalso y) = UU",
slotosch@2640
    69
			"(y andalso TT) = y",
slotosch@2640
    70
		  	"(y andalso y) = y"
slotosch@2640
    71
                        ];
slotosch@2640
    72
slotosch@2640
    73
val orelse_thms = map prover [
slotosch@2640
    74
                        "(TT orelse y) = TT",
slotosch@2640
    75
                        "(FF orelse y) = y",
slotosch@2640
    76
                        "(UU orelse y) = UU",
slotosch@2640
    77
                        "(y orelse FF) = y",
slotosch@2640
    78
			"(y orelse y) = y"];
slotosch@2640
    79
slotosch@2640
    80
val neg_thms = map prover [
slotosch@2640
    81
                        "neg`TT = FF",
slotosch@2640
    82
                        "neg`FF = TT",
slotosch@2640
    83
                        "neg`UU = UU"
slotosch@2640
    84
                        ];
slotosch@2640
    85
slotosch@2640
    86
val ifte_thms = map prover [
slotosch@2640
    87
                        "If UU then e1 else e2 fi = UU",
slotosch@2640
    88
                        "If FF then e1 else e2 fi = e2",
slotosch@2640
    89
                        "If TT then e1 else e2 fi = e1"];
slotosch@2640
    90
slotosch@2640
    91
Addsimps (dist_less_tr @ dist_eq_tr @ andalso_thms @ 
slotosch@2640
    92
	  orelse_thms @ neg_thms @ ifte_thms);
slotosch@2640
    93
mueller@3038
    94
(* ------------------------------------------------------------------- *)
mueller@3038
    95
(*  split-tac for If via If2 because the constant has to be a constant *)
mueller@3038
    96
(* ------------------------------------------------------------------- *)
mueller@3038
    97
  
wenzelm@5068
    98
Goalw [If2_def] 
mueller@3038
    99
  "P (If2 Q x y ) = ((Q=UU --> P UU) & (Q=TT --> P x) & (Q=FF --> P y))";
mueller@3038
   100
by (res_inst_tac [("p","Q")] trE 1);
mueller@3038
   101
by (REPEAT (Asm_full_simp_tac 1));
nipkow@4833
   102
qed"split_If2";
slotosch@2640
   103
mueller@3038
   104
val split_If_tac =
nipkow@4833
   105
  simp_tac (HOL_basic_ss addsimps [symmetric If2_def]) THEN' (split_tac [split_If2]);
slotosch@2640
   106
mueller@3038
   107
 
slotosch@2640
   108
mueller@3038
   109
(* ----------------------------------------------------------------- *)
mueller@3038
   110
        section"Rewriting of HOLCF operations to HOL functions";
mueller@3038
   111
(* ----------------------------------------------------------------- *)
slotosch@2640
   112
slotosch@2640
   113
wenzelm@5068
   114
Goal
mueller@3038
   115
"!!t.[|t~=UU|]==> ((t andalso s)=FF)=(t=FF | s=FF)";
mueller@3038
   116
by (rtac iffI 1);
mueller@3038
   117
by (res_inst_tac [("p","t")] trE 1);
paulson@4477
   118
by Auto_tac;
mueller@3038
   119
by (res_inst_tac [("p","t")] trE 1);
paulson@4477
   120
by Auto_tac;
mueller@3038
   121
qed"andalso_or";
slotosch@2640
   122
paulson@5143
   123
Goal "[|t~=UU|]==> ((t andalso s)~=FF)=(t~=FF & s~=FF)";
slotosch@2640
   124
by (rtac iffI 1);
mueller@3038
   125
by (res_inst_tac [("p","t")] trE 1);
paulson@4477
   126
by Auto_tac;
slotosch@2640
   127
by (res_inst_tac [("p","t")] trE 1);
paulson@4477
   128
by Auto_tac;
slotosch@2640
   129
qed"andalso_and";
slotosch@2640
   130
wenzelm@5068
   131
Goal "(Def x ~=FF)= x";
wenzelm@4098
   132
by (simp_tac (simpset() addsimps [FF_def]) 1);
mueller@3038
   133
qed"Def_bool1";
slotosch@2640
   134
wenzelm@5068
   135
Goal "(Def x = FF) = (~x)";
wenzelm@4098
   136
by (simp_tac (simpset() addsimps [FF_def]) 1);
mueller@3038
   137
qed"Def_bool2";
slotosch@2640
   138
wenzelm@5068
   139
Goal "(Def x = TT) = x";
wenzelm@4098
   140
by (simp_tac (simpset() addsimps [TT_def]) 1);
mueller@3038
   141
qed"Def_bool3";
mueller@3038
   142
wenzelm@5068
   143
Goal "(Def x ~= TT) = (~x)";
wenzelm@4098
   144
by (simp_tac (simpset() addsimps [TT_def]) 1);
mueller@3038
   145
qed"Def_bool4";
slotosch@2640
   146
wenzelm@5068
   147
Goal 
slotosch@2640
   148
  "(If Def P then A else B fi)= (if P then A else B)";
slotosch@2640
   149
by (res_inst_tac [("p","Def P")]  trE 1);
slotosch@2640
   150
by (Asm_full_simp_tac 1);
wenzelm@4098
   151
by (asm_full_simp_tac (simpset() addsimps tr_defs@[flift1_def,o_def]) 1);
wenzelm@4098
   152
by (asm_full_simp_tac (simpset() addsimps tr_defs@[flift1_def,o_def]) 1);
slotosch@2640
   153
qed"If_and_if";
slotosch@2640
   154
mueller@3038
   155
Addsimps [Def_bool1,Def_bool2,Def_bool3,Def_bool4];
mueller@3038
   156
mueller@3038
   157
(* ----------------------------------------------------------------- *)
mueller@3038
   158
        section"admissibility";
mueller@3038
   159
(* ----------------------------------------------------------------- *)
mueller@3038
   160
mueller@3038
   161
mueller@3038
   162
(* The following rewrite rules for admissibility should in the future be 
mueller@3038
   163
   replaced by a more general admissibility test that also checks 
mueller@3038
   164
   chain-finiteness, of which these lemmata are specific examples *)
mueller@3038
   165
wenzelm@5068
   166
Goal "x~=FF = (x=TT|x=UU)";
mueller@3038
   167
by (res_inst_tac [("p","x")] trE 1);
mueller@3038
   168
by (TRYALL (Asm_full_simp_tac));
mueller@3038
   169
qed"adm_trick_1";
mueller@3038
   170
wenzelm@5068
   171
Goal "x~=TT = (x=FF|x=UU)";
mueller@3038
   172
by (res_inst_tac [("p","x")] trE 1);
mueller@3038
   173
by (TRYALL (Asm_full_simp_tac));
mueller@3038
   174
qed"adm_trick_2";
mueller@3038
   175
mueller@3038
   176
val adm_tricks = [adm_trick_1,adm_trick_2];
mueller@3038
   177
mueller@3038
   178
paulson@5143
   179
Goal "cont(f) ==> adm (%x. (f x)~=TT)";
mueller@3038
   180
by (simp_tac (HOL_basic_ss addsimps adm_tricks) 1);
mueller@3038
   181
by (REPEAT ((resolve_tac (adm_lemmas@cont_lemmas1) 1) ORELSE atac 1));
mueller@3038
   182
qed"adm_nTT";
mueller@3038
   183
paulson@5143
   184
Goal "cont(f) ==> adm (%x. (f x)~=FF)";
mueller@3038
   185
by (simp_tac (HOL_basic_ss addsimps adm_tricks) 1);
mueller@3038
   186
by (REPEAT ((resolve_tac (adm_lemmas@cont_lemmas1) 1) ORELSE atac 1));
mueller@3038
   187
qed"adm_nFF";
mueller@3038
   188
nipkow@4642
   189
Addsimps [adm_nTT,adm_nFF];