MindFormal v1.0.0One Mind

MindFormal.Chapters.Ch16.MarketReplay

@[reducible, inline]
abbrev MindFormal.MarketReplay.Plan (A : Type u_3) (Price : Type u_4) :
Type (max u_4 u_3)

18.11: a phase plan is an offered pair and price, or an idle length. The distinct-pair and positive-length conditions are stated in PlanValid.

Equations
Instances For
    @[reducible, inline]
    abbrev MindFormal.MarketReplay.Firsts (A : Type u_3) (N : A → ℕ) :
    Type u_3

    18.11: the stored first act includes its phase-relative time and label. Absent acts stay absent; only the two parties' slots are retained in a phase.

    Equations
    Instances For
      @[reducible, inline]
      abbrev MindFormal.MarketReplay.Phase (A : Type u_3) (N : A → ℕ) (Price : Type u_4) :
      Type (max (max u_4 u_3) u_3)

      18.11: the phase's ordinary coordinates, before imposing the invariant that its deadline is still pending and the two first acts are not both present.

      Equations
      Instances For
        @[reducible, inline]
        abbrev MindFormal.MarketReplay.Memory (M : Type u_3) (A : Type u_4) (N : A → ℕ) (Price : Type u_5) :
        Type (max u_3 u_5 u_4)

        18.11: the memory coordinates are exactly the stream memory, ledger and outstanding/idle phase. There is no retained replay record or source path.

        Equations
        Instances For
          def MindFormal.MarketReplay.length {A : Type u_1} {Price : Type u_2} (deadline : NNReal) :
          Plan A Price → NNReal

          18.11: the primitive phase length is the common offer deadline or the selected idle duration. An idle plan is not an offered encounter.

          Equations
          Instances For
            def MindFormal.MarketReplay.PlanValid {A : Type u_1} {Price : Type u_2} (deadline minimum : NNReal) :
            Plan A Price → Prop

            18.11: primitive plans have distinct parties, or an idle interval between the declared minimum and deadline, as required by the completion menu. This is data validation, not a restart or a market composition premise.

            Equations
            Instances For
              def MindFormal.MarketReplay.PhaseValid {A : Type u_1} {N : A → ℕ} {Price : Type u_2} (deadline minimum : NNReal) (p : Phase A N Price) :

              18.11: ordinary phase memories have a pending deadline, phase-relative first acts at or before their age, and no already-completed pair.

              Equations
              • One or more equations did not get rendered due to their size.
              Instances For
                def MindFormal.MarketReplay.fresh {A : Type u_1} {N : A → ℕ} {Price : Type u_2} (plan : Plan A Price) :
                Phase A N Price

                18.11: a new offer or idle phase begins at age zero and with no remembered acts, after the settlement and the primitive step-end jump.

                Equations
                Instances For

                  Decode the first occupied record slot as a timed label, leaving an absent slot absent. Valid chronological records have nonnegative times.

                  Equations
                  Instances For
                    theorem MindFormal.MarketReplay.firstSlot_join {C : Type u_3} (c : NNReal) {p f : FiniteActionHistory C} (hv : CutValid (↑c) p f) :
                    firstSlot (joinHistory (↑c) p f) = (firstSlot p).or (Option.map (fun (q : NNReal × C) => (c + q.1, q.2)) (firstSlot f))

                    At a valid join the first slot is the past's first slot, if present, otherwise the future's first slot translated by the cut.

                    theorem MindFormal.MarketReplay.firstSlot_past_le {C : Type u_3} (c : NNReal) {p f : FiniteActionHistory C} (hv : CutValid (↑c) p f) {q : NNReal × C} (hq : firstSlot p = some q) :
                    q.1 ≤ c

                    A present first slot in a valid past is no later than the cut.

                    theorem MindFormal.MarketReplay.firstSlot_future_pos {C : Type u_3} (c : NNReal) {p f : FiniteActionHistory C} (hv : CutValid (↑c) p f) {q : NNReal × C} (hq : firstSlot f = some q) :
                    0 < q.1

                    A present first slot on the future side of a valid cut is positive.

                    A previously collected first act stays fixed. Otherwise the first new act is translated from elapsed time into the phase's own age coordinate.

                    Equations
                    Instances For
                      noncomputable def MindFormal.MarketReplay.observe {A : Type u_1} {N : A → ℕ} {Price : Type u_2} (p : Phase A N Price) (t : NNReal) (history : (a : A) → FiniteActionHistory (Fin (N a))) :
                      Phase A N Price

                      18.11: record the parties' first acts and advance phase age, without settling. Callers use the record closed at the elapsed time in this read.

                      Equations
                      • One or more equations did not get rendered due to their size.
                      Instances For
                        theorem MindFormal.MarketReplay.collect_join {C : Type u_3} (age c : NNReal) (old : Option (NNReal × C)) {p f : FiniteActionHistory C} (hv : CutValid (↑c) p f) :
                        collect (age + c) (collect age old p) f = collect age old (joinHistory (↑c) p f)

                        Collecting across a valid cut preserves the original first act and its phase-relative time, including an act exactly at the cut.

                        theorem MindFormal.MarketReplay.observe_join {A : Type u_1} {N : A → ℕ} {Price : Type u_2} (p : Phase A N Price) (c s : NNReal) (X Y : (a : A) → FiniteActionHistory (Fin (N a))) (hv : ∀ (a : A), CutValid (↑c) (X a) (Y a)) :
                        observe (observe p c X) s Y = observe p (c + s) fun (a : A) => joinHistory (↑c) (X a) (Y a)

                        Observation of phase coordinates composes across the same cut-valid records as the stream. No restart is assumed.

                        def MindFormal.MarketReplay.partyEnd {C : Type u_3} (remaining : NNReal) (old : Option (NNReal × C)) (h : FiniteActionHistory C) :

                        A party already collected needs no elapsed time. A missing first act uses its next record slot, capped at the remaining deadline; absence times out.

                        Equations
                        Instances For
                          theorem MindFormal.MarketReplay.partyEnd_join_before {C : Type u_3} (r c : NNReal) (old : Option (NNReal × C)) {p f : FiniteActionHistory C} (hv : CutValid (↑c) p f) (hp : partyEnd r old p ≤ c) :
                          partyEnd r old (joinHistory (↑c) p f) = partyEnd r old p

                          A party already completing by the cut has the same capped end on the joined record. Later acts cannot replace its first act.

                          theorem MindFormal.MarketReplay.min_shift (r c q : NNReal) (hc : c ≤ r) :
                          min (c + q) r = c + min q (r - c)

                          Capping an arrival translated by a cut is the translation of its residual cap, provided the deadline is after the cut.

                          theorem MindFormal.MarketReplay.partyEnd_join_max {C : Type u_3} (r age c : NNReal) (old : Option (NNReal × C)) {p f : FiniteActionHistory C} (hv : CutValid (↑c) p f) (hc : c < r) :
                          max c (partyEnd r old (joinHistory (↑c) p f)) = c + partyEnd (r - c) (collect age old p) f

                          A party's capped end after joining, clipped below at the cut, is the cut plus its residual end from the observed phase.

                          theorem MindFormal.MarketReplay.partyEnd_join_gt {C : Type u_3} (r c : NNReal) (old : Option (NNReal × C)) {p f : FiniteActionHistory C} (hv : CutValid (↑c) p f) (hp : c < partyEnd r old p) :
                          c < partyEnd r old (joinHistory (↑c) p f)

                          A party unfinished at the cut is still unfinished at the cut on the joined record: future acts are strictly after zero.

                          def MindFormal.MarketReplay.phaseEnd {A : Type u_1} {N : A → ℕ} {Price : Type u_2} (deadline : NNReal) (p : Phase A N Price) (history : (a : A) → FiniteActionHistory (Fin (N a))) :

                          18.11: the phase ends when both first acts have arrived or its deadline expires. Idle ends at its remaining duration and has no parties.

                          Equations
                          • One or more equations did not get rendered due to their size.
                          Instances For
                            theorem MindFormal.MarketReplay.length_pos {A : Type u_1} {Price : Type u_2} {deadline minimum : NNReal} (hd : 0 < deadline) (hm : 0 < minimum) {p : Plan A Price} (hp : PlanValid deadline minimum p) :
                            0 < length deadline p

                            A valid plan has positive length, from the two primitive positive durations; this is not a positive pause between successive acts.

                            theorem MindFormal.MarketReplay.fresh_valid {A : Type u_1} {N : A → ℕ} {Price : Type u_2} {deadline minimum : NNReal} (hd : 0 < deadline) (hm : 0 < minimum) {p : Plan A Price} (hp : PlanValid deadline minimum p) :
                            PhaseValid deadline minimum (fresh p)

                            The primitive step-end rule starts a valid phase whenever it returns a valid plan. No earlier first act is carried into the new offer.

                            theorem MindFormal.MarketReplay.partyEnd_le {C : Type u_3} (r : NNReal) (old : Option (NNReal × C)) (h : FiniteActionHistory C) :
                            partyEnd r old h ≤ r

                            Every party's completion is capped by the remaining deadline.

                            theorem MindFormal.MarketReplay.phaseEnd_le {A : Type u_1} {N : A → ℕ} {Price : Type u_2} (deadline : NNReal) (p : Phase A N Price) (h : (a : A) → FiniteActionHistory (Fin (N a))) :
                            phaseEnd deadline p h ≤ length deadline p.1 - p.2.1

                            The phase's end never exceeds its remaining length.

                            theorem MindFormal.MarketReplay.phaseEnd_join_before {A : Type u_1} {N : A → ℕ} {Price : Type u_2} (deadline : NNReal) (p : Phase A N Price) (c : NNReal) (X Y : (a : A) → FiniteActionHistory (Fin (N a))) (hv : ∀ (a : A), CutValid (↑c) (X a) (Y a)) (hc : phaseEnd deadline p X ≤ c) :
                            (phaseEnd deadline p fun (a : A) => joinHistory (↑c) (X a) (Y a)) = phaseEnd deadline p X

                            A phase ending by the cut ends at the identical time on the joined record. This includes timeout and an act exactly at the cut.

                            theorem MindFormal.MarketReplay.phaseEnd_join_after {A : Type u_1} {N : A → ℕ} {Price : Type u_2} (deadline : NNReal) (p : Phase A N Price) (c : NNReal) (X Y : (a : A) → FiniteActionHistory (Fin (N a))) (hv : ∀ (a : A), CutValid (↑c) (X a) (Y a)) (hc : c < phaseEnd deadline p X) :
                            (phaseEnd deadline p fun (a : A) => joinHistory (↑c) (X a) (Y a)) = c + phaseEnd deadline (observe p c X) Y

                            If the cut precedes the phase end, the joined end is the cut plus the end read from the observed phase and the future's own record.

                            theorem MindFormal.MarketReplay.phaseEnd_empty {A : Type u_1} {N : A → ℕ} {Price : Type u_2} {deadline minimum : NNReal} {p : Phase A N Price} (hp : PhaseValid deadline minimum p) :
                            (phaseEnd deadline p fun (a : A) => emptyHistory (Fin (N a))) = length deadline p.1 - p.2.1

                            With no new acts, an unfinished valid phase ends at its remaining deadline. In particular its end is strictly positive.

                            theorem MindFormal.MarketReplay.observe_zero_empty {A : Type u_1} {N : A → ℕ} {Price : Type u_2} {deadline minimum : NNReal} {p : Phase A N Price} (hp : PhaseValid deadline minimum p) :
                            (observe p 0 fun (a : A) => emptyHistory (Fin (N a))) = p

                            Observing no elapsed time and no acts preserves every valid phase coordinate, including a stored first act and absent bystander slots.

                            theorem MindFormal.MarketReplay.firstSlot_closed_le {C : Type u_3} (t : NNReal) (h : FiniteActionHistory C) {q : NNReal × C} (hq : firstSlot (closedHistory (↑t) h) = some q) :
                            q.1 ≤ t

                            A decoded first act in a closed record is no later than its cut, including arbitrary nonchronological input codes.

                            theorem MindFormal.MarketReplay.collect_time {C : Type u_3} (age t : NNReal) (old : Option (NNReal × C)) (h : FiniteActionHistory C) (ho : ∀ (q : NNReal × C), old = some q → q.1 ≤ age) {q : NNReal × C} (hq : collect age old (closedHistory (↑t) h) = some q) :
                            q.1 ≤ age + t

                            A retained first act stays within the advanced phase age.

                            theorem MindFormal.MarketReplay.partyEnd_le_of_collected {C : Type u_3} (r age t : NNReal) (old : Option (NNReal × C)) (h : FiniteActionHistory C) (hc : collect age old (closedHistory (↑t) h) ≠ none) :
                            partyEnd r old h ≤ t

                            If a previously missing first act has been collected by the cut, that party's capped end on the original record is at or before the cut.

                            theorem MindFormal.MarketReplay.observe_valid {A : Type u_1} {N : A → ℕ} {Price : Type u_2} {deadline minimum : NNReal} {p : Phase A N Price} (hp : PhaseValid deadline minimum p) (t : NNReal) (h : (a : A) → FiniteActionHistory (Fin (N a))) (ht : t < phaseEnd deadline p h) :
                            PhaseValid deadline minimum (observe p t fun (a : A) => closedHistory (↑t) (h a))

                            Before a phase's end, observing the closed prefix preserves the phase invariant. The proof works for every input code, not only native records.

                            A stored first act is exposed to the existing bilateral ledger as one timed occupied slot; absent acts produce the existing empty record.

                            Equations
                            Instances For
                              noncomputable def MindFormal.MarketReplay.settle {A : Type u_1} {N : A → ℕ} {Price : Type u_2} [DecidableEq A] (price : Price → ℝ) (accept : (a : A) → Fin (N a) → Bool) (ledger : Bilateral.Ledger A) (p : Phase A N Price) :

                              18.11: settlement is the existing physical ledger operation on the collected first acts. Idle phases leave the ledger for the stream's own packets.

                              Equations
                              • One or more equations did not get rendered due to their size.
                              Instances For
                                def MindFormal.MarketReplay.replayFuel {A : Type u_1} {N : A → ℕ} {Price : Type u_2} [DecidableEq A] {Ω : Type u_3} [MeasurableSpace Ω] {n : A → ℕ} {T : A → Type u_4} {Λ : A → Type u_5} [(a : A) → Fintype (T a)] [(a : A) → Fintype (Λ a)] {J : Type u_6} [Fintype J] {I : (a : A) → EquationInstance (N a) (n a) (T a) (Λ a) J} {G : EquationGround Ω J} (stream : HomogeneousGroupWorld I G) (deadline : NNReal) (price : Price → ℝ) (accept : (a : A) → Fin (N a) → Bool) (jump : stream.world.Memory → Bilateral.Ledger A → Phase A N Price → stream.world.Memory × Bilateral.Ledger A × Plan A Price) :
                                ℕ → Memory stream.world.Memory A N Price → (J ⊕ stream.world.Private → C(NNReal, ℝ)) → NNReal → ((a : A) → FiniteActionHistory (Fin (N a))) → Memory stream.world.Memory A N Price

                                18.11: one chronological replay with a finite recursion budget. At each phase end the stream is advanced on the closed record, settlement is computed, and the primitive jump selects the next fresh phase. The zero-budget branch is a total fallback. The lemmas below prove sufficient fuel, phase validity and composition for the constructed market advance.

                                Equations
                                Instances For
                                  theorem MindFormal.MarketReplay.replayFuel_valid {A : Type u_1} {N : A → ℕ} {Price : Type u_2} [DecidableEq A] {Ω : Type u_3} [MeasurableSpace Ω] {n : A → ℕ} {T : A → Type u_4} {Λ : A → Type u_5} [(a : A) → Fintype (T a)] [(a : A) → Fintype (Λ a)] {J : Type u_6} [Fintype J] {I : (a : A) → EquationInstance (N a) (n a) (T a) (Λ a) J} {G : EquationGround Ω J} (stream : HomogeneousGroupWorld I G) (deadline minimum : NNReal) (hd : 0 < deadline) (hm : 0 < minimum) (price : Price → ℝ) (accept : (a : A) → Fin (N a) → Bool) (jump : stream.world.Memory → Bilateral.Ledger A → Phase A N Price → stream.world.Memory × Bilateral.Ledger A × Plan A Price) (hj : ∀ (s : stream.world.Memory) (l : Bilateral.Ledger A) (p : Phase A N Price), PlanValid deadline minimum (jump s l p).2.2) (fuel : ℕ) (m : Memory stream.world.Memory A N Price) (hv : PhaseValid deadline minimum m.2.2) (w : J ⊕ stream.world.Private → C(NNReal, ℝ)) (t : NNReal) (h : (a : A) → FiniteActionHistory (Fin (N a))) :
                                  PhaseValid deadline minimum (replayFuel stream deadline price accept jump fuel m w t h).2.2

                                  Every finite replay level preserves the phase invariant, including the total zero-fuel branch. The jump only supplies the next primitive plan.

                                  theorem MindFormal.MarketReplay.missing_party_consumed {C : Type u_7} (r e : NNReal) (h : FiniteActionHistory C) (he : e < r) (hp : partyEnd r none h ≤ e) :
                                  ∃ (i : C), (↑(closedHistory (↑e) h) 0).2 = Sum.inl i

                                  An unfinished party completing before the remaining deadline has an occupied first slot in the closed record at completion.

                                  theorem MindFormal.MarketReplay.phaseEnd_consumes {A : Type u_1} {N : A → ℕ} {Price : Type u_2} {deadline minimum : NNReal} {p : Phase A N Price} (hp : PhaseValid deadline minimum p) (h : (a : A) → FiniteActionHistory (Fin (N a))) (he : phaseEnd deadline p h < length deadline p.1 - p.2.1) :
                                  ∃ (a : A) (i : Fin (N a)), (↑(closedHistory (↑(phaseEnd deadline p h)) (h a)) 0).2 = Sum.inl i

                                  Ending a valid phase before its timeout consumes at least one act. It cannot be an idle phase, or a pair whose two acts were both stored already.

                                  noncomputable def MindFormal.MarketReplay.potential {A : Type u_1} {N : A → ℕ} {Price : Type u_2} [Fintype A] (deadline minimum : NNReal) (p : Phase A N Price) (t : NNReal) (h : (a : A) → FiniteActionHistory (Fin (N a))) :

                                  The replay's decreasing natural potential counts remaining acts, full minimum intervals, and a possibly already-aged first phase.

                                  Equations
                                  Instances For
                                    theorem MindFormal.MarketReplay.ceil_duration_decreases {δ e t : NNReal} (hd : 0 < δ) (he : δ ≤ e) (ht : e ≤ t) :
                                    ⌈↑(t - e) / ↑δ⌉₊ < ⌈↑t / ↑δ⌉₊

                                    Consuming at least a minimum interval lowers the ceiling count. Both elapsed times are nonnegative; no rounding assumption is used.

                                    theorem MindFormal.MarketReplay.potential_decreases {A : Type u_1} {N : A → ℕ} {Price : Type u_2} [Fintype A] {deadline minimum : NNReal} (hd : 0 < deadline) (hm : 0 < minimum) {p : Phase A N Price} (hp : PhaseValid deadline minimum p) (t : NNReal) (h : (a : A) → FiniteActionHistory (Fin (N a))) (hh : ∀ (a : A), ChronologicalHistory (h a)) (he : phaseEnd deadline p h ≤ t) (plan : Plan A Price) :
                                    (potential deadline minimum (fresh plan) (t - phaseEnd deadline p h) fun (a : A) => laterHistory (↑(phaseEnd deadline p h)) (h a)) < potential deadline minimum p t h

                                    At every completed valid phase the potential strictly decreases on the rebased record and the fresh phase returned by the rule.

                                    noncomputable def MindFormal.MarketReplay.budget {A : Type u_1} {N : A → ℕ} [Fintype A] (deadline minimum t : NNReal) (history : (a : A) → FiniteActionHistory (Fin (N a))) :

                                    18.11: the finite replay budget counts all input acts and positive-length timeout/idle intervals. potential_le_budget and replayFuel_stable below prove its adequacy from primitive data.

                                    Equations
                                    Instances For
                                      noncomputable def MindFormal.MarketReplay.replay {A : Type u_1} {N : A → ℕ} {Price : Type u_2} [DecidableEq A] {Ω : Type u_3} [MeasurableSpace Ω] {n : A → ℕ} {T : A → Type u_4} {Λ : A → Type u_5} [(a : A) → Fintype (T a)] [(a : A) → Fintype (Λ a)] {J : Type u_6} [Fintype J] {I : (a : A) → EquationInstance (N a) (n a) (T a) (Λ a) J} {G : EquationGround Ω J} [Fintype A] (stream : HomogeneousGroupWorld I G) (deadline minimum : NNReal) (price : Price → ℝ) (accept : (a : A) → Fin (N a) → Bool) (jump : stream.world.Memory → Bilateral.Ledger A → Phase A N Price → stream.world.Memory × Bilateral.Ledger A × Plan A Price) (m : Memory stream.world.Memory A N Price) (w : J ⊕ stream.world.Private → C(NNReal, ℝ)) (t : NNReal) (history : (a : A) → FiniteActionHistory (Fin (N a))) :
                                      Memory stream.world.Memory A N Price

                                      18.11: the chronological market advance from primitive data. Its proved laws below construct the homogeneous world in MarketWorld.

                                      Equations
                                      • One or more equations did not get rendered due to their size.
                                      Instances For
                                        theorem MindFormal.MarketReplay.potential_le_budget {A : Type u_1} {N : A → ℕ} {Price : Type u_2} [Fintype A] (deadline minimum : NNReal) (p : Phase A N Price) (t : NNReal) (h : (a : A) → FiniteActionHistory (Fin (N a))) :
                                        potential deadline minimum p t h ≤ budget deadline minimum t h

                                        The computed budget dominates the phase-dependent potential.

                                        theorem MindFormal.MarketReplay.replayFuel_stable {A : Type u_1} {N : A → ℕ} {Price : Type u_2} [DecidableEq A] {Ω : Type u_3} [MeasurableSpace Ω] {n : A → ℕ} {T : A → Type u_4} {Λ : A → Type u_5} [(a : A) → Fintype (T a)] [(a : A) → Fintype (Λ a)] {J : Type u_6} [Fintype J] {I : (a : A) → EquationInstance (N a) (n a) (T a) (Λ a) J} {G : EquationGround Ω J} [Fintype A] (stream : HomogeneousGroupWorld I G) (deadline minimum : NNReal) (hd : 0 < deadline) (hm : 0 < minimum) (price : Price → ℝ) (accept : (a : A) → Fin (N a) → Bool) (jump : stream.world.Memory → Bilateral.Ledger A → Phase A N Price → stream.world.Memory × Bilateral.Ledger A × Plan A Price) (hj : ∀ (s : stream.world.Memory) (l : Bilateral.Ledger A) (p : Phase A N Price), PlanValid deadline minimum (jump s l p).2.2) (k l : ℕ) (m : Memory stream.world.Memory A N Price) (hv : PhaseValid deadline minimum m.2.2) (w : J ⊕ stream.world.Private → C(NNReal, ℝ)) (t : NNReal) (h : (a : A) → FiniteActionHistory (Fin (N a))) (hh : ∀ (a : A), ChronologicalHistory (h a)) (hk : potential deadline minimum m.2.2 t h ≤ k) (hl : potential deadline minimum m.2.2 t h ≤ l) :
                                        replayFuel stream deadline price accept jump k m w t h = replayFuel stream deadline price accept jump l m w t h

                                        Every fuel at least the potential computes exactly the same replay. This proves adequacy without assuming termination or composition.

                                        theorem MindFormal.MarketReplay.replay_stop {A : Type u_1} {N : A → ℕ} {Price : Type u_2} [DecidableEq A] {Ω : Type u_3} [MeasurableSpace Ω] {n : A → ℕ} {T : A → Type u_4} {Λ : A → Type u_5} [(a : A) → Fintype (T a)] [(a : A) → Fintype (Λ a)] {J : Type u_6} [Fintype J] {I : (a : A) → EquationInstance (N a) (n a) (T a) (Λ a) J} {G : EquationGround Ω J} [Fintype A] (stream : HomogeneousGroupWorld I G) (deadline minimum : NNReal) (price : Price → ℝ) (accept : (a : A) → Fin (N a) → Bool) (jump : stream.world.Memory → Bilateral.Ledger A → Phase A N Price → stream.world.Memory × Bilateral.Ledger A × Plan A Price) (m : Memory stream.world.Memory A N Price) (w : J ⊕ stream.world.Private → C(NNReal, ℝ)) (t : NNReal) (h : (a : A) → FiniteActionHistory (Fin (N a))) (ht : t < phaseEnd deadline m.2.2 h) :
                                        replay stream deadline minimum price accept jump m w t h = (stream.advance m.1 w t fun (a : A) => closedHistory (↑t) (h a), m.2.1, observe m.2.2 t fun (a : A) => closedHistory (↑t) (h a))

                                        The replay's equation before the next phase end has no fuel.

                                        noncomputable def MindFormal.MarketReplay.nextMemory {A : Type u_1} {N : A → ℕ} {Price : Type u_2} [DecidableEq A] {Ω : Type u_3} [MeasurableSpace Ω] {n : A → ℕ} {T : A → Type u_4} {Λ : A → Type u_5} [(a : A) → Fintype (T a)] [(a : A) → Fintype (Λ a)] {J : Type u_6} [Fintype J] {I : (a : A) → EquationInstance (N a) (n a) (T a) (Λ a) J} {G : EquationGround Ω J} (stream : HomogeneousGroupWorld I G) (deadline : NNReal) (price : Price → ℝ) (accept : (a : A) → Fin (N a) → Bool) (jump : stream.world.Memory → Bilateral.Ledger A → Phase A N Price → stream.world.Memory × Bilateral.Ledger A × Plan A Price) (m : Memory stream.world.Memory A N Price) (w : J ⊕ stream.world.Private → C(NNReal, ℝ)) (h : (a : A) → FiniteActionHistory (Fin (N a))) :
                                        Memory stream.world.Memory A N Price

                                        The computed post-settlement memory: advance the stream on the closed record, settle the physical ledger, then apply its primitive rule.

                                        Equations
                                        • One or more equations did not get rendered due to their size.
                                        Instances For
                                          theorem MindFormal.MarketReplay.replay_step {A : Type u_1} {N : A → ℕ} {Price : Type u_2} [DecidableEq A] {Ω : Type u_3} [MeasurableSpace Ω] {n : A → ℕ} {T : A → Type u_4} {Λ : A → Type u_5} [(a : A) → Fintype (T a)] [(a : A) → Fintype (Λ a)] {J : Type u_6} [Fintype J] {I : (a : A) → EquationInstance (N a) (n a) (T a) (Λ a) J} {G : EquationGround Ω J} [Fintype A] (stream : HomogeneousGroupWorld I G) (deadline minimum : NNReal) (hd : 0 < deadline) (hm : 0 < minimum) (price : Price → ℝ) (accept : (a : A) → Fin (N a) → Bool) (jump : stream.world.Memory → Bilateral.Ledger A → Phase A N Price → stream.world.Memory × Bilateral.Ledger A × Plan A Price) (hj : ∀ (s : stream.world.Memory) (l : Bilateral.Ledger A) (p : Phase A N Price), PlanValid deadline minimum (jump s l p).2.2) (m : Memory stream.world.Memory A N Price) (hv : PhaseValid deadline minimum m.2.2) (w : J ⊕ stream.world.Private → C(NNReal, ℝ)) (t : NNReal) (h : (a : A) → FiniteActionHistory (Fin (N a))) (hh : ∀ (a : A), ChronologicalHistory (h a)) (ht : phaseEnd deadline m.2.2 h ≤ t) :
                                          replay stream deadline minimum price accept jump m w t h = replay stream deadline minimum price accept jump (nextMemory stream deadline price accept jump m w h) (fun (j : J ⊕ stream.world.Private) => SourceReplay.shifted (phaseEnd deadline m.2.2 h) (w j)) (t - phaseEnd deadline m.2.2 h) fun (a : A) => laterHistory (↑(phaseEnd deadline m.2.2 h)) (h a)

                                          The replay's equation at or after a phase end has no fuel.

                                          theorem MindFormal.MarketReplay.replay_valid {A : Type u_1} {N : A → ℕ} {Price : Type u_2} [DecidableEq A] {Ω : Type u_3} [MeasurableSpace Ω] {n : A → ℕ} {T : A → Type u_4} {Λ : A → Type u_5} [(a : A) → Fintype (T a)] [(a : A) → Fintype (Λ a)] {J : Type u_6} [Fintype J] {I : (a : A) → EquationInstance (N a) (n a) (T a) (Λ a) J} {G : EquationGround Ω J} [Fintype A] (stream : HomogeneousGroupWorld I G) (deadline minimum : NNReal) (hd : 0 < deadline) (hm : 0 < minimum) (price : Price → ℝ) (accept : (a : A) → Fin (N a) → Bool) (jump : stream.world.Memory → Bilateral.Ledger A → Phase A N Price → stream.world.Memory × Bilateral.Ledger A × Plan A Price) (hj : ∀ (s : stream.world.Memory) (l : Bilateral.Ledger A) (p : Phase A N Price), PlanValid deadline minimum (jump s l p).2.2) (m : Memory stream.world.Memory A N Price) (hv : PhaseValid deadline minimum m.2.2) (w : J ⊕ stream.world.Private → C(NNReal, ℝ)) (t : NNReal) (h : (a : A) → FiniteActionHistory (Fin (N a))) :
                                          PhaseValid deadline minimum (replay stream deadline minimum price accept jump m w t h).2.2

                                          The replay's output belongs to the required valid-phase memory type for every record and every source path.

                                          theorem MindFormal.MarketReplay.replay_compose {A : Type u_1} {N : A → ℕ} {Price : Type u_2} [DecidableEq A] {Ω : Type u_3} [MeasurableSpace Ω] {n : A → ℕ} {T : A → Type u_4} {Λ : A → Type u_5} [(a : A) → Fintype (T a)] [(a : A) → Fintype (Λ a)] {J : Type u_6} [Fintype J] {I : (a : A) → EquationInstance (N a) (n a) (T a) (Λ a) J} {G : EquationGround Ω J} [Fintype A] (stream : HomogeneousGroupWorld I G) (deadline minimum : NNReal) (hd : 0 < deadline) (hm : 0 < minimum) (price : Price → ℝ) (accept : (a : A) → Fin (N a) → Bool) (jump : stream.world.Memory → Bilateral.Ledger A → Phase A N Price → stream.world.Memory × Bilateral.Ledger A × Plan A Price) (hj : ∀ (s : stream.world.Memory) (l : Bilateral.Ledger A) (p : Phase A N Price), PlanValid deadline minimum (jump s l p).2.2) (m : Memory stream.world.Memory A N Price) (hv : PhaseValid deadline minimum m.2.2) (w : J ⊕ stream.world.Private → C(NNReal, ℝ)) (c t : NNReal) (past future : (a : A) → FiniteActionHistory (Fin (N a))) (hcut : ∀ (a : A), CutValid (↑c) (past a) (future a)) :
                                          (replay stream deadline minimum price accept jump m w (c + t) fun (a : A) => joinHistory (↑c) (past a) (future a)) = replay stream deadline minimum price accept jump (replay stream deadline minimum price accept jump m w c past) (fun (j : J ⊕ stream.world.Private) => SourceReplay.shifted c (w j)) t future

                                          18.11: the constructed replay composes at every cut-valid cut, including a cut inside an offer or idle phase. All sources are arbitrary; the proof uses the stream's existing law and the proved finite budget.

                                          theorem MindFormal.MarketReplay.replay_zero {A : Type u_1} {N : A → ℕ} {Price : Type u_2} [DecidableEq A] {Ω : Type u_3} [MeasurableSpace Ω] {n : A → ℕ} {T : A → Type u_4} {Λ : A → Type u_5} [(a : A) → Fintype (T a)] [(a : A) → Fintype (Λ a)] {J : Type u_6} [Fintype J] {I : (a : A) → EquationInstance (N a) (n a) (T a) (Λ a) J} {G : EquationGround Ω J} [Fintype A] (stream : HomogeneousGroupWorld I G) (deadline minimum : NNReal) (price : Price → ℝ) (accept : (a : A) → Fin (N a) → Bool) (jump : stream.world.Memory → Bilateral.Ledger A → Phase A N Price → stream.world.Memory × Bilateral.Ledger A × Plan A Price) (m : Memory stream.world.Memory A N Price) (hv : PhaseValid deadline minimum m.2.2) (w : J ⊕ stream.world.Private → C(NNReal, ℝ)) (hw : ∀ (j : J ⊕ stream.world.Private), (w j) 0 = 0) :
                                          (replay stream deadline minimum price accept jump m w 0 fun (a : A) => emptyHistory (Fin (N a))) = m

                                          The replay has the class's zero-time law on valid phases and sources starting at zero. No chronological restriction is needed on the empty record.

                                          theorem MindFormal.MarketReplay.stream_advance_stopped {A : Type u_1} {N : A → ℕ} {Ω : Type u_3} [MeasurableSpace Ω] {n : A → ℕ} {T : A → Type u_4} {Λ : A → Type u_5} [(a : A) → Fintype (T a)] [(a : A) → Fintype (Λ a)] {J : Type u_6} [Fintype J] {I : (a : A) → EquationInstance (N a) (n a) (T a) (Λ a) J} {G : EquationGround Ω J} (stream : HomogeneousGroupWorld I G) (m : stream.world.Memory) (w : J ⊕ stream.world.Private → C(NNReal, ℝ)) (e t : NNReal) (he : e ≤ t) (h : (a : A) → FiniteActionHistory (Fin (N a))) :
                                          stream.advance m (fun (j : J ⊕ stream.world.Private) => SourceReplay.stopped t (w j)) e h = stream.advance m w e h

                                          The stream's existing prefix law also removes a truncation later than the current read. This is an algebraic consequence of that law.

                                          theorem MindFormal.MarketReplay.replayFuel_source_prefix {A : Type u_1} {N : A → ℕ} {Price : Type u_2} [DecidableEq A] {Ω : Type u_3} [MeasurableSpace Ω] {n : A → ℕ} {T : A → Type u_4} {Λ : A → Type u_5} [(a : A) → Fintype (T a)] [(a : A) → Fintype (Λ a)] {J : Type u_6} [Fintype J] {I : (a : A) → EquationInstance (N a) (n a) (T a) (Λ a) J} {G : EquationGround Ω J} (stream : HomogeneousGroupWorld I G) (deadline : NNReal) (price : Price → ℝ) (accept : (a : A) → Fin (N a) → Bool) (jump : stream.world.Memory → Bilateral.Ledger A → Phase A N Price → stream.world.Memory × Bilateral.Ledger A × Plan A Price) (fuel : ℕ) (m : Memory stream.world.Memory A N Price) (w : J ⊕ stream.world.Private → C(NNReal, ℝ)) (t : NNReal) (h : (a : A) → FiniteActionHistory (Fin (N a))) :
                                          replayFuel stream deadline price accept jump fuel m (fun (j : J ⊕ stream.world.Private) => SourceReplay.stopped t (w j)) t h = replayFuel stream deadline price accept jump fuel m w t h

                                          Every fuel level reads only the source prefix up to elapsed time. The recursive shift uses exactly the remaining truncation.

                                          theorem MindFormal.MarketReplay.replay_source_prefix {A : Type u_1} {N : A → ℕ} {Price : Type u_2} [DecidableEq A] {Ω : Type u_3} [MeasurableSpace Ω] {n : A → ℕ} {T : A → Type u_4} {Λ : A → Type u_5} [(a : A) → Fintype (T a)] [(a : A) → Fintype (Λ a)] {J : Type u_6} [Fintype J] {I : (a : A) → EquationInstance (N a) (n a) (T a) (Λ a) J} {G : EquationGround Ω J} [Fintype A] (stream : HomogeneousGroupWorld I G) (deadline minimum : NNReal) (price : Price → ℝ) (accept : (a : A) → Fin (N a) → Bool) (jump : stream.world.Memory → Bilateral.Ledger A → Phase A N Price → stream.world.Memory × Bilateral.Ledger A × Plan A Price) (m : Memory stream.world.Memory A N Price) (w : J ⊕ stream.world.Private → C(NNReal, ℝ)) (t : NNReal) (h : (a : A) → FiniteActionHistory (Fin (N a))) :
                                          replay stream deadline minimum price accept jump m (fun (j : J ⊕ stream.world.Private) => SourceReplay.stopped t (w j)) t h = replay stream deadline minimum price accept jump m w t h

                                          The computed budget reads no source, so the full replay has the class's source-prefix law on every record.

                                          def MindFormal.MarketReplay.CompositionObligation {A : Type u_1} {N : A → ℕ} {Price : Type u_2} [DecidableEq A] {Ω : Type u_3} [MeasurableSpace Ω] {n : A → ℕ} {T : A → Type u_4} {Λ : A → Type u_5} [(a : A) → Fintype (T a)] [(a : A) → Fintype (Λ a)] {J : Type u_6} [Fintype J] {I : (a : A) → EquationInstance (N a) (n a) (T a) (Λ a) J} {G : EquationGround Ω J} [Fintype A] (stream : HomogeneousGroupWorld I G) (deadline minimum : NNReal) (price : Price → ℝ) (accept : (a : A) → Fin (N a) → Bool) (jump : stream.world.Memory → Bilateral.Ledger A → Phase A N Price → stream.world.Memory × Bilateral.Ledger A × Plan A Price) :

                                          18.11: the exact composition obligation for the computed replay. All antecedents are primitive positive lengths, valid next plans, ordinary phase memories and the class's cut-valid input records. It is proved by compositionObligation, never supplied as a construction hypothesis.

                                          Equations
                                          • One or more equations did not get rendered due to their size.
                                          Instances For
                                            theorem MindFormal.MarketReplay.compositionObligation {A : Type u_1} {N : A → ℕ} {Price : Type u_2} [DecidableEq A] {Ω : Type u_3} [MeasurableSpace Ω] {n : A → ℕ} {T : A → Type u_4} {Λ : A → Type u_5} [(a : A) → Fintype (T a)] [(a : A) → Fintype (Λ a)] {J : Type u_6} [Fintype J] {I : (a : A) → EquationInstance (N a) (n a) (T a) (Λ a) J} {G : EquationGround Ω J} [Fintype A] (stream : HomogeneousGroupWorld I G) (deadline minimum : NNReal) (price : Price → ℝ) (accept : (a : A) → Fin (N a) → Bool) (jump : stream.world.Memory → Bilateral.Ledger A → Phase A N Price → stream.world.Memory × Bilateral.Ledger A × Plan A Price) :
                                            CompositionObligation stream deadline minimum price accept jump

                                            18.11: L24b's exact composition obligation, with only L24c's permitted idle upper bound, follows from the constructed replay's proved equations.