Skip to content

Commit 350570b

Browse files
Merge pull request #26 from AdrienChampion/master
improved ADTs + edition 2018
2 parents 30199ec + 7b658f7 commit 350570b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+5599
-3126
lines changed

Cargo.lock

Lines changed: 130 additions & 61 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ readme = "README.md"
99
categories = ["science"]
1010
keywords = ["machine learning", "verification", "proof"]
1111
license = "MIT"
12+
edition = "2018"
1213

1314
[[bin]]
1415
name = "hoice"
@@ -34,12 +35,13 @@ bench = [ ]
3435
libc = "*"
3536
lazy_static = "*"
3637
clap = "*"
37-
hashconsing = { git = "https://github.com/AdrienChampion/hashconsing" }
38+
hashconsing = "*"
3839
error-chain = "*"
3940
ansi_term = "*"
40-
rsmt2 = "^0.9.11"
41+
rsmt2 = "^0.10.0"
4142
num = "*"
4243
mylib = { git = "https://github.com/AdrienChampion/mylib" }
4344
either = "*"
4445
rand = "*"
46+
rand_xorshift = "*"
4547
atty = "*"

rsc/inactive/adt/list-synasc-unsat.smt2

Lines changed: 0 additions & 20 deletions
This file was deleted.

rsc/inactive/adt/list-synasc.smt2

Lines changed: 0 additions & 21 deletions
This file was deleted.

rsc/inactive/adt/sorted.smt2

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
(set-logic HORN)
22

3-
(declare-datatypes () (
4-
(Lst nil (cons (head Int) (tail Lst)))
3+
(declare-datatypes ((Lst 1)) (
4+
(par (T) (
5+
nil (cons (head T) (tail (Lst T))))
6+
)
57
) )
68

79

@@ -14,16 +16,16 @@
1416

1517
; Post-condition.
1618
(declare-fun
17-
rev_pst ( Lst Lst Lst ) Bool
19+
rev_pst ( (Lst Int) (Lst Int) (Lst Int) ) Bool
1820
)
1921
; Terminal case.
2022
(assert
21-
(forall ( (acc Lst) )
23+
(forall ( (acc (Lst Int)) )
2224
(rev_pst acc nil acc)
2325
) )
2426
; Recursive case.
2527
(assert
26-
(forall ( (acc Lst) (lst Lst) (res Lst) )
28+
(forall ( (acc (Lst Int)) (lst (Lst Int)) (res (Lst Int)) )
2729
(=>
2830
(and
2931
(not (= lst nil))
@@ -45,7 +47,7 @@
4547

4648
; Post-condition.
4749
(declare-fun
48-
srt_pst ( Lst Bool ) Bool
50+
srt_pst ( (Lst Int) Bool ) Bool
4951
)
5052
; Terminal cases.
5153
(assert
@@ -57,7 +59,7 @@
5759
(srt_pst (cons hd nil) true)
5860
) )
5961
(assert
60-
(forall ( (lst Lst) )
62+
(forall ( (lst (Lst Int)) )
6163
(=>
6264
(and
6365
(not (= lst nil))
@@ -69,7 +71,7 @@
6971
) )
7072
; Recursive case.
7173
(assert
72-
(forall ( (lst Lst) (res Bool) )
74+
(forall ( (lst (Lst Int)) (res Bool) )
7375
(=>
7476
(and
7577
(not (= lst nil))
@@ -90,7 +92,7 @@
9092
; | nil | _ :: nil => ()
9193
; | _ => assert false
9294
(assert
93-
(forall ( (lst1 Lst) (lst2 Lst) )
95+
(forall ( (lst1 (Lst Int)) (lst2 (Lst Int)) )
9496
(=>
9597
(and
9698
(rev_pst nil lst1 lst2)

rsc/inactive/adt/sorted_len.smt2

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@
77
) )
88
) )
99

10-
(define-funs-rec
11-
(
12-
(len ( (l (Lst Int)) ) Int)
13-
)
14-
(
10+
(define-fun-rec
11+
;(
12+
len ( (l (Lst Int)) ) Int
13+
;)
14+
;(
1515
(ite
1616
(= l nil)
1717
0
1818
(+ 1 (len (tail l)))
1919
)
20-
)
20+
;)
2121
)
2222

2323
(assert (forall
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
(set-logic HORN)
22

3-
(declare-datatypes () (
4-
(Pair (P (left Int) (right Bool)) )
3+
(declare-datatypes ((Pair 0)) (
4+
((P (left Int) (right Bool)))
55
) )
66

77
(declare-fun I1 (Pair) Bool)
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
(set-logic HORN)
22

3-
(declare-datatypes () (
4-
(ArRec0 (new (dflt Int)) )
3+
(declare-datatypes ((ArRec0 0)) (
4+
(
5+
(new (dflt Int))
6+
)
57
) )
68

79
(define-fun storeRec0 ((new ArRec0) (old ArRec0) (ind Int) (val Int)) Bool

src/bin/main.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
//! Entry point for the binary.
22
3-
extern crate hoice;
4-
// extern crate libc;
5-
63
use hoice::common::*;
74

85
// /// Renices the process group.
@@ -29,7 +26,8 @@ fn main() {
2926
or specify a different z3 command with option `{}`",
3027
conf.emph(&conf.solver.conf().get_cmd()),
3128
conf.emph("--z3")
32-
).into(),
29+
)
30+
.into(),
3331
_ => errs,
3432
};
3533
print_err(&errs);

src/check/mod.rs

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@
1111
//! [hoice]: https://github.com/hopv/hoice (hoice github repository)
1212
//! [smt]: http://smtlib.cs.uiowa.edu/ (SMT-LIB website)
1313
14-
use common::{conf, ColorExt, HashMap, Read, Solver};
15-
use errors::*;
14+
use crate::{
15+
common::{conf, ColorExt, HashMap, Instance, Read, Solver},
16+
errors::*,
17+
};
1618

1719
pub mod parse;
1820

@@ -93,7 +95,7 @@ impl Input {
9395
pub fn of_file<P: AsRef<::std::path::Path>>(file: P) -> Res<Self> {
9496
use std::fs::OpenOptions;
9597
let file = file.as_ref();
96-
log_info!{
98+
log_info! {
9799
"loading horn clause file {}...", conf.emph(file.to_string_lossy())
98100
}
99101
let mut buff = String::new();
@@ -120,7 +122,7 @@ impl Output {
120122
/// Loads some input data from a file.
121123
pub fn of_file(file: &str) -> Res<Self> {
122124
use std::fs::OpenOptions;
123-
log_info!{ "loading hoice output file {}...", conf.emph(file) }
125+
log_info! { "loading hoice output file {}...", conf.emph(file) }
124126
let mut buff = String::new();
125127
OpenOptions::new()
126128
.read(true)
@@ -138,7 +140,7 @@ impl Output {
138140
/// Checks the signature of the predicates match the declarations of an input
139141
/// `smt2` file. Also checks that all predicates are defined *once*.
140142
pub fn check_consistency(&mut self, input: &Input) -> Res<()> {
141-
log_info!{ "checking predicate signature consistency..." }
143+
log_info! { "checking predicate signature consistency..." }
142144
let mut map = HashMap::with_capacity(self.pred_defs.len());
143145
log! { @4 "checking for duplicate definitions" }
144146
for &PredDef {
@@ -147,7 +149,7 @@ impl Output {
147149
{
148150
let prev = map.insert(pred.clone(), args.clone());
149151
if prev.is_some() {
150-
bail!(
152+
error_chain::bail!(
151153
"predicate {} is defined twice in hoice's output",
152154
conf.emph(pred)
153155
)
@@ -157,7 +159,7 @@ impl Output {
157159
for &PredDec { ref pred, ref sig } in &input.pred_decs {
158160
if let Some(args) = map.get(pred) {
159161
if sig.len() != args.len() {
160-
bail!(
162+
error_chain::bail!(
161163
"arguments of predicate {}'s definition \
162164
does not match its signature",
163165
conf.emph(pred)
@@ -167,7 +169,7 @@ impl Output {
167169
let iter = sig.iter().zip(args.iter()).enumerate();
168170
for (count, (ty_1, &(ref arg, ref ty_2))) in iter {
169171
if ty_1 != ty_2 {
170-
bail!(
172+
error_chain::bail!(
171173
"type of argument {} ({}) in predicate {}'s definition ({}) \
172174
match that of the input file ({})",
173175
count,
@@ -329,9 +331,9 @@ impl Data {
329331
}
330332

331333
if !okay {
332-
bail!("predicates do not verify all the clauses of the input file")
334+
error_chain::bail!("predicates do not verify all the clauses of the input file")
333335
} else if err {
334-
bail!("at least one error while checking the clauses")
336+
error_chain::bail!("at least one error while checking the clauses")
335337
} else {
336338
Ok(())
337339
}
@@ -344,9 +346,7 @@ pub fn do_it(input_file: &str, output_file: &str) -> Res<()> {
344346

345347
log! { @4 "spawning solver" }
346348

347-
let mut solver = conf
348-
.solver
349-
.spawn("check", Parser, &::instance::Instance::new())?;
349+
let mut solver = conf.solver.spawn("check", Parser, &Instance::new())?;
350350

351351
let res = data.check(&mut solver);
352352
if res.is_ok() {
@@ -369,9 +369,7 @@ pub fn do_it_from_str<P: AsRef<::std::path::Path>>(input_file: P, model: &str) -
369369
Output::of_str(model).chain_err(|| "while loading model")?,
370370
)?;
371371

372-
let mut solver = conf
373-
.solver
374-
.spawn("check", Parser, &::instance::Instance::new())?;
372+
let mut solver = conf.solver.spawn("check", Parser, &Instance::new())?;
375373
let res = data.check(&mut solver);
376374
let end_res = solver.kill().chain_err(|| "While killing solver");
377375
res.and_then(|_| end_res)
@@ -381,7 +379,7 @@ mod smt {
381379
use rsmt2::parse::{ExprParser, IdentParser, ValueParser};
382380
use rsmt2::SmtRes;
383381

384-
use check::{Ident, Term, Value};
382+
use crate::check::{Ident, Term, Value};
385383

386384
/// Parser for the output of the SMT solver.
387385
///

0 commit comments

Comments
 (0)