dpllt_solve_predicate_no_timeout(SolverName, Pred, SolvedPred, SolverResult) :-
debug_format_dpllt("After parsing: ", [], Pred),
debug_format_dpllt("~nStart preprocessing", []),
start_ms_timer(T0),
simplify_negation(Pred, SPred),
debug_format_dpllt("After simplifying negations: ", [], SPred),
reset_optimizer_state,
assert_ground_id_values(0, SPred),
replace_ids_with_ground_values(SPred, 0, [], AstOpt),
precompute_values(AstOpt, [instantiate_quantifier_limit(2)], AstPrecomputed),
debug_format_dpllt("After precomputing values: ", [], AstOpt),
stop_ms_timer_with_debug_msg(T0,precompute_values_for_dpllt),
find_identifier_uses(AstPrecomputed, [], UsedIds),
temporary_set_preference(data_validation_mode, true),
b_compile(AstPrecomputed, UsedIds, [], [], AstCompiled, no_wf_available),
clear_wd_errors, % b_compile might throw a wd error
reset_temporary_preference(data_validation_mode),
debug_format_dpllt("After compiling values: ", [], AstCompiled),
start_ms_timer(T1),
(clean_up_pred(AstCompiled, _, CleanPred) -> true
; add_internal_error('Clean up failed ',SolverName), CleanPred=AstCompiled),
stop_ms_timer_with_debug_msg(T1,clean_up_pred_for_dpllt),
start_ms_timer(T2),
debug_format_dpllt("After AST cleanup: ", [], CleanPred),
( CleanPred = b(truth,pred,_)
-> SolverResult = solution([]),
SolvedPred = b(truth,pred,[])
; CleanPred = b(falsity,pred,_)
-> SolverResult = contradiction_found,
SolvedPred = b(falsity,pred,[])
; is_rewrite_to_idl(RewriteToIdl),
( dpllt_settings:static_smt_symmetry_breaking(true)
-> debug_format_dpllt("Start symmetry breaking..", []),
( get_symmetry_breaking_predicates_decomposed(CleanPred, SymPred)
; add_message(smt_symmetry_breaking, 'Symmetry breaking failed on the top-level.'),
SymPred = b(truth,pred,[])
)
; SymPred = b(truth,pred,[])
),
debug_format_dpllt("done.", []),
dpllt_settings:static_syntax_analysis(PerformStaticAnalysis),
preprocess_predicate(PerformStaticAnalysis, RewriteToIdl, CleanPred, LiftedPred, FilteredCandidateImplsConj, CandidateImpls),
debug_format_dpllt("Lifted predicate: ", [], LiftedPred),
predicate_to_sat(normal, LiftedPred, Env1, WDPOs1, SmtBoolFormula, SatVars1),
preprocess_predicate(false, RewriteToIdl, SymPred, LiftedSymPred, _, _),
predicate_to_sat(normal, WDPOs1, SatVars1, Env1, LiftedSymPred, Env2, WDPOs2, SymBoolFormula, SatVars2),
( PerformStaticAnalysis=true
-> predicate_to_sat(only_reuse, WDPOs2, SatVars2, Env2, FilteredCandidateImplsConj, Env3, WDPOsList, ImplBoolFormula, SatVars3),
debug_format_dpllt("Static analysis inferred: ", [], ImplBoolFormula)
; ImplBoolFormula = b(truth,pred,[]),
SatVars3 = SatVars2, Env3 = Env2, WDPOsList = WDPOs2
),
% well-definedness implication on the top-level to encode well-definedness in the SAT solver
dpllt_sat_solver:init_dynamic_solver_state(SolverName), % TODO: check if this can be moved inside the SAT solver again
conjunct_predicates(WDPOsList, WDPOs),
preprocess_predicate(false, RewriteToIdl, WDPOs, _, _, WDCandidateImpls),
% theory deduction for wd
get_wd_theory_implications(CandidateImpls, WDCandidateImpls, WDTheoryImpls),
predicate_to_sat(normal, WDTheoryImpls, SatVars3, Env3, WDPOs, Env4, _, WDTheoryImplsBoolFormula, SatVars4),
debug_format_dpllt("WD Theory Deduction Implications: ", [], WDTheoryImpls),
predicate_to_sat(normal, WDPOs, SatVars4, Env4, WDPOs, NewEnv, _, WDPosBoolFormula, SatVars),
debug_format_dpllt("WD Implication: ", [], WDPOs),
debug_format_dpllt("WD Implication as Boolean formula: ", [], WDPosBoolFormula),
!,
conjunct_predicates([SymBoolFormula,WDTheoryImplsBoolFormula,ImplBoolFormula], AnalysisBoolFormula),
find_typed_identifier_uses(LiftedPred, SmtVars), % TO DO: improve
debug_format_dpllt("Check LiftedPred", []),
( check_ast(LiftedPred)
-> true
; add_internal_error('AST is missing well-definedness information for solver ', SolverName)
),
dpllt_sat_solver:cnf_to_smt(SmtBoolFormula, SolvedPred),
stop_ms_timer_with_debug_msg(T2,preprocessing_for_dpllt),
debug_format_dpllt("End preprocessing", []),
start_ms_timer(T3),
enter_new_error_scope(ScopeID, dpllt_solve_predicate),
%nl, write('smtBoolFormula: '), nl, translate:print_bexpr(SmtBoolFormula), nl,
%nl, write('Analysis Bool formula: '), nl, translate:print_bexpr(AnalysisBoolFormula), nl,
call_cleanup(conflict_driven_clause_learning_online(SolverName, NewEnv, SmtVars, SatVars, WDPosBoolFormula, AnalysisBoolFormula, SmtBoolFormula, SolverResult),
exit_error_scope(ScopeID, _, dpllt_solve_predicate)),
stop_ms_timer_with_debug_msg(T3,dpllt_solving_success)
).
dpllt_solve_predicate_no_timeout(_, Pred, _, _) :-
add_error(dpllt_solve_predicate, 'Cannot create SAT formula from B predicate:', [Pred]).