Exact contextual observations determine the enriched action
ProvedAPFObservedProcess.contextual_actionTwo same-typed descriptions agree on admission and every observation in all before-and-after contexts exactly when their enriched partial actions agree, including domains. This comparison is a strong two-sided congruence and preserves support.
Generic mathematics under the displayed hypotheses; this does not supply a physical source or observation family.
Evidence: the papers supply the original resource and continuation meanings; existing code supplies the explicit source interfaces; independent Lean checking covers these exact exports; recursive physical-premise closure is accepted for the original-source applications only.
This is the native whole-ledger component of history comparison at the stated source and input. It does not establish all-input or full physical-profile equivalence, universal accounting of composites, observed readout, physical transport completion, or quantum structure.
import Definitions.Def_APFObservedComparison
set_option autoImplicit false
namespace APFObservedProcess
open APFTypedHistory
open APFObservedHistory
universe u v w
variable {N : Type u} {E : N → N → Type v} {V : Type w} {a b c d : N}
variable {L : Language E a} {B : Observation E V a}
theorem context_to_action {p q : Path E b c} (he : ContextEq L B p q) : Action L B p = Action L B q := by
have forward : ∀ {p q : Path E b c}, ContextEq L B p q →
∀ s t, Action L B p s t → Action L B q s t := by
intro p q he s t hs
obtain ⟨h,_,hh⟩ := s.property
constructor
· have hp := hs.1
rw [hh] at hp
have e := (he h c (.nil c)).1
simp only [Path.append_nil] at e
change s.val.1 c q
rw [hh]
exact e.mp hp
· rw [hs.2]
apply Prod.ext
· funext d r; apply propext
simpa only [APFObservedHistory.residual,hh,Path.append_assoc] using (he h d r).1
· funext d r t; apply propext
simpa only [APFObservedHistory.residual,hh,Path.append_assoc] using (he h d r).2 t
funext s t
exact propext ⟨forward he s t,forward (fun h d r => ⟨(he h d r).1.symm,fun t => ((he h d r).2 t).symm⟩) s t⟩
theorem action_recovery (hc : PrefixClosed L) {p q : Path E b c}
(he : Action L B p = Action L B q) (h : Path E a b) (r : Path E c d)
(hp : L d (Path.append (Path.append h p) r)) :
APFObservedHistory.residual (L,B) (Path.append h p) = APFObservedHistory.residual (L,B) (Path.append h q) := by
have hp' := hc c d (Path.append h p) r hp
have hh := hc b c h p hp'
let s := APFObservedHistory.stateOf L B h hh
let t := APFObservedHistory.stateOf L B (Path.append h p) hp'
have st : Action L B p s t := ⟨hp',(APFObservedHistory.residual_append (L,B) h p).symm⟩
have sq : Action L B q s t := by rw [←he];exact st
simpa only [s,t,APFObservedHistory.stateOf,APFObservedHistory.residual_append] using sq.2
theorem action_to_context (hc : PrefixClosed L) (hb : Compatible L B) {p q : Path E b c}
(he : Action L B p = Action L B q) : ContextEq L B p q := by
have fL : ∀ {p q : Path E b c}, Action L B p = Action L B q → ∀ h d (r : Path E c d),
L d (Path.append (Path.append h p) r) → L d (Path.append (Path.append h q) r) := by
intro p q he h d r hp
exact Eq.mp (congrArg (fun K : View E V c => K.1 d r) (action_recovery hc he h r hp)) hp
have fB : ∀ {p q : Path E b c}, Action L B p = Action L B q → ∀ h d (r : Path E c d) t,
B d (Path.append (Path.append h p) r) t → B d (Path.append (Path.append h q) r) t := by
intro p q he h d r t hp
exact Eq.mp (congrArg (fun K : View E V c => K.2 d r t)
(action_recovery hc he h r (hb d _ t hp))) hp
intro h d r
exact ⟨⟨fL he h d r,fL he.symm h d r⟩,fun t => ⟨fB he h d r t,fB he.symm h d r t⟩⟩
theorem contextual_action_iff (hc : PrefixClosed L) (hb : Compatible L B) (p q : Path E b c) :
ContextEq L B p q ↔ Action L B p = Action L B q := ⟨context_to_action,action_to_context hc hb⟩
theorem context_insert {e : N} {p q : Path E b c} (l : Path E d b) (r : Path E c e)
(he : ContextEq L B p q) : ContextEq L B (Path.append (Path.append l p) r) (Path.append (Path.append l q) r) := by
intro h f s
simpa only [Path.append_assoc] using he (Path.append h l) f (Path.append r s)
theorem supported_iff (hc : PrefixClosed L) (p : Path E b c) :
Supported L B p ↔ ∃ h : Path E a b, L c (Path.append h p) := by
constructor
· rintro ⟨s,t,hs⟩;obtain ⟨h,_,hh⟩ := s.property
exact ⟨h,by simpa only [hh,APFObservedHistory.residual] using hs.1⟩
· rintro ⟨h,hp⟩
have hh := hc b c h p hp
exact ⟨APFObservedHistory.stateOf L B h hh,APFObservedHistory.stateOf L B (Path.append h p) hp,
hp,(APFObservedHistory.residual_append (L,B) h p).symm⟩
theorem supported_respects {p q : Path E b c} (he : ContextEq L B p q) : Supported L B p ↔ Supported L B q := by
change (∃s t, Action L B p s t) ↔ (∃s t,Action L B q s t)
rw [context_to_action he]
theorem context_append {p p' : Path E b c} {q q' : Path E c d}
(hp : ContextEq L B p p') (hq : ContextEq L B q q') :
ContextEq L B (Path.append p q) (Path.append p' q') := by
intro h e r
have x := hp h e (Path.append q r)
have y := hq (Path.append h p') e r
simp only [Path.append_assoc] at x y ⊢
exact ⟨x.1.trans y.1,fun t => (x.2 t).trans (y.2 t)⟩
end APFObservedProcess
open APFTypedHistory APFObservedHistory APFObservedProcess
universe u v w
variable {N : Type u} {E : N → N → Type v} {V : Type w} {a : N}
theorem APFObservedProcess.contextual_action (L : Language E a) (B : Observation E V a)
(hc : PrefixClosed L) (hb : Compatible L B) : ComparisonLaws L B := by
sorry