Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

The supplied two-context pass world with optional return

Definition
APFPaper5_Worlds_PassWorld

by FiniteUniverse · Nov 15, 2026 · Mathlib 0df444a (Lean v4.33.1)

apfapf-referencesib-v66-pullbacks-v22-2026-11

Defines two contexts, a mark and pool, partial pass fragments, word resources and bills, capacity two, profile tasks, alignments and EightHold. ret controls the return pass. All states, fragments, costs, capacities, protocol membership, actual alignments and singleton admissible sets for A2/BW are supplied data. Satisfaction of declared forms on them certifies no original physical instance. B02 r2 is handled as the current finite-combination clause; r3 is not installed. A pass requires mark-here and pool-held, plus return permission from B. Execution, budget, profile and active-alignment support lemmas are part of this module; no transition-selection law is supplied by A2.

Supplied data and hypotheses

  • All states, fragments, costs, capacities, protocol membership, actual alignments and singleton admissible sets for A2/BW are supplied data. Satisfaction of declared forms on them certifies no original physical instance. B02 r2 is handled as the current finite-combination clause; r3 is not installed. A pass requires mark-here and pool-held, plus return permission from B. Execution, budget, profile and active-alignment support lemmas are part of this module; no transition-selection law is supplied by A2.

Limits

This is conditional reference mathematics. The supplied model and its hypotheses are not adopted Foundation inputs, and this node does not establish K1, K3 or K4 closure.

Definition code
/-
APF Foundation Ledger — definition node DRAFT (session EthanBrooke-01WrrBvu, 2026-11-14; not gated, not reviewed)
name: APFPaper5_Worlds_PassWorld
title: Supplied data for the pass world: two contexts, one mark that is held at one of them, a pool held at both, and a pass that takes the mark across and keeps the pool's record
inputs_revision: 2026-11-14.1
mathlib_rev: 0df444a360eaa60ab8c11dca51a86af692955474
source: supplied data, built on Def_APFPaper1_ContinuationWords (the whole-word budgeted class, author ruling
 2026-11-12). The shape follows Paper 27 v1.2, section 2 and Appendix A (two distinctions and a shared pool;
 cost passes between them with the total fixed; no transfer without the pool) and Paper 24 v1.4, section 4
 (what a moving anchor sheds lands elsewhere). The author, 2026-11-14 16:34 HST: "Let's build this world".
 FOUNDATION_INPUTS is not consumed; no claim is made that a physical context is like this.
standing: supplied data only. Every definition here is a choice of this seat. The parameter `ret` says
 whether the pass from B back to A is admitted: true is the exchange of Paper 27, false the one-way shedding
 of Paper 24.
contents: two contexts, A and B. A raw state says where the mark is (at A or at B) and whether the pool is
 held; it is the same four states at both contexts. Each context has two distinctions: "the mark is here"
 and "the pool is held". "The mark is here" at B is "the mark is here" at A read the other way. Fragments:
 rm keeps the mark's record and runs where the mark is here; rs keeps the pool's record and runs where the
 pool is held; pass goes to the other context, runs where the mark is here and the pool is held, moves the
 mark across, and keeps the pool's record. A word keeps the records of its fragments; its bill is the
 number of records it keeps; capacity 2 at both contexts. Every word is a protocol. EightHold names the
 eight declared forms on this data for a given actual alignment. heldAt is the family a state holds at a
 context and neededAt the records that family needs. Support lemmas (execution of one fragment,
 the budget, the profiles) are included because the alignments need them; they are not nodes.
-/
import Definitions.Def_APFPaper1_ContinuationWords
import Definitions.Def_APFPaper1_FamilyCost
import Definitions.Def_APF_B01_DeclaredInput
import Definitions.Def_APF_B02_DeclaredInput_r2_proposed
import Definitions.Def_APF_B03_DeclaredInput_r2
import Definitions.Def_APF_B04_DeclaredInput
import Definitions.Def_APF_B05_DeclaredInput_r2
import Definitions.Def_APF_B06_DeclaredInput
import Definitions.Def_APF_B07a_DeclaredInput
import Definitions.Def_APF_B07b_DeclaredInput
import Definitions.Def_APFB06_ExtensionalJoint
import Definitions.Def_APFB06_PhysicalDomain
import Mathlib.Data.Fintype.Prod
import Mathlib.Data.Fintype.Pi
import Mathlib.Data.Fintype.Card
import Mathlib.Data.Finset.Card

set_option autoImplicit false
open APFPaper1.Continuation

namespace APFPaper5.Worlds.PassWorld

/-- The two contexts. -/
inductive Ctx : Type
  | A : Ctx
  | B : Ctx
  deriving DecidableEq

/-- The fragments: two that keep a record, and the pass. -/
inductive Fr : Type
  | rm : Fr
  | rs : Fr
  | pass : Fr
  deriving DecidableEq

/-- A raw state: (the mark is at A, the pool is held). -/
abbrev G : Type := Bool × Bool
/-- Records: true is the mark's record, false the pool's. -/
abbrev Rec : Type := Bool
abbrev Frag : Ctx → Ctx → Type := fun _ _ => Fr
abbrev Raw : Ctx → Type := fun _ => G
abbrev Res : Ctx → Type := fun _ => Finset Rec

def other : Ctx → Ctx
  | Ctx.A => Ctx.B
  | Ctx.B => Ctx.A

/-- The mark is held at the context. -/
def here : Ctx → G → Bool
  | Ctx.A, x => x.1
  | Ctx.B, x => !x.1

/-- The pool is held. -/
def dS : G → Bool := fun x => x.2

/-- The mark goes to the other context; the pool is left as it was. -/
def flip : G → G := fun x => (!x.1, x.2)

/-- Where a fragment runs. -/
def runs (ret : Bool) (g h : Ctx) : Fr → G → Prop
  | Fr.rm, x => g = h ∧ here g x = true
  | Fr.rs, x => g = h ∧ x.2 = true
  | Fr.pass, x => g ≠ h ∧ here g x = true ∧ x.2 = true ∧ (g = Ctx.B → ret = true)

/-- What a fragment does to the state. -/
def act : Fr → G → G
  | Fr.rm, x => x
  | Fr.rs, x => x
  | Fr.pass, x => flip x

def step (ret : Bool) : (g h : Ctx) → Frag g h → Raw g → Raw h → Prop :=
  fun g h f x y => runs ret g h f x ∧ y = act f x

/-- The record a fragment keeps. The pass keeps the pool's record. -/
def fragRec : Fr → Finset Rec
  | Fr.rm => {true}
  | Fr.rs => {false}
  | Fr.pass => {false}

/-- The records a word keeps: those of its fragments. -/
def keptW : {g h : Ctx} → Word Frag g h → Finset Rec
  | _, _, Word.nil _ => ∅
  | _, _, Word.cons f w => fragRec f ∪ keptW w

/-- Whether a word has a pass in it. -/
def hasPass : {g h : Ctx} → Word Frag g h → Bool
  | _, _, Word.nil _ => false
  | _, _, Word.cons f w => decide (f = Fr.pass) || hasPass w

def kept : (g : Ctx) → WordFrom Frag g → Finset Rec := fun _ w => keptW w.2
def cost : Rec → NNReal := fun _ => 1
def resource : (g : Ctx) → WordFrom Frag g → Res g := fun g w => kept g w
def calibration : (g : Ctx) → Res g → NNReal := fun _ s => (s.card : NNReal)
def C : Ctx → NNReal := fun _ => 2

abbrev K (ret : Bool) : (g : Ctx) → Raw g → WordFrom Frag g → Prop :=
  Cont (step ret) resource calibration C

/-- The distinction domain of a context: "the mark is here" and "the pool is held". -/
def Delta : (g : Ctx) → (G → Bool) → Prop := fun g d => d = here g ∨ d = dS
abbrev Dist (g : Ctx) : Type := {d : G → Bool // Delta g d}

def dMd (g : Ctx) : Dist g := ⟨here g, Or.inl rfl⟩
def dSd (g : Ctx) : Dist g := ⟨dS, Or.inr rfl⟩

/-- Every word is a protocol. -/
def protocols : (g : Ctx) → Set (WordFrom Frag g) := fun _ => Set.univ
abbrev Proto : Ctx → Type := fun g => {p : WordFrom Frag g // p ∈ protocols g}

def maint : (g : Ctx) → Proto g → Set Rec := fun g p => (↑(kept g p.val) : Set Rec)

/-- A state where the mark is at the context and the pool is not held. -/
def markOnly : Ctx → G
  | Ctx.A => (true, false)
  | Ctx.B => (false, false)

/-- The record a distinction needs: the mark's record for "the mark is here", the pool's for "the pool is
held". -/
def need {g : Ctx} : Dist g → Finset Rec := fun d => {d.val (markOnly g)}

def suff : (g : Ctx) → Proto g → Set Rec → Dist g → Prop := fun _ _ sigma d =>
  (↑(need d) : Set Rec) ⊆ sigma
def uses : (g : Ctx) → Proto g → Dist g → Set Rec → Prop := fun _ _ _ _ => True
def wholeRes : (g : Ctx) → Proto g → Res g := fun g p => resource g p.val

/-- The words used as witnesses. -/
def wM (g : Ctx) : WordFrom Frag g := ⟨g, Word.single (g := g) (h := g) Fr.rm⟩
def wS (g : Ctx) : WordFrom Frag g := ⟨g, Word.single (g := g) (h := g) Fr.rs⟩
def wBoth (g : Ctx) : WordFrom Frag g :=
  ⟨g, Word.cons (g := g) (h := g) (k := g) Fr.rm (Word.single (g := g) (h := g) Fr.rs)⟩
def wPass (g : Ctx) : WordFrom Frag g := ⟨other g, Word.single (g := g) (h := other g) Fr.pass⟩
/-- From A: pass to B and pass back. -/
def wRound : WordFrom Frag Ctx.A :=
  ⟨Ctx.A, Word.cons (g := Ctx.A) (h := Ctx.B) (k := Ctx.A) Fr.pass
    (Word.single (g := Ctx.B) (h := Ctx.A) Fr.pass)⟩

/-- From A: keep the mark's record, keep the pool's record, then pass to B. -/
def wServeAndPass : WordFrom Frag Ctx.A :=
  ⟨Ctx.B, Word.cons (g := Ctx.A) (h := Ctx.A) (k := Ctx.B) Fr.rm
    (Word.cons (g := Ctx.A) (h := Ctx.A) (k := Ctx.B) Fr.rs
      (Word.single (g := Ctx.A) (h := Ctx.B) Fr.pass))⟩

/-- A word that keeps exactly a given set of records. -/
def wordOfSet (g : Ctx) (T : Finset Rec) : WordFrom Frag g :=
  if true ∈ T then (if false ∈ T then wBoth g else wM g) else (if false ∈ T then wS g else nullWord g)

/-- The occupant's raw state at a context: the mark is here and the pool is held. -/
def occ : Ctx → G
  | Ctx.A => (true, true)
  | Ctx.B => (false, true)

/-- The records needed by what is held at a context in a state: the mark's record if the mark is here, the
pool's record if the pool is held. -/
def neededAt (g : Ctx) (x : G) : Finset Rec :=
  (if here g x = true then {true} else ∅) ∪ (if x.2 = true then {false} else ∅)

/-! ### Support lemmas (not nodes): execution of one fragment, the budget, and the profiles. -/

theorem executes_single (ret : Bool) (g h : Ctx) (f : Fr) (x y : G) :
    Executes (step ret) (Word.single (g := g) (h := h) f) x y ↔ runs ret g h f x ∧ y = act f x := by
  constructor
  · rintro ⟨y', ⟨hr, hy'⟩, hnil⟩
    have e : y' = y := hnil
    exact ⟨hr, e ▸ hy'⟩
  · rintro ⟨hr, hy⟩
    exact ⟨act f x, ⟨hr, rfl⟩, hy.symm⟩

theorem budget (g : Ctx) (w : WordFrom Frag g) : calibration g (resource g w) ≤ C g := by
  show ((kept g w).card : NNReal) ≤ 2
  have h : (kept g w).card ≤ 2 := by
    have h1 := Finset.card_le_univ (kept g w)
    rwa [Fintype.card_bool] at h1
  exact_mod_cast h

theorem cont_wM (ret : Bool) (g : Ctx) (x : G) : K ret g x (wM g) ↔ here g x = true := by
  constructor
  · rintro ⟨⟨y, hy⟩, _⟩
    exact ((executes_single ret g g Fr.rm x y).mp hy).1.2
  · intro h
    exact ⟨⟨x, (executes_single ret g g Fr.rm x x).mpr ⟨⟨rfl, h⟩, rfl⟩⟩, budget _ _⟩

theorem cont_wS (ret : Bool) (g : Ctx) (x : G) : K ret g x (wS g) ↔ x.2 = true := by
  constructor
  · rintro ⟨⟨y, hy⟩, _⟩
    exact ((executes_single ret g g Fr.rs x y).mp hy).1.2
  · intro h
    exact ⟨⟨x, (executes_single ret g g Fr.rs x x).mpr ⟨⟨rfl, h⟩, rfl⟩⟩, budget _ _⟩

theorem here_inj (g : Ctx) (x y : G) (h1 : here g x = here g y) (h2 : x.2 = y.2) : x = y := by
  cases g
  · exact Prod.ext h1 h2
  · have h3 : x.1 = y.1 := by
      have h4 : (!x.1) = (!y.1) := h1
      cases hx : x.1 <;> cases hy : y.1 <;> rw [hx, hy] at h4 <;> first | rfl | exact absurd h4 (by decide)
    exact Prod.ext h3 h2

theorem profile_inj (ret : Bool) (g : Ctx) (x y : G) (h : K ret g x = K ret g y) : x = y := by
  have hM : (here g x = true) ↔ (here g y = true) := by
    rw [← cont_wM ret g x, ← cont_wM ret g y, h]
  have hS : (x.2 = true) ↔ (y.2 = true) := by
    rw [← cont_wS ret g x, ← cont_wS ret g y, h]
  exact here_inj g x y (Bool.eq_iff_iff.mpr hM) (Bool.eq_iff_iff.mpr hS)

theorem hresp (ret : Bool) (g : Ctx) (d : {d : G → Bool // Delta g d}) (x y : G)
    (h : K ret g x = K ret g y) : d.val x = d.val y := by
  rw [profile_inj ret g x y h]

theorem here_occ (g : Ctx) : here g (occ g) = true := by
  cases g <;> rfl

theorem dS_occ (g : Ctx) : dS (occ g) = true := by
  cases g <;> rfl

/-! ### The occupant's alignment at a context and the joint class, on the physical domain -/

def D (ret : Bool) : (g : Ctx) → Set (APFB01.PhysicalState (K ret g) → Bool) := fun g =>
  APFB06.physicalDomain (K ret g) (Delta g) (hresp ret g)

/-- The family the occupant carries, as raw distinctions and as tasks. -/
def carriedDist (g : Ctx) : Finset (Dist g) := {dMd g, dSd g}
def carriedTasks (ret : Bool) (g : Ctx) : Finset (APFB06.Task (K ret g) (D ret g)) :=
  (carriedDist g).map (APFB06.taskEquiv (K ret g) (Delta g) (hresp ret g)).symm.toEmbedding

/-- The family held at a context in a state: those of its two distinctions that read true there. -/
def heldAt (g : Ctx) (x : G) : Finset (Dist g) := (carriedDist g).filter (fun d => d.val x = true)

theorem carried_active (ret : Bool) (g : Ctx) :
    ∀ t ∈ carriedTasks ret g, t.val (APFB01.physicalClass (K ret g) (occ g)) = true := by
  intro t ht
  obtain ⟨d, hd, rfl⟩ := Finset.mem_map.mp ht
  show d.val (occ g) = true
  rcases Finset.mem_insert.mp hd with h | h
  · rw [h]
    exact here_occ g
  · rw [Finset.mem_singleton.mp h]
    exact dS_occ g

/-- The occupant of context `g`: it sits where the mark is at `g` and the pool is held, and carries both. -/
def align (ret : Bool) (g : Ctx) : APFB06.OriginalAlignment (K ret g) (D ret g) where
  carrier := APFB01.physicalClass (K ret g) (occ g)
  carried := carriedTasks ret g
  active := carried_active ret g

def suffT (ret : Bool) : (g : Ctx) → Proto g → Set Rec → APFB06.Task (K ret g) (D ret g) → Prop :=
  fun g p sigma t => suff g p sigma (APFB06.distinctionOfTask (K ret g) (Delta g) (hresp ret g) t)
def usesT (ret : Bool) : (g : Ctx) → Proto g → APFB06.Task (K ret g) (D ret g) → Set Rec → Prop :=
  fun _ _ _ _ => True

/-- The joint class: the extensional one (the other Claude seat's Def_APFB06_ExtensionalJoint). -/
def J (ret : Bool) : (g : Ctx) → Finset (APFB06.Task (K ret g) (D ret g)) → Set (Proto g) := fun g =>
  APFB06.extensionalJoint (maint g) (suffT ret g) (usesT ret g)

/-- The eight declared forms on the supplied data, B02 as revised, for a given set of actual alignments. -/
def EightHold (ret : Bool)
    (actual : Set (Sigma fun g => APFB06.OriginalAlignment (K ret g) (D ret g))) : Prop :=
  (∀ g : Ctx, APF_B01_DeclaredInput (K ret g)
      (fun (f : APFB01.PhysicalState (K ret g) → Prop) (x : G) =>
        f (APFB01.physicalClass (K ret g) x))
      (fun (f : APFB01.PhysicalState (K ret g) → Prop) (x : G) =>
        f (APFB01.physicalClass (K ret g) x))
      (fun (f : APFB01.PhysicalState (K ret g) → Prop) (x : G) =>
        f (APFB01.physicalClass (K ret g) x))
      (fun (f : APFB01.PhysicalState (K ret g) → Prop) (x : G) =>
        f (APFB01.physicalClass (K ret g) x))) ∧
    APFB02.B02SourceMeaning_r2 (Context := Ctx) (X := fun _ => G) (Q := fun g => WordFrom Frag g)
      (P := Proto) (Record := fun _ => Rec) (K ret) Delta maint suff uses ∧
    APFB03.B03TaskCost (Context := Ctx) (D := Dist) (P := Proto) (R := Res)
      (Record := fun _ => Rec) wholeRes calibration maint suff uses ∧
    APFB04.B04FiniteCapacity (Context := Ctx) (fun _ => (2 : ℝ)) ∧
    APFB05.MarginalFloor (Context := Ctx) (D := Dist) (P := Proto) (R := Res)
      (Record := fun _ => Rec) wholeRes calibration maint suff uses
      (fun _ _ => True) (fun _ => 2) (fun _ => 1) ∧
    APFB06.AmendedB06_20260914 (K ret) (D ret) protocols (J ret) wholeRes calibration C actual ∧
    APFB07a.A2Selection (Interface := Ctx)
      (Configuration := fun g => APFB01.PhysicalState (K ret g))
      (fun g s => s = APFB01.physicalClass (K ret g) (occ g)) (fun _ _ => (1 : ℝ))
      (fun g => APFB01.physicalClass (K ret g) (occ g)) ∧
    APFB07b.BWUniqueMinimum (Interface := Ctx)
      (Configuration := fun g => APFB01.PhysicalState (K ret g))
      (fun g s => s = APFB01.physicalClass (K ret g) (occ g)) (fun _ _ => (1 : ℝ))

end APFPaper5.Worlds.PassWorld
Source
Definitions.Def_APFPaper5_Worlds_PassWorld; Sib v66 / pullbacks v22, SHA-256 6c9661898c5c406e1984f71f8533b77a60f3bc0377645f9446884674c3a0f75f. rv2_v66_v22_PRIOR_WORK_CHECK.json; rv2_v66_v22_SOURCE_READ_SUPPLEMENT.json; C:\Users\brook\My Drive\__APF Library\Artifacts_2026-11-15_session\astra\sib_v66_publication\source\Definitions\Def_APFPaper5_Worlds_PassWorld.lean

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