equal
deleted
inserted
replaced
366 subgoals.*) |
366 subgoals.*) |
367 fun cut_rules_tac ths i = EVERY (map (fn th => metacut_tac th i) ths); |
367 fun cut_rules_tac ths i = EVERY (map (fn th => metacut_tac th i) ths); |
368 |
368 |
369 (*As above, but inserts only facts (unconditional theorems); |
369 (*As above, but inserts only facts (unconditional theorems); |
370 generates no additional subgoals. *) |
370 generates no additional subgoals. *) |
371 fun cut_facts_tac ths = cut_rules_tac (filter is_fact ths); |
371 fun cut_facts_tac ths = cut_rules_tac (List.filter is_fact ths); |
372 |
372 |
373 (*Introduce the given proposition as a lemma and subgoal*) |
373 (*Introduce the given proposition as a lemma and subgoal*) |
374 fun subgoal_tac sprop = |
374 fun subgoal_tac sprop = |
375 DETERM o res_inst_tac [("psi", sprop)] cut_rl THEN' SUBGOAL (fn (prop, _) => |
375 DETERM o res_inst_tac [("psi", sprop)] cut_rl THEN' SUBGOAL (fn (prop, _) => |
376 let val concl' = Logic.strip_assums_concl prop in |
376 let val concl' = Logic.strip_assums_concl prop in |
424 | NONE => error "insert_tagged_brl: elimination rule with no premises") |
424 | NONE => error "insert_tagged_brl: elimination rule with no premises") |
425 else (Net.insert_term ((concl_of th, kbrl), inet, K false), enet); |
425 else (Net.insert_term ((concl_of th, kbrl), inet, K false), enet); |
426 |
426 |
427 (*build a pair of nets for biresolution*) |
427 (*build a pair of nets for biresolution*) |
428 fun build_netpair netpair brls = |
428 fun build_netpair netpair brls = |
429 foldr insert_tagged_brl (taglist 1 brls, netpair); |
429 Library.foldr insert_tagged_brl (taglist 1 brls, netpair); |
430 |
430 |
431 (*delete one kbrl from the pair of nets*) |
431 (*delete one kbrl from the pair of nets*) |
432 local |
432 local |
433 fun eq_kbrl ((_, (_, th)), (_, (_, th'))) = Drule.eq_thm_prop (th, th') |
433 fun eq_kbrl ((_, (_, th)), (_, (_, th'))) = Drule.eq_thm_prop (th, th') |
434 in |
434 in |
471 fun insert_krl (krl as (k,th), net) = |
471 fun insert_krl (krl as (k,th), net) = |
472 Net.insert_term ((concl_of th, krl), net, K false); |
472 Net.insert_term ((concl_of th, krl), net, K false); |
473 |
473 |
474 (*build a net of rules for resolution*) |
474 (*build a net of rules for resolution*) |
475 fun build_net rls = |
475 fun build_net rls = |
476 foldr insert_krl (taglist 1 rls, Net.empty); |
476 Library.foldr insert_krl (taglist 1 rls, Net.empty); |
477 |
477 |
478 (*resolution using a net rather than rules; pred supports filt_resolve_tac*) |
478 (*resolution using a net rather than rules; pred supports filt_resolve_tac*) |
479 fun filt_resolution_from_net_tac match pred net = |
479 fun filt_resolution_from_net_tac match pred net = |
480 SUBGOAL |
480 SUBGOAL |
481 (fn (prem,i) => |
481 (fn (prem,i) => |
560 val keys = distinct (sort (rev_order o int_ord) (map #2 keylist)) |
560 val keys = distinct (sort (rev_order o int_ord) (map #2 keylist)) |
561 in map (keyfilter keylist) keys end; |
561 in map (keyfilter keylist) keys end; |
562 |
562 |
563 val rev_defs = sort_lhs_depths o map symmetric; |
563 val rev_defs = sort_lhs_depths o map symmetric; |
564 |
564 |
565 fun fold_rule defs thm = foldl (fn (th, ds) => rewrite_rule ds th) (thm, rev_defs defs); |
565 fun fold_rule defs thm = Library.foldl (fn (th, ds) => rewrite_rule ds th) (thm, rev_defs defs); |
566 fun fold_tac defs = EVERY (map rewrite_tac (rev_defs defs)); |
566 fun fold_tac defs = EVERY (map rewrite_tac (rev_defs defs)); |
567 fun fold_goals_tac defs = EVERY (map rewrite_goals_tac (rev_defs defs)); |
567 fun fold_goals_tac defs = EVERY (map rewrite_goals_tac (rev_defs defs)); |
568 |
568 |
569 |
569 |
570 (*** Renaming of parameters in a subgoal |
570 (*** Renaming of parameters in a subgoal |
618 fun thins ((tac,n),H) = |
618 fun thins ((tac,n),H) = |
619 if p H then (tac,n+1) |
619 if p H then (tac,n+1) |
620 else (Then tac (rotate_tac n THEN' etac thin_rl),0); |
620 else (Then tac (rotate_tac n THEN' etac thin_rl),0); |
621 in SUBGOAL(fn (subg,n) => |
621 in SUBGOAL(fn (subg,n) => |
622 let val Hs = Logic.strip_assums_hyp subg |
622 let val Hs = Logic.strip_assums_hyp subg |
623 in case fst(foldl thins ((NONE,0),Hs)) of |
623 in case fst(Library.foldl thins ((NONE,0),Hs)) of |
624 NONE => no_tac | SOME tac => tac n |
624 NONE => no_tac | SOME tac => tac n |
625 end) |
625 end) |
626 end; |
626 end; |
627 |
627 |
628 |
628 |
642 fun prove sign xs asms prop tac = |
642 fun prove sign xs asms prop tac = |
643 let |
643 let |
644 val statement = Logic.list_implies (asms, prop); |
644 val statement = Logic.list_implies (asms, prop); |
645 val frees = map Term.dest_Free (Term.term_frees statement); |
645 val frees = map Term.dest_Free (Term.term_frees statement); |
646 val fixed_frees = filter_out (fn (x, _) => x mem_string xs) frees; |
646 val fixed_frees = filter_out (fn (x, _) => x mem_string xs) frees; |
647 val fixed_tfrees = foldr Term.add_typ_tfree_names (map #2 fixed_frees, []); |
647 val fixed_tfrees = Library.foldr Term.add_typ_tfree_names (map #2 fixed_frees, []); |
648 val params = mapfilter (fn x => apsome (pair x) (assoc_string (frees, x))) xs; |
648 val params = List.mapPartial (fn x => Option.map (pair x) (assoc_string (frees, x))) xs; |
649 |
649 |
650 fun err msg = raise ERROR_MESSAGE |
650 fun err msg = raise ERROR_MESSAGE |
651 (msg ^ "\nThe error(s) above occurred for the goal statement:\n" ^ |
651 (msg ^ "\nThe error(s) above occurred for the goal statement:\n" ^ |
652 Sign.string_of_term sign (Term.list_all_free (params, statement))); |
652 Sign.string_of_term sign (Term.list_all_free (params, statement))); |
653 |
653 |