conflict_driven_clause_learning_online(_, _, _, _, _, _, b(truth,pred,_), SolverResult) :-
!,
SolverResult = solution([]).
conflict_driven_clause_learning_online(_, _, _, _, _, _, b(falsity,pred,_), SolverResult) :-
!,
SolverResult = contradiction_found.
conflict_driven_clause_learning_online(SolverName, Env, SmtVars, SatVars, WDPosBoolFormula, AnalysisBoolFormula, BoolFormula, SolverResult) :-
% rewriting similar to Tseitin
optimize_clause_size_by_rewriting(BoolFormula, SatVars, TOptBoolFormula, NewSatVars, NewVarConjList),
conjunct_predicates(NewVarConjList, NewVarConj),
conjunct_predicates([AnalysisBoolFormula,TOptBoolFormula], TFullBoolFormula),
% add new top-level Boolean variables introduced by Tseitin rewriting
( NewVarConj = b(truth,pred,_)
-> FullBoolFormula = TFullBoolFormula
; safe_create_texpr(conjunct(NewVarConj,TFullBoolFormula), pred, [], FullBoolFormula)
),
get_bindings_from_ids(NewSatVars, StackBindings, SatBindings, SatVarNames, IdPrologVarTuples, PlVars),
b_to_cnf_safe(FullBoolFormula, StackBindings, CnfBoolFormula),
setup_theory_wf_store(SmtVars, SmtBindings, WfStoreSmt),
( get_preference(cdclt_use_idl_theory_solver,true)
-> difference_logic_solver:init_idl_solver(IdlGraphMut)
; true
),
( WDPosBoolFormula \= b(truth,pred,_)
-> % add WD PO implications
b_to_cnf_safe(WDPosBoolFormula, StackBindings, CnfWDPosBoolFormula),
append(CnfWDPosBoolFormula, CnfBoolFormula, TNCnfBoolFormula)
; TNCnfBoolFormula = CnfBoolFormula
),
cdclt_sat_solver:create_solver_state(SatStateMutable),
SolverEnv = [sat_vars:NewSatVars,sat_varnames:SatVarNames,sat_bindings:SatBindings,t2b_env:Env,pl_vars:PlVars],
log_unique_predicates(SatVarNames),
cdclt_sat_solver:unit_propagate_cnf(SolverEnv, SatStateMutable, TNCnfBoolFormula, TNCnfBoolFormula2),
remove_subsumed_clauses(TNCnfBoolFormula2, TNCnfBoolFormula3),
sort(TNCnfBoolFormula3, NCnfBoolFormula),
( debug_mode(off)
-> true
; cdclt_sat_solver:portray_cnf(NCnfBoolFormula)
),
analyze_binary_clauses(CnfBoolFormula, VarsFromBinaryClauses),
NSolverEnv = [sat_vars:NewSatVars,sat_varnames:SatVarNames,sat_bindings:SatBindings,t2b_env:Env,pl_vars:PlVars,binary_clause_vars:VarsFromBinaryClauses],
setup_reification(SatStateMutable, IdlGraphMut, IdPrologVarTuples, SmtBindings, WfStoreSmt),
cdclt_sat_solver:sat(SolverName, NSolverEnv, SatStateMutable, NCnfBoolFormula, [allow_partial_model]),
retractall(unfixed_deferred_set_error_after_grounding),
cdclt_sat_solver:clear_pending_theory_propagations,
( severe_error_occurred
-> % error occurred during SAT solving
!,
SolverResult = error
; debug_format_cdclt("Ground waitflags", []),
remove_pending_theory_propagations_on_bt,
( conflict_driven_clause_learning_online_grounding(IdlGraphMut, SmtVars, PlVars, SmtBindings, WfStoreSmt, SolverResult)
-> true
; ( unfixed_deferred_set_has_been_propagated
-> % a contradiction has been found but at least one unfixed deferred set has been propagated
% we thus do not know if it's a genuine contradiction
asserta(unfixed_deferred_set_error_after_grounding),
fail
; % this is a genuine contradiction after grounding
fail
)
)
).
conflict_driven_clause_learning_online(_, _, _, _, _, _, _, Res) :-
\+ wd_error_occurred_in_error_scope(_),
critical_enumeration_warning_occured_in_error_scope(A, B, C, D),
!,
clear_enumeration_warnings,
Res = no_solution_found(enumeration_warning(A,B,C,D,critical)).
conflict_driven_clause_learning_online(_, _, _, _, _, _, _, Res) :-
severe_error_occurred,
!,
Res = error.
conflict_driven_clause_learning_online(_, _, _, _, _, _, _, error) :-
\+ initial_solution,
wd_error_occurred_in_error_scope(Reason),
add_error(well_definedness_error, Reason, 'conflict_driven_clause_learning_online').
conflict_driven_clause_learning_online(_, _, _, _, _, _, _, Res) :-
( grounding_timeout_occurred
; cdclt_sat_solver:assignment_timeout_occurred
),
!,
Res = no_solution_found(solver_answered_unknown).
conflict_driven_clause_learning_online(_, _, _, _, _, _, _, no_solution_found(unfixed_deferred_sets)) :-
\+ solve_in_state,
( cdclt_sat_solver:unfixed_deferred_set_error_occurred
; unfixed_deferred_set_error_after_grounding
; unfixed_deferred_set_has_been_propagated
).
conflict_driven_clause_learning_online(_, _, _, _, _, _, _, contradiction_found) :-
\+ initial_solution,
( solve_in_state
-> true
; \+ unfixed_deferred_set_error_after_grounding,
\+ cdclt_sat_solver:unfixed_deferred_set_error_occurred,
\+ unfixed_deferred_set_has_been_propagated
),
\+ wd_error_occurred_in_error_scope(_).