src/HOL/Tools/sat_funcs.ML
changeset 26939 1035c89b4c02
parent 26931 aa226d8405a8
child 27115 0dcafa5c9e3f
equal deleted inserted replaced
26938:64e850c3da9e 26939:1035c89b4c02
   162 
   162 
   163 		(* Thm.thm * (int * Thm.cterm) list -> Thm.thm * (int * Thm.cterm) list -> Thm.thm * (int * Thm.cterm) list *)
   163 		(* Thm.thm * (int * Thm.cterm) list -> Thm.thm * (int * Thm.cterm) list -> Thm.thm * (int * Thm.cterm) list *)
   164 		fun resolution (c1, hyps1) (c2, hyps2) =
   164 		fun resolution (c1, hyps1) (c2, hyps2) =
   165 		let
   165 		let
   166 			val _ = if !trace_sat then
   166 			val _ = if !trace_sat then
   167 					tracing ("Resolving clause: " ^ Display.string_of_thm c1 ^ " (hyps: " ^ ML_Syntax.print_list (Sign.string_of_term (theory_of_thm c1)) (#hyps (rep_thm c1))
   167 					tracing ("Resolving clause: " ^ Display.string_of_thm c1 ^ " (hyps: " ^ ML_Syntax.print_list (Syntax.string_of_term_global (theory_of_thm c1)) (#hyps (rep_thm c1))
   168 						^ ")\nwith clause: " ^ Display.string_of_thm c2 ^ " (hyps: " ^ ML_Syntax.print_list (Sign.string_of_term (theory_of_thm c2)) (#hyps (rep_thm c2)) ^ ")")
   168 						^ ")\nwith clause: " ^ Display.string_of_thm c2 ^ " (hyps: " ^ ML_Syntax.print_list (Syntax.string_of_term_global (theory_of_thm c2)) (#hyps (rep_thm c2)) ^ ")")
   169 				else ()
   169 				else ()
   170 
   170 
   171 			(* the two literals used for resolution *)
   171 			(* the two literals used for resolution *)
   172 			val (hyp1_is_neg, hyp1, hyp2, new_hyps) = find_res_hyps (hyps1, hyps2) []
   172 			val (hyp1_is_neg, hyp1, hyp2, new_hyps) = find_res_hyps (hyps1, hyps2) []
   173 
   173 
   189 			val c_new = Thm.implies_elim
   189 			val c_new = Thm.implies_elim
   190 				(Thm.implies_elim res_thm (if hyp1_is_neg then c2' else c1'))
   190 				(Thm.implies_elim res_thm (if hyp1_is_neg then c2' else c1'))
   191 				(if hyp1_is_neg then c1' else c2')
   191 				(if hyp1_is_neg then c1' else c2')
   192 
   192 
   193 			val _ = if !trace_sat then
   193 			val _ = if !trace_sat then
   194 					tracing ("Resulting clause: " ^ Display.string_of_thm c_new ^ " (hyps: " ^ ML_Syntax.print_list (Sign.string_of_term (theory_of_thm c_new)) (#hyps (rep_thm c_new)) ^ ")")
   194 					tracing ("Resulting clause: " ^ Display.string_of_thm c_new ^ " (hyps: " ^ ML_Syntax.print_list (Syntax.string_of_term_global (theory_of_thm c_new)) (#hyps (rep_thm c_new)) ^ ")")
   195 				else ()
   195 				else ()
   196 			val _ = inc counter
   196 			val _ = inc counter
   197 		in
   197 		in
   198 			(c_new, new_hyps)
   198 			(c_new, new_hyps)
   199 		end
   199 		end
   388 	| SatSolver.SATISFIABLE assignment =>
   388 	| SatSolver.SATISFIABLE assignment =>
   389 		let
   389 		let
   390 			val msg = "SAT solver found a countermodel:\n"
   390 			val msg = "SAT solver found a countermodel:\n"
   391 				^ (commas
   391 				^ (commas
   392 					o map (fn (term, idx) =>
   392 					o map (fn (term, idx) =>
   393 						Sign.string_of_term (the_context ()) term ^ ": "
   393 						Syntax.string_of_term_global (the_context ()) term ^ ": "
   394 							^ (case assignment idx of NONE => "arbitrary" | SOME true => "true" | SOME false => "false")))
   394 							^ (case assignment idx of NONE => "arbitrary" | SOME true => "true" | SOME false => "false")))
   395 					(Termtab.dest atom_table)
   395 					(Termtab.dest atom_table)
   396 		in
   396 		in
   397 			raise THM (msg, 0, [])
   397 			raise THM (msg, 0, [])
   398 		end
   398 		end