# HG changeset patch # User wenzelm # Date 968180761 -7200 # Node ID 95dca9f991f26be223194ebb03a530fc3f845a58 # Parent 580c50fc6559bbb347d0737cdea193f58039ac51 improved meson setup; diff -r 580c50fc6559 -r 95dca9f991f2 src/HOL/HOL.thy --- a/src/HOL/HOL.thy Tue Sep 05 18:59:22 2000 +0200 +++ b/src/HOL/HOL.thy Tue Sep 05 21:06:01 2000 +0200 @@ -7,8 +7,8 @@ *) theory HOL = CPure -files ("HOL_lemmas.ML") ("cladata.ML") ("blastdata.ML") ("simpdata.ML") - ("Tools/meson.ML"): +files ("HOL_lemmas.ML") ("cladata.ML") ("blastdata.ML") ("simpdata.ML") + ("meson_lemmas.ML") ("Tools/meson.ML"): (** Core syntax **) @@ -54,7 +54,7 @@ (* Overloaded Constants *) -axclass zero < "term" +axclass zero < "term" axclass plus < "term" axclass minus < "term" axclass times < "term" @@ -65,7 +65,7 @@ "+" :: "['a::plus, 'a] => 'a" (infixl 65) - :: "['a::minus, 'a] => 'a" (infixl 65) uminus :: "['a::minus] => 'a" ("- _" [81] 80) - abs :: "('a::minus) => 'a" + abs :: "('a::minus) => 'a" * :: "['a::times, 'a] => 'a" (infixl 70) (*See Nat.thy for "^"*) @@ -193,7 +193,11 @@ (* theory and package setup *) use "HOL_lemmas.ML" -use "cladata.ML" setup hypsubst_setup setup Classical.setup setup clasetup + +use "cladata.ML" +setup hypsubst_setup +setup Classical.setup +setup clasetup lemma all_eq: "(!!x. P x) == Trueprop (ALL x. P x)" proof (rule equal_intr_rule) @@ -216,12 +220,17 @@ lemmas atomize = all_eq imp_eq -use "blastdata.ML" setup Blast.setup -use "simpdata.ML" setup Simplifier.setup - setup "Simplifier.method_setup Splitter.split_modifiers" setup simpsetup - setup Splitter.setup setup Clasimp.setup - setup rulify_attrib_setup +use "blastdata.ML" +setup Blast.setup +use "simpdata.ML" +setup Simplifier.setup +setup "Simplifier.method_setup Splitter.split_modifiers" setup simpsetup +setup Splitter.setup setup Clasimp.setup +setup rulify_attrib_setup + +use "meson_lemmas.ML" use "Tools/meson.ML" +setup meson_setup end diff -r 580c50fc6559 -r 95dca9f991f2 src/HOL/HOL_lemmas.ML --- a/src/HOL/HOL_lemmas.ML Tue Sep 05 18:59:22 2000 +0200 +++ b/src/HOL/HOL_lemmas.ML Tue Sep 05 21:06:01 2000 +0200 @@ -144,7 +144,7 @@ by (REPEAT (resolve_tac (prems @ [major RS spec]) 1)) ; qed "allE"; -val prems = goal (the_context ()) +val prems = goal (the_context ()) "[| ALL x. P(x); [| P(x); ALL x. P(x) |] ==> R |] ==> R"; by (REPEAT (resolve_tac (prems @ (prems RL [spec])) 1)) ; qed "all_dupE"; @@ -224,7 +224,7 @@ by (etac selectI 1) ; qed "exI"; -val [major,minor] = +val [major,minor] = Goalw [Ex_def] "[| EX x::'a. P(x); !!x. P(x) ==> Q |] ==> Q"; by (rtac (major RS minor) 1); qed "exE"; @@ -451,8 +451,8 @@ val major::prems = Goal "[| P=Q; [| P; Q |] ==> R; [| ~P; ~Q |] ==> R |] ==> R"; by (rtac (major RS iffE) 1); -by (REPEAT (DEPTH_SOLVE_1 - (eresolve_tac ([asm_rl,impCE,notE]@prems) 1))); +by (REPEAT (DEPTH_SOLVE_1 + (eresolve_tac ([asm_rl,impCE,notE]@prems) 1))); qed "iffCE"; val prems = Goal "(ALL x. ~P(x) ==> P(a)) ==> EX x. P(x)"; @@ -471,9 +471,9 @@ by (rtac (thm"plus_ac0.zero") 1); qed "plus_ac0_zero_right"; -bind_thms ("plus_ac0", [thm"plus_ac0.assoc", thm"plus_ac0.commute", - plus_ac0_left_commute, - thm"plus_ac0.zero", plus_ac0_zero_right]); +bind_thms ("plus_ac0", [thm"plus_ac0.assoc", thm"plus_ac0.commute", + plus_ac0_left_commute, + thm"plus_ac0.zero", plus_ac0_zero_right]); (* case distinction *) @@ -488,7 +488,7 @@ (** Standard abbreviations **) -(* combination of (spec RS spec RS ...(j times) ... spec RS mp *) +(* combination of (spec RS spec RS ...(j times) ... spec RS mp *) local fun wrong_prem (Const ("All", _) $ (Abs (_, _, t))) = wrong_prem t | wrong_prem (Bound _) = true @@ -500,4 +500,4 @@ end; -fun strip_tac i = REPEAT(resolve_tac [impI,allI] i); +fun strip_tac i = REPEAT(resolve_tac [impI,allI] i); diff -r 580c50fc6559 -r 95dca9f991f2 src/HOL/IsaMakefile --- a/src/HOL/IsaMakefile Tue Sep 05 18:59:22 2000 +0200 +++ b/src/HOL/IsaMakefile Tue Sep 05 21:06:01 2000 +0200 @@ -33,45 +33,43 @@ Pure: @cd $(SRC)/Pure; $(ISATOOL) make Pure -$(OUT)/HOL: $(OUT)/Pure $(SRC)/Provers/Arith/abel_cancel.ML \ - $(SRC)/Provers/Arith/cancel_sums.ML \ - $(SRC)/Provers/Arith/assoc_fold.ML \ - $(SRC)/Provers/Arith/combine_numerals.ML \ - $(SRC)/Provers/Arith/cancel_numerals.ML \ - $(SRC)/Provers/Arith/fast_lin_arith.ML $(SRC)/Provers/blast.ML \ - $(SRC)/Provers/make_elim.ML $(SRC)/Provers/clasimp.ML \ - $(SRC)/Provers/classical.ML $(SRC)/Provers/hypsubst.ML \ - $(SRC)/Provers/simplifier.ML $(SRC)/Provers/split_paired_all.ML \ - $(SRC)/Provers/splitter.ML $(SRC)/TFL/dcterm.sml $(SRC)/TFL/post.sml \ - $(SRC)/TFL/rules.sml $(SRC)/TFL/rules.sig $(SRC)/TFL/tfl.sig \ - $(SRC)/TFL/tfl.sml $(SRC)/TFL/thms.sig $(SRC)/TFL/thms.sml \ - $(SRC)/TFL/thry.sig $(SRC)/TFL/thry.sml $(SRC)/TFL/usyntax.sig \ - $(SRC)/TFL/usyntax.sml $(SRC)/TFL/utils.sig $(SRC)/TFL/utils.sml \ - Arith.ML Arith.thy Calculation.thy Datatype.thy Divides.ML \ - Divides.thy Finite.ML Finite.thy Fun.ML Fun.thy Gfp.ML Gfp.thy \ - HOL.ML HOL.thy HOL_lemmas.ML Inductive.thy \ - Integ/Bin.ML Integ/Bin.thy Integ/Equiv.ML Integ/Equiv.thy \ - Integ/IntArith.ML Integ/IntArith.thy \ - Integ/IntPower.ML Integ/IntPower.thy \ - Integ/IntDef.ML Integ/IntDef.thy Integ/Int.ML \ - Integ/Int.thy Integ/IntDiv.ML Integ/IntDiv.thy Integ/NatBin.ML \ - Integ/NatBin.thy Integ/NatSimprocs.thy Integ/NatSimprocs.ML \ - Integ/int_arith1.ML Integ/int_arith2.ML Integ/nat_simprocs.ML \ - Lfp.ML Lfp.thy List.ML List.thy Main.ML Main.thy Map.ML Map.thy Nat.ML \ - Nat.thy NatDef.ML NatDef.thy Numeral.thy Option.ML Option.thy Ord.ML \ - Ord.thy Power.ML Power.thy PreList.thy Prod.ML Prod.thy ROOT.ML \ - Recdef.thy Record.thy RelPow.ML RelPow.thy Relation.ML Relation.thy \ - Set.ML Set.thy SetInterval.ML SetInterval.thy String.thy \ - SVC_Oracle.ML SVC_Oracle.thy Sum.ML Sum.thy Tools/datatype_aux.ML \ - Tools/datatype_abs_proofs.ML Tools/datatype_package.ML Tools/datatype_prop.ML \ - Tools/datatype_rep_proofs.ML Tools/induct_method.ML \ - Tools/inductive_package.ML Tools/meson.ML Tools/numeral_syntax.ML \ - Tools/primrec_package.ML Tools/recdef_package.ML \ - Tools/record_package.ML Tools/svc_funcs.ML Tools/typedef_package.ML \ - Trancl.ML Trancl.thy Univ.ML Univ.thy Vimage.ML Vimage.thy WF.ML \ - WF.thy WF_Rel.ML WF_Rel.thy While.ML While.thy arith_data.ML blastdata.ML \ - cladata.ML equalities.ML equalities.thy hologic.ML mono.ML mono.thy \ - simpdata.ML subset.ML subset.thy thy_syntax.ML +$(OUT)/HOL: $(OUT)/Pure $(SRC)/Provers/Arith/abel_cancel.ML \ + $(SRC)/Provers/Arith/cancel_sums.ML \ + $(SRC)/Provers/Arith/assoc_fold.ML \ + $(SRC)/Provers/Arith/combine_numerals.ML \ + $(SRC)/Provers/Arith/cancel_numerals.ML \ + $(SRC)/Provers/Arith/fast_lin_arith.ML $(SRC)/Provers/blast.ML \ + $(SRC)/Provers/make_elim.ML $(SRC)/Provers/clasimp.ML \ + $(SRC)/Provers/classical.ML $(SRC)/Provers/hypsubst.ML \ + $(SRC)/Provers/simplifier.ML $(SRC)/Provers/split_paired_all.ML \ + $(SRC)/Provers/splitter.ML $(SRC)/TFL/dcterm.sml $(SRC)/TFL/post.sml \ + $(SRC)/TFL/rules.sml $(SRC)/TFL/tfl.sml $(SRC)/TFL/thms.sml \ + $(SRC)/TFL/thry.sml $(SRC)/TFL/usyntax.sml $(SRC)/TFL/utils.sml \ + Arith.ML Arith.thy Calculation.thy Datatype.thy Divides.ML \ + Divides.thy Finite.ML Finite.thy Fun.ML Fun.thy Gfp.ML Gfp.thy \ + HOL.ML HOL.thy HOL_lemmas.ML Inductive.thy Integ/Bin.ML \ + Integ/Bin.thy Integ/Equiv.ML Integ/Equiv.thy Integ/IntArith.ML \ + Integ/IntArith.thy Integ/IntPower.ML Integ/IntPower.thy \ + Integ/IntDef.ML Integ/IntDef.thy Integ/Int.ML Integ/Int.thy \ + Integ/IntDiv.ML Integ/IntDiv.thy Integ/NatBin.ML Integ/NatBin.thy \ + Integ/NatSimprocs.thy Integ/NatSimprocs.ML Integ/int_arith1.ML \ + Integ/int_arith2.ML Integ/nat_simprocs.ML Lfp.ML Lfp.thy List.ML \ + List.thy Main.ML Main.thy Map.ML Map.thy Nat.ML Nat.thy NatDef.ML \ + NatDef.thy Numeral.thy Option.ML Option.thy Ord.ML Ord.thy Power.ML \ + Power.thy PreList.thy Prod.ML Prod.thy ROOT.ML Recdef.thy Record.thy \ + RelPow.ML RelPow.thy Relation.ML Relation.thy Set.ML Set.thy \ + SetInterval.ML SetInterval.thy String.thy SVC_Oracle.ML \ + SVC_Oracle.thy Sum.ML Sum.thy Tools/datatype_aux.ML \ + Tools/datatype_abs_proofs.ML Tools/datatype_package.ML \ + Tools/datatype_prop.ML Tools/datatype_rep_proofs.ML \ + Tools/induct_method.ML Tools/inductive_package.ML Tools/meson.ML \ + Tools/numeral_syntax.ML Tools/primrec_package.ML \ + Tools/recdef_package.ML Tools/record_package.ML Tools/svc_funcs.ML \ + Tools/typedef_package.ML Trancl.ML Trancl.thy Univ.ML Univ.thy \ + Vimage.ML Vimage.thy WF.ML WF.thy WF_Rel.ML WF_Rel.thy While.ML \ + While.thy arith_data.ML blastdata.ML cladata.ML equalities.ML \ + equalities.thy hologic.ML meson_lemmas.ML mono.ML mono.thy simpdata.ML \ + subset.ML subset.thy thy_syntax.ML @$(ISATOOL) usedir -b $(OUT)/Pure HOL diff -r 580c50fc6559 -r 95dca9f991f2 src/HOL/Tools/meson.ML --- a/src/HOL/Tools/meson.ML Tue Sep 05 18:59:22 2000 +0200 +++ b/src/HOL/Tools/meson.ML Tue Sep 05 21:06:01 2000 +0200 @@ -1,9 +1,9 @@ -(* Title: HOL/ex/meson +(* Title: HOL/Tools/meson.ML ID: $Id$ Author: Lawrence C Paulson, Cambridge University Computer Laboratory Copyright 1992 University of Cambridge -The MESON resolution proof procedure for HOL +The MESON resolution proof procedure for HOL. When making clauses, avoids using the rewriter -- instead uses RS recursively @@ -11,100 +11,12 @@ FUNCTION nodups -- if done to goal clauses too! *) - -(**** LEMMAS : outside the "local" block ****) - -(** "Axiom" of Choice, proved using the description operator **) - -Goal "ALL x. EX y. Q x y ==> EX f. ALL x. Q x (f x)"; -by (fast_tac (claset() addEs [selectI]) 1); -qed "choice"; - -(*** Generation of contrapositives ***) - -(*Inserts negated disjunct after removing the negation; P is a literal*) -val [major,minor] = Goal "~P|Q ==> ((~P==>P) ==> Q)"; -by (rtac (major RS disjE) 1); -by (rtac notE 1); -by (etac minor 2); -by (ALLGOALS assume_tac); -qed "make_neg_rule"; - -(*For Plaisted's "Postive refinement" of the MESON procedure*) -Goal "~P|Q ==> (P ==> Q)"; -by (Blast_tac 1); -qed "make_refined_neg_rule"; - -(*P should be a literal*) -val [major,minor] = Goal "P|Q ==> ((P==>~P) ==> Q)"; -by (rtac (major RS disjE) 1); -by (rtac notE 1); -by (etac minor 1); -by (ALLGOALS assume_tac); -qed "make_pos_rule"; - -(*** Generation of a goal clause -- put away the final literal ***) - -val [major,minor] = Goal "~P ==> ((~P==>P) ==> False)"; -by (rtac notE 1); -by (rtac minor 2); -by (ALLGOALS (rtac major)); -qed "make_neg_goal"; - -val [major,minor] = Goal "P ==> ((P==>~P) ==> False)"; -by (rtac notE 1); -by (rtac minor 1); -by (ALLGOALS (rtac major)); -qed "make_pos_goal"; - - -(**** Lemmas for forward proof (like congruence rules) ****) - -(*NOTE: could handle conjunctions (faster?) by - nf(th RS conjunct2) RS (nf(th RS conjunct1) RS conjI) *) -val major::prems = Goal - "[| P'&Q'; P' ==> P; Q' ==> Q |] ==> P&Q"; -by (rtac (major RS conjE) 1); -by (rtac conjI 1); -by (ALLGOALS (eresolve_tac prems)); -qed "conj_forward"; - -val major::prems = Goal - "[| P'|Q'; P' ==> P; Q' ==> Q |] ==> P|Q"; -by (rtac (major RS disjE) 1); -by (ALLGOALS (dresolve_tac prems)); -by (ALLGOALS (eresolve_tac [disjI1,disjI2])); -qed "disj_forward"; - -(*Version for removal of duplicate literals*) -val major::prems = Goal - "[| P'|Q'; P' ==> P; [| Q'; P==>False |] ==> Q |] ==> P|Q"; -by (cut_facts_tac [major] 1); -by (blast_tac (claset() addIs prems) 1); -qed "disj_forward2"; - -val major::prems = Goal - "[| ALL x. P'(x); !!x. P'(x) ==> P(x) |] ==> ALL x. P(x)"; -by (rtac allI 1); -by (resolve_tac prems 1); -by (rtac (major RS spec) 1); -qed "all_forward"; - -val major::prems = Goal - "[| EX x. P'(x); !!x. P'(x) ==> P(x) |] ==> EX x. P(x)"; -by (rtac (major RS exE) 1); -by (rtac exI 1); -by (eresolve_tac prems 1); -qed "ex_forward"; - -(**** END OF LEMMAS ****) - local (*Prove theorems using fast_tac*) - fun prove_fun s = + fun prove_fun s = prove_goal (the_context ()) s - (fn prems => [ cut_facts_tac prems 1, Fast_tac 1 ]); + (fn prems => [ cut_facts_tac prems 1, Fast_tac 1 ]); (**** Negation Normal Form ****) @@ -174,11 +86,11 @@ (*Are any of the constants in "bs" present in the term?*) - fun has_consts bs = + fun has_consts bs = let fun has (Const(a,_)) = a mem bs - | has (f$u) = has f orelse has u - | has (Abs(_,_,t)) = has t - | has _ = false + | has (f$u) = has f orelse has u + | has (Abs(_,_,t)) = has t + | has _ = false in has end; @@ -197,12 +109,12 @@ | taut_lits ((flg,t)::ts) = (not flg,t) mem ts orelse taut_lits ts; (*Include False as a literal: an occurrence of ~False is a tautology*) - fun is_taut th = taut_lits ((true, HOLogic.false_const) :: - literals (prop_of th)); + fun is_taut th = taut_lits ((true, HOLogic.false_const) :: + literals (prop_of th)); (*Generation of unique names -- maxidx cannot be relied upon to increase! Cannot rely on "variant", since variables might coincide when literals - are joined to make a clause... + are joined to make a clause... 19 chooses "U" as the first variable name*) val name_ref = ref 19; @@ -211,31 +123,31 @@ fun freeze_spec th = let val sth = th RS spec val newname = (name_ref := !name_ref + 1; - radixstring(26, "A", !name_ref)) + radixstring(26, "A", !name_ref)) in read_instantiate [("x", newname)] sth end; fun resop nf [prem] = resolve_tac (nf prem) 1; (*Conjunctive normal form, detecting tautologies early. Strips universal quantifiers and breaks up conjunctions. *) - fun cnf_aux seen (th,ths) = + fun cnf_aux seen (th,ths) = if taut_lits (literals(prop_of th) @ seen) then ths else if not (has_consts ["All","op &"] (prop_of th)) then th::ths else (*conjunction?*) - cnf_aux seen (th RS conjunct1, - cnf_aux seen (th RS conjunct2, ths)) + cnf_aux seen (th RS conjunct1, + cnf_aux seen (th RS conjunct2, ths)) handle THM _ => (*universal quant?*) - cnf_aux seen (freeze_spec th, ths) + cnf_aux seen (freeze_spec th, ths) handle THM _ => (*disjunction?*) - let val tac = - (METAHYPS (resop (cnf_nil seen)) 1) THEN - (fn st' => st' |> - METAHYPS (resop (cnf_nil (literals (concl_of st') @ seen))) 1) + let val tac = + (METAHYPS (resop (cnf_nil seen)) 1) THEN + (fn st' => st' |> + METAHYPS (resop (cnf_nil (literals (concl_of st') @ seen))) 1) in Seq.list_of (tac (th RS disj_forward)) @ ths end and cnf_nil seen th = cnf_aux seen (th,[]); (*Top-level call to cnf -- it's safe to reset name_ref*) - fun cnf (th,ths) = + fun cnf (th,ths) = (name_ref := 19; cnf (th RS conjunct1, cnf (th RS conjunct2, ths)) handle THM _ => (*not a conjunction*) cnf_aux [] (th, ths)); @@ -244,9 +156,9 @@ (*Forward proof, passing extra assumptions as theorems to the tactic*) fun forward_res2 nf hyps st = case Seq.pull - (REPEAT - (METAHYPS (fn major::minors => rtac (nf (minors@hyps) major) 1) 1) - st) + (REPEAT + (METAHYPS (fn major::minors => rtac (nf (minors@hyps) major) 1) 1) + st) of Some(th,_) => th | None => raise THM("forward_res2", 0, [st]); @@ -255,7 +167,7 @@ fun nodups_aux rls th = nodups_aux rls (th RS disj_assoc) handle THM _ => tryres(th,rls) handle THM _ => tryres(forward_res2 nodups_aux rls (th RS disj_forward2), - [disj_FalseD1, disj_FalseD2, asm_rl]) + [disj_FalseD1, disj_FalseD2, asm_rl]) handle THM _ => th; (*Remove duplicate literals, if there are any*) @@ -268,7 +180,7 @@ (*Associate disjuctions to right -- make leftmost disjunct a LITERAL*) fun assoc_right th = assoc_right (th RS disj_assoc) - handle THM _ => th; + handle THM _ => th; (*Must check for negative literal first!*) val clause_rules = [disj_assoc, make_neg_rule, make_pos_rule]; @@ -278,7 +190,7 @@ (*Create a goal or support clause, conclusing False*) fun make_goal th = (*Must check for negative literal first!*) - make_goal (tryres(th, clause_rules)) + make_goal (tryres(th, clause_rules)) handle THM _ => tryres(th, [make_neg_goal, make_pos_goal]); (*Sort clauses by number of literals*) @@ -291,23 +203,23 @@ fun generalize th = forall_elim_vars 0 (forall_intr_frees th); (*Create a meta-level Horn clause*) - fun make_horn crules th = make_horn crules (tryres(th,crules)) - handle THM _ => th; + fun make_horn crules th = make_horn crules (tryres(th,crules)) + handle THM _ => th; (*Generate Horn clauses for all contrapositives of a clause*) - fun add_contras crules (th,hcs) = + fun add_contras crules (th,hcs) = let fun rots (0,th) = hcs - | rots (k,th) = zero_var_indexes (make_horn crules th) :: - rots(k-1, assoc_right (th RS disj_comm)) + | rots (k,th) = zero_var_indexes (make_horn crules th) :: + rots(k-1, assoc_right (th RS disj_comm)) in case nliterals(prop_of th) of - 1 => th::hcs + 1 => th::hcs | n => rots(n, assoc_right th) end; (*Use "theorem naming" to label the clauses*) - fun name_thms label = + fun name_thms label = let fun name1 (th, (k,ths)) = - (k-1, Thm.name_thm (label ^ string_of_int k, th) :: ths) + (k-1, Thm.name_thm (label ^ string_of_int k, th) :: ths) in fn ths => #2 (foldr name1 (ths, (length ths, []))) end; @@ -320,7 +232,7 @@ (***** MESON PROOF PROCEDURE *****) fun rhyps (Const("==>",_) $ (Const("Trueprop",_) $ A) $ phi, - As) = rhyps(phi, A::As) + As) = rhyps(phi, A::As) | rhyps (_, As) = As; (** Detecting repeated assumptions in a subgoal **) @@ -333,23 +245,23 @@ | has_reps [_] = false | has_reps [t,u] = (t aconv u) | has_reps ts = (foldl ins_term (Net.empty, ts); false) - handle INSERT => true; + handle INSERT => true; (*Like TRYALL eq_assume_tac, but avoids expensive THEN calls*) fun TRYALL_eq_assume_tac 0 st = Seq.single st - | TRYALL_eq_assume_tac i st = - TRYALL_eq_assume_tac (i-1) (eq_assumption i st) - handle THM _ => TRYALL_eq_assume_tac (i-1) st; + | TRYALL_eq_assume_tac i st = + TRYALL_eq_assume_tac (i-1) (eq_assumption i st) + handle THM _ => TRYALL_eq_assume_tac (i-1) st; (*Loop checking: FAIL if trying to prove the same thing twice -- if *ANY* subgoal has repeated literals*) - fun check_tac st = + fun check_tac st = if exists (fn prem => has_reps (rhyps(prem,[]))) (prems_of st) then Seq.empty else Seq.single st; (* net_resolve_tac actually made it slower... *) - fun prolog_step_tac horns i = + fun prolog_step_tac horns i = (assume_tac i APPEND resolve_tac horns i) THEN check_tac THEN TRYALL eq_assume_tac; @@ -365,48 +277,48 @@ (*Negation Normal Form*) val nnf_rls = [imp_to_disjD, iff_to_disjD, not_conjD, not_disjD, - not_impD, not_iffD, not_allD, not_exD, not_notD]; + not_impD, not_iffD, not_allD, not_exD, not_notD]; fun make_nnf th = make_nnf (tryres(th, nnf_rls)) - handle THM _ => - forward_res make_nnf - (tryres(th, [conj_forward,disj_forward,all_forward,ex_forward])) + handle THM _ => + forward_res make_nnf + (tryres(th, [conj_forward,disj_forward,all_forward,ex_forward])) handle THM _ => th; (*Pull existential quantifiers (Skolemization)*) -fun skolemize th = +fun skolemize th = if not (has_consts ["Ex"] (prop_of th)) then th else skolemize (tryres(th, [choice, conj_exD1, conj_exD2, - disj_exD, disj_exD1, disj_exD2])) - handle THM _ => - skolemize (forward_res skolemize - (tryres (th, [conj_forward, disj_forward, all_forward]))) + disj_exD, disj_exD1, disj_exD2])) + handle THM _ => + skolemize (forward_res skolemize + (tryres (th, [conj_forward, disj_forward, all_forward]))) handle THM _ => forward_res skolemize (th RS ex_forward); (*Make clauses from a list of theorems, previously Skolemized and put into nnf. The resulting clauses are HOL disjunctions.*) -fun make_clauses ths = +fun make_clauses ths = sort_clauses (map (generalize o nodups) (foldr cnf (ths,[]))); (*Convert a list of clauses to (contrapositive) Horn clauses*) -fun make_horns ths = +fun make_horns ths = name_thms "Horn#" (gen_distinct eq_thm (foldr (add_contras clause_rules) (ths,[]))); (*Could simply use nprems_of, which would count remaining subgoals -- no discrimination as to their size! With BEST_FIRST, fails for problem 41.*) -fun best_prolog_tac sizef horns = +fun best_prolog_tac sizef horns = BEST_FIRST (has_fewer_prems 1, sizef) (prolog_step_tac horns 1); -fun depth_prolog_tac horns = +fun depth_prolog_tac horns = DEPTH_FIRST (has_fewer_prems 1) (prolog_step_tac horns 1); (*Return all negative clauses, as possible goal clauses*) fun gocls cls = name_thms "Goal#" (map make_goal (neg_clauses cls)); -fun skolemize_tac prems = +fun skolemize_tac prems = cut_facts_tac (map (skolemize o make_nnf) prems) THEN' REPEAT o (etac exE); @@ -419,21 +331,21 @@ (** Best-first search versions **) -fun best_meson_tac sizef = - MESON (fn cls => +fun best_meson_tac sizef = + MESON (fn cls => THEN_BEST_FIRST (resolve_tac (gocls cls) 1) (has_fewer_prems 1, sizef) (prolog_step_tac (make_horns cls) 1)); (*First, breaks the goal into independent units*) val safe_best_meson_tac = - SELECT_GOAL (TRY Safe_tac THEN + SELECT_GOAL (TRY Safe_tac THEN TRYALL (best_meson_tac size_of_subgoals)); (** Depth-first search version **) val depth_meson_tac = - MESON (fn cls => EVERY [resolve_tac (gocls cls) 1, + MESON (fn cls => EVERY [resolve_tac (gocls cls) 1, depth_prolog_tac (make_horns cls)]); @@ -442,7 +354,7 @@ (*This version does only one inference per call; having only one eq_assume_tac speeds it up!*) -fun prolog_step_tac' horns = +fun prolog_step_tac' horns = let val (horn0s, hornps) = (*0 subgoals vs 1 or more*) take_prefix Thm.no_prems horns val nrtac = net_resolve_tac horns @@ -451,17 +363,34 @@ ((assume_tac i APPEND nrtac i) THEN check_tac) end; -fun iter_deepen_prolog_tac horns = +fun iter_deepen_prolog_tac horns = ITER_DEEPEN (has_fewer_prems 1) (prolog_step_tac' horns); -val iter_deepen_meson_tac = - MESON (fn cls => +val iter_deepen_meson_tac = + MESON (fn cls => (THEN_ITER_DEEPEN (resolve_tac (gocls cls) 1) (has_fewer_prems 1) (prolog_step_tac' (make_horns cls)))); -val meson_tac = - SELECT_GOAL (TRY Safe_tac THEN - TRYALL (iter_deepen_meson_tac)); +fun meson_claset_tac cs = + SELECT_GOAL (TRY (safe_tac cs) THEN TRYALL iter_deepen_meson_tac); + +val meson_tac = CLASET' meson_claset_tac; + + +(* proof method setup *) + +local + +fun meson_meth ctxt = + Method.SIMPLE_METHOD' HEADGOAL (CHANGED o meson_claset_tac (Classical.get_local_claset ctxt)); + +in + +val meson_setup = + [Method.add_methods + [("meson", Method.ctxt_args meson_meth, "The MESON resolution proof procedure")]]; end; + +end; diff -r 580c50fc6559 -r 95dca9f991f2 src/HOL/meson_lemmas.ML --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/HOL/meson_lemmas.ML Tue Sep 05 21:06:01 2000 +0200 @@ -0,0 +1,92 @@ +(* Title: HOL/meson_lemmas.ML + ID: $Id$ + Author: Lawrence C Paulson, Cambridge University Computer Laboratory + Copyright 1992 University of Cambridge + +Lemmas for Meson. +*) + +(* "Axiom" of Choice, proved using the description operator *) + +Goal "ALL x. EX y. Q x y ==> EX f. ALL x. Q x (f x)"; +by (fast_tac (claset() addEs [selectI]) 1); +qed "choice"; + + +(* Generation of contrapositives *) + +(*Inserts negated disjunct after removing the negation; P is a literal*) +val [major,minor] = Goal "~P|Q ==> ((~P==>P) ==> Q)"; +by (rtac (major RS disjE) 1); +by (rtac notE 1); +by (etac minor 2); +by (ALLGOALS assume_tac); +qed "make_neg_rule"; + +(*For Plaisted's "Postive refinement" of the MESON procedure*) +Goal "~P|Q ==> (P ==> Q)"; +by (Blast_tac 1); +qed "make_refined_neg_rule"; + +(*P should be a literal*) +val [major,minor] = Goal "P|Q ==> ((P==>~P) ==> Q)"; +by (rtac (major RS disjE) 1); +by (rtac notE 1); +by (etac minor 1); +by (ALLGOALS assume_tac); +qed "make_pos_rule"; + + +(* Generation of a goal clause -- put away the final literal *) + +val [major,minor] = Goal "~P ==> ((~P==>P) ==> False)"; +by (rtac notE 1); +by (rtac minor 2); +by (ALLGOALS (rtac major)); +qed "make_neg_goal"; + +val [major,minor] = Goal "P ==> ((P==>~P) ==> False)"; +by (rtac notE 1); +by (rtac minor 1); +by (ALLGOALS (rtac major)); +qed "make_pos_goal"; + + +(* Lemmas for forward proof (like congruence rules) *) + +(*NOTE: could handle conjunctions (faster?) by + nf(th RS conjunct2) RS (nf(th RS conjunct1) RS conjI) *) +val major::prems = Goal + "[| P'&Q'; P' ==> P; Q' ==> Q |] ==> P&Q"; +by (rtac (major RS conjE) 1); +by (rtac conjI 1); +by (ALLGOALS (eresolve_tac prems)); +qed "conj_forward"; + +val major::prems = Goal + "[| P'|Q'; P' ==> P; Q' ==> Q |] ==> P|Q"; +by (rtac (major RS disjE) 1); +by (ALLGOALS (dresolve_tac prems)); +by (ALLGOALS (eresolve_tac [disjI1,disjI2])); +qed "disj_forward"; + +(*Version for removal of duplicate literals*) +val major::prems = Goal + "[| P'|Q'; P' ==> P; [| Q'; P==>False |] ==> Q |] ==> P|Q"; +by (cut_facts_tac [major] 1); +by (blast_tac (claset() addIs prems) 1); +qed "disj_forward2"; + +val major::prems = Goal + "[| ALL x. P'(x); !!x. P'(x) ==> P(x) |] ==> ALL x. P(x)"; +by (rtac allI 1); +by (resolve_tac prems 1); +by (rtac (major RS spec) 1); +qed "all_forward"; + +val major::prems = Goal + "[| EX x. P'(x); !!x. P'(x) ==> P(x) |] ==> EX x. P(x)"; +by (rtac (major RS exE) 1); +by (rtac exI 1); +by (eresolve_tac prems 1); +qed "ex_forward";