src/Pure/proofterm.ML
changeset 71777 3875815f5967
parent 71533 d7175626d61e
child 74155 0faa68dedce5
equal deleted inserted replaced
71776:5ef7f374e0f8 71777:3875815f5967
    20    | AbsP of string * term option * proof
    20    | AbsP of string * term option * proof
    21    | % of proof * term option
    21    | % of proof * term option
    22    | %% of proof * proof
    22    | %% of proof * proof
    23    | Hyp of term
    23    | Hyp of term
    24    | PAxm of string * term * typ list option
    24    | PAxm of string * term * typ list option
    25    | OfClass of typ * class
    25    | PClass of typ * class
    26    | Oracle of string * term * typ list option
    26    | Oracle of string * term * typ list option
    27    | PThm of thm_header * thm_body
    27    | PThm of thm_header * thm_body
    28   and proof_body = PBody of
    28   and proof_body = PBody of
    29     {oracles: ((string * Position.T) * term option) Ord_List.T,
    29     {oracles: ((string * Position.T) * term option) Ord_List.T,
    30      thms: (serial * thm_node) Ord_List.T,
    30      thms: (serial * thm_node) Ord_List.T,
   212  | AbsP of string * term option * proof
   212  | AbsP of string * term option * proof
   213  | op % of proof * term option
   213  | op % of proof * term option
   214  | op %% of proof * proof
   214  | op %% of proof * proof
   215  | Hyp of term
   215  | Hyp of term
   216  | PAxm of string * term * typ list option
   216  | PAxm of string * term * typ list option
   217  | OfClass of typ * class
   217  | PClass of typ * class
   218  | Oracle of string * term * typ list option
   218  | Oracle of string * term * typ list option
   219  | PThm of thm_header * thm_body
   219  | PThm of thm_header * thm_body
   220 and proof_body = PBody of
   220 and proof_body = PBody of
   221   {oracles: ((string * Position.T) * term option) Ord_List.T,
   221   {oracles: ((string * Position.T) * term option) Ord_List.T,
   222    thms: (serial * thm_node) Ord_List.T,
   222    thms: (serial * thm_node) Ord_List.T,
   366   fn AbsP (a, b, c) => ([a], pair (option (term consts)) (proof consts) (b, c)),
   366   fn AbsP (a, b, c) => ([a], pair (option (term consts)) (proof consts) (b, c)),
   367   fn a % b => ([], pair (proof consts) (option (term consts)) (a, b)),
   367   fn a % b => ([], pair (proof consts) (option (term consts)) (a, b)),
   368   fn a %% b => ([], pair (proof consts) (proof consts) (a, b)),
   368   fn a %% b => ([], pair (proof consts) (proof consts) (a, b)),
   369   fn Hyp a => ([], term consts a),
   369   fn Hyp a => ([], term consts a),
   370   fn PAxm (a, b, c) => ([a], pair (term consts) (option (list typ)) (b, c)),
   370   fn PAxm (a, b, c) => ([a], pair (term consts) (option (list typ)) (b, c)),
   371   fn OfClass (a, b) => ([b], typ a),
   371   fn PClass (a, b) => ([b], typ a),
   372   fn Oracle (a, b, c) => ([a], pair (term consts) (option (list typ)) (b, c)),
   372   fn Oracle (a, b, c) => ([a], pair (term consts) (option (list typ)) (b, c)),
   373   fn PThm ({serial, pos, theory_name, name, prop, types}, Thm_Body {open_proof, body, ...}) =>
   373   fn PThm ({serial, pos, theory_name, name, prop, types}, Thm_Body {open_proof, body, ...}) =>
   374     ([int_atom serial, theory_name, name],
   374     ([int_atom serial, theory_name, name],
   375       pair (list properties) (pair (term consts) (pair (option (list typ)) (proof_body consts)))
   375       pair (list properties) (pair (term consts) (pair (option (list typ)) (proof_body consts)))
   376         (map Position.properties_of pos, (prop, (types, map_proof_of open_proof (Future.join body)))))]
   376         (map Position.properties_of pos, (prop, (types, map_proof_of open_proof (Future.join body)))))]
   397   fn AbsP (a, SOME b, c) => ([a], pair (standard_term consts) (standard_proof consts) (b, c)),
   397   fn AbsP (a, SOME b, c) => ([a], pair (standard_term consts) (standard_proof consts) (b, c)),
   398   fn a % SOME b => ([], pair (standard_proof consts) (standard_term consts) (a, b)),
   398   fn a % SOME b => ([], pair (standard_proof consts) (standard_term consts) (a, b)),
   399   fn a %% b => ([], pair (standard_proof consts) (standard_proof consts) (a, b)),
   399   fn a %% b => ([], pair (standard_proof consts) (standard_proof consts) (a, b)),
   400   fn Hyp a => ([], standard_term consts a),
   400   fn Hyp a => ([], standard_term consts a),
   401   fn PAxm (name, _, SOME Ts) => ([name], list typ Ts),
   401   fn PAxm (name, _, SOME Ts) => ([name], list typ Ts),
   402   fn OfClass (T, c) => ([c], typ T),
   402   fn PClass (T, c) => ([c], typ T),
   403   fn Oracle (name, prop, SOME Ts) => ([name], pair (standard_term consts) (list typ) (prop, Ts)),
   403   fn Oracle (name, prop, SOME Ts) => ([name], pair (standard_term consts) (list typ) (prop, Ts)),
   404   fn PThm ({serial, theory_name, name, types = SOME Ts, ...}, _) =>
   404   fn PThm ({serial, theory_name, name, types = SOME Ts, ...}, _) =>
   405     ([int_atom serial, theory_name, name], list typ Ts)];
   405     ([int_atom serial, theory_name, name], list typ Ts)];
   406 
   406 
   407 in
   407 in
   427   fn ([a], b) => let val (c, d) = pair (option (term consts)) (proof consts) b in AbsP (a, c, d) end,
   427   fn ([a], b) => let val (c, d) = pair (option (term consts)) (proof consts) b in AbsP (a, c, d) end,
   428   fn ([], a) => op % (pair (proof consts) (option (term consts)) a),
   428   fn ([], a) => op % (pair (proof consts) (option (term consts)) a),
   429   fn ([], a) => op %% (pair (proof consts) (proof consts) a),
   429   fn ([], a) => op %% (pair (proof consts) (proof consts) a),
   430   fn ([], a) => Hyp (term consts a),
   430   fn ([], a) => Hyp (term consts a),
   431   fn ([a], b) => let val (c, d) = pair (term consts) (option (list typ)) b in PAxm (a, c, d) end,
   431   fn ([a], b) => let val (c, d) = pair (term consts) (option (list typ)) b in PAxm (a, c, d) end,
   432   fn ([b], a) => OfClass (typ a, b),
   432   fn ([b], a) => PClass (typ a, b),
   433   fn ([a], b) => let val (c, d) = pair (term consts) (option (list typ)) b in Oracle (a, c, d) end,
   433   fn ([a], b) => let val (c, d) = pair (term consts) (option (list typ)) b in Oracle (a, c, d) end,
   434   fn ([a, b, c], d) =>
   434   fn ([a, b, c], d) =>
   435     let
   435     let
   436       val ((e, (f, (g, h)))) =
   436       val ((e, (f, (g, h)))) =
   437         pair (list properties) (pair (term consts) (pair (option (list typ)) (proof_body consts))) d;
   437         pair (list properties) (pair (term consts) (pair (option (list typ)) (proof_body consts))) d;
   514             handle Same.SAME => prf % Same.map_option term t)
   514             handle Same.SAME => prf % Same.map_option term t)
   515       | proof (prf1 %% prf2) =
   515       | proof (prf1 %% prf2) =
   516           (proof prf1 %% Same.commit proof prf2
   516           (proof prf1 %% Same.commit proof prf2
   517             handle Same.SAME => prf1 %% proof prf2)
   517             handle Same.SAME => prf1 %% proof prf2)
   518       | proof (PAxm (a, prop, SOME Ts)) = PAxm (a, prop, SOME (typs Ts))
   518       | proof (PAxm (a, prop, SOME Ts)) = PAxm (a, prop, SOME (typs Ts))
   519       | proof (OfClass T_c) = ofclass T_c
   519       | proof (PClass T_c) = ofclass T_c
   520       | proof (Oracle (a, prop, SOME Ts)) = Oracle (a, prop, SOME (typs Ts))
   520       | proof (Oracle (a, prop, SOME Ts)) = Oracle (a, prop, SOME (typs Ts))
   521       | proof (PThm ({serial, pos, theory_name, name, prop, types = SOME Ts}, thm_body)) =
   521       | proof (PThm ({serial, pos, theory_name, name, prop, types = SOME Ts}, thm_body)) =
   522           PThm (thm_header serial pos theory_name name prop (SOME (typs Ts)), thm_body)
   522           PThm (thm_header serial pos theory_name name prop (SOME (typs Ts)), thm_body)
   523       | proof _ = raise Same.SAME;
   523       | proof _ = raise Same.SAME;
   524   in proof end;
   524   in proof end;
   525 
   525 
   526 fun map_proof_terms_same term typ = map_proof_same term typ (fn (T, c) => OfClass (typ T, c));
   526 fun map_proof_terms_same term typ = map_proof_same term typ (fn (T, c) => PClass (typ T, c));
   527 fun map_proof_types_same typ = map_proof_terms_same (Term_Subst.map_types_same typ) typ;
   527 fun map_proof_types_same typ = map_proof_terms_same (Term_Subst.map_types_same typ) typ;
   528 
   528 
   529 fun same eq f x =
   529 fun same eq f x =
   530   let val x' = f x
   530   let val x' = f x
   531   in if eq (x, x') then raise Same.SAME else x' end;
   531   in if eq (x, x') then raise Same.SAME else x' end;
   548   | fold_proof_terms_types f g (prf % SOME t) = fold_proof_terms_types f g prf #> f t
   548   | fold_proof_terms_types f g (prf % SOME t) = fold_proof_terms_types f g prf #> f t
   549   | fold_proof_terms_types f g (prf % NONE) = fold_proof_terms_types f g prf
   549   | fold_proof_terms_types f g (prf % NONE) = fold_proof_terms_types f g prf
   550   | fold_proof_terms_types f g (prf1 %% prf2) =
   550   | fold_proof_terms_types f g (prf1 %% prf2) =
   551       fold_proof_terms_types f g prf1 #> fold_proof_terms_types f g prf2
   551       fold_proof_terms_types f g prf1 #> fold_proof_terms_types f g prf2
   552   | fold_proof_terms_types _ g (PAxm (_, _, SOME Ts)) = fold g Ts
   552   | fold_proof_terms_types _ g (PAxm (_, _, SOME Ts)) = fold g Ts
   553   | fold_proof_terms_types _ g (OfClass (T, _)) = g T
   553   | fold_proof_terms_types _ g (PClass (T, _)) = g T
   554   | fold_proof_terms_types _ g (Oracle (_, _, SOME Ts)) = fold g Ts
   554   | fold_proof_terms_types _ g (Oracle (_, _, SOME Ts)) = fold g Ts
   555   | fold_proof_terms_types _ g (PThm ({types = SOME Ts, ...}, _)) = fold g Ts
   555   | fold_proof_terms_types _ g (PThm ({types = SOME Ts, ...}, _)) = fold g Ts
   556   | fold_proof_terms_types _ _ _ = I;
   556   | fold_proof_terms_types _ _ _ = I;
   557 
   557 
   558 fun maxidx_proof prf = fold_proof_terms_types Term.maxidx_term Term.maxidx_typ prf;
   558 fun maxidx_proof prf = fold_proof_terms_types Term.maxidx_term Term.maxidx_typ prf;
   562   | size_of_proof (prf % _) = 1 + size_of_proof prf
   562   | size_of_proof (prf % _) = 1 + size_of_proof prf
   563   | size_of_proof (prf1 %% prf2) = size_of_proof prf1 + size_of_proof prf2
   563   | size_of_proof (prf1 %% prf2) = size_of_proof prf1 + size_of_proof prf2
   564   | size_of_proof _ = 1;
   564   | size_of_proof _ = 1;
   565 
   565 
   566 fun change_types types (PAxm (name, prop, _)) = PAxm (name, prop, types)
   566 fun change_types types (PAxm (name, prop, _)) = PAxm (name, prop, types)
   567   | change_types (SOME [T]) (OfClass (_, c)) = OfClass (T, c)
   567   | change_types (SOME [T]) (PClass (_, c)) = PClass (T, c)
   568   | change_types types (Oracle (name, prop, _)) = Oracle (name, prop, types)
   568   | change_types types (Oracle (name, prop, _)) = Oracle (name, prop, types)
   569   | change_types types (PThm ({serial, pos, theory_name, name, prop, types = _}, thm_body)) =
   569   | change_types types (PThm ({serial, pos, theory_name, name, prop, types = _}, thm_body)) =
   570       PThm (thm_header serial pos theory_name name prop types, thm_body)
   570       PThm (thm_header serial pos theory_name name prop types, thm_body)
   571   | change_types _ prf = prf;
   571   | change_types _ prf = prf;
   572 
   572 
   708       | norm (prf1 %% prf2) =
   708       | norm (prf1 %% prf2) =
   709           (norm prf1 %% Same.commit norm prf2
   709           (norm prf1 %% Same.commit norm prf2
   710             handle Same.SAME => prf1 %% norm prf2)
   710             handle Same.SAME => prf1 %% norm prf2)
   711       | norm (PAxm (s, prop, Ts)) =
   711       | norm (PAxm (s, prop, Ts)) =
   712           PAxm (s, prop, Same.map_option (htypeTs Envir.norm_types_same) Ts)
   712           PAxm (s, prop, Same.map_option (htypeTs Envir.norm_types_same) Ts)
   713       | norm (OfClass (T, c)) =
   713       | norm (PClass (T, c)) =
   714           OfClass (htypeT Envir.norm_type_same T, c)
   714           PClass (htypeT Envir.norm_type_same T, c)
   715       | norm (Oracle (s, prop, Ts)) =
   715       | norm (Oracle (s, prop, Ts)) =
   716           Oracle (s, prop, Same.map_option (htypeTs Envir.norm_types_same) Ts)
   716           Oracle (s, prop, Same.map_option (htypeTs Envir.norm_types_same) Ts)
   717       | norm (PThm ({serial = i, pos = p, theory_name, name = a, prop = t, types = Ts}, thm_body)) =
   717       | norm (PThm ({serial = i, pos = p, theory_name, name = a, prop = t, types = Ts}, thm_body)) =
   718           PThm (thm_header i p theory_name a t
   718           PThm (thm_header i p theory_name a t
   719             (Same.map_option (htypeTs Envir.norm_types_same) Ts), thm_body)
   719             (Same.map_option (htypeTs Envir.norm_types_same) Ts), thm_body)
   988           handle Same.SAME => prf % Same.map_option (same (op =) (lift'' Us Ts)) t)
   988           handle Same.SAME => prf % Same.map_option (same (op =) (lift'' Us Ts)) t)
   989       | lift' Us Ts (prf1 %% prf2) = (lift' Us Ts prf1 %% lifth' Us Ts prf2
   989       | lift' Us Ts (prf1 %% prf2) = (lift' Us Ts prf1 %% lifth' Us Ts prf2
   990           handle Same.SAME => prf1 %% lift' Us Ts prf2)
   990           handle Same.SAME => prf1 %% lift' Us Ts prf2)
   991       | lift' _ _ (PAxm (s, prop, Ts)) =
   991       | lift' _ _ (PAxm (s, prop, Ts)) =
   992           PAxm (s, prop, (Same.map_option o Same.map) (Logic.incr_tvar_same inc) Ts)
   992           PAxm (s, prop, (Same.map_option o Same.map) (Logic.incr_tvar_same inc) Ts)
   993       | lift' _ _ (OfClass (T, c)) =
   993       | lift' _ _ (PClass (T, c)) =
   994           OfClass (Logic.incr_tvar_same inc T, c)
   994           PClass (Logic.incr_tvar_same inc T, c)
   995       | lift' _ _ (Oracle (s, prop, Ts)) =
   995       | lift' _ _ (Oracle (s, prop, Ts)) =
   996           Oracle (s, prop, (Same.map_option o Same.map) (Logic.incr_tvar_same inc) Ts)
   996           Oracle (s, prop, (Same.map_option o Same.map) (Logic.incr_tvar_same inc) Ts)
   997       | lift' _ _ (PThm ({serial = i, pos = p, theory_name, name = s, prop, types = Ts}, thm_body)) =
   997       | lift' _ _ (PThm ({serial = i, pos = p, theory_name, name = s, prop, types = Ts}, thm_body)) =
   998           PThm (thm_header i p theory_name s prop
   998           PThm (thm_header i p theory_name s prop
   999             ((Same.map_option o Same.map) (Logic.incr_tvar inc) Ts), thm_body)
   999             ((Same.map_option o Same.map) (Logic.incr_tvar inc) Ts), thm_body)
  1160 fun const_proof mk name prop =
  1160 fun const_proof mk name prop =
  1161   let
  1161   let
  1162     val args = prop_args prop;
  1162     val args = prop_args prop;
  1163     val ({outer_constraints, ...}, prop1) = Logic.unconstrainT [] prop;
  1163     val ({outer_constraints, ...}, prop1) = Logic.unconstrainT [] prop;
  1164     val head = mk (name, prop1, NONE);
  1164     val head = mk (name, prop1, NONE);
  1165   in proof_combP (proof_combt' (head, args), map OfClass outer_constraints) end;
  1165   in proof_combP (proof_combt' (head, args), map PClass outer_constraints) end;
  1166 
  1166 
  1167 val axm_proof = const_proof PAxm;
  1167 val axm_proof = const_proof PAxm;
  1168 val oracle_proof = const_proof Oracle;
  1168 val oracle_proof = const_proof Oracle;
  1169 
  1169 
  1170 val shrink_proof =
  1170 val shrink_proof =
  1196              orelse has_duplicates (op =)
  1196              orelse has_duplicates (op =)
  1197                (Library.foldl (fn (js, SOME (Bound j)) => j :: js | (js, _) => js) ([], ts))
  1197                (Library.foldl (fn (js, SOME (Bound j)) => j :: js | (js, _) => js) ([], ts))
  1198              orelse exists #1 prfs then [i] else [], false, map (pair false) ts, prf)
  1198              orelse exists #1 prfs then [i] else [], false, map (pair false) ts, prf)
  1199       | shrink' _ _ ts _ (Hyp t) = ([], false, map (pair false) ts, Hyp t)
  1199       | shrink' _ _ ts _ (Hyp t) = ([], false, map (pair false) ts, Hyp t)
  1200       | shrink' _ _ ts _ (prf as MinProof) = ([], false, map (pair false) ts, prf)
  1200       | shrink' _ _ ts _ (prf as MinProof) = ([], false, map (pair false) ts, prf)
  1201       | shrink' _ _ ts _ (prf as OfClass _) = ([], false, map (pair false) ts, prf)
  1201       | shrink' _ _ ts _ (prf as PClass _) = ([], false, map (pair false) ts, prf)
  1202       | shrink' _ _ ts prfs prf =
  1202       | shrink' _ _ ts prfs prf =
  1203           let
  1203           let
  1204             val prop =
  1204             val prop =
  1205               (case prf of
  1205               (case prf of
  1206                 PAxm (_, prop, _) => prop
  1206                 PAxm (_, prop, _) => prop
  1376       | mtch Ts i j inst (prf1, AbsP (_, _, prf2)) =
  1376       | mtch Ts i j inst (prf1, AbsP (_, _, prf2)) =
  1377           mtch Ts (i+1) j inst (incr_pboundvars 1 0 prf1 %% PBound 0, prf2)
  1377           mtch Ts (i+1) j inst (incr_pboundvars 1 0 prf1 %% PBound 0, prf2)
  1378       | mtch Ts i j inst (PAxm (s1, _, opTs), PAxm (s2, _, opUs)) =
  1378       | mtch Ts i j inst (PAxm (s1, _, opTs), PAxm (s2, _, opUs)) =
  1379           if s1 = s2 then optmatch matchTs inst (opTs, opUs)
  1379           if s1 = s2 then optmatch matchTs inst (opTs, opUs)
  1380           else raise PMatch
  1380           else raise PMatch
  1381       | mtch Ts i j inst (OfClass (T1, c1), OfClass (T2, c2)) =
  1381       | mtch Ts i j inst (PClass (T1, c1), PClass (T2, c2)) =
  1382           if c1 = c2 then matchT inst (T1, T2)
  1382           if c1 = c2 then matchT inst (T1, T2)
  1383           else raise PMatch
  1383           else raise PMatch
  1384       | mtch Ts i j inst
  1384       | mtch Ts i j inst
  1385             (PThm ({name = name1, prop = prop1, types = types1, ...}, _),
  1385             (PThm ({name = name1, prop = prop1, types = types1, ...}, _),
  1386               PThm ({name = name2, prop = prop2, types = types2, ...}, _)) =
  1386               PThm ({name = name2, prop = prop2, types = types2, ...}, _)) =
  1425       | subst plev tlev (Hyp (Var (xi, _))) =
  1425       | subst plev tlev (Hyp (Var (xi, _))) =
  1426           (case AList.lookup (op =) pinst xi of
  1426           (case AList.lookup (op =) pinst xi of
  1427             NONE => raise Same.SAME
  1427             NONE => raise Same.SAME
  1428           | SOME prf' => incr_pboundvars plev tlev prf')
  1428           | SOME prf' => incr_pboundvars plev tlev prf')
  1429       | subst _ _ (PAxm (id, prop, Ts)) = PAxm (id, prop, Same.map_option substTs Ts)
  1429       | subst _ _ (PAxm (id, prop, Ts)) = PAxm (id, prop, Same.map_option substTs Ts)
  1430       | subst _ _ (OfClass (T, c)) = OfClass (substT T, c)
  1430       | subst _ _ (PClass (T, c)) = PClass (substT T, c)
  1431       | subst _ _ (Oracle (id, prop, Ts)) = Oracle (id, prop, Same.map_option substTs Ts)
  1431       | subst _ _ (Oracle (id, prop, Ts)) = Oracle (id, prop, Same.map_option substTs Ts)
  1432       | subst _ _ (PThm ({serial = i, pos = p, theory_name, name = id, prop, types}, thm_body)) =
  1432       | subst _ _ (PThm ({serial = i, pos = p, theory_name, name = id, prop, types}, thm_body)) =
  1433           PThm (thm_header i p theory_name id prop (Same.map_option substTs types), thm_body)
  1433           PThm (thm_header i p theory_name id prop (Same.map_option substTs types), thm_body)
  1434       | subst _ _ _ = raise Same.SAME;
  1434       | subst _ _ _ = raise Same.SAME;
  1435   in fn t => subst 0 0 t handle Same.SAME => t end;
  1435   in fn t => subst 0 0 t handle Same.SAME => t end;
  1451 
  1451 
  1452   in case (head_of prf1, head_of prf2) of
  1452   in case (head_of prf1, head_of prf2) of
  1453         (_, Hyp (Var _)) => true
  1453         (_, Hyp (Var _)) => true
  1454       | (Hyp (Var _), _) => true
  1454       | (Hyp (Var _), _) => true
  1455       | (PAxm (a, _, _), PAxm (b, _, _)) => a = b andalso matchrands prf1 prf2
  1455       | (PAxm (a, _, _), PAxm (b, _, _)) => a = b andalso matchrands prf1 prf2
  1456       | (OfClass (_, c), OfClass (_, d)) => c = d andalso matchrands prf1 prf2
  1456       | (PClass (_, c), PClass (_, d)) => c = d andalso matchrands prf1 prf2
  1457       | (PThm ({name = a, prop = propa, ...}, _), PThm ({name = b, prop = propb, ...}, _)) =>
  1457       | (PThm ({name = a, prop = propa, ...}, _), PThm ({name = b, prop = propb, ...}, _)) =>
  1458           a = b andalso propa = propb andalso matchrands prf1 prf2
  1458           a = b andalso propa = propb andalso matchrands prf1 prf2
  1459       | (PBound i, PBound j) => i = j andalso matchrands prf1 prf2
  1459       | (PBound i, PBound j) => i = j andalso matchrands prf1 prf2
  1460       | (AbsP _, _) =>  true   (*because of possible eta equality*)
  1460       | (AbsP _, _) =>  true   (*because of possible eta equality*)
  1461       | (Abst _, _) =>  true
  1461       | (Abst _, _) =>  true
  1605         (fn TVar ((a, i), S) => subst_same (TVar ((a, i - shift), S)) | A => subst_same A);
  1605         (fn TVar ((a, i), S) => subst_same (TVar ((a, i - shift), S)) | A => subst_same A);
  1606   in Same.commit (map_proof_types_same subst_type_same) prf end;
  1606   in Same.commit (map_proof_types_same subst_type_same) prf end;
  1607 
  1607 
  1608 fun guess_name (PThm ({name, ...}, _)) = name
  1608 fun guess_name (PThm ({name, ...}, _)) = name
  1609   | guess_name (prf %% Hyp _) = guess_name prf
  1609   | guess_name (prf %% Hyp _) = guess_name prf
  1610   | guess_name (prf %% OfClass _) = guess_name prf
  1610   | guess_name (prf %% PClass _) = guess_name prf
  1611   | guess_name (prf % NONE) = guess_name prf
  1611   | guess_name (prf % NONE) = guess_name prf
  1612   | guess_name (prf % SOME (Var _)) = guess_name prf
  1612   | guess_name (prf % SOME (Var _)) = guess_name prf
  1613   | guess_name _ = "";
  1613   | guess_name _ = "";
  1614 
  1614 
  1615 
  1615 
  1799                end)
  1799                end)
  1800       | mk_cnstrts env _ _ vTs (prf as PThm ({prop, types = opTs, ...}, _)) =
  1800       | mk_cnstrts env _ _ vTs (prf as PThm ({prop, types = opTs, ...}, _)) =
  1801           mk_cnstrts_atom env vTs prop opTs prf
  1801           mk_cnstrts_atom env vTs prop opTs prf
  1802       | mk_cnstrts env _ _ vTs (prf as PAxm (_, prop, opTs)) =
  1802       | mk_cnstrts env _ _ vTs (prf as PAxm (_, prop, opTs)) =
  1803           mk_cnstrts_atom env vTs prop opTs prf
  1803           mk_cnstrts_atom env vTs prop opTs prf
  1804       | mk_cnstrts env _ _ vTs (prf as OfClass (T, c)) =
  1804       | mk_cnstrts env _ _ vTs (prf as PClass (T, c)) =
  1805           mk_cnstrts_atom env vTs (Logic.mk_of_class (T, c)) NONE prf
  1805           mk_cnstrts_atom env vTs (Logic.mk_of_class (T, c)) NONE prf
  1806       | mk_cnstrts env _ _ vTs (prf as Oracle (_, prop, opTs)) =
  1806       | mk_cnstrts env _ _ vTs (prf as Oracle (_, prop, opTs)) =
  1807           mk_cnstrts_atom env vTs prop opTs prf
  1807           mk_cnstrts_atom env vTs prop opTs prf
  1808       | mk_cnstrts env _ _ vTs (Hyp t) = (t, Hyp t, [], env, vTs)
  1808       | mk_cnstrts env _ _ vTs (Hyp t) = (t, Hyp t, [], env, vTs)
  1809       | mk_cnstrts _ _ _ _ MinProof = raise MIN_PROOF ()
  1809       | mk_cnstrts _ _ _ _ MinProof = raise MIN_PROOF ()
  1897       Const ("Pure.imp", _) $ _ $ Q => Q
  1897       Const ("Pure.imp", _) $ _ $ Q => Q
  1898     | _ => error "prop_of: ==> expected")
  1898     | _ => error "prop_of: ==> expected")
  1899   | prop_of0 _ (Hyp t) = t
  1899   | prop_of0 _ (Hyp t) = t
  1900   | prop_of0 _ (PThm ({prop, types = SOME Ts, ...}, _)) = prop_of_atom prop Ts
  1900   | prop_of0 _ (PThm ({prop, types = SOME Ts, ...}, _)) = prop_of_atom prop Ts
  1901   | prop_of0 _ (PAxm (_, prop, SOME Ts)) = prop_of_atom prop Ts
  1901   | prop_of0 _ (PAxm (_, prop, SOME Ts)) = prop_of_atom prop Ts
  1902   | prop_of0 _ (OfClass (T, c)) = Logic.mk_of_class (T, c)
  1902   | prop_of0 _ (PClass (T, c)) = Logic.mk_of_class (T, c)
  1903   | prop_of0 _ (Oracle (_, prop, SOME Ts)) = prop_of_atom prop Ts
  1903   | prop_of0 _ (Oracle (_, prop, SOME Ts)) = prop_of_atom prop Ts
  1904   | prop_of0 _ _ = error "prop_of: partial proof object";
  1904   | prop_of0 _ _ = error "prop_of: partial proof object";
  1905 
  1905 
  1906 val prop_of' = Envir.beta_eta_contract oo prop_of0;
  1906 val prop_of' = Envir.beta_eta_contract oo prop_of0;
  1907 val prop_of = prop_of' [];
  1907 val prop_of = prop_of' [];
  2231     val proof =
  2231     val proof =
  2232       if unconstrain then
  2232       if unconstrain then
  2233         proof_combt' (head, (map o Option.map o Term.map_types) (#map_atyps ucontext) args)
  2233         proof_combt' (head, (map o Option.map o Term.map_types) (#map_atyps ucontext) args)
  2234       else
  2234       else
  2235         proof_combP (proof_combt' (head, args),
  2235         proof_combP (proof_combt' (head, args),
  2236           map OfClass (#outer_constraints ucontext) @ map Hyp hyps);
  2236           map PClass (#outer_constraints ucontext) @ map Hyp hyps);
  2237   in (thm, proof) end;
  2237   in (thm, proof) end;
  2238 
  2238 
  2239 in
  2239 in
  2240 
  2240 
  2241 fun thm_proof thy = prepare_thm_proof false thy;
  2241 fun thm_proof thy = prepare_thm_proof false thy;