src/Pure/thm.ML
changeset 79323 3bbe31b35f5b
parent 79322 f321ab14dd94
child 79329 992c494bda25
equal deleted inserted replaced
79322:f321ab14dd94 79323:3bbe31b35f5b
  1151 
  1151 
  1152 fun add_oracle (b, oracle_fn) thy1 =
  1152 fun add_oracle (b, oracle_fn) thy1 =
  1153   let
  1153   let
  1154     val (name, oracles') = Name_Space.define (Context.Theory thy1) true (b, ()) (get_oracles thy1);
  1154     val (name, oracles') = Name_Space.define (Context.Theory thy1) true (b, ()) (get_oracles thy1);
  1155     val thy2 = map_oracles (K oracles') thy1;
  1155     val thy2 = map_oracles (K oracles') thy1;
       
  1156     val cert2 = Context.Certificate_Id (Context.theory_id thy2);
  1156     fun invoke_oracle arg =
  1157     fun invoke_oracle arg =
  1157       let val ct as Cterm {cert = cert2, t = prop, T, maxidx, sorts} = oracle_fn arg in
  1158       let val ct as Cterm {cert = cert3, t = prop, T, maxidx, sorts} = oracle_fn arg in
  1158         if T <> propT then
  1159         if T <> propT then
  1159           raise THM ("Oracle's result must have type prop: " ^ name, 0, [])
  1160           raise THM ("Oracle's result must have type prop: " ^ name, 0, [])
  1160         else
  1161         else
  1161           let
  1162           let
  1162             val cert = Context.join_certificate (Context.Certificate thy2, cert2);
  1163             val cert = Context.join_certificate (cert2, cert3);
  1163             val proofs = Proofterm.get_proofs_level ();
  1164             val proofs = Proofterm.get_proofs_level ();
  1164             val oracle =
  1165             val oracle =
  1165               if Proofterm.oracle_enabled proofs
  1166               if Proofterm.oracle_enabled proofs
  1166               then ((name, Position.thread_data ()), SOME prop)
  1167               then ((name, Position.thread_data ()), SOME prop)
  1167               else ((name, Position.none), NONE);
  1168               else ((name, Position.none), NONE);
  1171               else MinProof;
  1172               else MinProof;
  1172             val zproof =
  1173             val zproof =
  1173               if Proofterm.zproof_enabled proofs then
  1174               if Proofterm.zproof_enabled proofs then
  1174                 let
  1175                 let
  1175                   val thy = Context.certificate_theory cert handle ERROR msg =>
  1176                   val thy = Context.certificate_theory cert handle ERROR msg =>
  1176                     raise CONTEXT (msg, [], [ct], [], SOME (Context.Theory thy2));
  1177                     raise CONTEXT (msg, [], [ct], [], NONE);
  1177                 in ZTerm.oracle_proof thy name prop end
  1178                 in ZTerm.oracle_proof thy name prop end
  1178               else ZDummy;
  1179               else ZDummy;
  1179           in
  1180           in
  1180             Thm (make_deriv [] [oracle] [] [] zproof proof,
  1181             Thm (make_deriv [] [oracle] [] [] zproof proof,
  1181              {cert = cert,
  1182              {cert = cert,