src/Pure/Isar/expression.ML
changeset 36610 bafd82950e24
parent 35845 e5980f0ad025
child 36674 d95f39448121
equal deleted inserted replaced
36609:6ed6112f0a95 36610:bafd82950e24
   640       thy
   640       thy
   641       |> bodyT = propT ? Sign.add_advanced_trfuns ([], [], [aprop_tr' (length args) name], [])
   641       |> bodyT = propT ? Sign.add_advanced_trfuns ([], [], [aprop_tr' (length args) name], [])
   642       |> Sign.declare_const ((Binding.conceal binding, predT), NoSyn) |> snd
   642       |> Sign.declare_const ((Binding.conceal binding, predT), NoSyn) |> snd
   643       |> PureThy.add_defs false
   643       |> PureThy.add_defs false
   644         [((Binding.conceal (Thm.def_binding binding), Logic.mk_equals (head, body)), [])];
   644         [((Binding.conceal (Thm.def_binding binding), Logic.mk_equals (head, body)), [])];
   645     val defs_ctxt = ProofContext.init defs_thy |> Variable.declare_term head;
   645     val defs_ctxt = ProofContext.init_global defs_thy |> Variable.declare_term head;
   646 
   646 
   647     val cert = Thm.cterm_of defs_thy;
   647     val cert = Thm.cterm_of defs_thy;
   648 
   648 
   649     val intro = Goal.prove_global defs_thy [] norm_ts statement (fn _ =>
   649     val intro = Goal.prove_global defs_thy [] norm_ts statement (fn _ =>
   650       MetaSimplifier.rewrite_goals_tac [pred_def] THEN
   650       MetaSimplifier.rewrite_goals_tac [pred_def] THEN
   727     val name = Sign.full_name thy binding;
   727     val name = Sign.full_name thy binding;
   728     val _ = Locale.defined thy name andalso
   728     val _ = Locale.defined thy name andalso
   729       error ("Duplicate definition of locale " ^ quote name);
   729       error ("Duplicate definition of locale " ^ quote name);
   730 
   730 
   731     val ((fixed, deps, body_elems), (parms, ctxt')) =
   731     val ((fixed, deps, body_elems), (parms, ctxt')) =
   732       prep_decl raw_import I raw_body (ProofContext.init thy);
   732       prep_decl raw_import I raw_body (ProofContext.init_global thy);
   733     val text as (((_, exts'), _), defs) = eval ctxt' deps body_elems;
   733     val text as (((_, exts'), _), defs) = eval ctxt' deps body_elems;
   734 
   734 
   735     val predicate_binding =
   735     val predicate_binding =
   736       if Binding.is_empty raw_predicate_binding then binding
   736       if Binding.is_empty raw_predicate_binding then binding
   737       else raw_predicate_binding;
   737       else raw_predicate_binding;
   793 local
   793 local
   794 
   794 
   795 fun gen_interpretation prep_expr parse_prop prep_attr
   795 fun gen_interpretation prep_expr parse_prop prep_attr
   796     expression equations theory =
   796     expression equations theory =
   797   let
   797   let
   798     val ((propss, deps, export), expr_ctxt) = ProofContext.init theory
   798     val ((propss, deps, export), expr_ctxt) = ProofContext.init_global theory
   799       |> prep_expr expression;
   799       |> prep_expr expression;
   800 
   800 
   801     val eqns = map (parse_prop expr_ctxt o snd) equations |> Syntax.check_terms expr_ctxt;
   801     val eqns = map (parse_prop expr_ctxt o snd) equations |> Syntax.check_terms expr_ctxt;
   802     val attrss = map ((apsnd o map) (prep_attr theory) o fst) equations;
   802     val attrss = map ((apsnd o map) (prep_attr theory) o fst) equations;
   803     val goal_ctxt = fold Variable.auto_fixes eqns expr_ctxt;
   803     val goal_ctxt = fold Variable.auto_fixes eqns expr_ctxt;
   807       let
   807       let
   808         val eqns = map (Morphism.thm (export' $> export)) raw_eqns;
   808         val eqns = map (Morphism.thm (export' $> export)) raw_eqns;
   809         val eqn_attrss = map2 (fn attrs => fn eqn =>
   809         val eqn_attrss = map2 (fn attrs => fn eqn =>
   810           ((apsnd o map) (Attrib.attribute_i thy) attrs, [([eqn], [])])) attrss eqns;
   810           ((apsnd o map) (Attrib.attribute_i thy) attrs, [([eqn], [])])) attrss eqns;
   811         fun meta_rewrite thy =
   811         fun meta_rewrite thy =
   812           map (Local_Defs.meta_rewrite_rule (ProofContext.init thy) #> Drule.abs_def) o maps snd;
   812           map (Local_Defs.meta_rewrite_rule (ProofContext.init_global thy) #> Drule.abs_def) o
       
   813             maps snd;
   813       in
   814       in
   814         thy
   815         thy
   815         |> PureThy.note_thmss Thm.lemmaK eqn_attrss
   816         |> PureThy.note_thmss Thm.lemmaK eqn_attrss
   816         |-> (fn facts => `(fn thy => meta_rewrite thy facts))
   817         |-> (fn facts => `(fn thy => meta_rewrite thy facts))
   817       end;
   818       end;