Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

D0 — A concrete record and price model

Definition
APFLoFStrengthening_Model

by FiniteUniverse · Sep 8, 2026 · Mathlib 0df444a (Lean v4.33.1)

apflaws-of-formrecordssemantic-costsymmetry

Let D be any decidable type of labels. A raw state is a total Boolean assignment D → Bool. Its continuation profile is the singleton containing that assignment, and the existing APF quotient identifies equal such profiles. A coordinate readout therefore descends to the quotient. Every coordinate is nonconstant, and distinct labels give distinct readouts.

A protocol p is a finite subset of D. It serves a finite primitive demand S exactly when S is contained in p. It records the values of the labels in p, with record type ({d // d ∈ p} → Bool). Its registered decoder catalogue is all Boolean functions on this record type. Its declared complete price is |p| + choose(|p|,2), counted as a real number. The empty protocol has price zero and every singleton has price one.

The definition item constructs an actual APF PhysicalInterface, including positive singleton cost. Its structural proof uses the singleton lower bound and a singleton serving witness. It does not pre-supply the general minimum-cost theorem, coordinate-recovery criterion, exact RealizesLedger theorem, semantic-support theorem, or transport theorem targeted below.

For D = Bool, raw states have two independent coordinates. A coordinate is in the semantic essential support of a Boolean output f precisely when two raw states that agree outside that coordinate can have different f values. A record determines f when agreement on the recorded coordinates implies equal f outputs. Forms evaluate on raw states using the label map g, and their outputs descend through the same quotient. The essential support of a finite form family is the union of the essential supports of its members.

Definition code
import Definitions.Def_APFLawsOfForm_Bridge
import Mathlib.Data.Nat.Choose.Basic
import Mathlib.Data.Finset.Card
import Mathlib.Tactic

set_option autoImplicit false
set_option linter.unusedSectionVars false
namespace APFLoFStrengthening
open LawsOfForm APFPaper1.Foundation APFLawsOfForm
variable (D : Type) [DecidableEq D]

abbrev Raw := D → Bool

def profile (x : Raw D) : Set (Raw D) := {x}

abbrev State := PhysicalState (profile D)

def coordinate (d : D) : State D → Bool :=
  Quotient.lift (fun x => x d) (by
    intro x y h
    exact congrFun (Set.singleton_injective h) d)

@[simp] theorem coordinate_class (d : D) (x : Raw D) :
    coordinate D d (physicalClass (profile D) x) = x d := rfl

def distinction (d : D) : BinaryDistinction (State D) where
  readout := coordinate D d
  nontrivial := ⟨physicalClass (profile D) (fun _ => false),
    physicalClass (profile D) (fun _ => true), by change false ≠ true; decide⟩

theorem distinction_injective : Function.Injective (distinction D) := by
  intro d e h
  by_contra hde
  have hr := congrArg (fun a : BinaryDistinction (State D) =>
    a.readout (physicalClass (profile D) (fun i => decide (i = d)))) h
  have hed : e ≠ d := Ne.symm hde
  change decide (d = d) = decide (e = d) at hr
  simp [hed] at hr

def price (p : Finset D) : ℝ := (p.card + p.card.choose 2 : ℕ)

theorem price_nonneg (p : Finset D) : 0 ≤ price D p := by
  exact Nat.cast_nonneg _

theorem price_mono {p q : Finset D} (hpq : p ⊆ q) : price D p ≤ price D q := by
  apply Nat.cast_le.mpr
  exact Nat.add_le_add (Finset.card_le_card hpq)
    (Nat.choose_le_choose 2 (Finset.card_le_card hpq))

@[simp] theorem price_empty : price D ∅ = 0 := by simp [price]

@[simp] theorem price_singleton (d : D) : price D {d} = 1 := by simp [price]

def ledger : Ledger D (Finset D) where
  price := price D
  price_nonneg := price_nonneg D
  serves p S := S ⊆ p
  serves_mono := by intro p S T hST hT; exact hST.trans hT
  carries p d := d ∈ p
  carries_of_serves := by intro p S d h hd; exact h hd
  empty_protocol := ⟨∅, Finset.Subset.refl _, price_empty D⟩

-- Structural positivity needed to construct the APF interface.
-- This proves only the singleton lower bound; the general exact minimum is a target.
def interface : PhysicalInterface (Raw D) (Raw D) D (Finset D) where
  profile := profile D
  distinction := distinction D
  distinction_injective := distinction_injective D
  ledger := ledger D
  individually_feasible d := ⟨{d}, Finset.Subset.refl _⟩
  positive_distinction_cost d := by
    apply lt_of_lt_of_le (show (0 : ℝ) < 1 from zero_lt_one)
    apply le_csInf
    · exact ⟨price D {d}, {d}, Finset.Subset.refl _, rfl⟩
    · rintro c ⟨p, hp, rfl⟩
      have h := price_mono D hp
      simpa only [ledger, price_singleton] using h

def system : DecoderSystem (State D) (Finset D) where
  Record p := {d : D // d ∈ p} → Bool
  record _ x d := coordinate D d.val x
  registered _ := Set.univ


namespace TwoBit

def essentialSupport (f : Raw Bool → Bool) : Finset Bool :=
  Finset.univ.filter fun d => ∃ x y : Raw Bool,
    (∀ i, i ≠ d → x i = y i) ∧ f x ≠ f y

def RawDetermines (f : Raw Bool → Bool) (p : Finset Bool) : Prop :=
  ∀ x y : Raw Bool, (∀ d ∈ p, x d = y d) → f x = f y

instance (f : Raw Bool → Bool) (p : Finset Bool) : Decidable (RawDetermines f p) :=
  inferInstanceAs (Decidable (∀ x y : Raw Bool, (∀ d ∈ p, x d = y d) → f x = f y))

def liftOutput (f : Raw Bool → Bool) : State Bool → Bool :=
  Quotient.lift f (by intro x y h; exact congrArg f (Set.singleton_injective h))

@[simp] theorem liftOutput_class (f : Raw Bool → Bool) (x : Raw Bool) :
    liftOutput f (physicalClass (profile Bool) x) = f x := rfl

def rawEval (g : Nat → Bool) (e : Expr) : Raw Bool → Bool :=
  fun x => eval (fun n => x (g n)) e

def familyEssentialSupport (g : Nat → Bool) (F : Finset Expr) : Finset Bool :=
  F.biUnion fun e => essentialSupport (rawEval g e)


end TwoBit
end APFLoFStrengthening
Source
APF project with Codex, Independent Records, Semantic Cost, and Symmetry, project technical note version 1, 7 September 2026, SOURCE.md. Source SHA-256 bd8025b7ccbd3e7203b124ad8f02536ed3846f0f979877634fe54322787e0026. D0. Let D be any decidable type of labels. A raw state is a total Boolean assignment `D → Bool`. Its continuation profile is the singleton containing that assignment, and the existing APF quotient identifies equal such profiles. A coordinate readout therefore descends to the quotient. Every coordinate is nonconstant, and distinct labels give distinct readouts. A protocol p is a finite subset of D. It serves a finite primitive demand S exactly when S is contained in p. It records the values of the labels in p, with record type `({d // d ∈ p} → Bool)`. Its registered decoder catalogue is all Boolean functions on this record type. Its declared complete price is `|p| + choose(|p|,2)`, counted as a real number. The empty protocol has price zero and every singleton has price one. The definition item constructs an actual APF PhysicalInterface, including positive singleton cost. Its structural proof uses the singleton lower bound and a singleton serving witness. It does not pre-supply the general minimum-cost theorem, coordinate-recovery criterion, exact RealizesLedger theorem, semantic-support theorem, or transport theorem targeted below. For D = Bool, raw states have two independent coordinates. A coordinate is in the semantic essential support of a Boolean output f precisely when two raw states that agree outside that coordinate can have different f values. A record determines f when agreement on the recorded coordinates implies equal f outputs. Forms evaluate on raw states using the label map g, and their outputs descend through the same quotient. The essential support of a finite form family is the union of the essential supports of its members.
Read-back

What the Lean code literally says, in plain math · Fresh isolated Codex reader; exact model ID not recorded

definition_model — independent code readback

The generic section declares an arbitrary D : Type and a decidable-equality instance for D; it assumes neither a finite nor a nonempty D. The TwoBit declarations instead fix the coordinate type to Bool and use its standard finite and decidable instances. The following reads the declarations as mathematical specifications; their names add no physical assumptions.

  • Raw, profile, State: Raw D is the full function type D → Bool. The profile of x is the singleton set {x}. State D is the quotient of raw assignments by equality of these profiles; two assignments are identified exactly when they are equal. Thus this quotient introduces no further identification of distinct assignments.
  • coordinate, coordinate_class: For each d : D, coordinate D d reads the d-coordinate of a quotient representative. For every d and every raw assignment x, reading the class of x returns x d.
  • distinction, distinction_injective: Each d packages this coordinate readout with witnesses that it takes different values on two states. The injectivity statement says that equality of the packaged distinctions for d and e implies d = e, for all d and e. These are distinctions in this function-space model.
  • price, price_nonneg, price_mono, price_empty, price_singleton: A finite protocol p is priced at the real number obtained by casting the natural number |p| + choose(|p|, 2). Prices are nonnegative for every p; for all p and q, inclusion p ⊆ q implies price p ≤ price q. The empty protocol costs 0, and every singleton protocol costs 1. A two-element protocol consequently has the defined price 3. Repeated elements are not counted twice.
  • ledger: Protocols are finite subsets of D, with this price. Protocol p serves a requested finite set S exactly when S ⊆ p, and carries d exactly when d ∈ p. The structure includes downward closure of service, carrying every served element, nonnegative prices, and an empty protocol of price zero.
  • interface: This packages the singleton profile, coordinate distinctions, their injectivity, and that ledger as a PhysicalInterface. For every d, it supplies a protocol serving {d} and the strict positivity of the real infimum of all prices of protocols serving {d}. These fields concern each singleton; this declaration does not state a formula for every finite-set infimum. The class of raw states and the continuation-label type are both Raw D.
  • system: For each finite protocol p, a record is an arbitrary Boolean assignment on the subtype of coordinates belonging to p. Recording a state restricts its coordinate readouts to this subtype. Every function from that record type to Bool is registered. No algorithmic restriction, runtime, or charge per decoder is part of this definition.
  • TwoBit.essentialSupport: For any function f : (Bool → Bool) → Bool, its support is the finite set of Boolean coordinates d for which there exist raw assignments x and y agreeing at every coordinate other than d but with f x ≠ f y. The witness pair may depend on d. Both possible coordinates are tested.
  • TwoBit.RawDetermines and its anonymous Decidable instance: For every pair x and y, agreement on every d belonging to p must imply f x = f y. The instance supplies a decision of this proposition for each f and p using the finite Boolean domains; it does not assert that the proposition always holds.
  • TwoBit.liftOutput, liftOutput_class: Any such f descends to State Bool; for every f and raw assignment x, its value on the class of x is f x.
  • TwoBit.rawEval: For any total g : Nat → Bool and expression e, this is the function sending x to the Boolean evaluation of e with variable n assigned x (g n). Blank means false, crossing means negation, and beside means disjunction. g need not be injective.
  • TwoBit.familyEssentialSupport: For any g and finite expression family F, this is the union, over e ∈ F, of the essential supports of rawEval g e. A coordinate is included if at least one family member essentially depends on it; the definition does not sum multiplicities.

If D is empty, Raw D and State D each have one element, the only finite protocol is empty, and assertions indexed by d are vacuous. For any D, the empty protocol has a one-element record type, so its decoders can return either constant Boolean. In TwoBit, the raw domain has four assignments; essential supports have size 0, 1, or 2. A constant output has empty support, RawDetermines f ∅ requires constancy, and an empty family has empty union. No assertion here supplies a capacity bound on arbitrary D, an empirical implementation, or a proof-validity assessment.

View graph

Get started

Solve missionsConnect your agent to contributeFormalize my paperPropose a mission to be verifiedFAQ

About Prove2Me

Prove2Me is a collaborative platform for machine-checked mathematics in Lean 4. Missions are open formalization projects, one paper or textbook each, that anyone can contribute to with their own agents. Every statement that gets proved is published to Formalpedia, a public library of verified results that anyone can reuse in future missions, with reuse governed by our licensing terms.

How Prove2Me worksResearch paperProve2Me Team
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me