src/HOL/Tools/specification_package.ML
changeset 20903 905effde63d9
parent 20548 8ef25fe585a8
child 21116 be58cded79da
equal deleted inserted replaced
20902:a0034e545c13 20903:905effde63d9
    85 fun add_specification axiomatic cos arg =
    85 fun add_specification axiomatic cos arg =
    86     arg |> apsnd Thm.freezeT
    86     arg |> apsnd Thm.freezeT
    87         |> proc_exprop axiomatic cos
    87         |> proc_exprop axiomatic cos
    88         |> apsnd standard
    88         |> apsnd standard
    89 
    89 
    90 fun add_spec x y (context, thm) =
       
    91   (Context.the_theory context, thm) |> add_specification x y |>> Context.Theory;
       
    92 
       
    93 
    90 
    94 (* Collect all intances of constants in term *)
    91 (* Collect all intances of constants in term *)
    95 
    92 
    96 fun collect_consts (        t $ u,tms) = collect_consts (u,collect_consts (t,tms))
    93 fun collect_consts (        t $ u,tms) = collect_consts (u,collect_consts (t,tms))
    97   | collect_consts (   Abs(_,_,t),tms) = collect_consts (t,tms)
    94   | collect_consts (   Abs(_,_,t),tms) = collect_consts (t,tms)
   223                         else ()
   220                         else ()
   224             in
   221             in
   225                 arg |> apsnd Thm.freezeT
   222                 arg |> apsnd Thm.freezeT
   226                     |> process_all (zip3 alt_names rew_imps frees)
   223                     |> process_all (zip3 alt_names rew_imps frees)
   227             end
   224             end
   228             fun post_proc (context, th) =
   225 
   229                 post_process (Context.theory_of context, th) |>> Context.Theory;
   226       fun after_qed [[thm]] = ProofContext.theory (fn thy =>
       
   227         #1 (post_process (add_specification axiomatic (zip3 names cnames overloaded) (thy, thm))));
   230     in
   228     in
   231       IsarThy.theorem_i PureThy.internalK
   229       thy
   232         ("", [add_spec axiomatic (zip3 names cnames overloaded), post_proc])
   230       |> ProofContext.init
   233         (HOLogic.mk_Trueprop ex_prop, []) thy
   231       |> Proof.theorem_i PureThy.internalK NONE after_qed
   234     end
   232         (SOME "") ("", []) [(("", []), [(HOLogic.mk_Trueprop ex_prop, [])])]
       
   233     end;
   235 
   234 
   236 
   235 
   237 (* outer syntax *)
   236 (* outer syntax *)
   238 
   237 
   239 local structure P = OuterParse and K = OuterKeyword in
   238 local structure P = OuterParse and K = OuterKeyword in