Typed endpoint-control predicates and four-state examples
DefinitionAPFReachKernel_TypedDoorsapfconditional-referencereachkernel
The bare typed use signature supports admitted responses, endpoint readouts, maintenance, joint control, outcome agreement and score predicates. Two supplied four-state examples provide contrasting controls. They are instances of the displayed signature, not certificates of UseLaws or the complete original foundation. UK1Extends is a supplied endpoint encoding; endpoint agreement does not construct a physical record.
Definition code
import Definitions.Def_APFReachKernel_Foundation
import Definitions.Def_APFReachKernel_Typed
namespace ReachKernel.TypedDoors
end ReachKernel.TypedDoors
/-
ReachKernel/TypedDoors.lean
Conditional endpoint-control, outcome-agreement and score predicates
on the bare typed use signature. Cl4 and Cx4 instantiate that signature;
they do not instantiate original Account/Admission/SourceB06, full A2/BW,
or even UseLaws here. No full-foundation consistency or minimality follows.
Cx4 permits each named readout to be controlled at some value, but that
is distinct from B02Maintains at every attained value. UEndpointRegister
means agreement across outcomes, not a physical register. UK1Extends is a
proposed endpoint encoding, not the source Paper5 ordered-score condition.
-/
set_option autoImplicit false
namespace ReachKernel.TypedDoors
open Typed
section General
variable {Γ : Type} {Raw Proc : Γ → Type}
variable (T : Typing Γ Proc) (U : UseRelation T Raw)
/-- A distinction defined in every context (a tested task family). -/
def UDist : Type := ∀ δ, PhysicalState (UCont T U δ) → Bool
/-- The context-indexed endpoint of a use (C15's `boundaryState`). -/
def endpoint {γ : Γ} (p : Proc γ) (b : Raw (T.out γ p)) :
Σ δ, PhysicalState (UCont T U δ) :=
⟨T.out γ p, physicalClass (UCont T U (T.out γ p)) b⟩
def dAt (d : UDist T U) (y : Σ δ, PhysicalState (UCont T U δ)) : Bool := d y.1 y.2
/-! ### Door 1 on (T, U) -/
/-- Regulation into the fibre of `d` over `b`, on the arm's relation. -/
def UMaintains (γ : Γ) (ρ : Raw γ → Proc γ) (Ch : List (Raw γ)) (d : UDist T U) (b : Bool) : Prop :=
∀ x ∈ Ch, ∀ b', U γ (ρ x) x b' → dAt T U d (endpoint T U (ρ x) b') = b
def UAdmitted (γ : Γ) (ρ : Raw γ → Proc γ) (Ch : List (Raw γ)) : Prop :=
∀ x ∈ Ch, ρ x ∈ UCont T U γ x
def UJointlyMaintainable (γ : Γ) (Ch : List (Raw γ)) (d d' : UDist T U) (b b' : Bool) : Prop :=
∃ ρ : Raw γ → Proc γ, UAdmitted T U γ ρ Ch ∧ UMaintains T U γ ρ Ch d b ∧ UMaintains T U γ ρ Ch d' b'
def UComplementary (γ : Γ) (Ch : List (Raw γ)) (d d' : UDist T U) : Prop :=
(∃ b ρ, UAdmitted T U γ ρ Ch ∧ UMaintains T U γ ρ Ch d b) ∧
(∃ b' ρ, UAdmitted T U γ ρ Ch ∧ UMaintains T U γ ρ Ch d' b') ∧
∀ b b', ¬ UJointlyMaintainable T U γ Ch d d' b b'
def USingleTarget (γ : Γ) (ρ : Raw γ → Proc γ) (Ch : List (Raw γ))
(y₀ : Σ δ, PhysicalState (UCont T U δ)) : Prop :=
∀ x ∈ Ch, ∀ b', U γ (ρ x) x b' → endpoint T U (ρ x) b' = y₀
/-! ### Door 2 on (T, U) -/
def UValueDefinite (γ : Γ) (p : Proc γ) (x : Raw γ) (d : UDist T U) : Prop :=
∃ v, ∀ b, U γ p x b → dAt T U d (endpoint T U p b) = v
/-- Single-valued results: lane B's `IsOriginalResult` is a function of (p, x). -/
def UDeterministic : Prop :=
∀ γ (p : Proc γ) (x : Raw γ) b b', U γ p x b → U γ p x b' →
physicalClass (UCont T U (T.out γ p)) b = physicalClass (UCont T U (T.out γ p)) b'
/-- Outcome agreement on the typed use relation, not a physical endpoint-register supplier. -/
def UEndpointRegister (γ : Γ) (ρ : Raw γ → Proc γ) (Ch : List (Raw γ)) (Δ : List (UDist T U)) : Prop :=
∀ x ∈ Ch, ∀ d ∈ Δ, UValueDefinite T U γ (ρ x) x d
/-! ### Door 3 on (T, U) -/
/-- A reach pair of the arm's relation: a use with its boundary. -/
structure UPair where
γ : Γ
p : Proc γ
x : Raw γ
b : Raw (T.out γ p)
use : U γ p x b
def UPair.endpoint (q : UPair T U) : Σ δ, PhysicalState (UCont T U δ) :=
TypedDoors.endpoint T U q.p q.b
def UScore (D V : Type) : Type := D → UPair T U → V
def UClassScore {D V : Type} (s : UScore T U D V) : Prop :=
∃ f : D → (Σ δ, PhysicalState (UCont T U δ)) → V, ∀ d q, s d q = f d q.endpoint
def UContextual {D V : Type} (s : UScore T U D V) : Prop :=
∃ (d : D) (q q' : UPair T U), q.endpoint = q'.endpoint ∧ s d q ≠ s d q'
/-- The proposed endpoint Boolean encoding on typed pairs, not the Paper5 ordered-score condition. -/
def UK1Extends {D V : Type} [LT V] (t : D → UDist T U) (s : UScore T U D V) : Prop :=
∃ ι : Bool → V, ι false < ι true ∧ ∀ d q, s d q = ι (dAt T U (t d) q.endpoint)
end General
/-! ### Two instances of the same signature -/
/-- Four raw states. -/
inductive S4 | s0 | s1 | s2 | s3
deriving DecidableEq, Repr
open S4
/-- d: "in {s0, s1}"; d': "in {s0, s2}". -/
def dRaw : S4 → Bool | s0 => true | s1 => true | _ => false
def dRaw' : S4 → Bool | s0 => true | s2 => true | _ => false
section Cx4
/-- Processes: `Pd` pins d (ends at s0 or s1), `Pd'` pins d' (ends at s0 or
s2), `At s` is available only at s and ends there (it makes B01 separate the
four states, as SpinControl's start tag does). -/
inductive P | Pd | Pd' | At (s : S4)
deriving DecidableEq
open P
def T : Typing Unit (fun _ => P) := ⟨fun _ _ => ()⟩
def U : UseRelation (Raw := fun _ => S4) T := fun _ p x b =>
match p with
| Pd => b = s0 ∨ b = s1
| Pd' => b = s0 ∨ b = s2
| At s => x = s ∧ b = s
instance (γ : Unit) (p : P) (x b : S4) : Decidable (U γ p x b) := by
cases p <;> simp only [U] <;> infer_instance
/-- B01 separates the four states: `At x` is available exactly at x. -/
theorem ucont_inj (x y : S4) (h : UCont T U () x = UCont T U () y) : x = y := by
have hx : At x ∈ UCont T U () x := ⟨x, rfl, rfl⟩
rw [h] at hx
obtain ⟨_, hy, _⟩ := hx
exact hy.symm
def liftD (f : S4 → Bool) : UDist T U := fun _ =>
Quotient.lift f (fun a b (h : UCont T U () a = UCont T U () b) => by rw [ucont_inj a b h])
def d : UDist T U := liftD dRaw
def d' : UDist T U := liftD dRaw'
def Ch : List S4 := [s0, s1, s2, s3]
end Cx4
section Cl4
/-- The classical instance: `Go s` pins the destination to s from anywhere,
`At s` as before. -/
inductive P' | Go (s : S4) | At (s : S4)
deriving DecidableEq
open P'
def T' : Typing Unit (fun _ => P') := ⟨fun _ _ => ()⟩
def U' : UseRelation (Raw := fun _ => S4) T' := fun _ p x b =>
match p with
| Go s => b = s
| At s => x = s ∧ b = s
theorem ucont_inj' (x y : S4) (h : UCont T' U' () x = UCont T' U' () y) : x = y := by
have hx : At x ∈ UCont T' U' () x := ⟨x, rfl, rfl⟩
rw [h] at hx
obtain ⟨_, hy, _⟩ := hx
exact hy.symm
def liftD' (f : S4 → Bool) : UDist T' U' := fun _ =>
Quotient.lift f (fun a b (h : UCont T' U' () a = UCont T' U' () b) => by rw [ucont_inj' a b h])
end Cl4
end ReachKernel.TypedDoors
Source
APF ReachKernel; original archive f05a126714fe8d24a4377f87a7e460777555e19227087abb6c18dbe2ffae959e, ReachKernel/TypedDoors.lean; corrected compatible source manifest 2c8ccc43b416ba6e4f1b9eb02d4780b828e8dab689651eb567f7d159065cdfd2. Private conditional/reference model.