src/HOLCF/Tr.ML
author slotosch
Mon, 17 Feb 1997 10:57:11 +0100
changeset 2640 ee4dfce170a0
child 2646 099a9155f608
permissions -rw-r--r--
Changes of HOLCF from Oscar Slotosch: 1. axclass instead of class * less instead of less_fun, less_cfun, less_sprod, less_cprod, less_ssum, less_up, less_lift * @x.!y.x<<y instead of UUU instead of UU_fun, UU_cfun, ... * no witness type void needed (eliminated Void.thy.Void.ML) * inst_<typ>_<class> derived as theorems 2. improved some proves on less_sprod and less_cprod * eliminated the following theorems Sprod1.ML: less_sprod1a Sprod1.ML: less_sprod1b Sprod1.ML: less_sprod2a Sprod1.ML: less_sprod2b Sprod1.ML: less_sprod2c Sprod2.ML: less_sprod3a Sprod2.ML: less_sprod3b Sprod2.ML: less_sprod4b Sprod2.ML: less_sprod4c Sprod3.ML: less_sprod5b Sprod3.ML: less_sprod5c Cprod1.ML: less_cprod1b Cprod1.ML: less_cprod2a Cprod1.ML: less_cprod2b Cprod1.ML: less_cprod2c Cprod2.ML: less_cprod3a Cprod2.ML: less_cprod3b 3. new classes: * cpo<po, * chfin<pcpo, * flat<pcpo, * derived: flat<chfin to do: show instances for lift 4. Data Type One * Used lift for the definition: one = unit lift * Changed the constant one into ONE 5. Data Type Tr * Used lift for the definition: tr = bool lift * adopted definitions of if,andalso,orelse,neg * only one theory Tr.thy,Tr.ML instead of Tr1.thy,Tr1.ML, Tr2.thy,Tr2.ML * reintroduced ceils for =TT,=FF 6. typedef * Using typedef instead of faking type definitions to do: change fapp, fabs from Cfun1 to Rep_Cfun, Abs_Cfun 7. adopted examples and domain construct to theses changes These changes eliminated all rules and arities from HOLCF

(*  Title:      HOLCF/Tr.ML
    ID:         $Id$
    Author:     Franz Regensburger
    Copyright   1993 Technische Universitaet Muenchen

Lemmas for Tr.thy
*)

open Tr;

(* ------------------------------------------------------------------------ *)
(* Exhaustion and Elimination for type one                                  *)
(* ------------------------------------------------------------------------ *)
qed_goalw "Exh_tr" thy [FF_def,TT_def] "t=UU | t = TT | t = FF"
 (fn prems =>
        [
	(lift.induct_tac "t" 1),
	(fast_tac HOL_cs 1),
	(fast_tac (HOL_cs addss !simpset) 1)
	]);

qed_goal "trE" thy
        "[| p=UU ==> Q; p = TT ==>Q; p = FF ==>Q|] ==>Q"
 (fn prems =>
        [
        (rtac (Exh_tr RS disjE) 1),
        (eresolve_tac prems 1),
        (etac disjE 1),
        (eresolve_tac prems 1),
        (eresolve_tac prems 1)
        ]);

(* ------------------------------------------------------------------------ *) 
(* tactic for tr-thms with case split                                       *)
(* ------------------------------------------------------------------------ *)

val tr_defs = [andalso_def,orelse_def,neg_def,ifte_def,TT_def,FF_def];

fun prover t =  prove_goal thy t
 (fn prems =>
        [
        (res_inst_tac [("p","y")] trE 1),
	(REPEAT(asm_simp_tac (!simpset addsimps 
		[o_def,flift1_def,flift2_def,inst_lift_po]@tr_defs) 1))
	]);

(* ------------------------------------------------------------------------ *) 
(* distinctness for type tr                                                 *) 
(* ------------------------------------------------------------------------ *)

val dist_less_tr = map prover [
			"~TT << UU",
			"~FF << UU",
			"~TT << FF",
			"~FF << TT"
                        ];

val dist_eq_tr = map prover ["TT~=UU","FF~=UU","TT~=FF"];
val dist_eq_tr = dist_eq_tr @ (map (fn thm => (thm RS not_sym)) dist_eq_tr);

(* ------------------------------------------------------------------------ *) 
(* lemmas about andalso, orelse, neg and if                                 *) 
(* ------------------------------------------------------------------------ *)

val andalso_thms = map prover [
                        "(TT andalso y) = y",
                        "(FF andalso y) = FF",
                        "(UU andalso y) = UU",
			"(y andalso TT) = y",
		  	"(y andalso y) = y"
                        ];

val orelse_thms = map prover [
                        "(TT orelse y) = TT",
                        "(FF orelse y) = y",
                        "(UU orelse y) = UU",
                        "(y orelse FF) = y",
			"(y orelse y) = y"];

val neg_thms = map prover [
                        "neg`TT = FF",
                        "neg`FF = TT",
                        "neg`UU = UU"
                        ];

val ifte_thms = map prover [
                        "If UU then e1 else e2 fi = UU",
                        "If FF then e1 else e2 fi = e2",
                        "If TT then e1 else e2 fi = e1"];

Addsimps (dist_less_tr @ dist_eq_tr @ andalso_thms @ 
	  orelse_thms @ neg_thms @ ifte_thms);


                
(* --------------------------------------------------------- *)
(*                Theroems for the liftings                  *)
(* --------------------------------------------------------- *)


(* --------------------------------------------------------- *)
(*                Admissibility tactic and tricks            *)
(* --------------------------------------------------------- *)


goal thy "x~=FF = (x=TT|x=UU)";
by (res_inst_tac [("p","x")] trE 1);
  by (TRYALL (Asm_full_simp_tac));
qed"adm_trick_1";

goal thy "x~=TT = (x=FF|x=UU)";
by (res_inst_tac [("p","x")] trE 1);
  by (TRYALL (Asm_full_simp_tac));
qed"adm_trick_2";

val adm_tricks = [adm_trick_1,adm_trick_2];

(*val adm_tac = (fn i => ((resolve_tac adm_lemmas i)));*)
(*val adm_tacR = (fn i => (REPEAT (adm_tac i)));*)
(*val adm_cont_tac = (fn i => ((adm_tacR i) THEN (cont_tacR i)));*)

(* ----------------------------------------------------------------- *)
(*     Relations between domains and terms using lift constructs     *)
(* ----------------------------------------------------------------- *)

goal thy "!!t.[|t~=UU|]==> ((t andalso s)~=FF)=(t~=FF & s~=FF)";
by (rtac iffI 1);
(* 1 *)
by (res_inst_tac [("p","t")] trE 1);
by (fast_tac HOL_cs 1);
by (res_inst_tac [("p","s")] trE 1);
by (Asm_full_simp_tac 1);
by (Asm_full_simp_tac 1);
by (subgoal_tac "(t andalso s) = FF" 1);
by (fast_tac HOL_cs 1);
by (Asm_full_simp_tac 1);
by (res_inst_tac [("p","s")] trE 1);
by (subgoal_tac "(t andalso s) = FF" 1);
by (fast_tac HOL_cs 1);
by (Asm_full_simp_tac 1);
by (subgoal_tac "(t andalso s) = FF" 1);
by (fast_tac HOL_cs 1);
by (Asm_full_simp_tac 1);
by (subgoal_tac "(t andalso s) = FF" 1);
by (fast_tac HOL_cs 1);
by (Asm_full_simp_tac 1);
(* 2*)
by (res_inst_tac [("p","t")] trE 1);
by (fast_tac HOL_cs 1);
by (Asm_full_simp_tac 1);
by (fast_tac HOL_cs 1);
qed"andalso_and";

goal thy "Def x ~=UU";
by (Simp_tac 1);
qed"blift_not_UU";

goal thy "(Def x ~=FF)= x";
by (simp_tac (!simpset addsimps [FF_def]) 1);
qed"blift_and_bool";

goal thy "(Def x = TT) = x";
by (simp_tac (!simpset addsimps [TT_def]) 1);
qed"blift_and_bool2";

goal thy "(Def x = FF) = (~x)";
by (simp_tac (!simpset addsimps [FF_def]) 1);
by (fast_tac HOL_cs 1);
qed"blift_and_bool3";

goal thy "plift P`(Def y) = Def (P y)";
by (simp_tac (!simpset addsimps [plift_def,flift1_def]) 1);
qed"plift2blift";

goal thy 
  "(If Def P then A else B fi)= (if P then A else B)";
by (res_inst_tac [("p","Def P")]  trE 1);
by (Asm_full_simp_tac 1);
by (asm_full_simp_tac (!simpset addsimps tr_defs@[flift1_def,o_def]) 1);
by (asm_full_simp_tac (!simpset addsimps tr_defs@[flift1_def,o_def]) 1);
qed"If_and_if";

Addsimps [plift2blift,If_and_if,blift_not_UU,
	blift_and_bool,blift_and_bool2,blift_and_bool3];

simpset := !simpset addsolver (K (DEPTH_SOLVE_1 o cont_tac));