Spaces:
Sleeping
Sleeping
File size: 1,255 Bytes
66b1c50 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | """Unsat-core explanation helpers for the Week 3 verifier."""
from __future__ import annotations
from dataforge.verifier.schema import Schema
def explain_unsat_core(unsat_core: tuple[str, ...], schema: Schema) -> str:
"""Convert tracked unsat-core labels into user-facing text."""
if not unsat_core:
return "The verifier rejected the fix, but did not expose a tracked explanation."
parts: list[str] = []
for label in unsat_core:
tokens = label.split("::")
if len(tokens) >= 5 and tokens[0] == "domain":
_, column, bound_kind, _, row = tokens[:5]
adjective = "minimum" if bound_kind == "min" else "maximum"
parts.append(f"Row {row} would violate the {adjective} bound for column '{column}'.")
continue
if len(tokens) >= 5 and tokens[0] == "fd":
_, determinant, dependent, _, row = tokens[:5]
determinant_text = determinant.replace("+", ", ")
parts.append(
f"Row {row} would violate FD (functional dependency) "
f"{determinant_text} -> {dependent}."
)
continue
parts.append(f"Tracked verifier rule '{label}' rejected the fix.")
return " ".join(parts)
|