<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://invarians.org/index.php?action=history&amp;feed=atom&amp;title=The_Principia_Machina%2FTPC-PY%2Ftpc_tests.py</id>
	<title>The Principia Machina/TPC-PY/tpc tests.py - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://invarians.org/index.php?action=history&amp;feed=atom&amp;title=The_Principia_Machina%2FTPC-PY%2Ftpc_tests.py"/>
	<link rel="alternate" type="text/html" href="https://invarians.org/index.php?title=The_Principia_Machina/TPC-PY/tpc_tests.py&amp;action=history"/>
	<updated>2026-10-21T11:14:01Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.46.2</generator>
	<entry>
		<id>https://invarians.org/index.php?title=The_Principia_Machina/TPC-PY/tpc_tests.py&amp;diff=4891&amp;oldid=prev</id>
		<title>BFP Rauch: 1 revision imported</title>
		<link rel="alternate" type="text/html" href="https://invarians.org/index.php?title=The_Principia_Machina/TPC-PY/tpc_tests.py&amp;diff=4891&amp;oldid=prev"/>
		<updated>2026-09-30T02:11:04Z</updated>

		<summary type="html">&lt;p&gt;1 revision imported&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw-interface=&quot;&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 02:11, 30 September 2026&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;en&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>BFP Rauch</name></author>
	</entry>
	<entry>
		<id>https://invarians.org/index.php?title=The_Principia_Machina/TPC-PY/tpc_tests.py&amp;diff=4890&amp;oldid=prev</id>
		<title>BFP Rauch: TPC-PY source tpc_tests.py (0.2.1), SHA-256 be0f8d09ae45f552; conformed TPS 0.4.0; PROPOSED, not declared (TPC-PY 0.2.0)</title>
		<link rel="alternate" type="text/html" href="https://invarians.org/index.php?title=The_Principia_Machina/TPC-PY/tpc_tests.py&amp;diff=4890&amp;oldid=prev"/>
		<updated>2026-09-30T02:10:58Z</updated>

		<summary type="html">&lt;p&gt;TPC-PY source tpc_tests.py (0.2.1), SHA-256 be0f8d09ae45f552; conformed TPS 0.4.0; PROPOSED, not declared (TPC-PY 0.2.0)&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw-interface=&quot;&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 02:10, 30 September 2026&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l72&quot;&gt;Line 72:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 72:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;import tpc_form as F&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;import tpc_form as F&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;TPC_TESTS_VERSION = &quot;0.2.0&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&quot;&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;TPC_TESTS_VERSION = &quot;0.2.&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;1&quot;     # proposed PATCH with TPC-PY &lt;/ins&gt;0&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;.2.0 (C-MS-5: TPC-PHP reads the JSON as written, a {} apart from a [])&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# D106.1: the closed list of top-level joiners of claims.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# D106.1: the closed list of top-level joiners of claims.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>BFP Rauch</name></author>
	</entry>
	<entry>
		<id>https://invarians.org/index.php?title=The_Principia_Machina/TPC-PY/tpc_tests.py&amp;diff=4237&amp;oldid=prev</id>
		<title>BFP Rauch: 1 revision imported</title>
		<link rel="alternate" type="text/html" href="https://invarians.org/index.php?title=The_Principia_Machina/TPC-PY/tpc_tests.py&amp;diff=4237&amp;oldid=prev"/>
		<updated>2026-09-28T04:37:36Z</updated>

		<summary type="html">&lt;p&gt;1 revision imported&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw-interface=&quot;&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 04:37, 28 September 2026&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;en&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>BFP Rauch</name></author>
	</entry>
	<entry>
		<id>https://invarians.org/index.php?title=The_Principia_Machina/TPC-PY/tpc_tests.py&amp;diff=4236&amp;oldid=prev</id>
		<title>BFP Rauch: TPC-PY source tpc_tests.py (0.2.0), SHA-256 53f69cf161588b64; conformed TPS 0.3.0; PROPOSED, not declared (CO-8)</title>
		<link rel="alternate" type="text/html" href="https://invarians.org/index.php?title=The_Principia_Machina/TPC-PY/tpc_tests.py&amp;diff=4236&amp;oldid=prev"/>
		<updated>2026-09-27T15:43:18Z</updated>

		<summary type="html">&lt;p&gt;TPC-PY source tpc_tests.py (0.2.0), SHA-256 53f69cf161588b64; conformed TPS 0.3.0; PROPOSED, not declared (CO-8)&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;# -*- coding: utf-8 -*-&lt;br /&gt;
&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
TPC-PY --- kernel tests T2, T3, T4, T5, T6 and the isomorphism checks&lt;br /&gt;
IC1-IC4 (TPC step 2, increments 7 and 8) --- SELECTED D106.1, D107.1,&lt;br /&gt;
D108.1; increment 8 at Option 1 of every slot (2026-09-24)&lt;br /&gt;
======================================================================&lt;br /&gt;
SELECTED 2026-09-22: D106.1 (the T2 syntactic rule below), D107.1 (the&lt;br /&gt;
inventory the TrM maps onto: the DOF less REMOVE targets), D108.1 (an&lt;br /&gt;
OPTIONAL declared expression form). INCREMENT 8 (2026-09-24): the form&lt;br /&gt;
exists (tpc_form): where a LAW carries EQUATION, T4&amp;#039;s law half and T3 over&lt;br /&gt;
laws (the ground fragment) are MECHANICAL; where a BOUNDARY carries&lt;br /&gt;
CONDITION, T6&amp;#039;s totality is; where a SIGNATURE carries FORM and&lt;br /&gt;
IMAGE_FORM, IC4 (a) is, syntactically; the names check is T1&amp;#039;s. Where a&lt;br /&gt;
form is absent the part stays INSPECTION by H-DECL and is reported so,&lt;br /&gt;
never silently passed. Spec: tpm_kernel_tests 0.2.0 section 12,&lt;br /&gt;
tpm_increment_8 0.1.0. Standard library only; Python 3.8+; Windows/Linux.&lt;br /&gt;
&lt;br /&gt;
WHAT IS MECHANICAL HERE, AND WHY (guide 3.6, 4.6; TPS 2.2.3, 2.3.7-2.3.15):&lt;br /&gt;
  Under the D98 schema, statements, propositions and predicates are prose;&lt;br /&gt;
  names, citations (REFS, TARGET), dimensions, units and classes are fields.&lt;br /&gt;
  A check is mechanical exactly where it reads fields only.&lt;br /&gt;
    T1  tpc_zone.t1_well_formed (increment 4). It also discharges T4&amp;#039;s&lt;br /&gt;
        constraint half (a FIX&amp;#039;s UNIT against its TARGET&amp;#039;s DIMENSION,&lt;br /&gt;
        D104.1), T5 (a) (every REFS member resolves to a DOF or CONSTANT)&lt;br /&gt;
        and T6&amp;#039;s mechanical clause (a boundary names DOF and CONSTANTs only).&lt;br /&gt;
    T2  the syntactic part: an ASSUMPTION&amp;#039;s PROPOSITION is not a top-level&lt;br /&gt;
        conjunction, list or joined pair of claims (D106.1).&lt;br /&gt;
        The semantic part stays INSPECTION by the guide&amp;#039;s classing.&lt;br /&gt;
    T3  the executable fragment: CONSTRAINT entries. Two FIX of one TARGET&lt;br /&gt;
        at different values, or a FIX and a REMOVE of one TARGET, are P and&lt;br /&gt;
        not-P at depth 1 &amp;lt;= S_MAX. Over the laws, the ground fragment of&lt;br /&gt;
        tpc_form.t3_laws where a LAW carries EQUATION; assumptions, and laws&lt;br /&gt;
        without a form, stay INSPECTION.&lt;br /&gt;
    T4  the law half, tpc_form.t4_homogeneity, where a LAW carries EQUATION;&lt;br /&gt;
        a law without one stays INSPECTION and is listed.&lt;br /&gt;
    T5  (b) a CONSTRAINT&amp;#039;s TARGET is named by at least one LAW, else no law&lt;br /&gt;
        leaves it free and the constraint is void; (c) every DOF is named by&lt;br /&gt;
        at least one LAW, else it is idle.&lt;br /&gt;
    T6  totality, tpc_form.t6_totality, where a BOUNDARY carries CONDITION;&lt;br /&gt;
        a boundary without one stays INSPECTION and is listed.&lt;br /&gt;
    IC1 every environment quantity is identified by some entry.&lt;br /&gt;
    IC2 every DOF of the inventory the TrM maps onto is some entry&amp;#039;s DOF;&lt;br /&gt;
        a failure is a NAMED GAP, disposed of at the final pass by the&lt;br /&gt;
        TMS&amp;#039;s IC2_POLICY (GAP or REJECT), which TPX reads only then.&lt;br /&gt;
    IC3 no DOF is identified with two inequivalent environment quantities,&lt;br /&gt;
        and, the isomorphism being invertible (guide 4.5), no environment&lt;br /&gt;
        quantity with two DOF.&lt;br /&gt;
    IC4 (b) each entry&amp;#039;s DIMENSION equals its DOF&amp;#039;s and its environment&lt;br /&gt;
        quantity&amp;#039;s, canonically; (c) the necessary part: every DOF a law in&lt;br /&gt;
        BEARS names, and the TARGET of every constraint in BEARS, is&lt;br /&gt;
        identified by some entry. (a) the syntactic reading of&lt;br /&gt;
        tpc_form.ic4a_signature where a SIGNATURE carries FORM and&lt;br /&gt;
        IMAGE_FORM; the image holding in the environment stays INSPECTION.&lt;br /&gt;
        IC5 is INSPECTION by the guide&amp;#039;s classing.&lt;br /&gt;
  EQUIVALENCE: TRANSFORMATIONS are prose, so the checks treat distinct&lt;br /&gt;
  ENVIRONMENT_QUANTITY names as inequivalent. This errs toward rejection,&lt;br /&gt;
  never acceptance; equivalence under a TRANSFORMATION stays INSPECTION.&lt;br /&gt;
  THE INVENTORY (D107.1): the TrM maps onto the TPK&amp;#039;s DOF less the&lt;br /&gt;
  TARGETs of REMOVE constraints. A FIXed DOF stays in it: it is identified,&lt;br /&gt;
  and its FIX may be borne by its entry. An entry on a REMOVEd DOF is&lt;br /&gt;
  refused (CODOMAIN).&lt;br /&gt;
&lt;br /&gt;
ORDER (guide L0.5, 4.7; TPS 5.5.2; D98.1): as the TPK is entered, T1, then&lt;br /&gt;
T2, T5, T4 and T6 (T1 failing stops the run); as the TrM is entered,&lt;br /&gt;
IC1-IC4, with IC2&amp;#039;s gaps held; at the final pass, after the TMS, T3 over&lt;br /&gt;
the constraints and the laws, and IC2&amp;#039;s disposition. Every function&lt;br /&gt;
returns canonical lists and never raises on malformed input.&lt;br /&gt;
&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
import tpc_zone as Z&lt;br /&gt;
import tpc_strike as S&lt;br /&gt;
import tpc_form as F&lt;br /&gt;
&lt;br /&gt;
TPC_TESTS_VERSION = &amp;quot;0.2.0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# D106.1: the closed list of top-level joiners of claims.&lt;br /&gt;
T2_WORDS = [&amp;quot;and&amp;quot;, &amp;quot;but&amp;quot;, &amp;quot;whereas&amp;quot;]&lt;br /&gt;
T2_PHRASES = [[&amp;quot;as&amp;quot;, &amp;quot;well&amp;quot;, &amp;quot;as&amp;quot;]]&lt;br /&gt;
T2_SYMBOLS = [&amp;quot;&amp;amp;&amp;quot;, &amp;quot;∧&amp;quot;]                    # ampersand, LOGICAL AND&lt;br /&gt;
_OPEN = {&amp;quot;(&amp;quot;: &amp;quot;)&amp;quot;, &amp;quot;[&amp;quot;: &amp;quot;]&amp;quot;, &amp;quot;{&amp;quot;: &amp;quot;}&amp;quot;}&lt;br /&gt;
_CLOSE = set(_OPEN.values())&lt;br /&gt;
_LIST_MARKS = set(&amp;quot;-*+•&amp;quot;)                  # hyphen, asterisk, plus, bullet&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# ---- shared readers ------------------------------------------------------------&lt;br /&gt;
def _entries_of(zone, key):&lt;br /&gt;
    if not Z._obj(zone):&lt;br /&gt;
        return []&lt;br /&gt;
    v = zone.get(key, [])&lt;br /&gt;
    return [e for e in v if Z._obj(e)] if Z._list(v) else []&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def _s(e, f):&lt;br /&gt;
    v = e.get(f)&lt;br /&gt;
    return v if isinstance(v, str) else None&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def _set(e, f):&lt;br /&gt;
    v = e.get(f)&lt;br /&gt;
    if Z._list(v) and all(isinstance(x, str) for x in v):&lt;br /&gt;
        return v&lt;br /&gt;
    return []&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def _dof_dims(tpk):&lt;br /&gt;
    out = {}&lt;br /&gt;
    for e in _entries_of(tpk, &amp;quot;DOF&amp;quot;):&lt;br /&gt;
        n, d = _s(e, &amp;quot;NAME&amp;quot;), _s(e, &amp;quot;DIMENSION&amp;quot;)&lt;br /&gt;
        if n is not None and n not in out:&lt;br /&gt;
            out[n] = Z.normalize_dimension(d) if d is not None else None&lt;br /&gt;
    return out&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def _law_refs(tpk):&lt;br /&gt;
    out = set()&lt;br /&gt;
    for e in _entries_of(tpk, &amp;quot;LAW&amp;quot;):&lt;br /&gt;
        out.update(_set(e, &amp;quot;REFS&amp;quot;))&lt;br /&gt;
    return out&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def _removed(tpk):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;{DOF name: sorted names of the REMOVE constraints that target it}.&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    out = {}&lt;br /&gt;
    for e in _entries_of(tpk, &amp;quot;CONSTRAINT&amp;quot;):&lt;br /&gt;
        t, n = _s(e, &amp;quot;TARGET&amp;quot;), _s(e, &amp;quot;NAME&amp;quot;)&lt;br /&gt;
        if t is not None and n is not None and _s(e, &amp;quot;ACTION&amp;quot;) == &amp;quot;REMOVE&amp;quot;:&lt;br /&gt;
            out.setdefault(t, []).append(n)&lt;br /&gt;
    return {k: sorted(v) for k, v in out.items()}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# ---- T2, syntactic part (D106.1) -----------------------------------------------&lt;br /&gt;
def _top(chars):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;top[i] is True where chars[i] lies outside every CLOSED bracket pair and&lt;br /&gt;
    every CLOSED quotation. A pair counts only once its closer is found, so an&lt;br /&gt;
    unclosed bracket or quotation hides nothing. A quotation opens only&lt;br /&gt;
    outside brackets: an ASCII double quote closes at the next one; U+201C&lt;br /&gt;
    closes at the next U+201D. Nested pairs are marked too.&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    n = len(chars)&lt;br /&gt;
    inside = [False] * n&lt;br /&gt;
    stack = []                                    # (expected closer, index)&lt;br /&gt;
    i = 0&lt;br /&gt;
    while i &amp;lt; n:&lt;br /&gt;
        ch = chars[i]&lt;br /&gt;
        if not stack and ch in (&amp;#039;&amp;quot;&amp;#039;, &amp;quot;“&amp;quot;):&lt;br /&gt;
            closer = &amp;#039;&amp;quot;&amp;#039; if ch == &amp;#039;&amp;quot;&amp;#039; else &amp;quot;”&amp;quot;&lt;br /&gt;
            j = i + 1&lt;br /&gt;
            while j &amp;lt; n and chars[j] != closer:&lt;br /&gt;
                j += 1&lt;br /&gt;
            if j &amp;lt; n:&lt;br /&gt;
                for k in range(i, j + 1):&lt;br /&gt;
                    inside[k] = True&lt;br /&gt;
                i = j + 1&lt;br /&gt;
                continue&lt;br /&gt;
        elif ch in _OPEN:&lt;br /&gt;
            stack.append((_OPEN[ch], i))&lt;br /&gt;
        elif ch in _CLOSE and stack and stack[-1][0] == ch:&lt;br /&gt;
            start = stack.pop()[1]&lt;br /&gt;
            for k in range(start, i + 1):&lt;br /&gt;
                inside[k] = True&lt;br /&gt;
        i += 1&lt;br /&gt;
    return [not x for x in inside]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def _strip_ws(chars):&lt;br /&gt;
    a, b = 0, len(chars)&lt;br /&gt;
    while a &amp;lt; b and chars[a] in Z._WS:&lt;br /&gt;
        a += 1&lt;br /&gt;
    while b &amp;gt; a and chars[b - 1] in Z._WS:&lt;br /&gt;
        b -= 1&lt;br /&gt;
    return chars[a:b]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def _strip_enclosing(chars):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;Remove bracket pairs that enclose the whole text, repeatedly: a&lt;br /&gt;
    proposition written &amp;quot;(A and B)&amp;quot; is still a top-level conjunction.&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    chars = _strip_ws(chars)&lt;br /&gt;
    while len(chars) &amp;gt;= 2 and chars[0] in _OPEN:&lt;br /&gt;
        depth_zero_at = None&lt;br /&gt;
        stack = []&lt;br /&gt;
        for i, ch in enumerate(chars):&lt;br /&gt;
            if ch in _OPEN:&lt;br /&gt;
                stack.append(_OPEN[ch])&lt;br /&gt;
            elif ch in _CLOSE and stack and stack[-1] == ch:&lt;br /&gt;
                stack.pop()&lt;br /&gt;
                if not stack:&lt;br /&gt;
                    depth_zero_at = i&lt;br /&gt;
                    break&lt;br /&gt;
        if depth_zero_at != len(chars) - 1:&lt;br /&gt;
            break&lt;br /&gt;
        chars = _strip_ws(chars[1:-1])&lt;br /&gt;
    return chars&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def _is_word(ch):&lt;br /&gt;
    return (&amp;quot;a&amp;quot; &amp;lt;= ch &amp;lt;= &amp;quot;z&amp;quot;) or (&amp;quot;A&amp;quot; &amp;lt;= ch &amp;lt;= &amp;quot;Z&amp;quot;) or (&amp;quot;0&amp;quot; &amp;lt;= ch &amp;lt;= &amp;quot;9&amp;quot;) or ch == &amp;quot;_&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def t2_findings(prop):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;The syntactic findings for one PROPOSITION string, sorted: each names&lt;br /&gt;
    the joiner found at top level. [] when none.&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    chars = _strip_enclosing(list(Z._text(prop)))&lt;br /&gt;
    top = _top(chars)&lt;br /&gt;
    found = set()&lt;br /&gt;
    words = []                                    # (text, top) of maximal ASCII word runs&lt;br /&gt;
    i, n = 0, len(chars)&lt;br /&gt;
    while i &amp;lt; n:&lt;br /&gt;
        if _is_word(chars[i]):&lt;br /&gt;
            j = i&lt;br /&gt;
            while j &amp;lt; n and _is_word(chars[j]):&lt;br /&gt;
                j += 1&lt;br /&gt;
            words.append((&amp;quot;&amp;quot;.join(chars[i:j]).lower(), top[i]))&lt;br /&gt;
            i = j&lt;br /&gt;
        else:&lt;br /&gt;
            i += 1&lt;br /&gt;
    for k, (w, t) in enumerate(words):&lt;br /&gt;
        if t and w in T2_WORDS:&lt;br /&gt;
            found.add(&amp;#039;joins claims with &amp;quot;&amp;#039; + w + &amp;#039;&amp;quot;&amp;#039;)&lt;br /&gt;
        for ph in T2_PHRASES:&lt;br /&gt;
            seg = words[k:k + len(ph)]&lt;br /&gt;
            if len(seg) == len(ph) and all(s[1] for s in seg) and [s[0] for s in seg] == ph:&lt;br /&gt;
                found.add(&amp;#039;joins claims with &amp;quot;&amp;#039; + &amp;quot; &amp;quot;.join(ph) + &amp;#039;&amp;quot;&amp;#039;)&lt;br /&gt;
    for i, ch in enumerate(chars):&lt;br /&gt;
        if not top[i]:&lt;br /&gt;
            continue&lt;br /&gt;
        if ch in T2_SYMBOLS:&lt;br /&gt;
            found.add(&amp;quot;joins claims with &amp;quot; + (&amp;quot;U+2227&amp;quot; if ch == &amp;quot;∧&amp;quot; else &amp;#039;&amp;quot;&amp;amp;&amp;quot;&amp;#039;))&lt;br /&gt;
        elif ch == &amp;quot;;&amp;quot;:&lt;br /&gt;
            found.add(&amp;quot;has a semicolon&amp;quot;)&lt;br /&gt;
        elif ch in &amp;quot;.!?&amp;quot;:&lt;br /&gt;
            j = i + 1&lt;br /&gt;
            while j &amp;lt; n and chars[j] in Z._WS:&lt;br /&gt;
                j += 1&lt;br /&gt;
            if j &amp;gt; i + 1 and j &amp;lt; n and &amp;quot;A&amp;quot; &amp;lt;= chars[j] &amp;lt;= &amp;quot;Z&amp;quot;:&lt;br /&gt;
                found.add(&amp;quot;has more than one sentence&amp;quot;)&lt;br /&gt;
        elif ch == &amp;quot;\n&amp;quot;:&lt;br /&gt;
            j = i + 1&lt;br /&gt;
            while j &amp;lt; n and chars[j] in (&amp;quot; &amp;quot;, &amp;quot;\t&amp;quot;):&lt;br /&gt;
                j += 1&lt;br /&gt;
            if j &amp;lt; n and chars[j] in _LIST_MARKS:&lt;br /&gt;
                found.add(&amp;quot;is a list&amp;quot;)&lt;br /&gt;
            elif j &amp;lt; n and &amp;quot;0&amp;quot; &amp;lt;= chars[j] &amp;lt;= &amp;quot;9&amp;quot;:&lt;br /&gt;
                k = j&lt;br /&gt;
                while k &amp;lt; n and &amp;quot;0&amp;quot; &amp;lt;= chars[k] &amp;lt;= &amp;quot;9&amp;quot;:&lt;br /&gt;
                    k += 1&lt;br /&gt;
                if k &amp;lt; n and chars[k] in &amp;quot;.)&amp;quot;:&lt;br /&gt;
                    found.add(&amp;quot;is a list&amp;quot;)&lt;br /&gt;
    return sorted(found)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def t2_atomicity(tpk):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;Kernel test T2, syntactic part: no ASSUMPTION&amp;#039;s PROPOSITION is a&lt;br /&gt;
    top-level conjunction, list or joined pair of claims. [pass, problems].&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    probs = []&lt;br /&gt;
    for e in _entries_of(tpk, &amp;quot;ASSUMPTION&amp;quot;):&lt;br /&gt;
        p = _s(e, &amp;quot;PROPOSITION&amp;quot;)&lt;br /&gt;
        if p is None or Z._first_bad(p) is not None:&lt;br /&gt;
            continue                              # T1&amp;#039;s to report&lt;br /&gt;
        for f in t2_findings(p):&lt;br /&gt;
            probs.append(&amp;quot;ASSUMPTION:&amp;quot; + Z._name(e) + &amp;quot;: PROPOSITION &amp;quot; + f + &amp;quot; (T2)&amp;quot;)&lt;br /&gt;
    return Z._done(probs)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# ---- T3, the executable fragment -------------------------------------------------&lt;br /&gt;
def _fix_value(e):&lt;br /&gt;
    v, u = e.get(&amp;quot;VALUE&amp;quot;), e.get(&amp;quot;UNIT&amp;quot;)&lt;br /&gt;
    if not (isinstance(v, str) and isinstance(u, str)):&lt;br /&gt;
        return [&amp;quot;REFUSED&amp;quot;, &amp;quot;not comparable&amp;quot;]&lt;br /&gt;
    return _units().normalize_measurement(v, &amp;quot;0&amp;quot;, u)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def _units():&lt;br /&gt;
    import tpc_units&lt;br /&gt;
    return tpc_units&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def t3_consistency(tpk, tms):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;Kernel test T3 over the executable fragment: the CONSTRAINT entries -&lt;br /&gt;
    no TARGET is both removed and fixed, and no TARGET is fixed at two values&lt;br /&gt;
    (compared in coherent SI through canon(), the 12-significant-digit form&lt;br /&gt;
    TPC compares presented values in) - and, beside them, the ground fragment&lt;br /&gt;
    over the laws that carry EQUATION (tpc_form.t3_laws). Depth 1, within any&lt;br /&gt;
    S_MAX &amp;gt;= 1. [pass, problems].&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    probs = []&lt;br /&gt;
    pm = tms.get(&amp;quot;PARAMETERS&amp;quot;) if Z._obj(tms) else None&lt;br /&gt;
    sm = pm.get(&amp;quot;S_MAX&amp;quot;) if Z._obj(pm) else None&lt;br /&gt;
    if not (isinstance(sm, int) and not isinstance(sm, bool) and sm &amp;gt;= 1):&lt;br /&gt;
        return Z._done([&amp;quot;T3: S_MAX is not a declared depth of at least 1&amp;quot;])&lt;br /&gt;
    by_target = {}&lt;br /&gt;
    for e in _entries_of(tpk, &amp;quot;CONSTRAINT&amp;quot;):&lt;br /&gt;
        t, n, a = _s(e, &amp;quot;TARGET&amp;quot;), _s(e, &amp;quot;NAME&amp;quot;), _s(e, &amp;quot;ACTION&amp;quot;)&lt;br /&gt;
        if t is None or n is None or a not in (&amp;quot;REMOVE&amp;quot;, &amp;quot;FIX&amp;quot;):&lt;br /&gt;
            continue&lt;br /&gt;
        by_target.setdefault(t, []).append((n, a, e))&lt;br /&gt;
    for t in sorted(by_target):&lt;br /&gt;
        cs = sorted(by_target[t], key=lambda c: c[0])&lt;br /&gt;
        for i in range(len(cs)):&lt;br /&gt;
            for j in range(i + 1, len(cs)):&lt;br /&gt;
                (n1, a1, e1), (n2, a2, e2) = cs[i], cs[j]&lt;br /&gt;
                pair = &amp;quot;CONSTRAINT:&amp;quot; + n1 + &amp;quot; and CONSTRAINT:&amp;quot; + n2&lt;br /&gt;
                if a1 != a2:&lt;br /&gt;
                    probs.append(pair + &amp;quot;: &amp;quot; + t + &amp;quot; is both removed and fixed (T3)&amp;quot;)&lt;br /&gt;
                elif a1 == &amp;quot;FIX&amp;quot;:&lt;br /&gt;
                    r1, r2 = _fix_value(e1), _fix_value(e2)&lt;br /&gt;
                    if r1[0] != &amp;quot;OK&amp;quot; or r2[0] != &amp;quot;OK&amp;quot;:&lt;br /&gt;
                        probs.append(pair + &amp;quot;: the two FIX values of &amp;quot; + t + &amp;quot; cannot be compared (T3)&amp;quot;)&lt;br /&gt;
                    elif r1[4] != r2[4]:&lt;br /&gt;
                        probs.append(pair + &amp;quot;: the two FIX values of &amp;quot; + t&lt;br /&gt;
                                     + &amp;quot; cannot be compared: units of different kind: &amp;quot;&lt;br /&gt;
                                     + r1[4] + &amp;quot; and &amp;quot; + r2[4] + &amp;quot; (T3)&amp;quot;)&lt;br /&gt;
                    elif S.canon(r1[1]) != S.canon(r2[1]):&lt;br /&gt;
                        probs.append(pair + &amp;quot;: &amp;quot; + t + &amp;quot; fixed at &amp;quot; + e1[&amp;quot;VALUE&amp;quot;] + &amp;quot; &amp;quot; + e1[&amp;quot;UNIT&amp;quot;]&lt;br /&gt;
                                     + &amp;quot; and at &amp;quot; + e2[&amp;quot;VALUE&amp;quot;] + &amp;quot; &amp;quot; + e2[&amp;quot;UNIT&amp;quot;] + &amp;quot; (T3)&amp;quot;)&lt;br /&gt;
    probs += F.t3_laws(tpk)[1]&lt;br /&gt;
    return Z._done(probs)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# ---- T5 ---------------------------------------------------------------------------&lt;br /&gt;
def t5_dof_yield(tpk):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;Kernel test T5 over the declared citations: (b) every CONSTRAINT&amp;#039;s&lt;br /&gt;
    TARGET is named by some LAW; (c) every DOF is named by some LAW. Part (a)&lt;br /&gt;
    is T1&amp;#039;s REFS resolution. [pass, problems].&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    probs = []&lt;br /&gt;
    named = _law_refs(tpk)&lt;br /&gt;
    dofs = _dof_dims(tpk)&lt;br /&gt;
    for e in _entries_of(tpk, &amp;quot;CONSTRAINT&amp;quot;):&lt;br /&gt;
        t = _s(e, &amp;quot;TARGET&amp;quot;)&lt;br /&gt;
        if t is not None and t in dofs and t not in named:&lt;br /&gt;
            probs.append(&amp;quot;CONSTRAINT:&amp;quot; + Z._name(e) + &amp;quot;: TARGET &amp;quot; + t&lt;br /&gt;
                         + &amp;quot; is named by no LAW, so no law leaves it free (T5 b)&amp;quot;)&lt;br /&gt;
    for d in sorted(dofs):&lt;br /&gt;
        if d not in named:&lt;br /&gt;
            probs.append(&amp;quot;DOF:&amp;quot; + d + &amp;quot;: named by no LAW (T5 c)&amp;quot;)&lt;br /&gt;
    return Z._done(probs)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def kernel_tests(tpk):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;The kernel tests run as the TPK is entered, in order: T1, then T2, T5,&lt;br /&gt;
    T4 and T6. A T1 failure stops the run (guide L0.5). T3 runs at the final&lt;br /&gt;
    pass (D98.1). [pass, [[test, pass, problems], ...], inspections] with&lt;br /&gt;
    &amp;quot;NOT_RUN&amp;quot; in place of pass for a test the run did not reach and &amp;quot;NO FORM&amp;quot;&lt;br /&gt;
    for T4 when no LAW carries EQUATION and for T6 when no BOUNDARY carries&lt;br /&gt;
    CONDITION; inspections lists every law and boundary whose form is absent,&lt;br /&gt;
    so what stays INSPECTION is visible, never silently passed (12.3).&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    t1 = Z.t1_well_formed(tpk)&lt;br /&gt;
    rows = [[&amp;quot;T1&amp;quot;, t1[0], t1[1]]]&lt;br /&gt;
    if not t1[0]:&lt;br /&gt;
        rows += [[&amp;quot;T2&amp;quot;, &amp;quot;NOT_RUN&amp;quot;, []], [&amp;quot;T5&amp;quot;, &amp;quot;NOT_RUN&amp;quot;, []], [&amp;quot;T4&amp;quot;, &amp;quot;NOT_RUN&amp;quot;, []], [&amp;quot;T6&amp;quot;, &amp;quot;NOT_RUN&amp;quot;, []]]&lt;br /&gt;
        return [False, rows, []]&lt;br /&gt;
    t2, t5, t4, t6 = t2_atomicity(tpk), t5_dof_yield(tpk), F.t4_homogeneity(tpk), F.t6_totality(tpk)&lt;br /&gt;
    laws, bnds = F.form_coverage(tpk)&lt;br /&gt;
    all_laws = [Z._name(e) for e in _entries_of(tpk, &amp;quot;LAW&amp;quot;)]&lt;br /&gt;
    all_bnds = [Z._name(e) for e in _entries_of(tpk, &amp;quot;BOUNDARY&amp;quot;)]&lt;br /&gt;
    rows += [[&amp;quot;T2&amp;quot;, t2[0], t2[1]], [&amp;quot;T5&amp;quot;, t5[0], t5[1]],&lt;br /&gt;
             [&amp;quot;T4&amp;quot;, &amp;quot;NO FORM&amp;quot; if len(laws) == len(all_laws) else t4[0], t4[1]],&lt;br /&gt;
             [&amp;quot;T6&amp;quot;, &amp;quot;NO FORM&amp;quot; if len(bnds) == len(all_bnds) else t6[0], t6[1]]]&lt;br /&gt;
    insp = [&amp;quot;LAW:&amp;quot; + n + &amp;quot;: no EQUATION; T4 and T3 over this law by inspection&amp;quot; for n in laws]&lt;br /&gt;
    insp += [&amp;quot;BOUNDARY:&amp;quot; + n + &amp;quot;: no CONDITION; T6 totality by inspection&amp;quot; for n in bnds]&lt;br /&gt;
    return [t2[0] and t5[0] and t4[0] and t6[0], rows, sorted(insp)]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# ---- IC1-IC4 ----------------------------------------------------------------------&lt;br /&gt;
def _verdict(probs, gaps):&lt;br /&gt;
    probs = sorted(set(Z._show(p) for p in probs))&lt;br /&gt;
    gaps = sorted(set(gaps))&lt;br /&gt;
    return [&amp;quot;REJECT&amp;quot; if probs else (&amp;quot;GAP&amp;quot; if gaps else &amp;quot;PASS&amp;quot;), probs, gaps]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def ic_checks(trm, tpk):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;The four isomorphism checks as the TrM is entered (guide 4.6; TPS&lt;br /&gt;
    2.3.7), over the inventory of D107.1; IC4 (a) syntactically where a&lt;br /&gt;
    SIGNATURE carries FORM and IMAGE_FORM (tpc_form.ic4a_signature).&lt;br /&gt;
    [verdict, problems, gaps]: REJECT on any problem; else GAP with the&lt;br /&gt;
    untied DOF named; else PASS. NOT_RUN if the TPK fails T1 or the TrM is&lt;br /&gt;
    not well-formed.&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    if not Z.t1_well_formed(tpk)[0]:&lt;br /&gt;
        return [&amp;quot;NOT_RUN&amp;quot;, [&amp;quot;IC: the TPK does not pass T1&amp;quot;], []]&lt;br /&gt;
    if not Z.trm_well_formed(trm, tpk)[0]:&lt;br /&gt;
        return [&amp;quot;NOT_RUN&amp;quot;, [&amp;quot;IC: the TrM is not well-formed&amp;quot;], []]&lt;br /&gt;
    dofs = _dof_dims(tpk)&lt;br /&gt;
    removed = _removed(tpk)&lt;br /&gt;
    inventory = sorted(d for d in dofs if d not in removed)&lt;br /&gt;
    env = {}&lt;br /&gt;
    for e in _entries_of(trm.get(&amp;quot;HEADER&amp;quot;), &amp;quot;ENVIRONMENT_INVENTORY&amp;quot;):&lt;br /&gt;
        env[e[&amp;quot;ENVIRONMENT_QUANTITY&amp;quot;]] = Z.normalize_dimension(e[&amp;quot;DIMENSION&amp;quot;])&lt;br /&gt;
    ents = sorted(_entries_of(trm, &amp;quot;ENTRIES&amp;quot;), key=lambda e: e[&amp;quot;NAME&amp;quot;])&lt;br /&gt;
    laws = {e[&amp;quot;NAME&amp;quot;]: e for e in _entries_of(tpk, &amp;quot;LAW&amp;quot;)}&lt;br /&gt;
    cons = {e[&amp;quot;NAME&amp;quot;]: e for e in _entries_of(tpk, &amp;quot;CONSTRAINT&amp;quot;)}&lt;br /&gt;
    probs, gaps = [], []&lt;br /&gt;
    # CODOMAIN: an entry on a REMOVEd DOF maps outside the inventory.&lt;br /&gt;
    for e in ents:&lt;br /&gt;
        if e[&amp;quot;DOF&amp;quot;] in removed:&lt;br /&gt;
            probs.append(&amp;quot;CODOMAIN: ENTRY:&amp;quot; + e[&amp;quot;NAME&amp;quot;] + &amp;quot; identifies DOF &amp;quot; + e[&amp;quot;DOF&amp;quot;]&lt;br /&gt;
                         + &amp;quot;, which &amp;quot; + &amp;quot;, &amp;quot;.join(&amp;quot;CONSTRAINT:&amp;quot; + c for c in removed[e[&amp;quot;DOF&amp;quot;]])&lt;br /&gt;
                         + &amp;quot; removes&amp;quot;)&lt;br /&gt;
    identified = set(e[&amp;quot;DOF&amp;quot;] for e in ents if e[&amp;quot;DOF&amp;quot;] not in removed)&lt;br /&gt;
    # IC1 TOTAL&lt;br /&gt;
    covered = set(e[&amp;quot;ENVIRONMENT_QUANTITY&amp;quot;] for e in ents)&lt;br /&gt;
    for q in sorted(env):&lt;br /&gt;
        if q not in covered:&lt;br /&gt;
            probs.append(&amp;quot;IC1: environment quantity &amp;quot; + q + &amp;quot; is identified by no entry&amp;quot;)&lt;br /&gt;
    # IC2 SURJECTIVE: named gaps, disposed of at the final pass&lt;br /&gt;
    for d in inventory:&lt;br /&gt;
        if d not in identified:&lt;br /&gt;
            gaps.append(&amp;quot;IC2: DOF &amp;quot; + d + &amp;quot; is untied&amp;quot;)&lt;br /&gt;
    # IC3 INJECTIVE, both directions&lt;br /&gt;
    by_dof, by_q = {}, {}&lt;br /&gt;
    for e in ents:&lt;br /&gt;
        by_dof.setdefault(e[&amp;quot;DOF&amp;quot;], []).append(e)&lt;br /&gt;
        by_q.setdefault(e[&amp;quot;ENVIRONMENT_QUANTITY&amp;quot;], []).append(e)&lt;br /&gt;
    for d in sorted(by_dof):&lt;br /&gt;
        qs = sorted(set(e[&amp;quot;ENVIRONMENT_QUANTITY&amp;quot;] for e in by_dof[d]))&lt;br /&gt;
        if len(qs) &amp;gt; 1:&lt;br /&gt;
            probs.append(&amp;quot;IC3: DOF &amp;quot; + d + &amp;quot; is identified with inequivalent quantities &amp;quot;&lt;br /&gt;
                         + &amp;quot;, &amp;quot;.join(qs) + &amp;quot; (&amp;quot; + &amp;quot;, &amp;quot;.join(&amp;quot;ENTRY:&amp;quot; + e[&amp;quot;NAME&amp;quot;] for e in by_dof[d]) + &amp;quot;)&amp;quot;)&lt;br /&gt;
    for q in sorted(by_q):&lt;br /&gt;
        ds = sorted(set(e[&amp;quot;DOF&amp;quot;] for e in by_q[q]))&lt;br /&gt;
        if len(ds) &amp;gt; 1:&lt;br /&gt;
            probs.append(&amp;quot;IC3: environment quantity &amp;quot; + q + &amp;quot; is identified with DOF &amp;quot;&lt;br /&gt;
                         + &amp;quot;, &amp;quot;.join(ds) + &amp;quot; (&amp;quot; + &amp;quot;, &amp;quot;.join(&amp;quot;ENTRY:&amp;quot; + e[&amp;quot;NAME&amp;quot;] for e in by_q[q]) + &amp;quot;)&amp;quot;)&lt;br /&gt;
    # IC4 (b) dimensions, (c) the necessary part of BEARS&lt;br /&gt;
    for e in ents:&lt;br /&gt;
        tag = &amp;quot;ENTRY:&amp;quot; + e[&amp;quot;NAME&amp;quot;]&lt;br /&gt;
        dim = Z.normalize_dimension(e[&amp;quot;DIMENSION&amp;quot;])&lt;br /&gt;
        dd = dofs.get(e[&amp;quot;DOF&amp;quot;])&lt;br /&gt;
        if dd is not None and dim != dd:&lt;br /&gt;
            probs.append(&amp;quot;IC4(b): &amp;quot; + tag + &amp;quot;: DIMENSION &amp;quot; + dim + &amp;quot; differs from DOF &amp;quot; + e[&amp;quot;DOF&amp;quot;]&lt;br /&gt;
                         + &amp;quot;&amp;#039;s &amp;quot; + dd)&lt;br /&gt;
        qd = env.get(e[&amp;quot;ENVIRONMENT_QUANTITY&amp;quot;])&lt;br /&gt;
        if qd is not None and dim != qd:&lt;br /&gt;
            probs.append(&amp;quot;IC4(b): &amp;quot; + tag + &amp;quot;: DIMENSION &amp;quot; + dim + &amp;quot; differs from environment quantity &amp;quot;&lt;br /&gt;
                         + e[&amp;quot;ENVIRONMENT_QUANTITY&amp;quot;] + &amp;quot;&amp;#039;s &amp;quot; + qd)&lt;br /&gt;
        for b in sorted(set(e[&amp;quot;BEARS&amp;quot;])):&lt;br /&gt;
            if b in laws:&lt;br /&gt;
                for r in sorted(set(_set(laws[b], &amp;quot;REFS&amp;quot;))):&lt;br /&gt;
                    if r in dofs and r not in identified:&lt;br /&gt;
                        probs.append(&amp;quot;IC4(c): &amp;quot; + tag + &amp;quot;: BEARS LAW:&amp;quot; + b + &amp;quot;, which names DOF &amp;quot; + r&lt;br /&gt;
                                     + &amp;quot; that no entry identifies&amp;quot;)&lt;br /&gt;
            elif b in cons:&lt;br /&gt;
                t = _s(cons[b], &amp;quot;TARGET&amp;quot;)&lt;br /&gt;
                if t is not None and t not in identified:&lt;br /&gt;
                    probs.append(&amp;quot;IC4(c): &amp;quot; + tag + &amp;quot;: BEARS CONSTRAINT:&amp;quot; + b + &amp;quot;, whose TARGET &amp;quot; + t&lt;br /&gt;
                                 + &amp;quot; no entry identifies&amp;quot;)&lt;br /&gt;
    probs += F.ic4a_signature(trm, tpk)[1]&lt;br /&gt;
    return _verdict(probs, gaps)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# ---- the final pass ---------------------------------------------------------------&lt;br /&gt;
def final_checks(tfk):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;At the final pass, after the TMS is entered (D98.1): T3 over the&lt;br /&gt;
    constraints and the laws, and IC2&amp;#039;s disposition under the TMS&amp;#039;s&lt;br /&gt;
    IC2_POLICY (TPS 2.3.7; GAP when absent). [verdict, problems, gaps];&lt;br /&gt;
    NOT_RUN if a zone fails its checks.&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    if not Z._obj(tfk):&lt;br /&gt;
        return [&amp;quot;NOT_RUN&amp;quot;, [&amp;quot;final pass: the TFK is not an object&amp;quot;], []]&lt;br /&gt;
    tpk, trm, tms = tfk.get(&amp;quot;TPK&amp;quot;), tfk.get(&amp;quot;TrM&amp;quot;), tfk.get(&amp;quot;TMS&amp;quot;)&lt;br /&gt;
    if not kernel_tests(tpk)[0]:&lt;br /&gt;
        return [&amp;quot;NOT_RUN&amp;quot;, [&amp;quot;final pass: the TPK does not pass T1, T2, T5, T4 and T6&amp;quot;], []]&lt;br /&gt;
    if not Z.tms_well_formed(tms)[0]:&lt;br /&gt;
        return [&amp;quot;NOT_RUN&amp;quot;, [&amp;quot;final pass: the TMS is not well-formed&amp;quot;], []]&lt;br /&gt;
    ic = ic_checks(trm, tpk)&lt;br /&gt;
    if ic[0] in (&amp;quot;NOT_RUN&amp;quot;, &amp;quot;REJECT&amp;quot;):&lt;br /&gt;
        return [&amp;quot;NOT_RUN&amp;quot;, [&amp;quot;final pass: the TrM does not pass IC1-IC4&amp;quot;], []]&lt;br /&gt;
    probs = list(t3_consistency(tpk, tms)[1])&lt;br /&gt;
    policy = tms[&amp;quot;PARAMETERS&amp;quot;].get(&amp;quot;IC2_POLICY&amp;quot;, Z.IC2_DEFAULT)&lt;br /&gt;
    if policy == &amp;quot;REJECT&amp;quot;:&lt;br /&gt;
        probs += [g + &amp;quot; and IC2_POLICY is REJECT&amp;quot; for g in ic[2]]&lt;br /&gt;
    return _verdict(probs, ic[2])&lt;br /&gt;
&lt;/div&gt;</summary>
		<author><name>BFP Rauch</name></author>
	</entry>
</feed>