fix(query): correct explain/what-if/why-not diagnostics for variable rules #35
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "refs/pull/35/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Three user-visible correctness gaps in the query/explanation diagnostics,
surfaced by an elephant-3000 agent tour. All three are specific to theories
with variable-headed rules — spindle's own query tests only exercised
ground rules, so the gaps were untested.
Fixes
explanation:explaincontradicted itself on a proven defeasible conclusion.A conclusion derived by a variable rule carries a grounded instance label
(
pn_1) that is absent from the template theory, soexplain_inner'stheory.get_rule(label)missed and no proof tree was built. Thenatural-language formatter then printed a self-contradiction:
resolve_rulenow recovers the template from the grounded label(
{template}_{instance}), so the proof tree builds; the formatter'spositive-but-no-tree fallback is also made non-contradictory.
what_if:newly_provablelisted a literal once per derivation path.new_conclusionsmapped the modified conclusion set to literals with nodedup, so a literal proven at two positive tags (
+Dand+d) appearedtwice.
newly_provableis a set of literals — deduplicated on the sameinjective canonical key already used for the baseline.
why_not: reported the misleading "no rule concludes …" for variable rules.The deriving-rule, missing-premise, and attacker scans iterated the template
rules while
conclusionsare ground, and the family matchers compareargument values — so a ground query
(flies opus)never matched a templatehead
(flies ?x),found_rulestayed false, andblocked_bycame back empty.why_not_with_conclusionsnow reasons over the grounded rules(
ground_theory), so head / body-premise / attacker matching is consistentwith the conclusion set. Superiority still resolves via
template_label().The ambiguity case now reports the real contradiction, e.g.
rule r1_1: Contradicted by r2_2, instead of an empty result.Tests
Each fix ships a regression test confirmed to fail without it:
explain_builds_proof_tree_for_grounded_variable_rulewhat_if_deduplicates_new_conclusionswhy_not_finds_variable_headed_rules_in_ambiguityFull workspace suite: 2077 passed, 0 failed, 28 ignored.
spindle-coreclippy clean (the one pre-existing warning in
reason/defeasible.rsisuntouched).
🤖 Generated with Claude Code