diff --git a/spatial/cli.py b/spatial/cli.py index 2dea4d9..b9fdb7b 100644 --- a/spatial/cli.py +++ b/spatial/cli.py @@ -83,23 +83,32 @@ def check_labels() -> bool: def check_insufficient() -> bool: - """The point of the unknown label: identical observation, opposite truth.""" + """The point of the unknown label: the observation does not settle it. + + Under the monotone rule an unknown label no longer implies that *the one full + state we hold* answers differently from the observation's own world -- it + implies that the withheld content could be the missing piece. So the check is + that something is withheld and the visible structure does not already prove + the answer, which is exactly the condition the label promises. + """ found = 0 - for fam in ("cond.p1h", "area.sup2h", "dof.c6h"): + for fam in generator.FAMILIES: for i in range(8): sc = generator.make(fam, seed=5, index=i) if sc.label.answer != "unknown": continue restricted = FullState(entities=list(sc.obs.entities), edges=list(sc.obs.edges)) - a_full = checker.evaluate(sc.full.entities, sc.full.edges, sc.query) - a_obs = checker.evaluate(restricted.entities, restricted.edges, sc.query) - if a_full != a_obs: + a_vis = checker.evaluate(restricted.entities, restricted.edges, sc.query) + withheld = bool(sc.obs.dangling) or bool((sc.obs.hidden or {}).get("entity")) \ + or bool((sc.obs.hidden or {}).get("edge")) + if withheld and a_vis is not True: found += 1 else: - return _fail(f"{fam}[{i}] unknown but both worlds agree; label is not justified") + return _fail(f"{fam}[{i}] unknown without withheld content or with a " + f"visible proof; label is not justified") if found == 0: return _fail("no insufficient-evidence sample was produced") - print(f"ok {found} unknown samples have same observation, different truth") + print(f"ok {found} unknown samples are undecided by the observation") return True diff --git a/spatial/generator.py b/spatial/generator.py index 301ca97..f235812 100644 --- a/spatial/generator.py +++ b/spatial/generator.py @@ -31,12 +31,14 @@ FAMILIES = { "area.sup2h": {"domain": "stability", "n_blocks": 2, "hidden": 1}, "area.free": {"domain": "stability", "n_blocks": 2, "hidden": 0, "free": 1}, "area.sup3h": {"domain": "stability", "n_blocks": 3, "hidden": 1}, + "area.sup2d": {"domain": "stability", "n_blocks": 2, "hidden": 0, "notch": 1}, "dof.c6": {"domain": "freedom", "n_cons": 6, "hidden": 0}, "dof.c6r": {"domain": "freedom", "n_cons": 7, "hidden": 0}, "dof.c6h": {"domain": "freedom", "n_cons": 6, "hidden": 1}, # the pure sub-skill: no intervention at all, so the answer is exactly "are # all six axes covered". If this family cannot be learned, the edit families # are not the problem -- the set readout is. + "dof.c6d": {"domain": "freedom", "n_cons": 6, "hidden": 0, "notch": 1}, "dof.set": {"domain": "freedom", "n_cons": 6, "hidden": 0, "no_edit": 1}, } @@ -127,7 +129,7 @@ def _build_connection(rng, n_paths: int, hidden: int): # stability: stacked blocks, optional hidden pedestal -def _build_stability(rng, n_blocks: int, hidden: int, free: int = 0): +def _build_stability(rng, n_blocks: int, hidden: int, free: int = 0, notch: int = 0): if free: # the minimal pair against area.sup2h: here T has exactly one contact and # that contact leads to a block which itself hangs in the air. Nothing @@ -178,6 +180,17 @@ def _build_stability(rng, n_blocks: int, hidden: int, free: int = 0): vis_edges.discard(e.eid) vis_ents.discard("P") + if notch: + # a decoy that is *itself* withheld, hanging off the ground and never off + # the target: the visible structure still proves the target stands. This + # is the case that makes "something is hidden" and "I cannot tell" two + # different facts inside one family. Without it every hidden family is + # all-unknown and keying on the hidden flag is a perfect answer. + ents.append(Entity("H", "block", attrs={"box": [80, 70, -16, 100, 90, 0]})) + edges.append(Edge("kHG", "contact", "H", "G")) + vis_edges.discard("kHG") + vis_ents.discard("H") + # the target is T on purpose: it survives every legal edit except the one # that removes P, so "removed something" no longer implies "answer false" query = Query(kind="stability", a="T") @@ -188,6 +201,11 @@ def _build_stability(rng, n_blocks: int, hidden: int, free: int = 0): query.edit = {"op": "remove_entity", "entity": "P"} # collapses elif r < 0.75: query.edit = {"op": "remove_entity", "entity": harmless} # no effect + elif notch: + # removing P takes the only visible proof away; the hidden decoy cannot + # stand in for it, so the verdict becomes unknown rather than false + if r < 0.5: + query.edit = {"op": "remove_entity", "entity": "P"} return ents, edges, query, vis_edges, vis_ents, layers, ["front", "iso"], {"length": "mm", "per_unit": 1} @@ -195,7 +213,7 @@ def _build_stability(rng, n_blocks: int, hidden: int, free: int = 0): # freedom: constraint sets, optionally redundant on one axis -def _build_freedom(rng, n_cons: int, hidden: int, no_edit: int = 0): +def _build_freedom(rng, n_cons: int, hidden: int, no_edit: int = 0, notch: int = 0): # the axes are drawn, so a family spans both verdicts with the same entity # count: six mates that cover every axis lock the part, six that cover five # do not, and the difference is invisible from the shape of the scene @@ -223,6 +241,14 @@ def _build_freedom(rng, n_cons: int, hidden: int, no_edit: int = 0): if hidden: visible.discard("k5") # one mate lives in the part definition vis_ents.discard("F5") + if notch: + # a redundant mate kept outside the view: it dangles on the part, but the + # visible mates already cover every axis, so the proof stands + ents.append(Entity(f"F{n_cons}", "ground", attrs={"x": 0, "y": 0, "z": 0})) + edges.append(Edge(f"k{n_cons}", "constraint", "P", f"F{n_cons}", + attrs={"axis": rng.choice(list(DOF_AXES))})) + visible.discard(f"k{n_cons}") + vis_ents.discard(f"F{n_cons}") query = Query(kind="freedom", a="P") if no_edit: @@ -238,9 +264,9 @@ def _build_freedom(rng, n_cons: int, hidden: int, no_edit: int = 0): _BUILDERS = { "connection": lambda rng, spec: _build_connection(rng, spec["n_paths"], spec["hidden"]), "stability": lambda rng, spec: _build_stability(rng, spec["n_blocks"], spec["hidden"], - spec.get("free", 0)), + spec.get("free", 0), spec.get("notch", 0)), "freedom": lambda rng, spec: _build_freedom(rng, spec["n_cons"], spec["hidden"], - spec.get("no_edit", 0)), + spec.get("no_edit", 0), spec.get("notch", 0)), }