src/Pure/thm.ML
changeset 28364 0012c6e5347e
parent 28356 ac4498f95d1c
child 28378 60cc0359363d
equal deleted inserted replaced
28363:c2432d193705 28364:0012c6e5347e
   149   val first_order_match: cterm * cterm -> (ctyp * ctyp) list * (cterm * cterm) list
   149   val first_order_match: cterm * cterm -> (ctyp * ctyp) list * (cterm * cterm) list
   150   val incr_indexes_cterm: int -> cterm -> cterm
   150   val incr_indexes_cterm: int -> cterm -> cterm
   151   val varifyT: thm -> thm
   151   val varifyT: thm -> thm
   152   val varifyT': (string * sort) list -> thm -> ((string * sort) * indexname) list * thm
   152   val varifyT': (string * sort) list -> thm -> ((string * sort) * indexname) list * thm
   153   val freezeT: thm -> thm
   153   val freezeT: thm -> thm
   154   val promise: thm Future.T -> cterm -> thm
   154   val promise: (unit -> thm) -> cterm -> thm
   155   val fulfill: thm -> thm
       
   156   val proof_of: thm -> Proofterm.proof
   155   val proof_of: thm -> Proofterm.proof
   157   val extern_oracles: theory -> xstring list
   156   val extern_oracles: theory -> xstring list
   158   val add_oracle: bstring * ('a -> cterm) -> theory -> (string * ('a -> thm)) * theory
   157   val add_oracle: bstring * ('a -> cterm) -> theory -> (string * ('a -> thm)) * theory
   159 end;
   158 end;
   160 
   159 
   347   maxidx: int,                            (*maximum index of any Var or TVar*)
   346   maxidx: int,                            (*maximum index of any Var or TVar*)
   348   shyps: sort OrdList.T,                  (*sort hypotheses*)
   347   shyps: sort OrdList.T,                  (*sort hypotheses*)
   349   hyps: term OrdList.T,                   (*hypotheses*)
   348   hyps: term OrdList.T,                   (*hypotheses*)
   350   tpairs: (term * term) list,             (*flex-flex pairs*)
   349   tpairs: (term * term) list,             (*flex-flex pairs*)
   351   prop: term}                             (*conclusion*)
   350   prop: term}                             (*conclusion*)
   352 and deriv = Deriv of                
   351 and deriv = Deriv of
   353  {oracle: bool,                           (*oracle occurrence flag*)
   352  {oracle: bool,                           (*oracle occurrence flag*)
   354   proof: Pt.proof,                        (*proof term*)
   353   proof: Pt.proof,                        (*proof term*)
   355   promises: (serial * promise) OrdList.T} (*promised derivations*)
   354   promises: (serial * promise) OrdList.T} (*promised derivations*)
   356 and promise = Promise of
   355 and promise = Promise of
   357   thm Future.T * theory * sort OrdList.T * term;
   356   thm Future.T * theory * sort OrdList.T * term;
  1615 
  1614 
  1616 fun join_futures thy =
  1615 fun join_futures thy =
  1617   let
  1616   let
  1618     val futures = Futures.get thy;
  1617     val futures = Futures.get thy;
  1619     val results = Future.join_results (! futures);
  1618     val results = Future.join_results (! futures);
  1620     val _ = CRITICAL (fn () => change futures (filter_out Future.is_finished));
  1619     val done = CRITICAL (fn () =>
       
  1620       (change futures (filter_out Future.is_finished); null (! futures)));
  1621     val _ = ParList.release_results results;
  1621     val _ = ParList.release_results results;
  1622   in NONE end;
  1622   in if done then NONE else SOME thy end;
  1623 
  1623 
  1624 val _ = Context.>> (Context.map_theory (Futures.init #> Theory.at_end join_futures));
  1624 val _ = Context.>> (Context.map_theory (Futures.init #> Theory.at_end join_futures));
  1625 
  1625 
  1626 
  1626 
  1627 (* promise *)
  1627 (* promise *)
  1628 
  1628 
  1629 fun promise future ct =
  1629 fun promise make_result ct =
  1630   let
  1630   let
  1631     val {thy_ref = thy_ref, t = prop, T, maxidx, sorts} = rep_cterm ct;
  1631     val {thy_ref = thy_ref, t = prop, T, maxidx, sorts} = rep_cterm ct;
  1632     val thy = Context.reject_draft (Theory.deref thy_ref);
  1632     val thy = Context.reject_draft (Theory.deref thy_ref);
  1633     val _ = T <> propT andalso raise CTERM ("promise: prop expected", [ct]);
  1633     val _ = T <> propT andalso raise CTERM ("promise: prop expected", [ct]);
       
  1634     val future = Future.fork_irrelevant make_result;
  1634     val _ = add_future thy future;
  1635     val _ = add_future thy future;
  1635     val i = serial ();
  1636     val i = serial ();
  1636   in
  1637   in
  1637     Thm (make_deriv false [(i, Promise (future, thy, sorts, prop))] (Pt.promise_proof i prop),
  1638     Thm (make_deriv false [(i, Promise (future, thy, sorts, prop))] (Pt.promise_proof i prop),
  1638      {thy_ref = thy_ref,
  1639      {thy_ref = thy_ref,