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

fix: exit gracefully on unknown result #66

Merged
merged 1 commit into from
Sep 25, 2023
Merged
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
19 changes: 15 additions & 4 deletions src/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1145,7 +1145,7 @@ impl Data {
/// }
/// ```
pub fn check_unsat(&mut self) -> Res<bool> {
self.get_unsat_proof().map(|_| true)
self.try_get_unsat_proof().map(|opt| opt.is_some())
}

/// Retrieves a proof of unsat.
Expand Down Expand Up @@ -1182,8 +1182,19 @@ impl Data {
/// }
/// ```
pub fn get_unsat_proof(&mut self) -> Res<crate::unsat_core::UnsatRes> {
if let Some(res) = self.try_get_unsat_proof()? {
Ok(res)
} else {
bail!("asked for unsat proof while learning data is not unsat")
}
}

pub fn try_get_unsat_proof(&mut self) -> Res<Option<crate::unsat_core::UnsatRes>> {
self.propagate()?;
log_verb! { "learning data on unsat:\n{}", self.string_do(& (), |s| s.to_string()).unwrap() }
log_verb!(
"learning data on unsat:\n{}",
self.string_do(&(), |s| s.to_string()).unwrap(),
);
for (pred, samples) in self.pos.index_iter() {
for sample in samples {
for neg in &self.neg[pred] {
Expand All @@ -1198,12 +1209,12 @@ impl Data {
} else {
None
};
return Ok(crate::unsat_core::UnsatRes::new(entry_points));
return Ok(Some(crate::unsat_core::UnsatRes::new(entry_points)));
}
}
}
}
bail!("asked for unsat proof while learning data is not unsat")
Ok(None)
}

/// Propagates all staged samples.
Expand Down
Loading