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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

WitnessCreator creates SV-COMP violation witnesses for Java programs:

- `witness.yml` in the [YAML witness format 2.3](https://gitlab.com/sosy-lab/benchmarking/sv-witnesses)
- `witness.yml` in the [YAML witness format 2.4](https://gitlab.com/sosy-lab/benchmarking/sv-witnesses)
(required for Java in SV-COMP 2027): one `violation_sequence` with a `function_return`
waypoint per `Verifier.nondet*()` value (`\result == <java literal>` at the closing
parenthesis of the call) and a final `target` waypoint at the violating statement;
Expand Down
2 changes: 1 addition & 1 deletion src/witnesscreator/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.0.0"
__version__ = "1.1.0"
2 changes: 1 addition & 1 deletion src/witnesscreator/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def _add_common(p: argparse.ArgumentParser, producer_name: Optional[str], produc
def build_parser() -> argparse.ArgumentParser:
parser = argparse.ArgumentParser(
prog="witnesscreator",
description="Creates SV-COMP violation witnesses for Java (YAML format 2.3 and legacy GraphML).",
description="Creates SV-COMP violation witnesses for Java (YAML format 2.4 and legacy GraphML).",
)
parser.add_argument("--version", action="version", version=f"witnesscreator {__version__}")
parser.add_argument("-v", "--verbose", action="store_true", help="debug output")
Expand Down
2 changes: 1 addition & 1 deletion src/witnesscreator/witness.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def build_witness(task: Task, values: Iterable[NondetReturn], violation: Optiona


def render_yaml(task: Task, values: Iterable[NondetReturn], violation: Optional[Violation]) -> str:
"""The YAML (format 2.3) witness as a string."""
"""The YAML (format 2.4) witness as a string."""
built = build_witness(task, values, violation)
return _render_yaml(built.metadata, built.waypoints)

Expand Down
13 changes: 9 additions & 4 deletions src/witnesscreator/yaml_writer.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
"""Hand-written emitter for violation witnesses in the YAML format, version 2.3."""
"""Hand-written emitter for violation witnesses in the YAML format, version 2.4."""

from __future__ import annotations

from dataclasses import dataclass
from typing import List, Optional, Sequence, Tuple

FORMAT_VERSION = "2.3"
FORMAT_VERSION = "2.4"

_YAML_ESCAPES = {
'"': '\\"',
Expand Down Expand Up @@ -52,10 +52,15 @@ class Waypoint:
file_name: str
line: int
column: Optional[int] = None
constraint_format: Optional[str] = None

@classmethod
def function_return(cls, constraint: str, file_name: str, line: int, column: Optional[int]):
return cls("function_return", constraint, file_name, line, column)
# The constraint uses the \result extension keyword, so from format 2.4 on it must
# be declared as an extension expression; plain java_expression is no longer allowed
# for function_return waypoints (schema: ext_c/acsl/ext_java/ext_python_expression).
return cls("function_return", constraint, file_name, line, column,
constraint_format="ext_java_expression")

@classmethod
def target(cls, file_name: str, line: int, column: Optional[int]):
Expand Down Expand Up @@ -117,7 +122,7 @@ def render_yaml(metadata: Metadata, waypoints: List[Waypoint]) -> str:
if wp.constraint is not None:
out.append(" constraint:\n")
out.append(f" value: {q(wp.constraint)}\n")
out.append(' format: "java_expression"\n')
out.append(f" format: {q(wp.constraint_format or 'java_expression')}\n")
out.append(" location:\n")
out.append(f" file_name: {q(wp.file_name)}\n")
out.append(f" line: {int(wp.line)}\n")
Expand Down
6 changes: 3 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ def run(witness: Path, *programs: Path) -> str:


def load_yaml(path: Path):
"""Parses the witness with PyYAML and checks the basic 2.3 structure."""
"""Parses the witness with PyYAML and checks the basic 2.4 structure."""
doc = yaml.safe_load(path.read_text(encoding="utf-8"))
assert isinstance(doc, list) and len(doc) == 1
entry = doc[0]
assert entry["entry_type"] == "violation_sequence"
md = entry["metadata"]
assert md["format_version"] == "2.3"
assert md["format_version"] == "2.4"
assert md["task"]["language"] == "Java"
assert "data_model" not in md["task"]
assert set(md["task"]["input_file_hashes"]) == set(md["task"]["input_files"])
Expand All @@ -72,7 +72,7 @@ def load_yaml(path: Path):
if "column" in wp["location"]:
assert wp["location"]["column"] >= 1
if wp["type"] == "function_return":
assert wp["constraint"]["format"] == "java_expression"
assert wp["constraint"]["format"] == "ext_java_expression"
else:
assert wp["type"] == "target" and "constraint" not in wp
return entry
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
- entry_type: "violation_sequence"
metadata:
creation_time: "2026-09-08T17:36:11Z"
format_version: "2.3"
format_version: "2.4"
producer:
name: "GDart"
version: "VERSION_PLACEHOLDER"
Expand All @@ -29,7 +29,7 @@
action: "follow"
constraint:
value: "\\result == 0"
format: "java_expression"
format: "ext_java_expression"
location:
file_name: "./java/jpf-regression/ExDarko_false/Main.java"
line: 34
Expand All @@ -40,7 +40,7 @@
action: "follow"
constraint:
value: "\\result == 0"
format: "java_expression"
format: "ext_java_expression"
location:
file_name: "./java/jpf-regression/ExDarko_false/Main.java"
line: 35
Expand Down
2 changes: 1 addition & 1 deletion tests/test_e2e.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def test_gdart_example_matches_official_witness(tmp_path, witnesslint):
violation = Violation("java.lang.AssertionError", [Frame("Main", "Main.java", 48), Frame("Main", "Main.java", 35)])
paths = write_witnesses(task, values, violation, tmp_path)
ours = load_yaml(paths["yaml"])
official = yaml.safe_load((base / "ExDarko_false.witness-2.3.yml").read_text(encoding="utf-8"))[0]
official = yaml.safe_load((base / "ExDarko_false.witness-2.4.yml").read_text(encoding="utf-8"))[0]
assert ours["content"] == official["content"]
assert ours["metadata"]["task"] == official["metadata"]["task"]
assert ours["metadata"]["producer"] == official["metadata"]["producer"]
Expand Down
2 changes: 1 addition & 1 deletion tests/test_escaping.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def test_yaml_document_structure():
assert entry["metadata"]["task"]["input_file_hashes"] == {"a/Main.java": "0" * 64}
assert entry["metadata"]["task"]["specification"] == "CHECK( init(Main.main()), LTL(G assert) )"
wps = [s["segment"][0]["waypoint"] for s in entry["content"]]
assert wps[0]["constraint"] == {"value": '\\result.equals("x")', "format": "java_expression"}
assert wps[0]["constraint"] == {"value": '\\result.equals("x")', "format": "ext_java_expression"}
assert wps[0]["location"] == {"file_name": "a/Main.java", "line": 3, "column": 7}
assert wps[1] == {"type": "target", "action": "follow", "location": {"file_name": "a/Main.java", "line": 4}}
assert yaml.safe_load(render_yaml(md, []))[0]["content"] == []
Expand Down
Loading