src/Pure/Isar/element.ML
changeset 19897 fe661eb3b0e7
parent 19866 d47f32a4964a
child 19931 fb32b43e7f80
equal deleted inserted replaced
19896:286d950883bc 19897:fe661eb3b0e7
   212     | a => Pretty.block [Pretty.command kind, Pretty.brk 1, Pretty.str (Sign.base_name a ^ ":")])
   212     | a => Pretty.block [Pretty.command kind, Pretty.brk 1, Pretty.str (Sign.base_name a ^ ":")])
   213   in Pretty.block (Pretty.fbreaks (head :: prts)) end;
   213   in Pretty.block (Pretty.fbreaks (head :: prts)) end;
   214 
   214 
   215 fun obtain prop ctxt =
   215 fun obtain prop ctxt =
   216   let
   216   let
   217     val xs = ProofContext.rename_frees ctxt [] (Logic.strip_params prop);
   217     val xs = Variable.rename_wrt ctxt [] (Logic.strip_params prop);
   218     val args = rev (map Free xs);
   218     val args = rev (map Free xs);
   219     val As = Logic.strip_assums_hyp prop |> map (fn t => Term.subst_bounds (args, t));
   219     val As = Logic.strip_assums_hyp prop |> map (fn t => Term.subst_bounds (args, t));
   220     val ctxt' = ctxt |> fold ProofContext.declare_term args;
   220     val ctxt' = ctxt |> fold Variable.declare_term args;
   221   in (("", (map (apsnd SOME) xs, As)), ctxt') end;
   221   in (("", (map (apsnd SOME) xs, As)), ctxt') end;
   222 
   222 
   223 in
   223 in
   224 
   224 
   225 fun pretty_statement ctxt kind raw_th =
   225 fun pretty_statement ctxt kind raw_th =
   233         val C' = Var ((AutoBind.thesisN, Thm.maxidx_of th + 1), Term.fastype_of C);
   233         val C' = Var ((AutoBind.thesisN, Thm.maxidx_of th + 1), Term.fastype_of C);
   234       in Term.subst_atomic [(C, C')] t end;
   234       in Term.subst_atomic [(C, C')] t end;
   235 
   235 
   236     val raw_prop =
   236     val raw_prop =
   237       Thm.prop_of th
   237       Thm.prop_of th
   238       |> singleton (ProofContext.monomorphic ctxt)
   238       |> singleton (Variable.monomorphic ctxt)
   239       |> K (ObjectLogic.is_elim th) ? standard_thesis
   239       |> K (ObjectLogic.is_elim th) ? standard_thesis
   240       |> Term.zero_var_indexes;
   240       |> Term.zero_var_indexes;
   241 
   241 
   242     val vars = Term.add_vars raw_prop [];
   242     val vars = Term.add_vars raw_prop [];
   243     val frees = ProofContext.rename_frees ctxt [raw_prop] (map (apfst fst) vars);
   243     val frees = Variable.rename_wrt ctxt [raw_prop] (map (apfst fst) vars);
   244     val fixes = rev (filter_out (fn (x, _) => x = AutoBind.thesisN) frees);
   244     val fixes = rev (filter_out (fn (x, _) => x = AutoBind.thesisN) frees);
   245 
   245 
   246     val prop = Term.instantiate ([], vars ~~ map Free frees) raw_prop;
   246     val prop = Term.instantiate ([], vars ~~ map Free frees) raw_prop;
   247     val (prems, concl) = Logic.strip_horn prop;
   247     val (prems, concl) = Logic.strip_horn prop;
   248     val thesis = ObjectLogic.fixed_judgment thy AutoBind.thesisN;
   248     val thesis = ObjectLogic.fixed_judgment thy AutoBind.thesisN;
   250   in
   250   in
   251     pretty_ctxt ctxt (Fixes (map (fn (x, T) => (x, SOME T, NoSyn)) fixes)) @
   251     pretty_ctxt ctxt (Fixes (map (fn (x, T) => (x, SOME T, NoSyn)) fixes)) @
   252     pretty_ctxt ctxt (Assumes (map (fn t => (("", []), [(t, [])])) asms)) @
   252     pretty_ctxt ctxt (Assumes (map (fn t => (("", []), [(t, [])])) asms)) @
   253     pretty_stmt ctxt
   253     pretty_stmt ctxt
   254      (if null cases then Shows [(("", []), [(concl, [])])]
   254      (if null cases then Shows [(("", []), [(concl, [])])]
   255       else Obtains (#1 (fold_map obtain cases (ctxt |> ProofContext.declare_term prop))))
   255       else Obtains (#1 (fold_map obtain cases (ctxt |> Variable.declare_term prop))))
   256   end |> thm_name kind raw_th;
   256   end |> thm_name kind raw_th;
   257 
   257 
   258 end;
   258 end;
   259 
   259 
   260 
   260