Skip to content
Open
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
3 changes: 3 additions & 0 deletions src/batch_tamarin/model/tamarin_recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ class Lemma(BaseModel):
model_config = ConfigDict(extra="forbid")

name: str = Field(..., description="Name of the lemma to prove")
use_prefix_matching: bool = Field(
default=True, description="Do prefix matching for lemmas"
)
tamarin_versions: Optional[List[str]] = Field(
None,
min_length=1,
Expand Down
5 changes: 4 additions & 1 deletion src/batch_tamarin/modules/config_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,10 @@ def _parse_lemmas_with_specific_flags(
matching_lemmas = [
parsed_lemma
for parsed_lemma in visible_lemmas
if lemma_spec.name in parsed_lemma
if lemma_spec.use_prefix_matching
and lemma_spec.name in parsed_lemma
or not lemma_spec.use_prefix_matching
and lemma_spec.name == parsed_lemma
]

if not matching_lemmas:
Expand Down
23 changes: 23 additions & 0 deletions tests/test_config_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,29 @@ def test_lemma_prefix_matching(
lemma_names = {task.lemma for task in lemma_tasks}
assert lemma_names == {"test_lemma_1", "test_lemma_2", "different_lemma"}

def test_lemma_no_prefix_matching(
self,
complex_recipe_data: Dict[str, Any],
mock_notifications: Any,
setup_output_manager: Any,
):
"""Test the lemma mathing without prefix matching"""
recipe = TamarinRecipe.model_validate(complex_recipe_data)
# Disable prefix matching for all lemmas
for task in (t for t in recipe.tasks.values() if t.lemmas):
for lemma in task.lemmas:
lemma.use_prefix_matching = False
executable_tasks = ConfigManager.recipe_to_executable_tasks(recipe)

# Find lemma_specific_task tasks
lemma_tasks = [
t for t in executable_tasks if t.task_name.startswith("lemma_task--")
]

# Should match: different_lemma (from "different_lemma")
lemma_names = {task.lemma for task in lemma_tasks}
assert lemma_names == {"different_lemma"}

def test_lemma_no_matches_warning(
self,
minimal_recipe_data: Dict[str, Any],
Expand Down