Skip to content

Conversation

@mlaveaux
Copy link
Collaborator

Reopened the pull request to run tests, now as part of a fork since the main repository has been moved.

Tasks:

  • Add the data expression builders.
  • Parse permutations in cycle notation.

@mlaveaux mlaveaux self-assigned this Dec 21, 2025
Copilot AI review requested due to automatic review settings December 21, 2025 16:06
@mlaveaux mlaveaux added the enhancement New feature or request label Dec 21, 2025
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR continues static analysis work for the pbessymmetry tool by implementing cycle notation parsing for permutations and adding validation logic. The main accomplishment is the completion of parsing permutations in cycle notation (one of the two tasks in the PR description).

  • Added cycle notation parsing for permutations (e.g., "(0 2 1)(3 4)")
  • Introduced permutation validation to ensure control flow parameters are correctly mapped
  • Fixed a critical bug in C++ FFI code where mcrl2_srf_summand_condition was incorrectly returning the summand variable instead of the condition

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
tools/mcrl2/pbes/src/symmetry.rs Added documentation comments to struct fields, improved logging output format, and introduced is_valid_permutation method to validate permutation constraints
tools/mcrl2/pbes/src/permutation.rs Renamed from_input to from_mapping_notation, added from_cycle_notation parser, added domain method, and included test for cycle notation parsing
tools/mcrl2/pbes/src/main.rs Updated CLI arguments, added automatic detection of permutation format (mapping vs cycle notation), and integrated permutation validation
tools/mcrl2/crates/mcrl2/src/pbes.rs Added Display trait for PbesExpression and updated Debug formatting for SrfSummand to use Display instead of Debug
tools/mcrl2/crates/mcrl2-sys/src/pbes.rs Changed FFI signature from &aterm to &_aterm for consistency with C++ implementation
tools/mcrl2/crates/mcrl2-sys/cpp/pbes.h Fixed critical bug where mcrl2_srf_summand_condition returned summand.variable() instead of summand.condition(), and updated mcrl2_pbes_expression_to_string to properly handle _aterm references
.gitmodules Updated boost-include-only submodule URL to point to MERCorg fork

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 6 comments.

@mlaveaux mlaveaux force-pushed the feature/pbessymmetry branch from 2f6d669 to 07c585a Compare January 4, 2026 20:27
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 7 comments.

Comment on lines 155 to 175
pub fn is_valid_permutation(&self, pi: &Permutation) -> Result<(), MercError> {
// Check that all control flow parameters are mapped to control flow parameters.
for index in pi.domain() {
let mapped_index = pi.value(index);
if self.all_control_flow_parameters.contains(&index) != self.all_control_flow_parameters.contains(&mapped_index) {
return Err(format!(
"A parameter at index {} is mapped to parameter at index {}, but they are not both control flow parameters.",
index, mapped_index
).into());
}

if index >= self.parameters.len() || mapped_index >= self.parameters.len() {
return Err(format!(
"A parameter at index {} is mapped to parameter at index {}, but the PBES only has {} parameters.",
index, mapped_index, self.parameters.len()
).into());
}
}

Ok(())
}
Copy link

Copilot AI Jan 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new is_valid_permutation method lacks test coverage. Consider adding tests to verify the validation logic for both valid and invalid cases, including boundary conditions and control flow parameter constraints.

Copilot uses AI. Check for mistakes.
default_value_t = false
)]
partition_data_sorts: bool,
partition_data_sorts: bool,
Copy link

Copilot AI Jan 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing whitespace detected. Remove the trailing space at the end of this line.

Suggested change
partition_data_sorts: bool,
partition_data_sorts: bool,

Copilot uses AI. Check for mistakes.
let mut result: Vec<Vec<T>> = Vec::new();

for element in elements {

Copy link

Copilot AI Jan 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary blank line. Remove this empty line for consistency with the codebase formatting style.

Suggested change

Copilot uses AI. Check for mistakes.
format: Option<PbesFormat>,

/// Pass a single permutation in cycles notation to check for begin a (syntactic) symmetry
/// Pass a single permutation in cycles notation to check whether it is a symmetry.
Copy link

Copilot AI Jan 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Documentation comment is slightly inaccurate. The permutation can be in either mapping notation (e.g., [0->2, 1->0]) or cycle notation (e.g., (0 2 1)), not just cycle notation. Consider updating to: "Pass a single permutation in mapping notation [0->2, 1->0] or cycle notation (0 2 1) to check whether it is a symmetry."

Suggested change
/// Pass a single permutation in cycles notation to check whether it is a symmetry.
/// Pass a single permutation in mapping notation [0->2, 1->0] or cycle notation (0 2 1) to check whether it is a symmetry.

Copilot uses AI. Check for mistakes.
Comment on lines +90 to +128
pub fn from_cycle_notation(cycle_notation: &str) -> Result<Self, MercError> {
let mut mapping: Vec<(usize, usize)> = Vec::new();

// Split the input into cycles by finding all '(...)' groups
for cycle_str in cycle_notation.split('(').skip(1) {
// Find the closing parenthesis
let cycle_content = cycle_str
.split(')')
.next()
.ok_or_else(|| MercError::from("Invalid cycle notation: missing closing ')'"))?;

// Skip empty cycles
if cycle_content.trim().is_empty() {
continue;
}

// Parse all numbers in this cycle
let cycle_elements: Result<Vec<usize>, MercError> = cycle_content
.split_whitespace()
.map(|num_str| {
num_str
.parse::<usize>()
.map_err(|_| MercError::from(format!("Invalid number in cycle notation: {}", num_str)))
})
.collect();

let cycle_elements = cycle_elements?;

// Create mappings for the current cycle (each element maps to the next)
let len = cycle_elements.len();
for i in 0..len {
let from = cycle_elements[i];
let to = cycle_elements[(i + 1) % len];
mapping.push((from, to));
}
}

Ok(Permutation::from_mapping(mapping))
}
Copy link

Copilot AI Jan 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding test coverage for edge cases in from_cycle_notation, such as empty input, single-element cycles, invalid formatting (missing parentheses, invalid numbers), and cycles with duplicate elements.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant