#!/usr/bin/env python3 """The Oracle7 kernel, v3: kernel v2 plus the class fix from KERNEL SEALED 1's verdict (k26: the declared reading answered "a sphere with a radius of 0 m" with 0 litres, because only the induced path checked validity). THE LAW ON EVERY PATH: the declared reading runs the same validity check as the induced one (every given a physical amount, every number read) before planning, and refuses a non-finite or negative physical result. Nothing else changes. usage: module""" from __future__ import annotations import math from kernel_v2 import Kernel2, reader class Kernel3(Kernel2): def declared_answer(self, text): t = reader.normalise(text) givens, flags = reader.read_givens(t) if flags.get("unread_numbers"): return None, "declared: numbers I could not read" for q in givens: bad = reader.valid_given(q) if bad: return None, "declared: " + bad # the same law the induced path applies a, why = super().declared_answer(text) if a is not None and (not math.isfinite(a["value_si"]) or a["value_si"] <= 0): return None, "declared: the result %s is not a physical amount" % a["value_si"] return a, why