B0 — APF readouts and registered-decoder ledger
DefinitionAPFLawsOfForm_BridgeFor arbitrary state types Ω, denote interprets the existing finite LawsOfForm Expr syntax pointwise under any Nat-indexed Boolean readout family. Blank is false, crossing is complement, and juxtaposition is disjunction. interfaceReadouts selects original APF BinaryDistinction readouts on the actual PhysicalState quotient using an enumeration g that may repeat or omit labels. rawReadout pulls the interpretation back through physicalClass. These interface arguments entail inhabited labels and at least two physical states; general interpretations allow empty Ω.
Nonconstant means two states have different outputs. asDistinction packages a supplied function and proof of this condition into the existing APF BinaryDistinction. Realizes r S requires a state realizing each Boolean assignment on the finite index set S, with no matching condition outside S. Empty S still requires an inhabited state type.
DecoderSystem assigns each complete protocol a record type, a record map from states, and a specified set of registered Boolean decoders. There are no nonemptiness or closure axioms on the registry. Implements requires one registered decoder agreeing with the requested function on every state; it need not agree with anything specified at unreachable records. BooleanClosed requires the constant-false decoder and closure under complement and binary disjunction as functions on all records.
formLedger retains the original Ledger protocol type, nonnegative real prices, and zero-price empty-protocol witness. It serves a finite form family exactly when every requested form has a registered implementing decoder on the protocol's common record; the decoder may depend on the form. Carrying is implementation. Every protocol serves the empty family, including with an empty registry. Finite selections of registered decoders are thereby modeled as supplied by the complete protocol. This construction alone imposes no correspondence with the original ledger's service or carrying relations and no physical completeness or resource calibration.
RealizesLedger is the separate hypothesis that, for every original protocol and finite primitive demand family, the original interface serves that family if and only if each original distinction readout has a registered implementing decoder. It entails original service of the empty family by every protocol, asserts finite joint service for these implementations, and does not identify the original carrying relation or assert Boolean closure. The existing PhysicalInterface still includes its injective nonconstant distinction assignment, singleton feasibility, and positive singleton infimum.
atomicFamily takes the finite image under Expr.var. primitiveSupport takes the finite image under g of the syntactically occurring variable indices. Both use finite sets, discarding repetitions; support does not remove semantically redundant variables. Natural-number indices include zero, and all introduced generic types are Lean Type.
import Definitions.Def_APFPaper1_Foundation
import Definitions.Def_LawsOfForm_Canonical
set_option autoImplicit false
namespace APFLawsOfForm
open LawsOfForm APFPaper1.Foundation
def denote {Ω : Type} (r : Nat → Ω → Bool) (e : Expr) : Ω → Bool :=
fun x => eval (fun n => r n x) e
def interfaceReadouts {X Q D P : Type} [DecidableEq D]
(I : PhysicalInterface X Q D P) (g : Nat → D) : Nat → PhysicalState I.profile → Bool :=
fun n => (I.distinction (g n)).readout
def rawReadout {X Q D P : Type} [DecidableEq D]
(I : PhysicalInterface X Q D P) (g : Nat → D) (e : Expr) : X → Bool :=
fun x => denote (interfaceReadouts I g) e (physicalClass I.profile x)
def Nonconstant {Ω : Type} (f : Ω → Bool) : Prop := ∃ x y, f x ≠ f y
def asDistinction {Ω : Type} (f : Ω → Bool) (h : Nonconstant f) : BinaryDistinction Ω :=
⟨f, h⟩
def Realizes {Ω : Type} (r : Nat → Ω → Bool) (S : Finset Nat) : Prop :=
∀ b : Nat → Bool, ∃ x : Ω, ∀ n ∈ S, r n x = b n
structure DecoderSystem (Ω P : Type) where
Record : P → Type
record : (p : P) → Ω → Record p
registered : (p : P) → Set (Record p → Bool)
def Implements {Ω P : Type} (M : DecoderSystem Ω P) (p : P) (f : Ω → Bool) : Prop :=
∃ d : M.Record p → Bool, d ∈ M.registered p ∧ ∀ x, d (M.record p x) = f x
def BooleanClosed {Ω P : Type} (M : DecoderSystem Ω P) (p : P) : Prop :=
(fun _ => false) ∈ M.registered p ∧
(∀ d ∈ M.registered p, (fun z => !(d z)) ∈ M.registered p) ∧
(∀ d ∈ M.registered p, ∀ e ∈ M.registered p, (fun z => d z || e z) ∈ M.registered p)
def formLedger {Ω D P : Type} (L : Ledger D P) (M : DecoderSystem Ω P)
(r : Nat → Ω → Bool) : Ledger Expr P where
price := L.price
price_nonneg := L.price_nonneg
serves p F := ∀ e ∈ F, Implements M p (denote r e)
serves_mono := by intro p S T hST hT e he; exact hT e (hST he)
carries p e := Implements M p (denote r e)
carries_of_serves := by intro p S e h he; exact h e he
empty_protocol := by
obtain ⟨p, _, hp⟩ := L.empty_protocol
exact ⟨p, by simp, hp⟩
def RealizesLedger {X Q D P : Type} [DecidableEq D]
(I : PhysicalInterface X Q D P) (M : DecoderSystem (PhysicalState I.profile) P) : Prop :=
∀ p S, I.ledger.serves p S ↔ ∀ d ∈ S, Implements M p (I.distinction d).readout
def atomicFamily (S : Finset Nat) : Finset Expr := S.image Expr.var
def primitiveSupport {D : Type} [DecidableEq D] (g : Nat → D) (e : Expr) : Finset D :=
(freeVars e).image g
end APFLawsOfForm
Read-back
What the Lean code literally says, in plain math · Codex (GPT-6)
denote. For an arbitrary type , a family , and a finite expression built inductively from a blank, variables indexed by natural numbers, a unary crossing operation, and a binary beside operation, this definition gives the function obtained by evaluating separately at each : a blank evaluates to false, variable evaluates to , a crossing negates its argument's Boolean value, and a beside operation takes the Boolean disjunction of its two argument values. Natural-number indices include zero. There is no restriction on the family , no requirement that any variable or expression have a nonconstant value, and no requirement that be inhabited; when it is empty the result is the unique function with that empty domain.
interfaceReadouts. Let be arbitrary types, with decidable equality on , and let consist of the following interface data and assumptions: a map ; for each , a Boolean function on the quotient , where means , together with two quotient states on which differs; an injective assignment of these functions with their nonconstancy witnesses to the elements of ; and a ledger with prices , a relation for finite , and a relation . The ledger satisfies for every ; serving a finite set implies serving every subset; serving implies carrying every member of ; and some serves the empty set at price zero. In addition, each singleton is served by some protocol, and the real infimum of the set is strictly positive. Given also a map , the definition returns the family for every natural number , including zero, and every . The map need not be injective or surjective, so indices may repeat a distinction and some distinctions may be unused. Its existence forces to be inhabited, and the required nonconstancy of any selected distinction forces to contain two different states; thus these arguments cannot be supplied with an empty or with fewer than two quotient states. The singleton price sets appearing in the assumptions are nonempty and bounded below by zero.
rawReadout. Let be arbitrary types, with decidable equality on , and suppose an interface supplies a profile , the quotient for , and, injectively for each , a Boolean function with witnesses to two unequal output values. It also supplies a ledger on : every protocol has a nonnegative real price; serving a finite set implies serving each subset and carrying each member; and at least one protocol serves the empty set at price zero. Every singleton is served by at least one protocol, and the infimum of all prices of protocols serving that singleton is strictly positive; these price sets are consequently nonempty and bounded below. For a map and an expression , built finitely from a blank, natural-number-indexed variables, unary crossing, and binary beside, this definition returns the Boolean function on raw states that evaluates with variable assigned , where is the equivalence class of . Evaluation assigns false to a blank, Boolean negation to crossing, and Boolean disjunction to beside. Indices include zero, and may repeat or omit distinctions. The existence of forces to be inhabited and hence forces at least two quotient states. The resulting function is equal on states with equal profiles, but the expression is allowed to evaluate to a constant function, including false for the blank, despite each individual being nonconstant.
Nonconstant. For an arbitrary type and a Boolean function , this proposition means that there exist with . Both witnesses are existentially quantified, with no uniqueness requirement; their unequal outputs force and mean that both Boolean values occur. The proposition is false when is empty or has at most one element, and it is false for every constant .
asDistinction. For an arbitrary type , a function , and a supplied proof that there exist with , this definition constructs the pair consisting of the readout function and its nontriviality proof ; that pair is what a binary distinction on means here. It adds no condition on beyond the stated existence of unequal outputs and does not change its values. No such input proof exists for a constant function or for an empty or one-element state type.
Realizes. For an arbitrary type , an arbitrary family , and a finite set , this proposition says that for every total Boolean assignment there exists a state such that for every . The existential state may depend on and need not be unique; no matching is required outside , and natural-number indices include zero. When is empty, the matching condition is vacuous but a state is still required, so the proposition is equivalent to being inhabited; if is empty it is false for every . No separate nonconstancy assumption is imposed on the family, although requiring all assignments on a nonempty forces each selected coordinate to take both Boolean values.
DecoderSystem. For arbitrary types and , a decoder system consists of a type for each , a function for each , and a set for each . These are respectively its record types, record maps, and sets of registered Boolean functions on records. The record type may depend on . No axiom requires any to be nonempty or closed under any operation, or any to be injective or surjective. Empty parameter types are allowed; if is empty all fields have no indexed instances, while if is empty each record map has empty domain. When is inhabited, the existence of forces to be inhabited for every existing .
Implements. For arbitrary types , a decoder system consisting of record types , maps , and sets for every , a specified , and a function , this proposition means that there exists a function such that and for every . One registered function must work simultaneously for all states, with no uniqueness requirement. No condition is imposed on that function's values at records outside the image of . If is empty, the equality condition is vacuous and implementation is equivalent to being nonempty; if is empty, implementation is false even for an empty state type. No nonconstancy requirement is imposed on .
BooleanClosed. For arbitrary types , a decoder system with record types , record maps , and sets of registered functions for every , and a specified , this proposition is the conjunction of three requirements: the constant-false function on belongs to ; for every , the function belongs to ; and for every , the function belongs to . These operations are Boolean negation and disjunction, and membership concerns entire functions on , including records not reached by the record map. No condition is imposed on any for , and the record maps do not enter these requirements. The first conjunct rules out an empty ; if is empty, there is only one Boolean function on it and the requirements reduce to registering that function. An empty does not by itself make these requirements vacuous.
formLedger. Let be arbitrary types, and let be a ledger consisting of a price function , relations for finite and , and proofs that every price is nonnegative, serving a set implies serving every subset, serving a set implies carrying each member, and some protocol serves the empty set at price zero. Let be a decoder system consisting, for each , of a record type , a map , and a set of Boolean functions on ; let be any family. This definition constructs a ledger whose items are finite expressions generated by a blank, natural-number-indexed variables, unary crossing, and binary beside, and whose protocols are still . Its price of is exactly . Write for evaluation of expression with blank equal to false, variable equal to , crossing equal to Boolean negation, and beside equal to Boolean disjunction. The constructed ledger serves a finite expression set at exactly when, for every , there exists with and for every ; the decoder may depend on . It carries an expression exactly when this same existential implementation condition holds for . Its subset and carrying axioms follow from these definitions, and a zero-price protocol required by supplies its zero-price empty-set witness. Every protocol in the constructed ledger serves the empty expression set, even if is empty; if is empty, every expression is carried precisely when is nonempty, and a nonempty expression set is served precisely under that same condition. The construction requires neither Boolean closure nor any relationship between 's original service or carrying relations and ; in particular the original item type may be empty, although cannot be empty because supplies a zero-price protocol. Constant expression evaluations and index zero are allowed.
RealizesLedger. Let be arbitrary types, with decidable equality on , and let an interface consist of a profile , a quotient for , and an injective assignment to each of a Boolean function on together with witnesses to . Its ledger has a nonnegative real price for every , service and carrying relations satisfying downward closure of service under finite subsets and carrying of all members of a served set, and a protocol serving the empty set at price zero. It additionally has a protocol serving each singleton , and the infimum of the nonempty, bounded-below set of prices for serving each singleton is strictly positive. Let be a decoder system on , meaning that for each it gives a record type , a map , and a set of Boolean functions on . This proposition states that for every and every finite , the interface ledger serves at if and only if, for each , there exists a registered function such that for every . The implementing function may depend on and , and is not required to be unique. For , the right-hand side is true without any registered decoder, so this proposition requires every protocol to serve the empty set. No equivalence for the ledger's carrying relation, no additional price equality, and no closure property of registered decoders is part of this proposition. The type may be empty, in which case the distinction and singleton conditions are vacuous and the proposition reduces to every protocol serving the empty set; an empty quotient state type is compatible with the interface only when is empty. The ledger's zero-price witness ensures is inhabited.
atomicFamily. For any finite set , this definition returns the finite set of variable expressions indexed by the members of . Expressions here are freely generated finite syntax built from a blank, one variable constructor for every natural-number index, unary crossing, and binary beside; the output uses only the variable constructor. Natural-number indices include zero. The image is a set, so repetitions would be discarded, and distinct indices in fact give distinct variable expressions. In particular, the empty input set gives the empty expression set; it does not give a set containing the blank expression.
primitiveSupport. For an arbitrary type with decidable equality, a map , and a finite expression built from a blank, natural-number-indexed variables, unary crossing, and binary beside, this definition returns the finite set , where the finite set of occurring variable indices is recursively defined by , , , and . Index zero is included among possible indices. Both repeated variable occurrences and equal images under are counted only once; need not be injective or surjective. Variable-free expressions have empty support, including the blank and any variable-free expression built with crossing and beside. Support is determined by syntactic occurrence, so the definition does not discard an occurring variable merely because evaluation of the whole expression might be independent of it. The existence of the supplied map requires to be inhabited, even when the particular expression has empty support.