src/Pure/Isar/code.ML
changeset 42360 da8817d01e7c
parent 42359 6ca5407863ed
child 42375 774df7c59508
equal deleted inserted replaced
42359:6ca5407863ed 42360:da8817d01e7c
   111 
   111 
   112 fun string_of_typ thy =
   112 fun string_of_typ thy =
   113   Syntax.string_of_typ (Config.put show_sorts true (Syntax.init_pretty_global thy));
   113   Syntax.string_of_typ (Config.put show_sorts true (Syntax.init_pretty_global thy));
   114 
   114 
   115 fun string_of_const thy c =
   115 fun string_of_const thy c =
   116   let val ctxt = ProofContext.init_global thy in
   116   let val ctxt = Proof_Context.init_global thy in
   117     case AxClass.inst_of_param thy c of
   117     case AxClass.inst_of_param thy c of
   118       SOME (c, tyco) =>
   118       SOME (c, tyco) =>
   119         ProofContext.extern_const ctxt c ^ " " ^ enclose "[" "]"
   119         Proof_Context.extern_const ctxt c ^ " " ^ enclose "[" "]"
   120           (ProofContext.extern_type ctxt tyco)
   120           (Proof_Context.extern_type ctxt tyco)
   121     | NONE => ProofContext.extern_const ctxt c
   121     | NONE => Proof_Context.extern_const ctxt c
   122   end;
   122   end;
   123 
   123 
   124 
   124 
   125 (* constants *)
   125 (* constants *)
   126 
   126 
   351   end;
   351   end;
   352 
   352 
   353 fun cert_signature thy = Logic.varifyT_global o Type.cert_typ (build_tsig thy) o Type.no_tvars;
   353 fun cert_signature thy = Logic.varifyT_global o Type.cert_typ (build_tsig thy) o Type.no_tvars;
   354 
   354 
   355 fun read_signature thy = cert_signature thy o Type.strip_sorts
   355 fun read_signature thy = cert_signature thy o Type.strip_sorts
   356   o Syntax.parse_typ (ProofContext.init_global thy);
   356   o Syntax.parse_typ (Proof_Context.init_global thy);
   357 
   357 
   358 fun expand_signature thy = Type.cert_typ_mode Type.mode_syntax (Sign.tsig_of thy);
   358 fun expand_signature thy = Type.cert_typ_mode Type.mode_syntax (Sign.tsig_of thy);
   359 
   359 
   360 fun lookup_typ thy = Symtab.lookup ((snd o the_signatures o the_exec) thy);
   360 fun lookup_typ thy = Symtab.lookup ((snd o the_signatures o the_exec) thy);
   361 
   361 
   574       else error ("Type arguments do not satisfy sort constraints of abstype certificate.");
   574       else error ("Type arguments do not satisfy sort constraints of abstype certificate.");
   575   in (thm, tyco) end;
   575   in (thm, tyco) end;
   576 
   576 
   577 fun assert_eqn thy = error_thm (gen_assert_eqn thy true);
   577 fun assert_eqn thy = error_thm (gen_assert_eqn thy true);
   578 
   578 
   579 fun meta_rewrite thy = Local_Defs.meta_rewrite_rule (ProofContext.init_global thy);
   579 fun meta_rewrite thy = Local_Defs.meta_rewrite_rule (Proof_Context.init_global thy);
   580 
   580 
   581 fun mk_eqn thy = error_thm (gen_assert_eqn thy false) o
   581 fun mk_eqn thy = error_thm (gen_assert_eqn thy false) o
   582   apfst (meta_rewrite thy);
   582   apfst (meta_rewrite thy);
   583 
   583 
   584 fun mk_eqn_warning thy = Option.map (fn (thm, _) => (thm, is_linear thm))
   584 fun mk_eqn_warning thy = Option.map (fn (thm, _) => (thm, is_linear thm))
   961 
   961 
   962 (* diagnostic *)
   962 (* diagnostic *)
   963 
   963 
   964 fun print_codesetup thy =
   964 fun print_codesetup thy =
   965   let
   965   let
   966     val ctxt = ProofContext.init_global thy;
   966     val ctxt = Proof_Context.init_global thy;
   967     val exec = the_exec thy;
   967     val exec = the_exec thy;
   968     fun pretty_equations const thms =
   968     fun pretty_equations const thms =
   969       (Pretty.block o Pretty.fbreaks) (
   969       (Pretty.block o Pretty.fbreaks) (
   970         Pretty.str (string_of_const thy const) :: map (Display.pretty_thm ctxt) thms
   970         Pretty.str (string_of_const thy const) :: map (Display.pretty_thm ctxt) thms
   971       );
   971       );
  1148     val T_cong = nth Ts pos;
  1148     val T_cong = nth Ts pos;
  1149     fun mk_prem z = Free (z, T_cong);
  1149     fun mk_prem z = Free (z, T_cong);
  1150     fun mk_concl z = list_comb (Const (case_const, T), map2 (curry Free) (ws @ z :: vs) Ts);
  1150     fun mk_concl z = list_comb (Const (case_const, T), map2 (curry Free) (ws @ z :: vs) Ts);
  1151     val (prem, concl) = pairself Logic.mk_equals (pairself mk_prem (x, y), pairself mk_concl (x, y));
  1151     val (prem, concl) = pairself Logic.mk_equals (pairself mk_prem (x, y), pairself mk_concl (x, y));
  1152     fun tac { context, prems } = Simplifier.rewrite_goals_tac prems
  1152     fun tac { context, prems } = Simplifier.rewrite_goals_tac prems
  1153       THEN ALLGOALS (ProofContext.fact_tac [Drule.reflexive_thm]);
  1153       THEN ALLGOALS (Proof_Context.fact_tac [Drule.reflexive_thm]);
  1154   in Skip_Proof.prove_global thy (x :: y :: zs) [prem] concl tac end;
  1154   in Skip_Proof.prove_global thy (x :: y :: zs) [prem] concl tac end;
  1155 
  1155 
  1156 fun add_case thm thy =
  1156 fun add_case thm thy =
  1157   let
  1157   let
  1158     val (case_const, (k, case_pats)) = case_cert thm;
  1158     val (case_const, (k, case_pats)) = case_cert thm;