Repository navigation
Merged
Conversation
Search continues past an abort instead of re-running the same find calls on the same input. The returned index is the end of the first non-aborted automaton, as a byte index into the original input. Adds regression tests for an abort before the first --END--, multiple aborts, and inputs without any --END--.
AbstractLabelExpression::try_into_bdd now folds the expression recursively instead of only handling flat conjunctions/disjunctions of atoms. This fixes: - nested labels such as `0&!1 | !0&1` or `(0|1)&!1` being rejected, - `0 & !0` yielding `!0` instead of `false`, - `0 & !7` with 2 APs panicking instead of returning an error. The new signature takes a pre-built `&BddVariableSet` (and `&self`), so a whole automaton can be converted with a single variable set; AP `i` is `BddVariable::from_index(i)`, making the `vars` slice unnecessary. The unused `build_vars` helper is removed.
- Print labels as `[<expr>]` via a precedence-aware Display for AbstractLabelExpression (parenthesise a disjunction inside a conjunction and anything non-atomic inside a negation) instead of the Rust Debug representation. - Print `LabelExpression::Expression(Bdd)` as DNF from sat_clauses(). - Fix the `unambiguous` property spelling. - Quote `tool:`/`name:` values and drop the trailing space when `tool:` has no version. - Add a quoting helper that escapes `\` and `"` and use it for all strings (AP names, tool/name, state comments). - Stop emitting a trailing newline in State Display (blank line after every state) and a trailing space for edges without an acceptance signature. Adds round-trip tests (parse, print, parse, compare) over hoa/ and a sample using nested labels, aliases and every quoting path, plus tests for parenthesisation and BDD label printing.
- integer() and acceptance-info integers use try_map, so overflowing values (e.g. `States: 99999999999`) are parse errors with a span instead of ParseIntError panics. - Label AP identifiers are converted with u16::try_from, so an index >= 65536 is a parse error instead of being silently truncated. - Remove the debug_asserts on header multiplicity from num_states, start, aps, acceptance and acceptance_name: `States:`, `Start:`, `acc-name:` and `AP:` are all optional, so debug builds panicked on valid files. - Accessor signatures: aps() -> &[String] (empty without `AP:`), num_aps() -> u16, acceptance() -> Option<HoaAcceptance>, Header::acceptance_name() -> Option<AcceptanceName>. - try_into_prop/try_into_hoa_expression take the AP count as u16 to match BddVariableSet and num_aps. Tests cover integer and AP-identifier overflow, and that a minimal file (`HOA: v1` + `Acceptance: 0 t` only) and Default::default() work with every accessor without panicking.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes the first four P0 items of the refactor list: a hang, wrong/failing label-to-BDD conversion, an invalid HOA writer, and panics on valid or untrusted input.
1.
first_automaton_split_positionno longer loops foreverWhen
--ABORT--appeared before the first--END--, the loop restarted the samefindcalls on the same slice. It now advances past the abort, skips aborted automata and returns the end of the first non-aborted automaton as an index into the original input (Noneif no--END--follows the last abort). Documented on the function, with tests for abort-before-end, abort-after-end, multiple aborts and no end.2. Labels convert to BDDs by recursive fold
AbstractLabelExpression::try_into_bddhandled only flat conjunctions/disjunctions of atoms, so Spot's usual output was rejected. It is now a plain recursive fold (Boolean→ true/false, bounds-checkedInteger→mk_var,Negated→not,Conjunction→andfrom true,Disjunction→orfrom false).Atomic/try_atomare gone.This fixes:
[0&!1 | !0&1],[(0|1) & !1],[0 & t]— wereErr, now convert;[0 & !0]— was the wrong BDD (!0), nowfalse;[0 & !7]with 2 APs — panicked, now returnsErr.The conversion takes a pre-built
&BddVariableSet(and&self), so a whole automaton can be converted with one variable set; APiisBddVariable::from_index(i), which removes the need for thevarsslice and for building a fresh set per label.3. The writer emits valid, re-parsable HOA
[<expr>]with precedence-aware parentheses (a disjunction inside a conjunction, a non-atom inside a negation) instead of the RustDebugrepresentation.LabelExpression::Expression(Bdd)is printed as a DNF fromsat_clauses().properties: unambiguousis spelled correctly (wasunabmiguous).tool:/name:values are quoted, andtool:without a version no longer prints a trailing space.\and"for every string (AP names, tool/name, state comments).Stateno longer ends in a newline (no blank line after every state), and edges omit the trailing space when they have no acceptance signature.4. Panics on untrusted or valid input
States: 99999999999) are reported as span-carrying parse errors instead of panicking, and an AP identifier ≥ 65536 is a parse error instead of being silently truncated.debug_assertmultiplicities the spec does not require (States:,Start:,acc-name:,AP:are all optional), so debug builds no longer panic on valid files.Breaking changes
HoaRepresentation::aps→&[String](empty withoutAP:),num_aps→u16,acceptance→Option<HoaAcceptance>,Header::acceptance_name→Option<AcceptanceName>.AbstractLabelExpression::try_into_bdd(&self, &BddVariableSet);try_into_prop/try_into_hoa_expressiontake the AP count asu16.build_vars(unused) removed.Both the changelog and the
README.mdversion notes are updated.Testing
./scripts/checkpasses (fmt, clippy-D warnings, doc, 24 tests).cardinality()for0&!1 | !0&1(2),(0|1)&!1(1),0&t(2),0&!0(0),t(4),f(0); out-of-bounds AP isErr; label parenthesisation; BDD labels printed as DNF and re-parsed to the same BDD; writer round-trip (parse → print → parse → compare) over every file inhoa/and a sample with aliases, nested labels and quoting; integer/AP overflow errors; every accessor on a minimal file (HOA: v1+Acceptance: 0 t) and onDefault::default().