removed eq_sg, pprint_sg, print_sg (now in sign.ML);
authorwenzelm
Thu, 03 Feb 1994 13:55:03 +0100
changeset 2527532f95d7f44
parent 251 c9b984c0a674
child 253 d7130a753ecf
removed eq_sg, pprint_sg, print_sg (now in sign.ML);
removed cterm_fun, read_ctyp (now in thm.ML);
print_theory: now shows all contents;
src/Pure/drule.ML
     1.1 --- a/src/Pure/drule.ML	Thu Feb 03 13:53:44 1994 +0100
     1.2 +++ b/src/Pure/drule.ML	Thu Feb 03 13:55:03 1994 +0100
     1.3 @@ -1,6 +1,6 @@
     1.4 -(*  Title: 	Pure/drule.ML
     1.5 +(*  Title:      Pure/drule.ML
     1.6      ID:         $Id$
     1.7 -    Author: 	Lawrence C Paulson, Cambridge University Computer Laboratory
     1.8 +    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
     1.9      Copyright   1993  University of Cambridge
    1.10  
    1.11  Derived rules and other operations on theorems and theories
    1.12 @@ -14,14 +14,12 @@
    1.13    local open Thm  in
    1.14    val asm_rl: thm
    1.15    val assume_ax: theory -> string -> thm
    1.16 -  val cterm_fun: (term -> term) -> (cterm -> cterm)
    1.17    val COMP: thm * thm -> thm
    1.18    val compose: thm * int * thm -> thm list
    1.19    val cterm_instantiate: (cterm*cterm)list -> thm -> thm
    1.20    val cut_rl: thm
    1.21    val equal_abs_elim: cterm  -> thm -> thm
    1.22    val equal_abs_elim_list: cterm list -> thm -> thm
    1.23 -  val eq_sg: Sign.sg * Sign.sg -> bool
    1.24    val eq_thm: thm * thm -> bool
    1.25    val eq_thm_sg: thm * thm -> bool
    1.26    val flexpair_abs_elim_list: cterm list -> thm -> thm
    1.27 @@ -36,7 +34,6 @@
    1.28    val MRS: thm list * thm -> thm
    1.29    val pprint_cterm: cterm -> pprint_args -> unit
    1.30    val pprint_ctyp: ctyp -> pprint_args -> unit
    1.31 -  val pprint_sg: Sign.sg -> pprint_args -> unit
    1.32    val pprint_theory: theory -> pprint_args -> unit
    1.33    val pprint_thm: thm -> pprint_args -> unit
    1.34    val pretty_thm: thm -> Sign.Syntax.Pretty.T
    1.35 @@ -44,16 +41,14 @@
    1.36    val print_ctyp: ctyp -> unit
    1.37    val print_goals: int -> thm -> unit
    1.38    val print_goals_ref: (int -> thm -> unit) ref
    1.39 -  val print_sg: Sign.sg -> unit
    1.40    val print_theory: theory -> unit
    1.41    val print_thm: thm -> unit
    1.42    val prth: thm -> thm
    1.43    val prthq: thm Sequence.seq -> thm Sequence.seq
    1.44    val prths: thm list -> thm list
    1.45 -  val read_ctyp: Sign.sg -> string -> ctyp
    1.46    val read_instantiate: (string*string)list -> thm -> thm
    1.47    val read_instantiate_sg: Sign.sg -> (string*string)list -> thm -> thm
    1.48 -  val read_insts: 
    1.49 +  val read_insts:
    1.50            Sign.sg -> (indexname -> typ option) * (indexname -> sort option)
    1.51                    -> (indexname -> typ option) * (indexname -> sort option)
    1.52                    -> (string*string)list
    1.53 @@ -82,7 +77,7 @@
    1.54    end
    1.55    end;
    1.56  
    1.57 -functor DruleFun (structure Logic: LOGIC and Thm: THM)(* : DRULE *) = (* FIXME *)
    1.58 +functor DruleFun (structure Logic: LOGIC and Thm: THM): DRULE =
    1.59  struct
    1.60  structure Thm = Thm;
    1.61  structure Sign = Thm.Sign;
    1.62 @@ -93,12 +88,6 @@
    1.63  
    1.64  (**** More derived rules and operations on theorems ****)
    1.65  
    1.66 -fun cterm_fun f ct =
    1.67 - let val {sign,t,...} = rep_cterm ct in cterm_of sign (f t) end;
    1.68 -
    1.69 -fun read_ctyp sign = ctyp_of sign o Sign.read_typ(sign, K None);
    1.70 -
    1.71 -
    1.72  (** reading of instantiations **)
    1.73  
    1.74  fun indexname cs = case Syntax.scan_varname cs of (v,[]) => v
    1.75 @@ -136,7 +125,8 @@
    1.76  in (map (fn (ixn,T) => (ixn,ctyp_of sign T)) tye', cterms) end;
    1.77  
    1.78  
    1.79 -(*** Printing of theorems ***)
    1.80 +
    1.81 +(*** Printing of theories, theorems, etc. ***)
    1.82  
    1.83  (*If false, hypotheses are printed as dots*)
    1.84  val show_hyps = ref true;
    1.85 @@ -144,11 +134,11 @@
    1.86  fun pretty_thm th =
    1.87  let val {sign, hyps, prop,...} = rep_thm th
    1.88      val hsymbs = if null hyps then []
    1.89 -		 else if !show_hyps then
    1.90 -		      [Pretty.brk 2,
    1.91 -		       Pretty.lst("[","]") (map (Sign.pretty_term sign) hyps)]
    1.92 -		 else Pretty.str" [" :: map (fn _ => Pretty.str".") hyps @
    1.93 -		      [Pretty.str"]"];
    1.94 +                 else if !show_hyps then
    1.95 +                      [Pretty.brk 2,
    1.96 +                       Pretty.lst("[","]") (map (Sign.pretty_term sign) hyps)]
    1.97 +                 else Pretty.str" [" :: map (fn _ => Pretty.str".") hyps @
    1.98 +                      [Pretty.str"]"];
    1.99  in Pretty.blk(0, Sign.pretty_term sign prop :: hsymbs) end;
   1.100  
   1.101  val string_of_thm = Pretty.string_of o pretty_thm;
   1.102 @@ -163,38 +153,49 @@
   1.103  
   1.104  (*Print and return a sequence of theorems, separated by blank lines. *)
   1.105  fun prthq thseq =
   1.106 -    (Sequence.prints (fn _ => print_thm) 100000 thseq;
   1.107 -     thseq);
   1.108 +  (Sequence.prints (fn _ => print_thm) 100000 thseq; thseq);
   1.109  
   1.110  (*Print and return a list of theorems, separated by blank lines. *)
   1.111  fun prths ths = (print_list_ln print_thm ths; ths);
   1.112  
   1.113 -(*Other printing commands*)
   1.114 -fun pprint_ctyp cT = 
   1.115 - let val {sign,T} = rep_ctyp cT in  Sign.pprint_typ sign T  end;
   1.116  
   1.117 -fun string_of_ctyp cT = 
   1.118 - let val {sign,T} = rep_ctyp cT in  Sign.string_of_typ sign T  end;
   1.119 +(* other printing commands *)
   1.120 +
   1.121 +fun pprint_ctyp cT =
   1.122 +  let val {sign, T} = rep_ctyp cT in Sign.pprint_typ sign T end;
   1.123 +
   1.124 +fun string_of_ctyp cT =
   1.125 +  let val {sign, T} = rep_ctyp cT in Sign.string_of_typ sign T end;
   1.126  
   1.127  val print_ctyp = writeln o string_of_ctyp;
   1.128  
   1.129 -fun pprint_cterm ct = 
   1.130 - let val {sign,t,...} = rep_cterm ct in  Sign.pprint_term sign t  end;
   1.131 +fun pprint_cterm ct =
   1.132 +  let val {sign, t, ...} = rep_cterm ct in Sign.pprint_term sign t end;
   1.133  
   1.134 -fun string_of_cterm ct = 
   1.135 - let val {sign,t,...} = rep_cterm ct in  Sign.string_of_term sign t  end;
   1.136 +fun string_of_cterm ct =
   1.137 +  let val {sign, t, ...} = rep_cterm ct in Sign.string_of_term sign t end;
   1.138  
   1.139  val print_cterm = writeln o string_of_cterm;
   1.140  
   1.141 -fun pretty_sg sg = 
   1.142 -  Pretty.lst ("{", "}") (map (Pretty.str o !) (#stamps (Sign.rep_sg sg)));
   1.143  
   1.144 -val pprint_sg = Pretty.pprint o pretty_sg;
   1.145 +(* print theory *)
   1.146  
   1.147 -val pprint_theory = pprint_sg o sign_of;
   1.148 +val pprint_theory = Sign.pprint_sg o sign_of;
   1.149  
   1.150 -val print_sg = writeln o Pretty.string_of o pretty_sg;
   1.151 -val print_theory = print_sg o sign_of;
   1.152 +fun print_theory thy =
   1.153 +  let
   1.154 +    fun prt_thm (name, thm) = Pretty.block
   1.155 +      [Pretty.str (name ^ ":"), Pretty.brk 1, Pretty.quote (pretty_thm thm)];
   1.156 +
   1.157 +    val sg = sign_of thy;
   1.158 +    val axioms =        (* FIXME should rather fix axioms_of *)
   1.159 +      sort (fn ((x, _), (y, _)) => x <= y)
   1.160 +        (gen_distinct eq_fst (axioms_of thy));
   1.161 +  in
   1.162 +    Sign.print_sg sg;
   1.163 +    Pretty.writeln (Pretty.big_list "axioms:" (map prt_thm axioms))
   1.164 +  end;
   1.165 +
   1.166  
   1.167  
   1.168  (** Print thm A1,...,An/B in "goal style" -- premises as numbered subgoals **)
   1.169 @@ -205,26 +206,26 @@
   1.170  let val {sign, hyps, prop,...} = rep_thm th;
   1.171      fun printgoals (_, []) = ()
   1.172        | printgoals (n, A::As) =
   1.173 -	let val prettyn = Pretty.str(" " ^ string_of_int n ^ ". ");
   1.174 -	    val prettyA = Sign.pretty_term sign A
   1.175 -	in prettyprints[prettyn,prettyA]; 
   1.176 -           printgoals (n+1,As) 
   1.177 +        let val prettyn = Pretty.str(" " ^ string_of_int n ^ ". ");
   1.178 +            val prettyA = Sign.pretty_term sign A
   1.179 +        in prettyprints[prettyn,prettyA];
   1.180 +           printgoals (n+1,As)
   1.181          end;
   1.182      fun prettypair(t,u) =
   1.183          Pretty.blk(0, [Sign.pretty_term sign t, Pretty.str" =?=", Pretty.brk 1,
   1.184 -		       Sign.pretty_term sign u]);
   1.185 +                       Sign.pretty_term sign u]);
   1.186      fun printff [] = ()
   1.187        | printff tpairs =
   1.188 -	 writeln("\nFlex-flex pairs:\n" ^
   1.189 -		 Pretty.string_of(Pretty.lst("","") (map prettypair tpairs)))
   1.190 +         writeln("\nFlex-flex pairs:\n" ^
   1.191 +                 Pretty.string_of(Pretty.lst("","") (map prettypair tpairs)))
   1.192      val (tpairs,As,B) = Logic.strip_horn(prop);
   1.193      val ngoals = length As
   1.194 -in 
   1.195 +in
   1.196     writeln (Sign.string_of_term sign B);
   1.197     if ngoals=0 then writeln"No subgoals!"
   1.198 -   else if ngoals>maxgoals 
   1.199 +   else if ngoals>maxgoals
   1.200          then (printgoals (1, take(maxgoals,As));
   1.201 -	      writeln("A total of " ^ string_of_int ngoals ^ " subgoals..."))
   1.202 +              writeln("A total of " ^ string_of_int ngoals ^ " subgoals..."))
   1.203          else printgoals (1, As);
   1.204     printff tpairs
   1.205  end;
   1.206 @@ -232,7 +233,7 @@
   1.207  (*"hook" for user interfaces: allows print_goals to be replaced*)
   1.208  val print_goals_ref = ref print_goals;
   1.209  
   1.210 -(*** Find the type (sort) associated with a (T)Var or (T)Free in a term 
   1.211 +(*** Find the type (sort) associated with a (T)Var or (T)Free in a term
   1.212       Used for establishing default types (of variables) and sorts (of
   1.213       type variables) when reading another term.
   1.214       Index -1 indicates that a (T)Free rather than a (T)Var is wanted.
   1.215 @@ -240,13 +241,13 @@
   1.216  
   1.217  fun types_sorts thm =
   1.218      let val {prop,hyps,...} = rep_thm thm;
   1.219 -	val big = list_comb(prop,hyps); (* bogus term! *)
   1.220 -	val vars = map dest_Var (term_vars big);
   1.221 -	val frees = map dest_Free (term_frees big);
   1.222 -	val tvars = term_tvars big;
   1.223 -	val tfrees = term_tfrees big;
   1.224 -	fun typ(a,i) = if i<0 then assoc(frees,a) else assoc(vars,(a,i));
   1.225 -	fun sort(a,i) = if i<0 then assoc(tfrees,a) else assoc(tvars,(a,i));
   1.226 +        val big = list_comb(prop,hyps); (* bogus term! *)
   1.227 +        val vars = map dest_Var (term_vars big);
   1.228 +        val frees = map dest_Free (term_frees big);
   1.229 +        val tvars = term_tvars big;
   1.230 +        val tfrees = term_tfrees big;
   1.231 +        fun typ(a,i) = if i<0 then assoc(frees,a) else assoc(vars,(a,i));
   1.232 +        fun sort(a,i) = if i<0 then assoc(tfrees,a) else assoc(tvars,(a,i));
   1.233      in (typ,sort) end;
   1.234  
   1.235  (** Standardization of rules **)
   1.236 @@ -254,31 +255,31 @@
   1.237  (*Generalization over a list of variables, IGNORING bad ones*)
   1.238  fun forall_intr_list [] th = th
   1.239    | forall_intr_list (y::ys) th =
   1.240 -	let val gth = forall_intr_list ys th
   1.241 -	in  forall_intr y gth   handle THM _ =>  gth  end;
   1.242 +        let val gth = forall_intr_list ys th
   1.243 +        in  forall_intr y gth   handle THM _ =>  gth  end;
   1.244  
   1.245  (*Generalization over all suitable Free variables*)
   1.246  fun forall_intr_frees th =
   1.247      let val {prop,sign,...} = rep_thm th
   1.248      in  forall_intr_list
   1.249 -         (map (cterm_of sign) (sort atless (term_frees prop))) 
   1.250 +         (map (cterm_of sign) (sort atless (term_frees prop)))
   1.251           th
   1.252      end;
   1.253  
   1.254  (*Replace outermost quantified variable by Var of given index.
   1.255      Could clash with Vars already present.*)
   1.256 -fun forall_elim_var i th = 
   1.257 +fun forall_elim_var i th =
   1.258      let val {prop,sign,...} = rep_thm th
   1.259      in case prop of
   1.260 -	  Const("all",_) $ Abs(a,T,_) =>
   1.261 -	      forall_elim (cterm_of sign (Var((a,i), T)))  th
   1.262 -	| _ => raise THM("forall_elim_var", i, [th])
   1.263 +          Const("all",_) $ Abs(a,T,_) =>
   1.264 +              forall_elim (cterm_of sign (Var((a,i), T)))  th
   1.265 +        | _ => raise THM("forall_elim_var", i, [th])
   1.266      end;
   1.267  
   1.268  (*Repeat forall_elim_var until all outer quantifiers are removed*)
   1.269 -fun forall_elim_vars i th = 
   1.270 +fun forall_elim_vars i th =
   1.271      forall_elim_vars i (forall_elim_var i th)
   1.272 -	handle THM _ => th;
   1.273 +        handle THM _ => th;
   1.274  
   1.275  (*Specialization over a list of cterms*)
   1.276  fun forall_elim_list cts th = foldr (uncurry forall_elim) (rev cts, th);
   1.277 @@ -290,21 +291,21 @@
   1.278  fun implies_elim_list impth ths = foldl (uncurry implies_elim) (impth,ths);
   1.279  
   1.280  (*Reset Var indexes to zero, renaming to preserve distinctness*)
   1.281 -fun zero_var_indexes th = 
   1.282 +fun zero_var_indexes th =
   1.283      let val {prop,sign,...} = rep_thm th;
   1.284          val vars = term_vars prop
   1.285          val bs = foldl add_new_id ([], map (fn Var((a,_),_)=>a) vars)
   1.286 -	val inrs = add_term_tvars(prop,[]);
   1.287 -	val nms' = rev(foldl add_new_id ([], map (#1 o #1) inrs));
   1.288 -	val tye = map (fn ((v,rs),a) => (v, TVar((a,0),rs))) (inrs ~~ nms')
   1.289 -	val ctye = map (fn (v,T) => (v,ctyp_of sign T)) tye;
   1.290 -	fun varpairs([],[]) = []
   1.291 -	  | varpairs((var as Var(v,T)) :: vars, b::bs) =
   1.292 -		let val T' = typ_subst_TVars tye T
   1.293 -		in (cterm_of sign (Var(v,T')),
   1.294 -		    cterm_of sign (Var((b,0),T'))) :: varpairs(vars,bs)
   1.295 -		end
   1.296 -	  | varpairs _ = raise TERM("varpairs", []);
   1.297 +        val inrs = add_term_tvars(prop,[]);
   1.298 +        val nms' = rev(foldl add_new_id ([], map (#1 o #1) inrs));
   1.299 +        val tye = map (fn ((v,rs),a) => (v, TVar((a,0),rs))) (inrs ~~ nms')
   1.300 +        val ctye = map (fn (v,T) => (v,ctyp_of sign T)) tye;
   1.301 +        fun varpairs([],[]) = []
   1.302 +          | varpairs((var as Var(v,T)) :: vars, b::bs) =
   1.303 +                let val T' = typ_subst_TVars tye T
   1.304 +                in (cterm_of sign (Var(v,T')),
   1.305 +                    cterm_of sign (Var((b,0),T'))) :: varpairs(vars,bs)
   1.306 +                end
   1.307 +          | varpairs _ = raise TERM("varpairs", []);
   1.308      in instantiate (ctye, varpairs(vars,rev bs)) th end;
   1.309  
   1.310  
   1.311 @@ -312,22 +313,22 @@
   1.312      all generality expressed by Vars having index 0.*)
   1.313  fun standard th =
   1.314      let val {maxidx,...} = rep_thm th
   1.315 -    in  varifyT (zero_var_indexes (forall_elim_vars(maxidx+1) 
   1.316 +    in  varifyT (zero_var_indexes (forall_elim_vars(maxidx+1)
   1.317                           (forall_intr_frees(implies_intr_hyps th))))
   1.318      end;
   1.319  
   1.320 -(*Assume a new formula, read following the same conventions as axioms. 
   1.321 +(*Assume a new formula, read following the same conventions as axioms.
   1.322    Generalizes over Free variables,
   1.323    creates the assumption, and then strips quantifiers.
   1.324    Example is [| ALL x:?A. ?P(x) |] ==> [| ?P(?a) |]
   1.325 -	     [ !(A,P,a)[| ALL x:A. P(x) |] ==> [| P(a) |] ]    *)
   1.326 +             [ !(A,P,a)[| ALL x:A. P(x) |] ==> [| P(a) |] ]    *)
   1.327  fun assume_ax thy sP =
   1.328      let val sign = sign_of thy
   1.329 -	val prop = Logic.close_form (term_of (read_cterm sign
   1.330 -			 (sP, propT)))
   1.331 +        val prop = Logic.close_form (term_of (read_cterm sign
   1.332 +                         (sP, propT)))
   1.333      in forall_elim_vars 0 (assume (cterm_of sign prop))  end;
   1.334  
   1.335 -(*Resolution: exactly one resolvent must be produced.*) 
   1.336 +(*Resolution: exactly one resolvent must be produced.*)
   1.337  fun tha RSN (i,thb) =
   1.338    case Sequence.chop (2, biresolution false [(false,tha)] i thb) of
   1.339        ([th],_) => th
   1.340 @@ -338,7 +339,7 @@
   1.341  fun tha RS thb = tha RSN (1,thb);
   1.342  
   1.343  (*For joining lists of rules*)
   1.344 -fun thas RLN (i,thbs) = 
   1.345 +fun thas RLN (i,thbs) =
   1.346    let val resolve = biresolution false (map (pair false) thas) i
   1.347        fun resb thb = Sequence.list_of_s (resolve thb) handle THM _ => []
   1.348    in  flat (map resb thbs)  end;
   1.349 @@ -347,27 +348,27 @@
   1.350  
   1.351  (*Resolve a list of rules against bottom_rl from right to left;
   1.352    makes proof trees*)
   1.353 -fun rls MRS bottom_rl = 
   1.354 +fun rls MRS bottom_rl =
   1.355    let fun rs_aux i [] = bottom_rl
   1.356 -	| rs_aux i (rl::rls) = rl RSN (i, rs_aux (i+1) rls)
   1.357 +        | rs_aux i (rl::rls) = rl RSN (i, rs_aux (i+1) rls)
   1.358    in  rs_aux 1 rls  end;
   1.359  
   1.360  (*As above, but for rule lists*)
   1.361 -fun rlss MRL bottom_rls = 
   1.362 +fun rlss MRL bottom_rls =
   1.363    let fun rs_aux i [] = bottom_rls
   1.364 -	| rs_aux i (rls::rlss) = rls RLN (i, rs_aux (i+1) rlss)
   1.365 +        | rs_aux i (rls::rlss) = rls RLN (i, rs_aux (i+1) rlss)
   1.366    in  rs_aux 1 rlss  end;
   1.367  
   1.368 -(*compose Q and [...,Qi,Q(i+1),...]==>R to [...,Q(i+1),...]==>R 
   1.369 +(*compose Q and [...,Qi,Q(i+1),...]==>R to [...,Q(i+1),...]==>R
   1.370    with no lifting or renaming!  Q may contain ==> or meta-quants
   1.371    ALWAYS deletes premise i *)
   1.372 -fun compose(tha,i,thb) = 
   1.373 +fun compose(tha,i,thb) =
   1.374      Sequence.list_of_s (bicompose false (false,tha,0) i thb);
   1.375  
   1.376  (*compose Q and [Q1,Q2,...,Qk]==>R to [Q2,...,Qk]==>R getting unique result*)
   1.377  fun tha COMP thb =
   1.378      case compose(tha,1,thb) of
   1.379 -        [th] => th  
   1.380 +        [th] => th
   1.381        | _ =>   raise THM("COMP", 1, [tha,thb]);
   1.382  
   1.383  (*Instantiate theorem th, reading instantiations under signature sg*)
   1.384 @@ -387,18 +388,18 @@
   1.385      let val {sign=signt, t=t, T= T, ...} = rep_cterm ct
   1.386          and {sign=signu, t=u, T= U, ...} = rep_cterm cu
   1.387          val sign' = Sign.merge(sign, Sign.merge(signt, signu))
   1.388 -	val tye' = Type.unify (#tsig(Sign.rep_sg sign')) ((T,U), tye)
   1.389 -	  handle Type.TUNIFY => raise TYPE("add_types", [T,U], [t,u])
   1.390 +        val tye' = Type.unify (#tsig(Sign.rep_sg sign')) ((T,U), tye)
   1.391 +          handle Type.TUNIFY => raise TYPE("add_types", [T,U], [t,u])
   1.392      in  (sign', tye')  end;
   1.393  in
   1.394 -fun cterm_instantiate ctpairs0 th = 
   1.395 +fun cterm_instantiate ctpairs0 th =
   1.396    let val (sign,tye) = foldr add_types (ctpairs0, (#sign(rep_thm th),[]))
   1.397        val tsig = #tsig(Sign.rep_sg sign);
   1.398        fun instT(ct,cu) = let val inst = subst_TVars tye
   1.399 -			 in (cterm_fun inst ct, cterm_fun inst cu) end
   1.400 +                         in (cterm_fun inst ct, cterm_fun inst cu) end
   1.401        fun ctyp2 (ix,T) = (ix, ctyp_of sign T)
   1.402    in  instantiate (map ctyp2 tye, map instT ctpairs0) th  end
   1.403 -  handle TERM _ => 
   1.404 +  handle TERM _ =>
   1.405             raise THM("cterm_instantiate: incompatible signatures",0,[th])
   1.406         | TYPE _ => raise THM("cterm_instantiate: types", 0, [th])
   1.407  end;
   1.408 @@ -406,21 +407,18 @@
   1.409  
   1.410  (** theorem equality test is exported and used by BEST_FIRST **)
   1.411  
   1.412 -(*equality of signatures means exact identity -- by ref equality*)
   1.413 -fun eq_sg (sg1,sg2) = (#stamps(Sign.rep_sg sg1) = #stamps(Sign.rep_sg sg2));
   1.414 -
   1.415 -(*equality of theorems uses equality of signatures and 
   1.416 +(*equality of theorems uses equality of signatures and
   1.417    the a-convertible test for terms*)
   1.418 -fun eq_thm (th1,th2) = 
   1.419 +fun eq_thm (th1,th2) =
   1.420      let val {sign=sg1, hyps=hyps1, prop=prop1, ...} = rep_thm th1
   1.421 -	and {sign=sg2, hyps=hyps2, prop=prop2, ...} = rep_thm th2
   1.422 -    in  eq_sg (sg1,sg2) andalso 
   1.423 -        aconvs(hyps1,hyps2) andalso 
   1.424 -        prop1 aconv prop2  
   1.425 +        and {sign=sg2, hyps=hyps2, prop=prop2, ...} = rep_thm th2
   1.426 +    in  Sign.eq_sg (sg1,sg2) andalso
   1.427 +        aconvs(hyps1,hyps2) andalso
   1.428 +        prop1 aconv prop2
   1.429      end;
   1.430  
   1.431  (*Do the two theorems have the same signature?*)
   1.432 -fun eq_thm_sg (th1,th2) = eq_sg(#sign(rep_thm th1), #sign(rep_thm th2));
   1.433 +fun eq_thm_sg (th1,th2) = Sign.eq_sg(#sign(rep_thm th1), #sign(rep_thm th2));
   1.434  
   1.435  (*Useful "distance" function for BEST_FIRST*)
   1.436  val size_of_thm = size_of_term o #prop o rep_thm;
   1.437 @@ -449,13 +447,13 @@
   1.438  
   1.439  (*In [A1,...,An]==>B, rewrite the selected A's only -- for rewrite_goals_tac*)
   1.440  (*Do not rewrite flex-flex pairs*)
   1.441 -fun goals_conv pred cv = 
   1.442 +fun goals_conv pred cv =
   1.443    let fun gconv i ct =
   1.444          let val (A,B) = Thm.dest_cimplies ct
   1.445              val (thA,j) = case term_of A of
   1.446                    Const("=?=",_)$_$_ => (reflexive A, i)
   1.447                  | _ => (if pred i then cv A else reflexive A, i+1)
   1.448 -	in  combination (combination refl_cimplies thA) (gconv j B) end
   1.449 +        in  combination (combination refl_cimplies thA) (gconv j B) end
   1.450          handle TERM _ => reflexive ct
   1.451    in gconv 1 end;
   1.452  
   1.453 @@ -504,10 +502,10 @@
   1.454    fun err th = raise THM("flexpair_inst: ", 0, [th])
   1.455    fun flexpair_inst def th =
   1.456      let val {prop = Const _ $ t $ u,  sign,...} = rep_thm th
   1.457 -	val cterm = cterm_of sign
   1.458 -	fun cvar a = cterm(Var((a,0),alpha))
   1.459 -	val def' = cterm_instantiate [(cvar"t", cterm t), (cvar"u", cterm u)] 
   1.460 -		   def
   1.461 +        val cterm = cterm_of sign
   1.462 +        fun cvar a = cterm(Var((a,0),alpha))
   1.463 +        val def' = cterm_instantiate [(cvar"t", cterm t), (cvar"u", cterm u)]
   1.464 +                   def
   1.465      in  equal_elim def' th
   1.466      end
   1.467      handle THM _ => err th | bind => err th
   1.468 @@ -517,7 +515,7 @@
   1.469  end;
   1.470  
   1.471  (*Version for flexflex pairs -- this supports lifting.*)
   1.472 -fun flexpair_abs_elim_list cts = 
   1.473 +fun flexpair_abs_elim_list cts =
   1.474      flexpair_intr o equal_abs_elim_list cts o flexpair_elim;
   1.475  
   1.476  
   1.477 @@ -527,17 +525,17 @@
   1.478  val asm_rl = trivial(read_cterm Sign.pure ("PROP ?psi",propT));
   1.479  
   1.480  (*Meta-level cut rule: [| V==>W; V |] ==> W *)
   1.481 -val cut_rl = trivial(read_cterm Sign.pure 
   1.482 -	("PROP ?psi ==> PROP ?theta", propT));
   1.483 +val cut_rl = trivial(read_cterm Sign.pure
   1.484 +        ("PROP ?psi ==> PROP ?theta", propT));
   1.485  
   1.486 -(*Generalized elim rule for one conclusion; cut_rl with reversed premises: 
   1.487 +(*Generalized elim rule for one conclusion; cut_rl with reversed premises:
   1.488       [| PROP V;  PROP V ==> PROP W |] ==> PROP W *)
   1.489  val revcut_rl =
   1.490    let val V = read_cterm Sign.pure ("PROP V", propT)
   1.491        and VW = read_cterm Sign.pure ("PROP V ==> PROP W", propT);
   1.492 -  in  standard (implies_intr V 
   1.493 -		(implies_intr VW
   1.494 -		 (implies_elim (assume VW) (assume V))))
   1.495 +  in  standard (implies_intr V
   1.496 +                (implies_intr VW
   1.497 +                 (implies_elim (assume VW) (assume V))))
   1.498    end;
   1.499  
   1.500  (* (!!x. PROP ?V) == PROP ?V       Allows removal of redundant parameters*)
   1.501 @@ -546,8 +544,9 @@
   1.502        and QV = read_cterm Sign.pure ("!!x::'a. PROP V", propT)
   1.503        and x  = read_cterm Sign.pure ("x", TFree("'a",["logic"]));
   1.504    in  standard (equal_intr (implies_intr QV (forall_elim x (assume QV)))
   1.505 -		           (implies_intr V  (forall_intr x (assume V))))
   1.506 +                           (implies_intr V  (forall_intr x (assume V))))
   1.507    end;
   1.508  
   1.509  end
   1.510  end;
   1.511 +