1 (******************************************************************************)
3 (* DESCRIPTION : The main functions for the Boyer-Moore-style prover. *)
5 (* READS FILES : <none> *)
6 (* WRITES FILES : <none> *)
8 (* AUTHOR : R.J.Boulton *)
9 (* DATE : 27th June 1991 *)
11 (* LAST MODIFIED : R.J.Boulton *)
12 (* DATE : 13th October 1992 *)
14 (* LAST MODIFIED : P. Papapanagiotou (University of Edinburgh) *)
15 (* DATE : July 2009 *)
16 (******************************************************************************)
18 (*----------------------------------------------------------------------------*)
19 (* BOYER_MOORE : conv *)
21 (* Boyer-Moore-style automatic theorem prover. *)
22 (* Given a term "tm", attempts to prove |- tm. *)
23 (*----------------------------------------------------------------------------*)
25 let BOYER_MOORE_MESON tm =
28 proof_print_depth := 0;
30 try (proof_print_newline
33 clausal_form_heuristic;
37 HL_simplify_heuristic;
38 use_equality_heuristic;
39 generalize_heuristic_ext;
40 irrelevance_heuristic]
41 induction_heuristic []
43 ) with Failure _ -> failwith "BOYER_MOORE";;
45 let BOYER_MOORE_GEN tm =
48 proof_print_depth := 0;
50 try (proof_print_newline
53 clausal_form_heuristic;
56 HL_simplify_heuristic;
57 use_equality_heuristic;
58 generalize_heuristic_ext;
59 irrelevance_heuristic]
60 induction_heuristic []
62 ) with Failure _ -> failwith "BOYER_MOORE";;
64 let BOYER_MOORE_EXT tm =
67 proof_print_depth := 0;
69 try (proof_print_newline
72 clausal_form_heuristic;
75 use_equality_heuristic;
76 HL_simplify_heuristic;
77 (* meson_heuristic; *)
79 irrelevance_heuristic]
80 induction_heuristic []
82 ) with Failure _ -> failwith "BOYER_MOORE";;
87 proof_print_depth := 0;
89 try (proof_print_newline
91 [clausal_form_heuristic;
94 use_equality_heuristic;
96 irrelevance_heuristic]
99 ) with Failure _ -> failwith "BOYER_MOORE";;
101 (*----------------------------------------------------------------------------*)
102 (* BOYER_MOORE_CONV : conv *)
104 (* Boyer-Moore-style automatic theorem prover. *)
105 (* Given a term "tm", attempts to prove |- tm = T. *)
106 (*----------------------------------------------------------------------------*)
108 let BOYER_MOORE_CONV tm =
109 try (EQT_INTRO (BOYER_MOORE tm)) with Failure _ -> failwith "BOYER_MOORE_CONV";;
111 (*----------------------------------------------------------------------------*)
112 (* HEURISTIC_TAC : *)
113 (* ((term # bool) -> ((term # bool) list # proof)) list -> tactic *)
115 (* Tactic to do automatic proof using a list of heuristics. The tactic will *)
116 (* fail if it thinks the goal is not a theorem. Otherwise it will either *)
117 (* prove the goal, or return as subgoals the conjectures it couldn't handle. *)
119 (* If the `proof_printing' flag is set to true, the tactic displays each new *)
120 (* conjecture it generates, prints blank lines between subconjectures which *)
121 (* resulted from a split, and prints a final blank line when it can do no *)
124 (* Given a goal, the tactic constructs an implication from it, so that the *)
125 (* hypotheses are made available. It then tries to prove this implication. *)
126 (* When it can do no more, the function splits the clauses that it couldn't *)
127 (* prove into disjuncts. The last disjunct is assumed to be a conclusion, and *)
128 (* the rest are taken to be hypotheses. These new goals are returned together *)
129 (* with a proof of the original goal. *)
131 (* The proof takes a list of theorems for the subgoals and discharges the *)
132 (* hypotheses so that the theorems are in clausal form. These clauses are *)
133 (* then used to prove the implication that was constructed from the original *)
134 (* goal. Finally the antecedants of this implication are undischarged to give *)
135 (* a theorem for the original goal. *)
136 (*----------------------------------------------------------------------------*)
138 let HEURISTIC_TAC heuristics (asl,w) =
139 proof_print_depth := 0; try
140 (let negate tm = if (is_neg tm) then (rand tm) else (mk_neg tm)
141 and NEG_DISJ_DISCH tm th =
143 then DISJ_DISCH (rand tm) th
144 else CONV_RULE (REWR_CONV IMP_DISJ_THM) (DISCH tm th)
145 in let tm = list_mk_imp (asl,w)
146 in let tree = proof_print_newline
147 (waterfall (clausal_form_heuristic::heuristics) (tm,false))
148 in let tml = map fst (fringe_of_clause_tree tree)
149 in let disjsl = map disj_list tml
150 in let goals = map (fun disjs -> (map negate (butlast disjs),last disjs)) disjsl
152 let thl' = map (fun (th,goal)-> itlist NEG_DISJ_DISCH (fst goal) th)
153 (lcombinep (thl,goals))
154 in funpow (length asl) UNDISCH (prove_clause_tree tree thl')
156 ) with Failure _ -> failwith "HEURISTIC_TAC";;
158 (*----------------------------------------------------------------------------*)
159 (* BOYER_MOORE_TAC : tactic *)
161 (* Tactic to do automatic proof using Boyer & Moore's heuristics. The tactic *)
162 (* will fail if it thinks the goal is not a theorem. Otherwise it will either *)
163 (* prove the goal, or return as subgoals the conjectures it couldn't handle. *)
164 (*----------------------------------------------------------------------------*)
166 let BOYER_MOORE_TAC aslw =
170 use_equality_heuristic;
171 generalize_heuristic;
172 irrelevance_heuristic;
175 ) with Failure _ -> failwith "BOYER_MOORE_TAC";;
177 (*----------------------------------------------------------------------------*)
178 (* BM_SIMPLIFY_TAC : tactic *)
180 (* Tactic to do automatic simplification using Boyer & Moore's heuristics. *)
181 (* The tactic will fail if it thinks the goal is not a theorem. Otherwise, it *)
182 (* will either prove the goal or return the simplified conjectures as *)
184 (*----------------------------------------------------------------------------*)
186 let BM_SIMPLIFY_TAC aslw =
187 try (HEURISTIC_TAC [subst_heuristic;simplify_heuristic] aslw
188 ) with Failure _ -> failwith "BM_SIMPLIFY_TAC";;
190 (*----------------------------------------------------------------------------*)
191 (* BM_INDUCT_TAC : tactic *)
193 (* Tactic which attempts to do a SINGLE induction using Boyer & Moore's *)
194 (* heuristics. The cases of the induction are returned as subgoals. *)
195 (*----------------------------------------------------------------------------*)
197 let BM_INDUCT_TAC aslw =
198 try (let induct = ref true
199 in let once_induction_heuristic x =
200 if !induct then (induct := false; induction_heuristic x) else failwith ""
201 in HEURISTIC_TAC [once_induction_heuristic] aslw
202 ) with Failure _ -> failwith "BM_INDUCT_TAC";;