Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Precise proof checking for satisfiable instances #47

Merged
merged 5 commits into from
May 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion varisat-cli/src/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::io;
use clap::{App, ArgMatches, SubCommand};
use failure::Error;

use varisat::checker::{Checker, WriteLrat};
use varisat::checker::{Checker, CheckerError, WriteLrat};

use super::{banner, init_logging};

Expand Down Expand Up @@ -66,6 +66,11 @@ pub fn check_main(matches: &ArgMatches) -> Result<i32, Error> {
Ok(()) => println!("s VERIFIED"),
Err(err) => {
log::error!("{}", err);
if let CheckerError::CheckFailed { debug_step, .. } = err {
if !debug_step.is_empty() {
log::error!("failed step was {}", debug_step)
}
}
println!("s NOT VERIFIED");
return Ok(1);
}
Expand Down
18 changes: 15 additions & 3 deletions varisat/src/binary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use partial_ref::{partial, PartialRef};

use crate::context::{AssignmentP, BinaryClausesP, Context, ProofP, SolverStateP};
use crate::proof::{self, ProofStep};
use crate::proof::{self, DeleteClauseProof, ProofStep};

use crate::lit::Lit;

Expand Down Expand Up @@ -57,7 +57,13 @@ pub fn simplify_binary<'a>(
// This check avoids deleting binary clauses twice if both literals are assigned.
if (!lit) < other_lit {
let lits = [!lit, other_lit];
proof::add_step(ctx.borrow(), &ProofStep::DeleteClause(&lits[..]));
proof::add_step(
ctx.borrow(),
&ProofStep::DeleteClause {
clause: &lits[..],
proof: DeleteClauseProof::Satisfied,
},
);
}
}
}
Expand All @@ -69,7 +75,13 @@ pub fn simplify_binary<'a>(
// This check avoids deleting binary clauses twice if both literals are assigned.
if ctx.part(ProofP).is_active() && !retain && (!lit) < other_lit {
let lits = [!lit, other_lit];
proof::add_step(ctx.borrow(), &ProofStep::DeleteClause(&lits[..]));
proof::add_step(
ctx.borrow(),
&ProofStep::DeleteClause {
clause: &lits[..],
proof: DeleteClauseProof::Satisfied,
},
);
}

retain
Expand Down
17 changes: 17 additions & 0 deletions varisat/src/cdcl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use crate::context::{
};
use crate::decision::make_decision;
use crate::incremental::{enqueue_assumption, EnqueueAssumption};
use crate::lit::Lit;
use crate::proof::{self, ProofStep};
use crate::prop::{backtrack, enqueue_assignment, propagate, Conflict, Reason};
use crate::simplify::{prove_units, simplify};
Expand Down Expand Up @@ -39,6 +40,21 @@ pub fn conflict_step<'a>(

let conflict = match conflict {
Ok(()) => {
if ctx.part(ProofP).models_in_proof() {
let (tmp, mut ctx) = ctx.split_part_mut(TmpDataP);
let model = &mut tmp.lits;
model.clear();
model.extend(
ctx.part(AssignmentP)
.assignment()
.iter()
.enumerate()
.flat_map(|(index, assignment)| {
assignment.map(|polarity| Lit::from_index(index, !polarity))
}),
);
proof::add_step(ctx.borrow(), &ProofStep::Model(&model));
}
ctx.part_mut(SolverStateP).sat_state = SatState::Sat;
return;
}
Expand Down Expand Up @@ -66,6 +82,7 @@ pub fn conflict_step<'a>(
proof::add_step(
ctx.borrow(),
&ProofStep::AtClause {
redundant: clause.len() > 2,
clause: clause.into(),
propagation_hashes: analyze.clause_hashes(),
},
Expand Down
Loading