equal
deleted
inserted
replaced
338 fun add_shyps shyps tab = fold (fn h => fn tab => Sorttab.update (h, ()) tab) shyps tab |
338 fun add_shyps shyps tab = fold (fn h => fn tab => Sorttab.update (h, ()) tab) shyps tab |
339 |
339 |
340 fun merge_shyps shyps1 shyps2 = Sorttab.keys (add_shyps shyps2 (add_shyps shyps1 Sorttab.empty)) |
340 fun merge_shyps shyps1 shyps2 = Sorttab.keys (add_shyps shyps2 (add_shyps shyps1 Sorttab.empty)) |
341 |
341 |
342 val (_, export_oracle) = Context.>>> (Context.map_theory_result |
342 val (_, export_oracle) = Context.>>> (Context.map_theory_result |
343 (Thm.add_oracle (@{binding compute}, fn (thy, hyps, shyps, prop) => |
343 (Thm.add_oracle (\<^binding>\<open>compute\<close>, fn (thy, hyps, shyps, prop) => |
344 let |
344 let |
345 val shyptab = add_shyps shyps Sorttab.empty |
345 val shyptab = add_shyps shyps Sorttab.empty |
346 fun delete s shyptab = Sorttab.delete s shyptab handle Sorttab.UNDEF _ => shyptab |
346 fun delete s shyptab = Sorttab.delete s shyptab handle Sorttab.UNDEF _ => shyptab |
347 fun delete_term t shyptab = fold delete (Sorts.insert_term t []) shyptab |
347 fun delete_term t shyptab = fold delete (Sorts.insert_term t []) shyptab |
348 fun has_witness s = not (null (Sign.witness_sorts thy [] [s])) |
348 fun has_witness s = not (null (Sign.witness_sorts thy [] [s])) |
433 val (a, b) = Logic.dest_equals t |
433 val (a, b) = Logic.dest_equals t |
434 val ty = type_of a |
434 val ty = type_of a |
435 val (encoding, a) = remove_types encoding a |
435 val (encoding, a) = remove_types encoding a |
436 val (encoding, b) = remove_types encoding b |
436 val (encoding, b) = remove_types encoding b |
437 val (eq, encoding) = |
437 val (eq, encoding) = |
438 Encode.insert (Const (@{const_name Pure.eq}, ty --> ty --> @{typ "prop"})) encoding |
438 Encode.insert (Const (\<^const_name>\<open>Pure.eq\<close>, ty --> ty --> \<^typ>\<open>prop\<close>)) encoding |
439 in |
439 in |
440 (encoding, EqPrem (a, b, ty, eq)) |
440 (encoding, EqPrem (a, b, ty, eq)) |
441 end handle TERM _ => let val (encoding, t) = remove_types encoding t in (encoding, Prem t) end) |
441 end handle TERM _ => let val (encoding, t) = remove_types encoding t in (encoding, Prem t) end) |
442 val (encoding, prems) = |
442 val (encoding, prems) = |
443 (fold_rev (fn t => fn (encoding, l) => |
443 (fold_rev (fn t => fn (encoding, l) => |
580 val b' = run true b |
580 val b' = run true b |
581 in |
581 in |
582 case match_aterms varsubst b' a' of |
582 case match_aterms varsubst b' a' of |
583 NONE => |
583 NONE => |
584 let |
584 let |
585 fun mk s = Syntax.string_of_term_global @{theory Pure} |
585 fun mk s = Syntax.string_of_term_global \<^theory>\<open>Pure\<close> |
586 (infer_types (naming_of computer) (encoding_of computer) ty s) |
586 (infer_types (naming_of computer) (encoding_of computer) ty s) |
587 val left = "computed left side: "^(mk a') |
587 val left = "computed left side: "^(mk a') |
588 val right = "computed right side: "^(mk b') |
588 val right = "computed right side: "^(mk b') |
589 in |
589 in |
590 raise Compute ("evaluate_prem: cannot assign computed left to right hand side\n"^left^"\n"^right^"\n") |
590 raise Compute ("evaluate_prem: cannot assign computed left to right hand side\n"^left^"\n"^right^"\n") |
629 let |
629 let |
630 val _ = check_compatible computer th |
630 val _ = check_compatible computer th |
631 val varsubst = varsubst_of_theorem th |
631 val varsubst = varsubst_of_theorem th |
632 val encoding = encoding_of computer |
632 val encoding = encoding_of computer |
633 val naming = naming_of computer |
633 val naming = naming_of computer |
634 fun infer t = infer_types naming encoding @{typ "prop"} t |
634 fun infer t = infer_types naming encoding \<^typ>\<open>prop\<close> t |
635 fun run t = infer (runprog (prog_of computer) (apply_subst true varsubst t)) |
635 fun run t = infer (runprog (prog_of computer) (apply_subst true varsubst t)) |
636 fun runprem p = run (prem2term p) |
636 fun runprem p = run (prem2term p) |
637 val prop = Logic.list_implies (map runprem (prems_of_theorem th), run (concl_of_theorem th)) |
637 val prop = Logic.list_implies (map runprem (prems_of_theorem th), run (concl_of_theorem th)) |
638 val hyps = merge_hyps (hyps_of computer) (hyps_of_theorem th) |
638 val hyps = merge_hyps (hyps_of computer) (hyps_of_theorem th) |
639 val shyps = merge_shyps (shyps_of_theorem th) (Sorttab.keys (shyptab_of computer)) |
639 val shyps = merge_shyps (shyps_of_theorem th) (Sorttab.keys (shyptab_of computer)) |