src/Pure/goal_display.ML
changeset 51959 18d758e38d85
parent 51958 bca32217b304
child 51960 61ac1efe02c3
equal deleted inserted replaced
51958:bca32217b304 51959:18d758e38d85
     8 signature GOAL_DISPLAY =
     8 signature GOAL_DISPLAY =
     9 sig
     9 sig
    10   val goals_limit_default: int Unsynchronized.ref
    10   val goals_limit_default: int Unsynchronized.ref
    11   val goals_limit_raw: Config.raw
    11   val goals_limit_raw: Config.raw
    12   val goals_limit: int Config.T
    12   val goals_limit: int Config.T
    13   val goals_total: bool Config.T
       
    14   val show_main_goal_default: bool Unsynchronized.ref
    13   val show_main_goal_default: bool Unsynchronized.ref
    15   val show_main_goal_raw: Config.raw
    14   val show_main_goal_raw: Config.raw
    16   val show_main_goal: bool Config.T
    15   val show_main_goal: bool Config.T
    17   val show_consts_default: bool Unsynchronized.ref
    16   val show_consts_default: bool Unsynchronized.ref
    18   val show_consts_raw: Config.raw
    17   val show_consts_raw: Config.raw
    28 struct
    27 struct
    29 
    28 
    30 val goals_limit_default = Unsynchronized.ref 10;
    29 val goals_limit_default = Unsynchronized.ref 10;
    31 val goals_limit_raw = Config.declare "goals_limit" (fn _ => Config.Int (! goals_limit_default));
    30 val goals_limit_raw = Config.declare "goals_limit" (fn _ => Config.Int (! goals_limit_default));
    32 val goals_limit = Config.int goals_limit_raw;
    31 val goals_limit = Config.int goals_limit_raw;
    33 
       
    34 val goals_total = Config.bool (Config.declare "goals_total" (fn _ => Config.Bool true));
       
    35 
    32 
    36 val show_main_goal_default = Unsynchronized.ref false;
    33 val show_main_goal_default = Unsynchronized.ref false;
    37 val show_main_goal_raw =
    34 val show_main_goal_raw =
    38   Config.declare "show_main_goal" (fn _ => Config.Bool (! show_main_goal_default));
    35   Config.declare "show_main_goal" (fn _ => Config.Bool (! show_main_goal_default));
    39 val show_main_goal = Config.bool show_main_goal_raw;
    36 val show_main_goal = Config.bool show_main_goal_raw;
    90     val show_sorts0 = Config.get ctxt0 show_sorts;
    87     val show_sorts0 = Config.get ctxt0 show_sorts;
    91     val show_types = Config.get ctxt show_types;
    88     val show_types = Config.get ctxt show_types;
    92     val show_consts = Config.get ctxt show_consts
    89     val show_consts = Config.get ctxt show_consts
    93     val show_main_goal = Config.get ctxt show_main_goal;
    90     val show_main_goal = Config.get ctxt show_main_goal;
    94     val goals_limit = Config.get ctxt goals_limit;
    91     val goals_limit = Config.get ctxt goals_limit;
    95     val goals_total = Config.get ctxt goals_total;
       
    96 
    92 
    97     val prt_sort = Syntax.pretty_sort ctxt;
    93     val prt_sort = Syntax.pretty_sort ctxt;
    98     val prt_typ = Syntax.pretty_typ ctxt;
    94     val prt_typ = Syntax.pretty_typ ctxt;
    99     val prt_term = Syntax.pretty_term ctxt;
    95     val prt_term = Syntax.pretty_term ctxt;
   100 
    96 
   133   in
   129   in
   134     (if show_main_goal then [Pretty.mark Markup.goal (prt_term B)] else []) @
   130     (if show_main_goal then [Pretty.mark Markup.goal (prt_term B)] else []) @
   135      (if ngoals = 0 then [Pretty.str "No subgoals!"]
   131      (if ngoals = 0 then [Pretty.str "No subgoals!"]
   136       else if ngoals > goals_limit then
   132       else if ngoals > goals_limit then
   137         pretty_subgoals (take goals_limit As) @
   133         pretty_subgoals (take goals_limit As) @
   138         (if goals_total then [Pretty.str ("A total of " ^ string_of_int ngoals ^ " subgoals...")]
   134         [Pretty.str ("A total of " ^ string_of_int ngoals ^ " subgoals...")]
   139          else [])
       
   140       else pretty_subgoals As) @
   135       else pretty_subgoals As) @
   141     pretty_ffpairs tpairs @
   136     pretty_ffpairs tpairs @
   142     (if show_consts then pretty_consts prop else []) @
   137     (if show_consts then pretty_consts prop else []) @
   143     (if show_types then pretty_vars prop else []) @
   138     (if show_types then pretty_vars prop else []) @
   144     (if show_sorts0 then pretty_varsT prop else [])
   139     (if show_sorts0 then pretty_varsT prop else [])
   147 fun pretty_goals_without_context th =
   142 fun pretty_goals_without_context th =
   148   let val ctxt =
   143   let val ctxt =
   149     Config.put show_main_goal true (Syntax.init_pretty_global (Thm.theory_of_thm th))
   144     Config.put show_main_goal true (Syntax.init_pretty_global (Thm.theory_of_thm th))
   150   in pretty_goals ctxt th end;
   145   in pretty_goals ctxt th end;
   151 
   146 
   152 fun pretty_goal ctxt th =
   147 val pretty_goal = Pretty.chunks oo pretty_goals;
   153   Pretty.chunks (pretty_goals (Config.put goals_total false ctxt) th);
       
   154 
       
   155 val string_of_goal = Pretty.string_of oo pretty_goal;
   148 val string_of_goal = Pretty.string_of oo pretty_goal;
   156 
   149 
   157 end;
   150 end;
   158 
   151 
   159 end;
   152 end;