src/Pure/Isar/expression.ML
changeset 59621 291934bac95e
parent 59616 eb59c6968219
child 59623 920889b0788e
equal deleted inserted replaced
59620:92d7d8e4f1bf 59621:291934bac95e
   627     val t = Logic.mk_conjunction_balanced ts;
   627     val t = Logic.mk_conjunction_balanced ts;
   628     val body = Object_Logic.atomize_term thy t;
   628     val body = Object_Logic.atomize_term thy t;
   629     val bodyT = Term.fastype_of body;
   629     val bodyT = Term.fastype_of body;
   630   in
   630   in
   631     if bodyT = propT
   631     if bodyT = propT
   632     then (t, propT, Thm.reflexive (Thm.cterm_of thy t))
   632     then (t, propT, Thm.reflexive (Thm.global_cterm_of thy t))
   633     else (body, bodyT, Object_Logic.atomize (Proof_Context.init_global thy) (Thm.cterm_of thy t))
   633     else (body, bodyT, Object_Logic.atomize (Proof_Context.init_global thy) (Thm.global_cterm_of thy t))
   634   end;
   634   end;
   635 
   635 
   636 (* achieve plain syntax for locale predicates (without "PROP") *)
   636 (* achieve plain syntax for locale predicates (without "PROP") *)
   637 
   637 
   638 fun aprop_tr' n c =
   638 fun aprop_tr' n c =
   682       (fn {context = ctxt, ...} =>
   682       (fn {context = ctxt, ...} =>
   683         rewrite_goals_tac ctxt [pred_def] THEN
   683         rewrite_goals_tac ctxt [pred_def] THEN
   684         compose_tac defs_ctxt (false, body_eq RS Drule.equal_elim_rule1, 1) 1 THEN
   684         compose_tac defs_ctxt (false, body_eq RS Drule.equal_elim_rule1, 1) 1 THEN
   685         compose_tac defs_ctxt
   685         compose_tac defs_ctxt
   686           (false,
   686           (false,
   687             Conjunction.intr_balanced (map (Thm.assume o Thm.cterm_of defs_thy) norm_ts), 0) 1);
   687             Conjunction.intr_balanced (map (Thm.assume o Thm.global_cterm_of defs_thy) norm_ts), 0) 1);
   688 
   688 
   689     val conjuncts =
   689     val conjuncts =
   690       (Drule.equal_elim_rule2 OF
   690       (Drule.equal_elim_rule2 OF
   691         [body_eq, rewrite_rule defs_ctxt [pred_def] (Thm.assume (Thm.cterm_of defs_thy statement))])
   691         [body_eq, rewrite_rule defs_ctxt [pred_def] (Thm.assume (Thm.global_cterm_of defs_thy statement))])
   692       |> Conjunction.elim_balanced (length ts);
   692       |> Conjunction.elim_balanced (length ts);
   693 
   693 
   694     val (_, axioms_ctxt) = defs_ctxt
   694     val (_, axioms_ctxt) = defs_ctxt
   695       |> Assumption.add_assumes (maps (#hyps o Thm.crep_thm) (defs @ conjuncts));
   695       |> Assumption.add_assumes (maps (#hyps o Thm.crep_thm) (defs @ conjuncts));
   696     val axioms = ts ~~ conjuncts |> map (fn (t, ax) =>
   696     val axioms = ts ~~ conjuncts |> map (fn (t, ax) =>
   703 (* main predicate definition function *)
   703 (* main predicate definition function *)
   704 
   704 
   705 fun define_preds binding parms (((exts, exts'), (ints, ints')), defs) thy =
   705 fun define_preds binding parms (((exts, exts'), (ints, ints')), defs) thy =
   706   let
   706   let
   707     val ctxt = Proof_Context.init_global thy;
   707     val ctxt = Proof_Context.init_global thy;
   708     val defs' = map (Thm.cterm_of thy #> Assumption.assume ctxt #> Drule.abs_def) defs;
   708     val defs' = map (Thm.global_cterm_of thy #> Assumption.assume ctxt #> Drule.abs_def) defs;
   709 
   709 
   710     val (a_pred, a_intro, a_axioms, thy'') =
   710     val (a_pred, a_intro, a_axioms, thy'') =
   711       if null exts then (NONE, NONE, [], thy)
   711       if null exts then (NONE, NONE, [], thy)
   712       else
   712       else
   713         let
   713         let
   755       |> apfst (curry Notes "")
   755       |> apfst (curry Notes "")
   756   | assumes_to_notes e axms = (e, axms);
   756   | assumes_to_notes e axms = (e, axms);
   757 
   757 
   758 fun defines_to_notes ctxt (Defines defs) =
   758 fun defines_to_notes ctxt (Defines defs) =
   759       Notes ("", map (fn (a, (def, _)) =>
   759       Notes ("", map (fn (a, (def, _)) =>
   760         (a, [([Assumption.assume ctxt (Proof_Context.cterm_of ctxt def)],
   760         (a, [([Assumption.assume ctxt (Thm.cterm_of ctxt def)],
   761           [(Attrib.internal o K) Locale.witness_add])])) defs)
   761           [(Attrib.internal o K) Locale.witness_add])])) defs)
   762   | defines_to_notes _ e = e;
   762   | defines_to_notes _ e = e;
   763 
   763 
   764 fun is_hyp (elem as Assumes asms) = true
   764 fun is_hyp (elem as Assumes asms) = true
   765   | is_hyp (elem as Defines defs) = true
   765   | is_hyp (elem as Defines defs) = true
   804     val hyp_spec = filter is_hyp body_elems;
   804     val hyp_spec = filter is_hyp body_elems;
   805 
   805 
   806     val notes =
   806     val notes =
   807       if is_some asm then
   807       if is_some asm then
   808         [("", [((Binding.conceal (Binding.suffix_name ("_" ^ axiomsN) binding), []),
   808         [("", [((Binding.conceal (Binding.suffix_name ("_" ^ axiomsN) binding), []),
   809           [([Assumption.assume pred_ctxt (Thm.cterm_of thy' (the asm))],
   809           [([Assumption.assume pred_ctxt (Thm.global_cterm_of thy' (the asm))],
   810             [(Attrib.internal o K) Locale.witness_add])])])]
   810             [(Attrib.internal o K) Locale.witness_add])])])]
   811       else [];
   811       else [];
   812 
   812 
   813     val notes' =
   813     val notes' =
   814       body_elems
   814       body_elems