src/HOL/Import/proof_kernel.ML
changeset 39126 ee117c5b3b75
parent 39118 12f3788be67b
child 39134 917b4b6ba3d2
equal deleted inserted replaced
39125:f45d332a90e3 39126:ee117c5b3b75
   187 fun quotename c =
   187 fun quotename c =
   188   if Syntax.is_identifier c andalso not (Keyword.is_keyword c) then c else quote c
   188   if Syntax.is_identifier c andalso not (Keyword.is_keyword c) then c else quote c
   189 
   189 
   190 fun simple_smart_string_of_cterm ctxt0 ct =
   190 fun simple_smart_string_of_cterm ctxt0 ct =
   191     let
   191     let
   192         val ctxt = Config.put show_all_types true ctxt0;
   192         val ctxt = ctxt0
       
   193           |> Config.put show_all_types true
       
   194           |> Config.put Syntax.ambiguity_enabled true;
   193         val {t,T,...} = rep_cterm ct
   195         val {t,T,...} = rep_cterm ct
   194         (* Hack to avoid parse errors with Trueprop *)
   196         (* Hack to avoid parse errors with Trueprop *)
   195         val ct  = cterm_of (Thm.theory_of_cterm ct) (HOLogic.dest_Trueprop t)
   197         val ct  = cterm_of (Thm.theory_of_cterm ct) (HOLogic.dest_Trueprop t)
   196                            handle TERM _ => ct
   198                            handle TERM _ => ct
   197     in
   199     in
   198         quote (
   200         quote (
   199         Print_Mode.setmp [] (
   201         Print_Mode.setmp [] (
   200         setmp_CRITICAL show_brackets false (
   202         setmp_CRITICAL show_brackets false (
   201         setmp_CRITICAL Syntax.ambiguity_is_error false (
   203         setmp_CRITICAL show_sorts true (Syntax.string_of_term ctxt o Thm.term_of)))
   202         setmp_CRITICAL show_sorts true (Syntax.string_of_term ctxt o Thm.term_of))))
       
   203         ct)
   204         ct)
   204     end
   205     end
   205 
   206 
   206 exception SMART_STRING
   207 exception SMART_STRING
   207 
   208 
   208 fun smart_string_of_cterm ctxt ct =
   209 fun smart_string_of_cterm ctxt0 ct =
   209     let
   210     let
       
   211         val ctxt = ctxt0 |> Config.put Syntax.ambiguity_enabled false;
   210         val {t,T,...} = rep_cterm ct
   212         val {t,T,...} = rep_cterm ct
   211         (* Hack to avoid parse errors with Trueprop *)
   213         (* Hack to avoid parse errors with Trueprop *)
   212         val ct  = cterm_of (Thm.theory_of_cterm ct) (HOLogic.dest_Trueprop t)
   214         val ct  = cterm_of (Thm.theory_of_cterm ct) (HOLogic.dest_Trueprop t)
   213                    handle TERM _ => ct
   215                    handle TERM _ => ct
   214         fun match u = t aconv u
   216         fun match u = t aconv u
   230             end
   232             end
   231             handle ERROR mesg => F (n + 1)
   233             handle ERROR mesg => F (n + 1)
   232               | SMART_STRING =>
   234               | SMART_STRING =>
   233                   error ("smart_string failed for: "^ G 0 Syntax.string_of_term ctxt (term_of ct))
   235                   error ("smart_string failed for: "^ G 0 Syntax.string_of_term ctxt (term_of ct))
   234     in
   236     in
   235       Print_Mode.setmp [] (setmp_CRITICAL Syntax.ambiguity_is_error true F) 0
   237       Print_Mode.setmp [] F 0
   236     end
   238     end
   237     handle ERROR mesg => simple_smart_string_of_cterm ctxt ct
   239     handle ERROR mesg => simple_smart_string_of_cterm ctxt0 ct
   238 
   240 
   239 fun smart_string_of_thm ctxt = smart_string_of_cterm ctxt o cprop_of
   241 fun smart_string_of_thm ctxt = smart_string_of_cterm ctxt o cprop_of
   240 
   242 
   241 fun prth th = writeln (Print_Mode.setmp [] Display.string_of_thm_without_context th);
   243 fun prth th = writeln (Print_Mode.setmp [] Display.string_of_thm_without_context th);
   242 fun prin t = writeln (Print_Mode.setmp []
   244 fun prin t = writeln (Print_Mode.setmp []