Skip to content

Commit

Permalink
wip: print witness function
Browse files Browse the repository at this point in the history
  • Loading branch information
ekiwi committed Nov 16, 2023
1 parent 5956ad8 commit 66029b1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
6 changes: 3 additions & 3 deletions examples/bmc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// author: Kevin Laeufer <[email protected]>

use clap::Parser;
use libpatron::btor2::print_witness;
use libpatron::ir::*;
use libpatron::*;

Expand Down Expand Up @@ -45,9 +46,8 @@ fn main() {
mc::ModelCheckResult::Success => {
println!("unsat");
}
mc::ModelCheckResult::Fail(_) => {
println!("sat");
println!("TODO: print witness")
mc::ModelCheckResult::Fail(wit) => {
print_witness(&mut std::io::stdout(), &wit).unwrap();
}
}
}
2 changes: 1 addition & 1 deletion src/btor2/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ mod witness;

pub use parse::{parse_file, parse_str};
pub use serialize::{serialize, serialize_to_str};
pub use witness::{parse_witness, parse_witnesses};
pub use witness::{parse_witness, parse_witnesses, print_witness};
8 changes: 7 additions & 1 deletion src/btor2/witness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use crate::btor2::parse::tokenize_line;
use crate::mc::{State, Value, Witness};
use std::io::BufRead;
use std::io::{BufRead, Write};

enum ParserState {
Start,
Expand Down Expand Up @@ -152,3 +152,9 @@ fn parse_assignment<'a>(tokens: &'a [&'a str]) -> (u64, &'a str, Value, Option<V
};
(index, name, value, array_index)
}

pub fn print_witness(out: &mut impl Write, witness: &Witness) -> std::io::Result<()> {
writeln!(out, "sat")?;

Ok(())
}

0 comments on commit 66029b1

Please sign in to comment.