35 sig |
35 sig |
36 include BASIC_PROOFTERM |
36 include BASIC_PROOFTERM |
37 |
37 |
38 type oracle = string * term |
38 type oracle = string * term |
39 type pthm = serial * (string * term * proof_body future) |
39 type pthm = serial * (string * term * proof_body future) |
40 val join_body: proof_body -> unit |
40 val check_body_thms: proof_body -> proof_body future |
41 val proof_of: proof_body -> proof |
41 val proof_of: proof_body -> proof |
42 val join_proof: proof_body future -> proof |
42 val join_proof: proof_body future -> proof |
43 val fold_proof_atoms: bool -> (proof -> 'a -> 'a) -> proof list -> 'a -> 'a |
43 val fold_proof_atoms: bool -> (proof -> 'a -> 'a) -> proof list -> 'a -> 'a |
44 val fold_body_thms: (string * term * proof_body -> 'a -> 'a) -> proof_body list -> 'a -> 'a |
44 val fold_body_thms: (string * term * proof_body -> 'a -> 'a) -> proof_body list -> 'a -> 'a |
45 val status_of: proof_body list -> {failed: bool, oracle: bool, unfinished: bool} |
45 val status_of: proof_body list -> {failed: bool, oracle: bool, unfinished: bool} |
169 proof: proof}; |
169 proof: proof}; |
170 |
170 |
171 type oracle = string * term; |
171 type oracle = string * term; |
172 type pthm = serial * (string * term * proof_body future); |
172 type pthm = serial * (string * term * proof_body future); |
173 |
173 |
174 fun join_thms thms = ignore (Future.joins (map (#3 o #2) thms)); |
174 fun join_thms (thms: pthm list) = ignore (Future.joins (map (#3 o #2) thms)); |
175 fun join_body (PBody {thms, ...}) = join_thms thms; |
175 |
|
176 fun check_body_thms (body as PBody {thms, ...}) = |
|
177 (singleton o Future.cond_forks) |
|
178 {name = "Proofterm.check_body_thms", group = NONE, |
|
179 deps = map (Future.task_of o #3 o #2) thms, pri = ~1, interrupts = true} |
|
180 (fn () => (join_thms thms; body)); |
176 |
181 |
177 fun proof_of (PBody {proof, ...}) = proof; |
182 fun proof_of (PBody {proof, ...}) = proof; |
178 val join_proof = Future.join #> proof_of; |
183 val join_proof = Future.join #> proof_of; |
179 |
184 |
180 |
185 |
1393 NONE => NONE |
1398 NONE => NONE |
1394 | SOME prf => SOME (instantiate (Term.add_tvars prop [] ~~ Ts, []) prf, normal_skel)) |
1399 | SOME prf => SOME (instantiate (Term.add_tvars prop [] ~~ Ts, []) prf, normal_skel)) |
1395 | fill _ = NONE; |
1400 | fill _ = NONE; |
1396 val (rules, procs) = get_data thy; |
1401 val (rules, procs) = get_data thy; |
1397 val proof = rewrite_prf fst (rules, K (K fill) :: procs) proof0; |
1402 val proof = rewrite_prf fst (rules, K (K fill) :: procs) proof0; |
1398 val _ = join_thms thms; |
|
1399 in PBody {oracles = oracles, thms = thms, proof = proof} end; |
1403 in PBody {oracles = oracles, thms = thms, proof = proof} end; |
1400 |
1404 |
1401 fun fulfill_proof_future _ [] postproc body = |
1405 fun fulfill_proof_future _ [] postproc body = Future.map postproc body |
1402 if not (Multithreading.enabled ()) then Future.value (postproc (Future.join body)) |
|
1403 else Future.map postproc body |
|
1404 | fulfill_proof_future thy promises postproc body = |
1406 | fulfill_proof_future thy promises postproc body = |
1405 (singleton o Future.forks) |
1407 (singleton o Future.forks) |
1406 {name = "Proofterm.fulfill_proof_future", group = NONE, |
1408 {name = "Proofterm.fulfill_proof_future", group = NONE, |
1407 deps = Future.task_of body :: map (Future.task_of o snd) promises, pri = 0, |
1409 deps = Future.task_of body :: map (Future.task_of o snd) promises, pri = ~1, |
1408 interrupts = true} |
1410 interrupts = true} |
1409 (fn () => |
1411 (fn () => |
1410 postproc (fulfill_norm_proof thy (map (apsnd Future.join) promises) (Future.join body))); |
1412 postproc (fulfill_norm_proof thy (map (apsnd Future.join) promises) (Future.join body))); |
1411 |
1413 |
1412 |
1414 |
1457 #4 (shrink_proof thy [] 0 (rew_proof thy (fold_rev implies_intr_proof hyps prf))); |
1459 #4 (shrink_proof thy [] 0 (rew_proof thy (fold_rev implies_intr_proof hyps prf))); |
1458 |
1460 |
1459 fun make_body0 proof0 = PBody {oracles = oracles0, thms = thms0, proof = proof0}; |
1461 fun make_body0 proof0 = PBody {oracles = oracles0, thms = thms0, proof = proof0}; |
1460 val body0 = |
1462 val body0 = |
1461 if not (proofs_enabled ()) then Future.value (make_body0 MinProof) |
1463 if not (proofs_enabled ()) then Future.value (make_body0 MinProof) |
1462 else if not (Multithreading.enabled ()) then Future.value (make_body0 (full_proof0 ())) |
|
1463 else |
1464 else |
1464 (singleton o Future.forks) |
1465 (singleton o Future.cond_forks) |
1465 {name = "Proofterm.prepare_thm_proof", group = NONE, |
1466 {name = "Proofterm.prepare_thm_proof", group = NONE, |
1466 deps = [], pri = ~1, interrupts = true} |
1467 deps = [], pri = ~1, interrupts = true} |
1467 (make_body0 o full_proof0); |
1468 (make_body0 o full_proof0); |
1468 |
1469 |
1469 fun new_prf () = (serial (), fulfill_proof_future thy promises postproc body0); |
1470 fun new_prf () = |
|
1471 let |
|
1472 val body' = body0 |
|
1473 |> fulfill_proof_future thy promises postproc |
|
1474 |> Future.map (fn body as PBody {thms, ...} => (join_thms thms; body)); |
|
1475 in (serial (), body') end; |
|
1476 |
1470 val (i, body') = |
1477 val (i, body') = |
1471 (*non-deterministic, depends on unknown promises*) |
1478 (*non-deterministic, depends on unknown promises*) |
1472 (case strip_combt (fst (strip_combP prf)) of |
1479 (case strip_combt (fst (strip_combP prf)) of |
1473 (PThm (i, ((old_name, prop', NONE), body')), args') => |
1480 (PThm (i, ((old_name, prop', NONE), body')), args') => |
1474 if (old_name = "" orelse old_name = name) andalso prop1 = prop' andalso args = args' |
1481 if (old_name = "" orelse old_name = name) andalso prop1 = prop' andalso args = args' |