52 (Scan.this_string "axiom" || Scan.this_string "definition" |
52 (Scan.this_string "axiom" || Scan.this_string "definition" |
53 || Scan.this_string "theorem" || Scan.this_string "lemma" |
53 || Scan.this_string "theorem" || Scan.this_string "lemma" |
54 || Scan.this_string "hypothesis" || Scan.this_string "conjecture" |
54 || Scan.this_string "hypothesis" || Scan.this_string "conjecture" |
55 || Scan.this_string "negated_conjecture") --| $$ "," -- parse_formula |
55 || Scan.this_string "negated_conjecture") --| $$ "," -- parse_formula |
56 --| $$ ")" --| $$ "." |
56 --| $$ ")" --| $$ "." |
57 >> (fn ("conjecture", phi) => AConn (ANot, [phi]) | (_, phi) => phi) |
57 >> (fn ("conjecture", phi) => (true, AConn (ANot, [phi])) |
|
58 | (_, phi) => (false, phi)) |
58 || Scan.this_string "thf" >> (fn _ => raise THF ()) |
59 || Scan.this_string "thf" >> (fn _ => raise THF ()) |
59 |
60 |
60 val parse_problem = |
61 val parse_problem = |
61 Scan.repeat parse_include |
62 Scan.repeat parse_include |
62 |-- Scan.repeat (parse_cnf_or_fof --| Scan.repeat parse_include) |
63 |-- Scan.repeat (parse_cnf_or_fof --| Scan.repeat parse_include) |
106 |
107 |
107 fun close_hol_prop t = fold (mk_all o Free) (Term.add_frees t []) t |
108 fun close_hol_prop t = fold (mk_all o Free) (Term.add_frees t []) t |
108 |
109 |
109 fun mk_meta_not P = Logic.mk_implies (P, @{prop False}) |
110 fun mk_meta_not P = Logic.mk_implies (P, @{prop False}) |
110 |
111 |
111 fun get_tptp_formula (_, role, _, P, _) = |
112 fun get_tptp_formula (_, role, P, _) = |
112 P |> role = TPTP_Syntax.Role_Conjecture ? mk_meta_not |
113 P |> role = TPTP_Syntax.Role_Conjecture ? mk_meta_not |
113 |
114 |
114 fun read_tptp_file thy file_name = |
115 fun read_tptp_file thy file_name = |
115 let val path = Path.explode file_name in |
116 let val path = Path.explode file_name in |
116 (case parse_tptp_problem (File.read path) of |
117 (case parse_tptp_problem (File.read path) of |
117 (_, s :: ss) => |
118 (_, s :: ss) => |
118 raise SYNTAX ("cannot parse " ^ quote (implode (s :: ss))) |
119 raise SYNTAX ("cannot parse " ^ quote (implode (s :: ss))) |
119 | (phis, []) => |
120 | (problem, []) => |
120 map (HOLogic.mk_Trueprop o close_hol_prop o hol_prop_from_formula) phis) |
121 (exists fst problem, |
|
122 map (HOLogic.mk_Trueprop o close_hol_prop o hol_prop_from_formula o snd) |
|
123 problem)) |
121 handle THF () => |
124 handle THF () => |
122 TPTP_Interpret.interpret_file true (Path.explode "$TPTP") path [] [] thy |
125 let |
123 |> fst |> #3 |> map get_tptp_formula |
126 val problem = |
124 end |
127 TPTP_Interpret.interpret_file true (Path.explode "$TPTP") path [] [] thy |
125 |
128 |> fst |> #3 |
126 fun print_szs_from_outcome s = |
129 in |
127 "% SZS status " ^ |
130 (exists (fn (_, role, _, _) => role = TPTP_Syntax.Role_Conjecture) problem, |
128 (if s = Nitpick.genuineN then |
131 map get_tptp_formula problem) |
129 "CounterSatisfiable" |
132 end |
130 else |
133 end |
131 "Unknown") |
|
132 |> writeln |
|
133 |
134 |
134 (** Isabelle (combination of provers) **) |
135 (** Isabelle (combination of provers) **) |
135 |
136 |
136 fun isabelle_tptp_file file_name = () |
137 fun isabelle_tptp_file file_name = () |
137 |
138 |
138 |
139 |
139 (** Nitpick (alias Nitrox) **) |
140 (** Nitpick (alias Nitrox) **) |
140 |
141 |
141 fun nitpick_tptp_file file_name = |
142 fun nitpick_tptp_file file_name = |
142 let |
143 let |
143 val ts = read_tptp_file @{theory} file_name |
144 val (falsify, ts) = read_tptp_file @{theory} file_name |
144 val state = Proof.init @{context} |
145 val state = Proof.init @{context} |
145 val params = |
146 val params = |
146 [("card", "1\<emdash>100"), |
147 [("card", "1\<emdash>100"), |
147 ("box", "false"), |
148 ("box", "false"), |
148 ("sat_solver", "smart"), |
149 ("sat_solver", "smart"), |
149 ("max_threads", "1"), |
150 ("max_threads", "1"), |
150 ("batch_size", "10"), |
151 ("batch_size", "10"), |
|
152 ("falsify", if falsify then "true" else "false"), |
151 (* ("debug", "true"), *) |
153 (* ("debug", "true"), *) |
152 ("verbose", "true"), |
154 ("verbose", "true"), |
153 (* ("overlord", "true"), *) |
155 (* ("overlord", "true"), *) |
154 ("show_consts", "true"), |
156 ("show_consts", "true"), |
155 ("format", "1000"), |
157 ("format", "1000"), |
160 val i = 1 |
162 val i = 1 |
161 val n = 1 |
163 val n = 1 |
162 val step = 0 |
164 val step = 0 |
163 val subst = [] |
165 val subst = [] |
164 in |
166 in |
165 Nitpick.pick_nits_in_term state params Nitpick.Normal i n step subst ts |
167 Nitpick.pick_nits_in_term state params Nitpick.TPTP i n step subst ts |
166 @{prop False} |
168 (if falsify then @{prop False} else @{prop True}); () |
167 |> fst |> print_szs_from_outcome |
|
168 end |
169 end |
169 |
170 |
170 |
171 |
171 (** Refute **) |
172 (** Refute **) |
|
173 |
|
174 fun print_szs_from_outcome falsify s = |
|
175 "% SZS status " ^ |
|
176 (if s = "genuine" then |
|
177 if falsify then "CounterSatisfiable" else "Satisfiable" |
|
178 else |
|
179 "Unknown") |
|
180 |> writeln |
172 |
181 |
173 fun refute_tptp_file file_name = |
182 fun refute_tptp_file file_name = |
174 let |
183 let |
175 val ts = read_tptp_file @{theory} file_name |
184 val (falsify, ts) = read_tptp_file @{theory} file_name |
176 val params = |
185 val params = |
177 [("maxtime", "10000"), |
186 [("maxtime", "10000"), |
178 ("assms", "true"), |
187 ("assms", "true"), |
179 ("expect", Nitpick.genuineN)] |
188 ("expect", Nitpick.genuineN)] |
180 in |
189 in |
181 Refute.refute_term @{context} params ts @{prop False} |
190 Refute.refute_term @{context} params ts @{prop False} |
182 |> print_szs_from_outcome |
191 |> print_szs_from_outcome falsify |
183 end |
192 end |
184 |
193 |
185 |
194 |
186 (** Sledgehammer **) |
195 (** Sledgehammer **) |
187 |
196 |