moved print_goals to locale.ML;
authorwenzelm
Tue Aug 04 18:21:20 1998 +0200 (1998-08-04)
changeset 5245a6167c446b0b
parent 5244 5313f781efe0
child 5246 99116a9e88f8
moved print_goals to locale.ML;
src/Pure/display.ML
     1.1 --- a/src/Pure/display.ML	Tue Aug 04 18:21:03 1998 +0200
     1.2 +++ b/src/Pure/display.ML	Tue Aug 04 18:21:20 1998 +0200
     1.3 @@ -30,7 +30,7 @@
     1.4    val print_theory	: theory -> unit
     1.5    val pretty_name_space : string * NameSpace.T -> Pretty.T
     1.6    val show_consts	: bool ref
     1.7 -  val print_goals	: int -> thm -> unit
     1.8 +
     1.9  end;
    1.10  
    1.11  structure Display: DISPLAY =
    1.12 @@ -195,119 +195,10 @@
    1.13  
    1.14  fun print_theory thy = (print_sign (sign_of thy); print_thy thy);
    1.15  
    1.16 -
    1.17 -
    1.18 -(** print_goals **)
    1.19 -
    1.20 -(*print thm A1,...,An/B in "goal style" -- premises as numbered subgoals*)
    1.21 -
    1.22  (*also show consts in case of showing types?*)
    1.23  val show_consts = ref false;
    1.24  
    1.25  
    1.26 -local
    1.27 -
    1.28 -  (* utils *)
    1.29 -
    1.30 -  fun ins_entry (x, y) [] = [(x, [y])]
    1.31 -    | ins_entry (x, y) ((pair as (x', ys')) :: pairs) =
    1.32 -        if x = x' then (x', y ins ys') :: pairs
    1.33 -        else pair :: ins_entry (x, y) pairs;
    1.34 -
    1.35 -  fun add_consts (Const (c, T), env) = ins_entry (T, (c, T)) env
    1.36 -    | add_consts (t $ u, env) = add_consts (u, add_consts (t, env))
    1.37 -    | add_consts (Abs (_, _, t), env) = add_consts (t, env)
    1.38 -    | add_consts (_, env) = env;
    1.39 -
    1.40 -  fun add_vars (Free (x, T), env) = ins_entry (T, (x, ~1)) env
    1.41 -    | add_vars (Var (xi, T), env) = ins_entry (T, xi) env
    1.42 -    | add_vars (Abs (_, _, t), env) = add_vars (t, env)
    1.43 -    | add_vars (t $ u, env) = add_vars (u, add_vars (t, env))
    1.44 -    | add_vars (_, env) = env;
    1.45 -
    1.46 -  fun add_varsT (Type (_, Ts), env) = foldr add_varsT (Ts, env)
    1.47 -    | add_varsT (TFree (x, S), env) = ins_entry (S, (x, ~1)) env
    1.48 -    | add_varsT (TVar (xi, S), env) = ins_entry (S, xi) env;
    1.49 -
    1.50 -  fun sort_idxs vs = map (apsnd (sort (prod_ord string_ord int_ord))) vs;
    1.51 -  fun sort_cnsts cs = map (apsnd (sort_wrt fst)) cs;
    1.52 -
    1.53 -
    1.54 -  (* prepare atoms *)
    1.55 -
    1.56 -  fun consts_of t = sort_cnsts (add_consts (t, []));
    1.57 -  fun vars_of t = sort_idxs (add_vars (t, []));
    1.58 -  fun varsT_of t = rev (sort_idxs (it_term_types add_varsT (t, [])));
    1.59 -
    1.60 -in
    1.61 -
    1.62 -  fun print_goals maxgoals state =
    1.63 -    let
    1.64 -      val {sign, ...} = rep_thm state;
    1.65 -
    1.66 -      val prt_term = Sign.pretty_term sign;
    1.67 -      val prt_typ = Sign.pretty_typ sign;
    1.68 -      val prt_sort = Sign.pretty_sort sign;
    1.69 -
    1.70 -      fun prt_atoms prt prtT (X, xs) = Pretty.block
    1.71 -        [Pretty.block (Pretty.commas (map prt xs)), Pretty.str " ::",
    1.72 -          Pretty.brk 1, prtT X];
    1.73 -
    1.74 -      fun prt_var (x, ~1) = prt_term (Syntax.free x)
    1.75 -        | prt_var xi = prt_term (Syntax.var xi);
    1.76 -
    1.77 -      fun prt_varT (x, ~1) = prt_typ (TFree (x, []))
    1.78 -        | prt_varT xi = prt_typ (TVar (xi, []));
    1.79 -
    1.80 -      val prt_consts = prt_atoms (prt_term o Const) prt_typ;
    1.81 -      val prt_vars = prt_atoms prt_var prt_typ;
    1.82 -      val prt_varsT = prt_atoms prt_varT prt_sort;
    1.83 -
    1.84 -
    1.85 -      fun print_list _ _ [] = ()
    1.86 -        | print_list name prt lst = (writeln "";
    1.87 -            Pretty.writeln (Pretty.big_list name (map prt lst)));
    1.88 -
    1.89 -      fun print_subgoals (_, []) = ()
    1.90 -        | print_subgoals (n, A :: As) = (Pretty.writeln (Pretty.blk (0,
    1.91 -            [Pretty.str (" " ^ string_of_int n ^ ". "), prt_term A]));
    1.92 -              print_subgoals (n + 1, As));
    1.93 -
    1.94 -      val print_ffpairs =
    1.95 -        print_list "Flex-flex pairs:" (prt_term o Logic.mk_flexpair);
    1.96 -
    1.97 -      val print_consts = print_list "Constants:" prt_consts o consts_of;
    1.98 -      val print_vars = print_list "Variables:" prt_vars o vars_of;
    1.99 -      val print_varsT = print_list "Type variables:" prt_varsT o varsT_of;
   1.100 -
   1.101 -
   1.102 -      val {prop, ...} = rep_thm state;
   1.103 -      val (tpairs, As, B) = Logic.strip_horn prop;
   1.104 -      val ngoals = length As;
   1.105 -
   1.106 -      fun print_gs (types, sorts) =
   1.107 -       (Pretty.writeln (prt_term B);
   1.108 -        if ngoals = 0 then writeln "No subgoals!"
   1.109 -        else if ngoals > maxgoals then
   1.110 -          (print_subgoals (1, take (maxgoals, As));
   1.111 -            writeln ("A total of " ^ string_of_int ngoals ^ " subgoals..."))
   1.112 -        else print_subgoals (1, As);
   1.113 -
   1.114 -        print_ffpairs tpairs;
   1.115 -
   1.116 -        if types andalso ! show_consts then print_consts prop else ();
   1.117 -        if types then print_vars prop else ();
   1.118 -        if sorts then print_varsT prop else ());
   1.119 -    in
   1.120 -      setmp show_no_free_types true
   1.121 -        (setmp show_types (! show_types orelse ! show_sorts)
   1.122 -          (setmp show_sorts false print_gs))
   1.123 -     (! show_types orelse ! show_sorts, ! show_sorts)
   1.124 -  end;
   1.125 -
   1.126 -end;
   1.127 -
   1.128 -
   1.129  end;
   1.130  
   1.131  open Display;