src/Pure/Isar/expression.ML
changeset 29210 4025459e3f83
parent 29208 b0c81b9a0133
child 29211 ab99da3854af
equal deleted inserted replaced
29209:c2a750c8a37b 29210:4025459e3f83
    26     Proof.context
    26     Proof.context
    27 
    27 
    28   (* Interpretation *)
    28   (* Interpretation *)
    29   val sublocale_cmd: string -> expression -> theory -> Proof.state;
    29   val sublocale_cmd: string -> expression -> theory -> Proof.state;
    30   val sublocale: string -> expression_i -> theory -> Proof.state;
    30   val sublocale: string -> expression_i -> theory -> Proof.state;
    31   val interpretation_cmd: expression -> theory -> Proof.state;
    31   val interpretation_cmd: expression -> Facts.ref list -> theory -> Proof.state;
    32   val interpretation: expression_i -> theory -> Proof.state;
    32   val interpretation: expression_i -> thm list -> theory -> Proof.state;
    33   val interpret_cmd: expression -> bool -> Proof.state -> Proof.state;
    33   val interpret_cmd: expression -> bool -> Proof.state -> Proof.state;
    34   val interpret: expression_i -> bool -> Proof.state -> Proof.state;
    34   val interpret: expression_i -> bool -> Proof.state -> Proof.state;
    35 end;
    35 end;
    36 
    36 
    37 
    37 
   784 
   784 
   785 (** Interpretation in theories **)
   785 (** Interpretation in theories **)
   786 
   786 
   787 local
   787 local
   788 
   788 
   789 fun gen_interpretation prep_expr
   789 fun gen_interpretation prep_expr prep_thms
   790     expression thy =
   790     expression equations thy =
   791   let
   791   let
   792     val ctxt = ProofContext.init thy;
   792     val ctxt = ProofContext.init thy;
   793 
   793 
       
   794     val eqns = equations |> prep_thms ctxt |>
       
   795       map (Drule.abs_def o LocalDefs.meta_rewrite_rule ctxt);
       
   796     val eq_morph =
       
   797       Morphism.term_morphism (MetaSimplifier.rewrite_term thy eqns []) $>
       
   798       Morphism.thm_morphism (MetaSimplifier.rewrite_rule eqns);
       
   799 
   794     val ((propss, regs, export), goal_ctxt) = prep_expr expression ctxt;
   800     val ((propss, regs, export), goal_ctxt) = prep_expr expression ctxt;
   795     
   801 
   796     fun store_reg ((name, morph), thms) =
   802     fun store_reg ((name, morph), thms) =
   797       let
   803       let
   798         val morph' = morph $> Element.satisfy_morphism thms $> export;
   804         val morph' = morph $> Element.satisfy_morphism thms;
   799       in
   805       in
   800         NewLocale.add_global_registration (name, morph') #>
   806         NewLocale.add_global_registration (name, (morph', export)) #>
   801         NewLocale.activate_global_facts (name, morph')
   807         NewLocale.amend_global_registration (name, morph') eq_morph #>
       
   808         NewLocale.activate_global_facts (name, morph' $> eq_morph $> export)
   802       end;
   809       end;
   803 
   810 
   804     fun after_qed results =
   811     fun after_qed results =
   805       ProofContext.theory (fold store_reg (regs ~~ prep_result propss results));
   812       ProofContext.theory (fold store_reg (regs ~~ prep_result propss results));
   806   in
   813   in
   809       Element.refine_witness |> Seq.hd
   816       Element.refine_witness |> Seq.hd
   810   end;
   817   end;
   811 
   818 
   812 in
   819 in
   813 
   820 
   814 fun interpretation_cmd x = gen_interpretation read_goal_expression x;
   821 fun interpretation_cmd x = gen_interpretation read_goal_expression
   815 fun interpretation x = gen_interpretation cert_goal_expression x;
   822   (fn ctxt => map (ProofContext.get_fact ctxt) #> flat) x;
       
   823 fun interpretation x = gen_interpretation cert_goal_expression (K I) x;
   816 
   824 
   817 end;
   825 end;
   818 
   826 
   819 
   827 
   820 (** Interpretation in proof contexts **)
   828 (** Interpretation in proof contexts **)