Skip to content
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
11 changes: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,16 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),

### Changed

- **Breaking:** label conversion returns the new `LabelError` instead of a `String`: `AbstractLabelExpression::try_into_bdd`, `AbstractLabelExpression::try_into_prop` and `LabelExpression::try_into_hoa_expression`. It tells an out-of-range AP (`LabelError::ApOutOfRange { ap, count }`) from an unresolved alias (`LabelError::UnresolvedAlias(name)`) and implements `std::error::Error` (issue 6).
- **Breaking:** `biodivine-lib-bdd` is no longer a dependency, so no BDD type appears in the API any more. Labels are only kept as the `AbstractLabelExpression` that was parsed: `Label` is now `Label(pub AbstractLabelExpression)` (and derefs to it), `LabelExpression` is gone, and `Aliases` holds `AbstractLabelExpression`s. Interpreting a label (as a BDD, a truth table, ...) is left to the user, who calls `HoaRepresentation::unalias` first and can use `AbstractLabelExpression::max_ap` (now public) to find the number of propositions it needs. `Label` is written with the `Display` of the expression, which no longer rewrites anything.

| 0.4 | 0.5 |
|---|---|
| `hoars::HoaExpression` (`Bdd`) | removed, build your own from the `AbstractLabelExpression` |
| `LabelExpression::{Abstract, Expression}`, `Label(LabelExpression)` | `Label(AbstractLabelExpression)`; `match &label.0 { LabelExpression::Abstract(e) => .. }` becomes `let e = &label.0;` |
| `AbstractLabelExpression::try_into_bdd`, `try_into_prop`, `LabelExpression::try_into_hoa_expression` | removed; fold the expression yourself over `Boolean`, `Integer`, `Negated`, `Conjunction`, `Disjunction` (`Alias` after `unalias` is an error) |
| `LabelError` (`ApOutOfRange`, `UnresolvedAlias`) | removed with the conversions; `HoaRepresentation::verify` still reports out-of-range propositions, `max_ap` gives the largest one |
| `Label(LabelExpression::Expression(bdd))` printed as a DNF | removed |
| `biodivine-lib-bdd` in `Cargo.toml` | none |
- **Breaking:** `HoaRepresentation::unalias` returns the new `AliasError` (`Undefined`, `Cyclic`) and `HoaRepresentation::verify` returns `VerifyErrors`, a list of `VerifyError` (`DuplicateState`, `StateCountMismatch`), instead of `String`. Both implement `std::error::Error`, and `VerifyErrors` derefs to `[VerifyError]` (issue 6).

## [0.4.0] - 2026-11-06
Expand Down
6 changes: 3 additions & 3 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@ RUSTDOCFLAGS="-D warnings" cargo doc --no-deps
## Layout

- `src/lexer.rs`: tokens (`chumsky`-based). `src/input.rs`: parsing entry points, `ariadne` diagnostics.
- `src/header.rs`, `src/body.rs`, `src/value.rs`: parsers/types for the header items, the body (states, edges), and values (integers, acceptance expressions, labels via `biodivine-lib-bdd`).
- `src/header.rs`, `src/body.rs`, `src/value.rs`: parsers/types for the header items, the body (states, edges), and values (integers, acceptance expressions, labels as `AbstractLabelExpression`; there is no BDD library, interpreting a label is up to the user).
- `src/format.rs`, `src/output.rs`: writing HOA. `src/interpretation.rs`: unaliasing and interpretation of the parsed automaton.
- `src/lib.rs`: `HoaAutomaton` (header + body), `from_parts`, `from_hoa` helpers.
- `hoa/`: sample HOA files used by tests (`spec/`, `spot/`; `bench/` is for benchmarks only); `doc/hoaf.pdf`: the format specification.

## Known sharp edges

- MSRV is 1.88 (`rust-version`; `biodivine-lib-bdd` needs it), checked in CI for the library only.
- MSRV is 1.88 (`rust-version`), checked in CI for the library only.
- Parsers use `chumsky` 0.9 (`Simple<Token>` errors), flagged with `allow(clippy::result_large_err)` in several places.
- 52 unit tests, including one that parses, round-trips and converts every fixture in `hoa/` (`hoa/spec/` holds the spec examples, `hoa/spot/` real Spot output); no fuzzing.
- Version `0.4.0` is the first release since crates.io `0.2.0` (0.3.0 was never published); breaking changes include `biodivine-lib-bdd` 0.6 and the reworked `Header`/`Body`/error API.
- Version `0.4.0` is the first release since crates.io `0.2.0` (0.3.0 was never published); breaking changes include the reworked `Header`/`Body`/error API.

## Benchmarks

Expand Down
116 changes: 0 additions & 116 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ exclude = ["fuzz", "hoa/*", "doc/hoaf.pdf", ".github", "scripts", "CLAUDE.md", "

[dependencies]
tracing = "0.1"
biodivine-lib-bdd = "0.6"
itertools = "0.15"

ariadne = "0.6"
Expand Down
19 changes: 8 additions & 11 deletions src/body.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::ops::Deref;
use chumsky::prelude::*;

use crate::{
AbstractLabelExpression, AcceptanceSignature, Id, Label, LabelExpression, StateConjunction,
AbstractLabelExpression, AcceptanceSignature, Id, Label, StateConjunction,
value::{self, HoaErr, sym, tok},
};

Expand All @@ -21,7 +21,7 @@ pub(crate) struct RawState {
#[derive(Clone, Debug, PartialEq, Eq)]
struct RawEdge(Option<Label>, StateConjunction, Option<AcceptanceSignature>);

/// Represents an edge in a HOA automaton. It contains the [`crate::LabelExpression`], the
/// Represents an edge in a HOA automaton. It contains the [`Label`], the
/// [`StateConjunction`] and the [`AcceptanceSignature`] of the edge.
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct Edge(
Expand Down Expand Up @@ -194,18 +194,17 @@ fn implicit_label(i: usize, num_aps: u16) -> Label {
}
})
.collect();
Label(LabelExpression::Abstract(match literals.len() {
Label(match literals.len() {
0 => AbstractLabelExpression::Boolean(true),
1 => literals.remove(0),
_ => AbstractLabelExpression::Conjunction(literals),
}))
})
}

pub fn label<'a, X: HoaErr<'a>>() -> impl Parser<'a, &'a str, Label, extra::Err<X>> + Clone {
sym('[')
.ignore_then(value::label_expression())
.then_ignore(sym(']'))
.map(LabelExpression::Abstract)
.map(Label)
}

Expand Down Expand Up @@ -338,12 +337,10 @@ mod tests {
[0 & !1] 0 {0}
[1] 1 {0}"#;
let t0 = Edge::from_parts(
Label(crate::LabelExpression::Abstract(
AbstractLabelExpression::Conjunction(vec![
AbstractLabelExpression::Integer(0),
AbstractLabelExpression::Negated(Box::new(AbstractLabelExpression::Integer(1))),
]),
)),
Label(AbstractLabelExpression::Conjunction(vec![
AbstractLabelExpression::Integer(0),
AbstractLabelExpression::Negated(Box::new(AbstractLabelExpression::Integer(1))),
])),
StateConjunction(vec![0]),
crate::AcceptanceSignature(vec![0]),
);
Expand Down
42 changes: 0 additions & 42 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,41 +137,6 @@ impl Display for ValidationError {
}
}

/// Why a label expression could not be converted to a BDD, see
/// [`crate::AbstractLabelExpression::try_into_bdd`].
#[derive(Debug, PartialEq, Eq, Clone)]
pub enum LabelError {
/// The expression uses an atomic proposition that the variable set does not have.
ApOutOfRange {
/// The offending atomic proposition.
ap: u16,
/// The number of variables in the BDD variable set.
count: u16,
},
/// The expression contains an alias reference (`@name`) that was not substituted;
/// call [`crate::HoaRepresentation::unalias`] before converting.
UnresolvedAlias(String),
}

impl Display for LabelError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::ApOutOfRange { ap, count } => {
write!(
f,
"AP identifier {ap} is too high, the set has {count} variables"
)
}
Self::UnresolvedAlias(name) => write!(
f,
"alias @{name} is not resolved, call `HoaRepresentation::unalias` first"
),
}
}
}

impl std::error::Error for LabelError {}

/// An `@name` reference that [`crate::HoaRepresentation::unalias`] cannot substitute.
#[derive(Debug, PartialEq, Eq, Clone)]
pub enum AliasError {
Expand Down Expand Up @@ -322,13 +287,6 @@ mod tests {
#[test]
fn conversion_errors_are_std_errors() {
let boxed = |e: Box<dyn std::error::Error>| e.to_string();
assert!(
boxed(Box::new(crate::LabelError::ApOutOfRange {
ap: 2,
count: 1
}))
.contains("AP identifier 2")
);
assert!(
boxed(Box::new(crate::AliasError::Undefined("a".into()))).contains("@a is not defined")
);
Expand Down
Loading
Loading