Documentation

Docs

Restriction N over Derived Predicates, and the Choice of One Form

25 November 2026. Answers open item 1 of the internal review of the paper draft ("the theorem is shallow") and the Lean half of item 3 (protective duties).

File: Derived.lean. It stands alone and imports neither Core nor Strict. It uses Lean 4.36 core only (no Mathlib), with no sorry, no new axioms and no native_decide.

Command: lean Derived.lean in proofs/lean/. Result: exit 0, 59 theorems, 1084 lines. Check time 1.15–1.7 s wall (three runs).

Revised 25 November 2026, after core.py fixed findings A, B and D (below). The revision adds four things:

  • trusted predicates and their check (trustedOK, liftShape, trusted_deps_rf, lift_rf, trusted_check_is_needed);
  • the new handling of reading-guarded asks, with min_useful as a parameter useful : Form → Bool and released;
  • release_reading_free_of_check for any default;
  • ask_withholds_default, now about decideSideOld, the semantics before the fix.

Planted false theorem. Each round, two false theorems were appended to a copy of the file. Both are rejected, with exit 1. The copy was then deleted. The false theorems were:

  • first round: that the derived-reading rule set releases the same under both readings, and that release is reading-free with or without the check;
  • revision: that the old semantics releases the same under both readings, and that release is reading-free under the old check, which has no trusted-clause condition.

Differential check of the forms. The 49 pairs of the seven-form order and its meet were compared with experiments/kernel/core.py (f_le, f_meet), with 0 mismatches. The key rank = 8·height + alphabetical index sorts the forms exactly as core.py's (f_height(f), f) does.

What Is Modelled

  • Three disjoint kinds of atom: facts F, readings Rd and derived predicates D. A literal is an atom with a negation flag. A clause is head :- body (a conjunction of literals).
  • Evaluation by strata (evalProg). The clause list is processed in order. Each clause sees the derived atoms of the clauses below it, as core.py's Model.__init__ does over topo_clauses.
  • Dependencies (deps, clo, dependsOn).
  • clo P n is the order-free closure that core.py's depends_on computes: every clause of the whole program with that head, followed for n steps.
  • dependsOn uses n = |P|.
  • deps is the structural set the proofs use. deps_sub_closure proves that deps is always contained in clo, so the check is sound.
  • The check (checkN), mirroring check_restrictions:
  • the guards of permit, forbid, cap and boundary have no reading in their dependency set;
  • a boundary's lifting conditions are positive conjunctions of facts and trusted derived atoms (liftShape). This is core.py's hard-coded lookup of declared and grant;
  • no clause whose head is trusted depends on a reading (trustedOK). This is core.py's TRUSTED_PREDS check of 25 November (finding A). Trusted predicates are a flag T : D → Bool on derived predicates;
  • the guard of a duty marked protective has no reading in its dependency set. This is core.py's PROTECTIVE_DUTIES (finding D);
  • a negated literal, in any rule guard or clause body, never depends on a reading. A reading is in its own dependency set, so this also gives positivity;
  • ask and non-protective duty guards may read.
  • The decision of one side (decideSide), in core.py's order: 1. forbid → deny; 2. an unlifted boundary → ask if a fact-only ask applies (F1), else deny; 3. otherwise the canonical choice among the offers meet(asked, permit, caps), as max(offers, key=(height, form name, rule id)); 4. otherwise ask, if a fact-only ask applies; 5. otherwise, if only reading-guarded asks apply, the tail's allow when it is useful (min_useful ⊑ f), else ask (finding B, fixed 25 November); 6. otherwise the tail (_tail): a failed permit → deny (decision 5), else the default at meet(asked, default, caps).
  • What leaves (released useful): an allow at a useful form. core.py's _decide_inner denies an allow below min_useful.
  • decideSideOld: the semantics before 25 November (any applicable ask wins), kept for the counterexample.
  • Duties: owed (all applicable duties) and protOwed (the protective ones).

Theorems

Theorem In words
eval_reading_free A derived predicate whose dependencies hold no reading has the same value under every assignment of readings. This holds for every clause order; no stratification hypothesis is needed.
deps_sub_closure Everything the structural dependency set reaches, the order-free (core.py-style) closure also reaches, so a guard the check passes really is reading-free.
gEval_rf A guard that passes the check evaluates the same under every reading.
evalProg_mono With negation only on reading-free atoms, more readings only make derived atoms truer.
chosen_offer_reading_free For a checked rule set, the ONE offer chosen, both form and rule, is the same under every reading.
release_reading_free_of_check For a checked rule set and any default, what is finally released (an allow at a useful form), including the chosen form, is the same under every reading.
reading_never_opens Before min_useful: if a form is allowed under one reading, then under any other the same form is allowed, or the verdict is ask. A reading never opens anything and never changes the form.
finish_tail_released Whether a reading-guarded ask applies does not change what is finally released.
trusted_deps_rf If no clause defining a trusted predicate depends on a reading, no trusted predicate does, in any tail of the program.
lift_rf A lifting condition of the allowed shape means the same under every reading.
noninterference_of_check Once a forbid applies under the facts, every reading gives deny.
protective_duties_reading_free The protective duties owed are the same under every reading.
owed_mono More readings only add duties, never remove one.
choose_congr The canonical choice depends only on the set of offers: neither their order nor repetition matters.
decide_perm Any permutation of the rule list gives the same decision, including the chosen form.
lt_iff, lt_asymm, lt_trans, lt_total, choose_none, choose_mem, choose_max, foldr_perm Lemmas: the key is a strict total order, the chosen offer is a maximal member, and the meet of the caps does not depend on their order.
Form7.meet_glb, meet_comm', meet_assoc', rank_inj' The seven forms: meet is the greatest lower bound, is commutative and associative, and the key is injective.
first_max_depends_on_order (decide) The old rule ("tallest, then first in the rule book") releases anonymised in one rule order and summarised in the other. The canonical key releases summarised in both.
check_is_needed_derived (decide) A permit guarded by d0 :- reading passes a check on the guard's own atoms (Strict.lean's check), fails checkN, and releases raw data under one reading and nothing under the other.
ask_withholds_default (decide) Under the old semantics (decideSideOld), a reading-guarded ask, which Restriction N allows, turns a default allow into ask. Under the current decideSide, the default allow is released under both readings.
trusted_check_is_needed (decide) A clause declared :- reading passes the old check (checkOld) and lifts a boundary: raw data under one reading, deny under the other. checkN rejects the clause, and the same rule set without it passes.
protective_check_is_needed (decide) The same min_cell duty guarded through a derived reading is accepted when unmarked and rejected when marked protective. Unchecked, a reading decides whether the protection is owed.
negation_check_is_needed (decide) A duty guarded by a negated derived reading fails the check. Unchecked, more readings remove the duty.
all_congr', all_mono', any_congr', filter_congr', guardRF_lit, guardRF_lit', atom_eval_rf, ok_guard, ok_lifts, ok_neg, checkN_rules, checkN_clauses, checkN_trusted, the *_rf lemmas, decide_shape, perm_isEmpty Helpers.

Axioms (#print axioms, exact):

  • propext, Quot.sound: eval_reading_free, deps_sub_closure, trusted_deps_rf, chosen_offer_reading_free, release_reading_free_of_check, reading_never_opens, protective_duties_reading_free, owed_mono.
  • propext, Classical.choice, Quot.sound: choose_congr, decide_perm. Classical.choice enters through by_cases on equality of forms, because the generic form type carries no DecidableEq.
  • propext only: the six decide counterexamples.

Departures from core.py (Exact)

  1. Ground. Atoms have no arguments and there is no unification. A program stands for the grounding of core.py's clauses over the finite domain, with the request's variables (?s, ?a, ?r, ?t, …) already substituted.
  2. Clause order. Clauses are evaluated in the given list order (latest first), not by topo_clauses. Restriction D (no recursion) is not modelled. That evalProg equals the least stratified model for a topological order is not proved. The reading-freedom theorems hold for every order, so they hold for the order core.py uses.
  3. depends_on is a bounded closure (|P| steps). For any program this is contained in core.py's unbounded closure, so a guard that core.py passes also passes here. For non-recursive programs the two are equal (argued, not proved).
  4. Name spaces. Facts, readings and derived predicates are separate types. In core.py all three are strings, and a clause may define a fact predicate's name. Such a clause is modelled as a derived predicate flagged trusted (T). The flag stands for core.py's TRUSTED_PREDS name list.
  5. Not modelled: - the built-in below, temporal facts (holds/grant intervals) and valid intervals, which are taken to be settled into the facts; - agent_rule and the agent side (§2.4); - roles and the hierarchy in touches, which is abstracted to anchors.all m as in Strict.lean; - retrieval.
  6. Lifting. core.py lifts a boundary when declared(r,u) and a current grant(s,u,…,owner) are in model.atoms for some u in lifts. Here lifts is a disjunction of positive conjunctions of facts and trusted derived atoms. The owner match and the time window are taken to be settled into the atoms.
  7. Default is one parameter dflt : Decision, not a table by level with label_up.
  8. Ask, form choice and reasons. Ask carries no recipients (ask_whom, the owner). Rule ids are Nat, not strings (any total order works). form_by and the reasons are not modelled.
  9. min_useful is a parameter useful : Form → Bool (min_useful ⊑ f), used inside finish (finding B) and by released. In core.py the second use is in _decide_inner, after the agent side.
  10. Outside _one_side, not modelled: - the auditor and history, tokens; - strict mode's wrapper: confirm, automatic labels, "which use case?" and request sets. Each of these only turns allow into ask or deny, as Core's releaseX covers.
  11. Protective duties are a flag on the duty. core.py recognises them by name prefix (PROTECTIVE_DUTIES: min_cell(, draft_only, mask(, suppress(, notify().
  12. Other checks. check_restrictions also rejects anchor-less rules, unnamed duties and unknown forms. Those checks are not modelled.

Disagreements Found Between core.py and SEMANTICS.md

Found on 25 November 2026 by running core.py from a scratch script. A, B and D were fixed in core.py the same day. A re-run of the same script confirms that A and D are now rejected and that B gives allow raw under both readings. SEMANTICS §2.3 now states the canonical tie-break, which closes C.

  • A (fixed). A derived predicate could lift a boundary from a reading.
  • The clause declared(?r, uc) :- reads_usecase(?r, uc), plus a boundary with lifts=["uc"], passed check_restrictions. It gave deny with no reading and allow raw with the reading.
  • The cause: _one_side reads declared and grant from the derived model.
  • The fix: a clause whose head is in TRUSTED_PREDS may not depend on readings.
  • Lean: trusted_check_is_needed, trusted_deps_rf, lift_rf.
  • B (fixed). A reading could withhold a default release.
  • core.py tried every ask before the default, so on public or internal data a reading turned allow into ask.
  • The fix: a side whose only applicable asks read falls through to the tail, and releases its allow when it is useful.
  • Lean: ask_withholds_default (old semantics), release_reading_free_of_check (any default, new semantics).
  • C (closed in SEMANTICS). §2.3 said "the first in the rule book on a tie". It now states the key (height, form name, rule id). Lean: first_max_depends_on_order, choose_congr, decide_perm.
  • D (fixed). There were no protective duties. A min_cell(5) duty guarded by a reading was accepted. Now PROTECTIVE_DUTIES may not depend on readings. Lean: protective_check_is_needed, protective_duties_reading_free.

Last built 2026-11-25