Inversion of runtime typing for replication to Adding a restriction around nil preserves runtime typing
TheoremInversion of runtime typing for replication#✓fully proved
General replica inversion retains completed/scoped/separated AMBIENT annotations and the structurally guarded BODY typed at EXACT EMPTY ownership.
theorem HasType.repl_inv {n : Nat} {Γ : ServiceEnv} {Δ : Context} {p : Proc}
(h : HasType n Γ Δ (.repl p)) :
Δ.Completed ∧ (∀ e ∈ Δ, e.name.ClosedAt n) ∧ Separated Γ Δ ∧
ServiceTemplate Γ p ∧ HasType n Γ ∅ p
abbrev ServiceEnv := Finmap (fun _ : Nat => ServiceSignature)
CSLibExt/Languages/SessionTypes/Endpoint/SharedEnvironment.lean:33
abbrev Context := Finmap (fun _ : Key => Capability)
CSLibExt/Languages/SessionTypes/Endpoint/Context.lean:32
inductive Proc where
| nil : Proc
| out (a b : Name) (p : Proc) : Proc
| inp (a : Name) (p : Proc) : Proc
| par (p q : Proc) : Proc
| nu (p : Proc) : Proc
| repl (p : Proc) : Proc
| sum (p q : Proc) : Proc
deriving DecidableEq, Repr
CSLibExt/Languages/PiCalculus/Basic.lean:52
inductive HasType : Nat → ServiceEnv → Context → Proc → Prop where
| nil {n : Nat} {Γ : ServiceEnv} {Δ : Context} :
Δ.Completed → (∀ e ∈ Δ, e.name.ClosedAt n) → Separated Γ Δ → HasType n Γ Δ .nil
| outName {n : Nat} {Γ : ServiceEnv} {Δ : Context} {e : Key} {c : Capability}
{b : Name} {s : Protocol} {p : Proc} :
GuardMin Δ e c.rank → Separated Γ Δ → Δ.lookup e = some c →
c.protocol.unfold = .sendName s → e.name.ClosedAt n → b.ClosedAt n →
HasType n Γ (Δ.insert e ⟨c.rank, s⟩) p → HasType n Γ Δ (.out e.name b p)
| inpName {n : Nat} {Γ : ServiceEnv} {Δ : Context} {e : Key} {c : Capability}
{s : Protocol} {p : Proc} :
GuardMin Δ e c.rank → Separated Γ Δ → Δ.lookup e = some c →
c.protocol.unfold = .recvName s → e.name.ClosedAt n →
⋯
CSLibExt/Languages/SessionTypes/Endpoint/SharedServices.lean:32
def Separated (Γ : ServiceEnv) (Δ : Context) : Prop :=
∀ e c, Δ.lookup e = some c → ∀ s sig, Γ.lookup s = some sig → e.name ≠ .const s
CSLibExt/Languages/SessionTypes/Endpoint/SharedEnvironment.lean:36
def ServiceTemplate (Γ : ServiceEnv) : Proc → Prop
| .nil => True
| .inp a _ => ∃ s, a = .const s ∧ s ∈ Γ
| .par p q => ServiceTemplate Γ p ∧ ServiceTemplate Γ q
| .nu p | .repl p => ServiceTemplate Γ p
| .out .. | .sum .. => False
CSLibExt/Languages/SessionTypes/Endpoint/ServiceTemplates.lean:29
Uses 20 · Used by 1
TheoremInversion of runtime typing for a replicated shared input#✓fully proved
A literal input template exposes its declared signature and fresh received BODY; completed ambient annotations are NOT inherited by that BODY.
theorem HasType.service_inv {n : Nat} {Γ : ServiceEnv} {Δ : Context} {s : Nat} {p : Proc}
(h : HasType n Γ Δ (.repl (.inp (.const s) p))) :
∃ sig, Δ.Completed ∧ Γ.lookup s = some sig ∧
HasType (n + 1) Γ (Finmap.singleton ⟨.var 0, sig.role⟩ sig.capability) p
abbrev ServiceEnv := Finmap (fun _ : Nat => ServiceSignature)
CSLibExt/Languages/SessionTypes/Endpoint/SharedEnvironment.lean:33
abbrev Context := Finmap (fun _ : Key => Capability)
CSLibExt/Languages/SessionTypes/Endpoint/Context.lean:32
inductive Proc where
| nil : Proc
| out (a b : Name) (p : Proc) : Proc
| inp (a : Name) (p : Proc) : Proc
| par (p q : Proc) : Proc
| nu (p : Proc) : Proc
| repl (p : Proc) : Proc
| sum (p q : Proc) : Proc
deriving DecidableEq, Repr
CSLibExt/Languages/PiCalculus/Basic.lean:52
inductive HasType : Nat → ServiceEnv → Context → Proc → Prop where
| nil {n : Nat} {Γ : ServiceEnv} {Δ : Context} :
Δ.Completed → (∀ e ∈ Δ, e.name.ClosedAt n) → Separated Γ Δ → HasType n Γ Δ .nil
| outName {n : Nat} {Γ : ServiceEnv} {Δ : Context} {e : Key} {c : Capability}
{b : Name} {s : Protocol} {p : Proc} :
GuardMin Δ e c.rank → Separated Γ Δ → Δ.lookup e = some c →
c.protocol.unfold = .sendName s → e.name.ClosedAt n → b.ClosedAt n →
HasType n Γ (Δ.insert e ⟨c.rank, s⟩) p → HasType n Γ Δ (.out e.name b p)
| inpName {n : Nat} {Γ : ServiceEnv} {Δ : Context} {e : Key} {c : Capability}
{s : Protocol} {p : Proc} :
GuardMin Δ e c.rank → Separated Γ Δ → Δ.lookup e = some c →
c.protocol.unfold = .recvName s → e.name.ClosedAt n →
⋯
CSLibExt/Languages/SessionTypes/Endpoint/SharedServices.lean:32
Uses 16 · Used by 1
TheoremTyped replicated shared inputs are offered services#✓fully proved
Typing-derived actual literal-input offering survives completed ambient annotations.
theorem HasType.service_offered {n : Nat} {Γ : ServiceEnv} {Δ : Context} {s : Nat} {p : Proc}
(h : HasType n Γ Δ (.repl (.inp (.const s) p))) :
∃ sig, Offered Γ (.repl (.inp (.const s) p)) s sig
abbrev ServiceEnv := Finmap (fun _ : Nat => ServiceSignature)
CSLibExt/Languages/SessionTypes/Endpoint/SharedEnvironment.lean:33
abbrev Context := Finmap (fun _ : Key => Capability)
CSLibExt/Languages/SessionTypes/Endpoint/Context.lean:32
inductive Proc where
| nil : Proc
| out (a b : Name) (p : Proc) : Proc
| inp (a : Name) (p : Proc) : Proc
| par (p q : Proc) : Proc
| nu (p : Proc) : Proc
| repl (p : Proc) : Proc
| sum (p q : Proc) : Proc
deriving DecidableEq, Repr
CSLibExt/Languages/PiCalculus/Basic.lean:52
inductive HasType : Nat → ServiceEnv → Context → Proc → Prop where
| nil {n : Nat} {Γ : ServiceEnv} {Δ : Context} :
Δ.Completed → (∀ e ∈ Δ, e.name.ClosedAt n) → Separated Γ Δ → HasType n Γ Δ .nil
| outName {n : Nat} {Γ : ServiceEnv} {Δ : Context} {e : Key} {c : Capability}
{b : Name} {s : Protocol} {p : Proc} :
GuardMin Δ e c.rank → Separated Γ Δ → Δ.lookup e = some c →
c.protocol.unfold = .sendName s → e.name.ClosedAt n → b.ClosedAt n →
HasType n Γ (Δ.insert e ⟨c.rank, s⟩) p → HasType n Γ Δ (.out e.name b p)
| inpName {n : Nat} {Γ : ServiceEnv} {Δ : Context} {e : Key} {c : Capability}
{s : Protocol} {p : Proc} :
GuardMin Δ e c.rank → Separated Γ Δ → Δ.lookup e = some c →
c.protocol.unfold = .recvName s → e.name.ClosedAt n →
⋯
CSLibExt/Languages/SessionTypes/Endpoint/SharedServices.lean:32
def Offered (Γ : ServiceEnv) (p : Proc) (s : Nat) (sig : ServiceSignature) : Prop :=
Γ.lookup s = some sig ∧ OfferedIn s p
CSLibExt/Languages/SessionTypes/Endpoint/ServiceTemplates.lean:131
TheoremInserting a completed entry preserves invocation priority#✓fully proved
A completed frame is ignored by shared priority, with NO active-payload exemption.
theorem InvocationPriority.insert_completed {sig : ServiceSignature} {Δ : Context}
(h : InvocationPriority sig Δ) {z : Key} {u : Capability} (hu : u.protocol.unfold = .done) :
InvocationPriority sig (Δ.insert z u)
structure ServiceSignature where
priority : Nat
role : Role
capability : Capability
CSLibExt/Languages/SessionTypes/Endpoint/SharedEnvironment.lean:27
abbrev Context := Finmap (fun _ : Key => Capability)
CSLibExt/Languages/SessionTypes/Endpoint/Context.lean:32
def InvocationPriority (sig : ServiceSignature) (Δ : Context) : Prop :=
∀ e c, Δ.lookup e = some c → c.protocol.unfold ≠ .done → sig.priority < c.rank
CSLibExt/Languages/SessionTypes/Endpoint/SharedEnvironment.lean:40
structure Key where
name : PiCalculus.Name
role : Role
deriving DecidableEq, Repr
CSLibExt/Languages/SessionTypes/Endpoint/Identity.lean:30
structure Capability where
rank : Nat
protocol : Protocol
CSLibExt/Languages/SessionTypes/Endpoint/Context.lean:27
Uses 9 · Used by 1
TheoremWeakening runtime typing by one fresh completed entry#✓fully proved
ALL10 rules admit a fresh COMPLETED ambient annotation. Its name is scoped and nonshared; accept/serve BODY ownership is unchanged, never captured.
theorem HasType.weaken_completed {n : Nat} {Γ : ServiceEnv} {Δ : Context} {p : Proc}
(h : HasType n Γ Δ p) {z : Key} {u : Capability} (hz : z ∉ Δ)
(hu : u.protocol.unfold = .done) (hscope : z.name.ClosedAt n)
(hshared : ∀ s sig, Γ.lookup s = some sig → z.name ≠ .const s) :
HasType n Γ (Δ.insert z u) p
abbrev ServiceEnv := Finmap (fun _ : Nat => ServiceSignature)
CSLibExt/Languages/SessionTypes/Endpoint/SharedEnvironment.lean:33
abbrev Context := Finmap (fun _ : Key => Capability)
CSLibExt/Languages/SessionTypes/Endpoint/Context.lean:32
inductive Proc where
| nil : Proc
| out (a b : Name) (p : Proc) : Proc
| inp (a : Name) (p : Proc) : Proc
| par (p q : Proc) : Proc
| nu (p : Proc) : Proc
| repl (p : Proc) : Proc
| sum (p q : Proc) : Proc
deriving DecidableEq, Repr
CSLibExt/Languages/PiCalculus/Basic.lean:52
inductive HasType : Nat → ServiceEnv → Context → Proc → Prop where
| nil {n : Nat} {Γ : ServiceEnv} {Δ : Context} :
Δ.Completed → (∀ e ∈ Δ, e.name.ClosedAt n) → Separated Γ Δ → HasType n Γ Δ .nil
| outName {n : Nat} {Γ : ServiceEnv} {Δ : Context} {e : Key} {c : Capability}
{b : Name} {s : Protocol} {p : Proc} :
GuardMin Δ e c.rank → Separated Γ Δ → Δ.lookup e = some c →
c.protocol.unfold = .sendName s → e.name.ClosedAt n → b.ClosedAt n →
HasType n Γ (Δ.insert e ⟨c.rank, s⟩) p → HasType n Γ Δ (.out e.name b p)
| inpName {n : Nat} {Γ : ServiceEnv} {Δ : Context} {e : Key} {c : Capability}
{s : Protocol} {p : Proc} :
GuardMin Δ e c.rank → Separated Γ Δ → Δ.lookup e = some c →
c.protocol.unfold = .recvName s → e.name.ClosedAt n →
⋯
CSLibExt/Languages/SessionTypes/Endpoint/SharedServices.lean:32
structure Key where
name : PiCalculus.Name
role : Role
deriving DecidableEq, Repr
CSLibExt/Languages/SessionTypes/Endpoint/Identity.lean:30
structure Capability where
rank : Nat
protocol : Protocol
CSLibExt/Languages/SessionTypes/Endpoint/Context.lean:27
Uses 36 · Used by 2
TheoremWeakening runtime typing by a disjoint completed context#✓fully proved
A disjoint completed/scoped/nonshared finite ambient frame can be reattached. The actual replica/accept BODY is not expanded by those annotations.
theorem HasType.weaken_completed_union {n : Nat} {Γ : ServiceEnv} {Δ Θ : Context} {p : Proc}
(h : HasType n Γ Δ p) (hd : Finmap.Disjoint Δ Θ) (hc : Θ.Completed)
(hs : ∀ e ∈ Θ, e.name.ClosedAt n) (hsep : Separated Γ Θ) : HasType n Γ (Δ ∪ Θ) p
abbrev ServiceEnv := Finmap (fun _ : Nat => ServiceSignature)
CSLibExt/Languages/SessionTypes/Endpoint/SharedEnvironment.lean:33
abbrev Context := Finmap (fun _ : Key => Capability)
CSLibExt/Languages/SessionTypes/Endpoint/Context.lean:32
inductive Proc where
| nil : Proc
| out (a b : Name) (p : Proc) : Proc
| inp (a : Name) (p : Proc) : Proc
| par (p q : Proc) : Proc
| nu (p : Proc) : Proc
| repl (p : Proc) : Proc
| sum (p q : Proc) : Proc
deriving DecidableEq, Repr
CSLibExt/Languages/PiCalculus/Basic.lean:52
inductive HasType : Nat → ServiceEnv → Context → Proc → Prop where
| nil {n : Nat} {Γ : ServiceEnv} {Δ : Context} :
Δ.Completed → (∀ e ∈ Δ, e.name.ClosedAt n) → Separated Γ Δ → HasType n Γ Δ .nil
| outName {n : Nat} {Γ : ServiceEnv} {Δ : Context} {e : Key} {c : Capability}
{b : Name} {s : Protocol} {p : Proc} :
GuardMin Δ e c.rank → Separated Γ Δ → Δ.lookup e = some c →
c.protocol.unfold = .sendName s → e.name.ClosedAt n → b.ClosedAt n →
HasType n Γ (Δ.insert e ⟨c.rank, s⟩) p → HasType n Γ Δ (.out e.name b p)
| inpName {n : Nat} {Γ : ServiceEnv} {Δ : Context} {e : Key} {c : Capability}
{s : Protocol} {p : Proc} :
GuardMin Δ e c.rank → Separated Γ Δ → Δ.lookup e = some c →
c.protocol.unfold = .recvName s → e.name.ClosedAt n →
⋯
CSLibExt/Languages/SessionTypes/Endpoint/SharedServices.lean:32
def Separated (Γ : ServiceEnv) (Δ : Context) : Prop :=
∀ e c, Δ.lookup e = some c → ∀ s sig, Γ.lookup s = some sig → e.name ≠ .const s
CSLibExt/Languages/SessionTypes/Endpoint/SharedEnvironment.lean:36
Uses 17 · Used by 2
TheoremErasing an owned key preserves invocation priority#✓fully proved
Removing an owned key preserves the shared priority inequalities on the remainder.
theorem InvocationPriority.erase {sig : ServiceSignature} {Δ : Context}
(h : InvocationPriority sig Δ) (z : Key) : InvocationPriority sig (Δ.erase z)
structure ServiceSignature where
priority : Nat
role : Role
capability : Capability
CSLibExt/Languages/SessionTypes/Endpoint/SharedEnvironment.lean:27
abbrev Context := Finmap (fun _ : Key => Capability)
CSLibExt/Languages/SessionTypes/Endpoint/Context.lean:32
def InvocationPriority (sig : ServiceSignature) (Δ : Context) : Prop :=
∀ e c, Δ.lookup e = some c → c.protocol.unfold ≠ .done → sig.priority < c.rank
CSLibExt/Languages/SessionTypes/Endpoint/SharedEnvironment.lean:40
structure Key where
name : PiCalculus.Name
role : Role
deriving DecidableEq, Repr
CSLibExt/Languages/SessionTypes/Endpoint/Identity.lean:30
TheoremOwned names absent from a runtime process are completed#✓fully proved
An owned name absent from ALL subject/payload/binder-adjusted positions already has an actual done unfolding, including in the shared runtime rules.
theorem HasType.absent_lookup_completed {n : Nat} {Γ : ServiceEnv} {Δ : Context} {p : Proc}
(h : HasType n Γ Δ p) {z : Key} {t : Capability}
(hz : Δ.lookup z = some t) (hab : NameAbsent z.name p) : t.protocol.unfold = .done
abbrev ServiceEnv := Finmap (fun _ : Nat => ServiceSignature)
CSLibExt/Languages/SessionTypes/Endpoint/SharedEnvironment.lean:33
abbrev Context := Finmap (fun _ : Key => Capability)
CSLibExt/Languages/SessionTypes/Endpoint/Context.lean:32
inductive Proc where
| nil : Proc
| out (a b : Name) (p : Proc) : Proc
| inp (a : Name) (p : Proc) : Proc
| par (p q : Proc) : Proc
| nu (p : Proc) : Proc
| repl (p : Proc) : Proc
| sum (p q : Proc) : Proc
deriving DecidableEq, Repr
CSLibExt/Languages/PiCalculus/Basic.lean:52
inductive HasType : Nat → ServiceEnv → Context → Proc → Prop where
| nil {n : Nat} {Γ : ServiceEnv} {Δ : Context} :
Δ.Completed → (∀ e ∈ Δ, e.name.ClosedAt n) → Separated Γ Δ → HasType n Γ Δ .nil
| outName {n : Nat} {Γ : ServiceEnv} {Δ : Context} {e : Key} {c : Capability}
{b : Name} {s : Protocol} {p : Proc} :
GuardMin Δ e c.rank → Separated Γ Δ → Δ.lookup e = some c →
c.protocol.unfold = .sendName s → e.name.ClosedAt n → b.ClosedAt n →
HasType n Γ (Δ.insert e ⟨c.rank, s⟩) p → HasType n Γ Δ (.out e.name b p)
| inpName {n : Nat} {Γ : ServiceEnv} {Δ : Context} {e : Key} {c : Capability}
{s : Protocol} {p : Proc} :
GuardMin Δ e c.rank → Separated Γ Δ → Δ.lookup e = some c →
c.protocol.unfold = .recvName s → e.name.ClosedAt n →
⋯
CSLibExt/Languages/SessionTypes/Endpoint/SharedServices.lean:32
structure Key where
name : PiCalculus.Name
role : Role
deriving DecidableEq, Repr
CSLibExt/Languages/SessionTypes/Endpoint/Identity.lean:30
structure Capability where
rank : Nat
protocol : Protocol
CSLibExt/Languages/SessionTypes/Endpoint/Context.lean:27
def NameAbsent (a : Name) : Proc → Prop
| .nil => True
| .out b c p => a ≠ b ∧ a ≠ c ∧ NameAbsent a p
| .inp b p => a ≠ b ∧ NameAbsent (liftName 0 a) p
| .par p q | .sum p q => NameAbsent a p ∧ NameAbsent a q
| .nu p => NameAbsent (liftName 0 a) p
| .repl p => NameAbsent a p
CSLibExt/Languages/SessionTypes/Endpoint/NameAbsence.lean:29
Uses 26 · Used by 1
TheoremErasing a key whose name is absent preserves runtime typing#✓fully proved
ALL10 runtime rules support erasure only under real all-position absence. Accept/serve ambient erasure does NOT alter their exact fresh/empty BODY domains.
theorem HasType.erase_nameAbsent {n : Nat} {Γ : ServiceEnv} {Δ : Context} {p : Proc}
(h : HasType n Γ Δ p) {z : Key} (hab : NameAbsent z.name p) :
HasType n Γ (Δ.erase z) p
abbrev ServiceEnv := Finmap (fun _ : Nat => ServiceSignature)
CSLibExt/Languages/SessionTypes/Endpoint/SharedEnvironment.lean:33
abbrev Context := Finmap (fun _ : Key => Capability)
CSLibExt/Languages/SessionTypes/Endpoint/Context.lean:32
inductive Proc where
| nil : Proc
| out (a b : Name) (p : Proc) : Proc
| inp (a : Name) (p : Proc) : Proc
| par (p q : Proc) : Proc
| nu (p : Proc) : Proc
| repl (p : Proc) : Proc
| sum (p q : Proc) : Proc
deriving DecidableEq, Repr
CSLibExt/Languages/PiCalculus/Basic.lean:52
inductive HasType : Nat → ServiceEnv → Context → Proc → Prop where
| nil {n : Nat} {Γ : ServiceEnv} {Δ : Context} :
Δ.Completed → (∀ e ∈ Δ, e.name.ClosedAt n) → Separated Γ Δ → HasType n Γ Δ .nil
| outName {n : Nat} {Γ : ServiceEnv} {Δ : Context} {e : Key} {c : Capability}
{b : Name} {s : Protocol} {p : Proc} :
GuardMin Δ e c.rank → Separated Γ Δ → Δ.lookup e = some c →
c.protocol.unfold = .sendName s → e.name.ClosedAt n → b.ClosedAt n →
HasType n Γ (Δ.insert e ⟨c.rank, s⟩) p → HasType n Γ Δ (.out e.name b p)
| inpName {n : Nat} {Γ : ServiceEnv} {Δ : Context} {e : Key} {c : Capability}
{s : Protocol} {p : Proc} :
GuardMin Δ e c.rank → Separated Γ Δ → Δ.lookup e = some c →
c.protocol.unfold = .recvName s → e.name.ClosedAt n →
⋯
CSLibExt/Languages/SessionTypes/Endpoint/SharedServices.lean:32
structure Key where
name : PiCalculus.Name
role : Role
deriving DecidableEq, Repr
CSLibExt/Languages/SessionTypes/Endpoint/Identity.lean:30
def NameAbsent (a : Name) : Proc → Prop
| .nil => True
| .out b c p => a ≠ b ∧ a ≠ c ∧ NameAbsent a p
| .inp b p => a ≠ b ∧ NameAbsent (liftName 0 a) p
| .par p q | .sum p q => NameAbsent a p ∧ NameAbsent a q
| .nu p => NameAbsent (liftName 0 a) p
| .repl p => NameAbsent a p
CSLibExt/Languages/SessionTypes/Endpoint/NameAbsence.lean:29
Uses 33 · Used by 1
TheoremEquivalent retyping preserves separation from shared names#✓fully proved
Semantic capability changes do not change owned physical names or Γ separation.
theorem Separated.retype {Γ : ServiceEnv} {Δ Ξ : Context} (hs : Separated Γ Δ)
(he : ContextEquivalent Δ Ξ) : Separated Γ Ξ
abbrev ServiceEnv := Finmap (fun _ : Nat => ServiceSignature)
CSLibExt/Languages/SessionTypes/Endpoint/SharedEnvironment.lean:33
abbrev Context := Finmap (fun _ : Key => Capability)
CSLibExt/Languages/SessionTypes/Endpoint/Context.lean:32
def Separated (Γ : ServiceEnv) (Δ : Context) : Prop :=
∀ e c, Δ.lookup e = some c → ∀ s sig, Γ.lookup s = some sig → e.name ≠ .const s
CSLibExt/Languages/SessionTypes/Endpoint/SharedEnvironment.lean:36
def ContextEquivalent (Δ Ξ : Context) : Prop :=
∀ e, Option.Rel Capability.Equivalent (Δ.lookup e) (Ξ.lookup e)
CSLibExt/Languages/SessionTypes/Endpoint/ContextEquivalence.lean:28
Uses 12 · Used by 1
TheoremEquivalent retyping preserves invocation priority#✓fully proved
Actual active-payload ranks preserve the strict shared invocation priority.
theorem InvocationPriority.retype {sig : ServiceSignature} {Δ Ξ : Context}
(hg : InvocationPriority sig Δ) (he : ContextEquivalent Δ Ξ) : InvocationPriority sig Ξ
structure ServiceSignature where
priority : Nat
role : Role
capability : Capability
CSLibExt/Languages/SessionTypes/Endpoint/SharedEnvironment.lean:27
abbrev Context := Finmap (fun _ : Key => Capability)
CSLibExt/Languages/SessionTypes/Endpoint/Context.lean:32
def InvocationPriority (sig : ServiceSignature) (Δ : Context) : Prop :=
∀ e c, Δ.lookup e = some c → c.protocol.unfold ≠ .done → sig.priority < c.rank
CSLibExt/Languages/SessionTypes/Endpoint/SharedEnvironment.lean:40
def ContextEquivalent (Δ Ξ : Context) : Prop :=
∀ e, Option.Rel Capability.Equivalent (Δ.lookup e) (Ξ.lookup e)
CSLibExt/Languages/SessionTypes/Endpoint/ContextEquivalence.lean:28
Uses 15 · Used by 1
TheoremRuntime typing transfers to an equivalent linear context#✓fully proved
ALL10 runtime rules retype at arbitrary equivalent linear contexts, with Γ UNCHANGED. Actual payload codes, literal cap ranks and empty BODY contexts are retained.
theorem HasType.retype {n : Nat} {Γ : ServiceEnv} {Δ Ξ : Context} {p : Proc}
(h : HasType n Γ Δ p) (he : ContextEquivalent Δ Ξ) : HasType n Γ Ξ p
abbrev ServiceEnv := Finmap (fun _ : Nat => ServiceSignature)
CSLibExt/Languages/SessionTypes/Endpoint/SharedEnvironment.lean:33
abbrev Context := Finmap (fun _ : Key => Capability)
CSLibExt/Languages/SessionTypes/Endpoint/Context.lean:32
inductive Proc where
| nil : Proc
| out (a b : Name) (p : Proc) : Proc
| inp (a : Name) (p : Proc) : Proc
| par (p q : Proc) : Proc
| nu (p : Proc) : Proc
| repl (p : Proc) : Proc
| sum (p q : Proc) : Proc
deriving DecidableEq, Repr
CSLibExt/Languages/PiCalculus/Basic.lean:52
inductive HasType : Nat → ServiceEnv → Context → Proc → Prop where
| nil {n : Nat} {Γ : ServiceEnv} {Δ : Context} :
Δ.Completed → (∀ e ∈ Δ, e.name.ClosedAt n) → Separated Γ Δ → HasType n Γ Δ .nil
| outName {n : Nat} {Γ : ServiceEnv} {Δ : Context} {e : Key} {c : Capability}
{b : Name} {s : Protocol} {p : Proc} :
GuardMin Δ e c.rank → Separated Γ Δ → Δ.lookup e = some c →
c.protocol.unfold = .sendName s → e.name.ClosedAt n → b.ClosedAt n →
HasType n Γ (Δ.insert e ⟨c.rank, s⟩) p → HasType n Γ Δ (.out e.name b p)
| inpName {n : Nat} {Γ : ServiceEnv} {Δ : Context} {e : Key} {c : Capability}
{s : Protocol} {p : Proc} :
GuardMin Δ e c.rank → Separated Γ Δ → Δ.lookup e = some c →
c.protocol.unfold = .recvName s → e.name.ClosedAt n →
⋯
CSLibExt/Languages/SessionTypes/Endpoint/SharedServices.lean:32
def ContextEquivalent (Δ Ξ : Context) : Prop :=
∀ e, Option.Rel Capability.Equivalent (Δ.lookup e) (Ξ.lookup e)
CSLibExt/Languages/SessionTypes/Endpoint/ContextEquivalence.lean:28
Uses 39 · Used by 2
TheoremRuntime typing is invariant under equivalent linear contexts#✓fully proved
Equivalent linear interfaces preserve runtime typing in BOTH directions at exactly the same shared environment, process and ambient depth.
theorem HasType.retype_iff {n : Nat} {Γ : ServiceEnv} {Δ Ξ : Context} {p : Proc}
(he : ContextEquivalent Δ Ξ) : HasType n Γ Δ p ↔ HasType n Γ Ξ p
abbrev ServiceEnv := Finmap (fun _ : Nat => ServiceSignature)
CSLibExt/Languages/SessionTypes/Endpoint/SharedEnvironment.lean:33
abbrev Context := Finmap (fun _ : Key => Capability)
CSLibExt/Languages/SessionTypes/Endpoint/Context.lean:32
inductive Proc where
| nil : Proc
| out (a b : Name) (p : Proc) : Proc
| inp (a : Name) (p : Proc) : Proc
| par (p q : Proc) : Proc
| nu (p : Proc) : Proc
| repl (p : Proc) : Proc
| sum (p q : Proc) : Proc
deriving DecidableEq, Repr
CSLibExt/Languages/PiCalculus/Basic.lean:52
def ContextEquivalent (Δ Ξ : Context) : Prop :=
∀ e, Option.Rel Capability.Equivalent (Δ.lookup e) (Ξ.lookup e)
CSLibExt/Languages/SessionTypes/Endpoint/ContextEquivalence.lean:28
inductive HasType : Nat → ServiceEnv → Context → Proc → Prop where
| nil {n : Nat} {Γ : ServiceEnv} {Δ : Context} :
Δ.Completed → (∀ e ∈ Δ, e.name.ClosedAt n) → Separated Γ Δ → HasType n Γ Δ .nil
| outName {n : Nat} {Γ : ServiceEnv} {Δ : Context} {e : Key} {c : Capability}
{b : Name} {s : Protocol} {p : Proc} :
GuardMin Δ e c.rank → Separated Γ Δ → Δ.lookup e = some c →
c.protocol.unfold = .sendName s → e.name.ClosedAt n → b.ClosedAt n →
HasType n Γ (Δ.insert e ⟨c.rank, s⟩) p → HasType n Γ Δ (.out e.name b p)
| inpName {n : Nat} {Γ : ServiceEnv} {Δ : Context} {e : Key} {c : Capability}
{s : Protocol} {p : Proc} :
GuardMin Δ e c.rank → Separated Γ Δ → Δ.lookup e = some c →
c.protocol.unfold = .recvName s → e.name.ClosedAt n →
⋯
CSLibExt/Languages/SessionTypes/Endpoint/SharedServices.lean:32
TheoremEach owned key of a runtime typing is scoped at ambient depth#✓fully proved
Every actual owned key is scoped at the runtime derivation's ambient depth.
theorem HasType.lookup_closedAt {n : Nat} {Γ : ServiceEnv} {Δ : Context} {p : Proc}
(h : HasType n Γ Δ p) {z : Key} {t : Capability} (hz : Δ.lookup z = some t) :
z.name.ClosedAt n
abbrev ServiceEnv := Finmap (fun _ : Nat => ServiceSignature)
CSLibExt/Languages/SessionTypes/Endpoint/SharedEnvironment.lean:33
abbrev Context := Finmap (fun _ : Key => Capability)
CSLibExt/Languages/SessionTypes/Endpoint/Context.lean:32
inductive Proc where
| nil : Proc
| out (a b : Name) (p : Proc) : Proc
| inp (a : Name) (p : Proc) : Proc
| par (p q : Proc) : Proc
| nu (p : Proc) : Proc
| repl (p : Proc) : Proc
| sum (p q : Proc) : Proc
deriving DecidableEq, Repr
CSLibExt/Languages/PiCalculus/Basic.lean:52
inductive HasType : Nat → ServiceEnv → Context → Proc → Prop where
| nil {n : Nat} {Γ : ServiceEnv} {Δ : Context} :
Δ.Completed → (∀ e ∈ Δ, e.name.ClosedAt n) → Separated Γ Δ → HasType n Γ Δ .nil
| outName {n : Nat} {Γ : ServiceEnv} {Δ : Context} {e : Key} {c : Capability}
{b : Name} {s : Protocol} {p : Proc} :
GuardMin Δ e c.rank → Separated Γ Δ → Δ.lookup e = some c →
c.protocol.unfold = .sendName s → e.name.ClosedAt n → b.ClosedAt n →
HasType n Γ (Δ.insert e ⟨c.rank, s⟩) p → HasType n Γ Δ (.out e.name b p)
| inpName {n : Nat} {Γ : ServiceEnv} {Δ : Context} {e : Key} {c : Capability}
{s : Protocol} {p : Proc} :
GuardMin Δ e c.rank → Separated Γ Δ → Δ.lookup e = some c →
c.protocol.unfold = .recvName s → e.name.ClosedAt n →
⋯
CSLibExt/Languages/SessionTypes/Endpoint/SharedServices.lean:32
structure Key where
name : PiCalculus.Name
role : Role
deriving DecidableEq, Repr
CSLibExt/Languages/SessionTypes/Endpoint/Identity.lean:30
structure Capability where
rank : Nat
protocol : Protocol
CSLibExt/Languages/SessionTypes/Endpoint/Context.lean:27
Uses 26 · Used by 2
TheoremWhole owned context of a runtime typing is scoped at ambient depth#✓fully proved
Scope applies to the actual complete owned domain, not only active subjects.
theorem HasType.context_closedAt {n : Nat} {Γ : ServiceEnv} {Δ : Context} {p : Proc}
(h : HasType n Γ Δ p) : ∀ e ∈ Δ, e.name.ClosedAt n
abbrev ServiceEnv := Finmap (fun _ : Nat => ServiceSignature)
CSLibExt/Languages/SessionTypes/Endpoint/SharedEnvironment.lean:33
abbrev Context := Finmap (fun _ : Key => Capability)
CSLibExt/Languages/SessionTypes/Endpoint/Context.lean:32
inductive Proc where
| nil : Proc
| out (a b : Name) (p : Proc) : Proc
| inp (a : Name) (p : Proc) : Proc
| par (p q : Proc) : Proc
| nu (p : Proc) : Proc
| repl (p : Proc) : Proc
| sum (p q : Proc) : Proc
deriving DecidableEq, Repr
CSLibExt/Languages/PiCalculus/Basic.lean:52
inductive HasType : Nat → ServiceEnv → Context → Proc → Prop where
| nil {n : Nat} {Γ : ServiceEnv} {Δ : Context} :
Δ.Completed → (∀ e ∈ Δ, e.name.ClosedAt n) → Separated Γ Δ → HasType n Γ Δ .nil
| outName {n : Nat} {Γ : ServiceEnv} {Δ : Context} {e : Key} {c : Capability}
{b : Name} {s : Protocol} {p : Proc} :
GuardMin Δ e c.rank → Separated Γ Δ → Δ.lookup e = some c →
c.protocol.unfold = .sendName s → e.name.ClosedAt n → b.ClosedAt n →
HasType n Γ (Δ.insert e ⟨c.rank, s⟩) p → HasType n Γ Δ (.out e.name b p)
| inpName {n : Nat} {Γ : ServiceEnv} {Δ : Context} {e : Key} {c : Capability}
{s : Protocol} {p : Proc} :
GuardMin Δ e c.rank → Separated Γ Δ → Δ.lookup e = some c →
c.protocol.unfold = .recvName s → e.name.ClosedAt n →
⋯
CSLibExt/Languages/SessionTypes/Endpoint/SharedServices.lean:32
Uses 10 · Used by 2
TheoremTyped service templates own only completed entries#✓fully proved
A typed structurally guarded template owns only completed AMBIENT entries. Its input and replica BODY proofs remain separate and may use their own formal key.
theorem HasType.template_completed {n : Nat} {Γ : ServiceEnv} {Δ : Context} {p : Proc}
(h : HasType n Γ Δ p) (ht : ServiceTemplate Γ p) : Δ.Completed
abbrev ServiceEnv := Finmap (fun _ : Nat => ServiceSignature)
CSLibExt/Languages/SessionTypes/Endpoint/SharedEnvironment.lean:33
abbrev Context := Finmap (fun _ : Key => Capability)
CSLibExt/Languages/SessionTypes/Endpoint/Context.lean:32
inductive Proc where
| nil : Proc
| out (a b : Name) (p : Proc) : Proc
| inp (a : Name) (p : Proc) : Proc
| par (p q : Proc) : Proc
| nu (p : Proc) : Proc
| repl (p : Proc) : Proc
| sum (p q : Proc) : Proc
deriving DecidableEq, Repr
CSLibExt/Languages/PiCalculus/Basic.lean:52
inductive HasType : Nat → ServiceEnv → Context → Proc → Prop where
| nil {n : Nat} {Γ : ServiceEnv} {Δ : Context} :
Δ.Completed → (∀ e ∈ Δ, e.name.ClosedAt n) → Separated Γ Δ → HasType n Γ Δ .nil
| outName {n : Nat} {Γ : ServiceEnv} {Δ : Context} {e : Key} {c : Capability}
{b : Name} {s : Protocol} {p : Proc} :
GuardMin Δ e c.rank → Separated Γ Δ → Δ.lookup e = some c →
c.protocol.unfold = .sendName s → e.name.ClosedAt n → b.ClosedAt n →
HasType n Γ (Δ.insert e ⟨c.rank, s⟩) p → HasType n Γ Δ (.out e.name b p)
| inpName {n : Nat} {Γ : ServiceEnv} {Δ : Context} {e : Key} {c : Capability}
{s : Protocol} {p : Proc} :
GuardMin Δ e c.rank → Separated Γ Δ → Δ.lookup e = some c →
c.protocol.unfold = .recvName s → e.name.ClosedAt n →
⋯
CSLibExt/Languages/SessionTypes/Endpoint/SharedServices.lean:32
def ServiceTemplate (Γ : ServiceEnv) : Proc → Prop
| .nil => True
| .inp a _ => ∃ s, a = .const s ∧ s ∈ Γ
| .par p q => ServiceTemplate Γ p ∧ ServiceTemplate Γ q
| .nu p | .repl p => ServiceTemplate Γ p
| .out .. | .sum .. => False
CSLibExt/Languages/SessionTypes/Endpoint/ServiceTemplates.lean:29
Uses 25 · Used by 4
TheoremTyped service templates retype at any well-formed completed context#✓fully proved
Structurally guarded typed templates can replace only their COMPLETED ambient annotations. Fresh input/empty replica BODY proofs are retained unchanged.
theorem HasType.template_reannotate {n : Nat} {Γ : ServiceEnv} {Δ Θ : Context} {p : Proc}
(h : HasType n Γ Δ p) (ht : ServiceTemplate Γ p) (hc : Θ.Completed)
(hs : ∀ e ∈ Θ, e.name.ClosedAt n) (hd : Separated Γ Θ) : HasType n Γ Θ p
abbrev ServiceEnv := Finmap (fun _ : Nat => ServiceSignature)
CSLibExt/Languages/SessionTypes/Endpoint/SharedEnvironment.lean:33
abbrev Context := Finmap (fun _ : Key => Capability)
CSLibExt/Languages/SessionTypes/Endpoint/Context.lean:32
inductive Proc where
| nil : Proc
| out (a b : Name) (p : Proc) : Proc
| inp (a : Name) (p : Proc) : Proc
| par (p q : Proc) : Proc
| nu (p : Proc) : Proc
| repl (p : Proc) : Proc
| sum (p q : Proc) : Proc
deriving DecidableEq, Repr
CSLibExt/Languages/PiCalculus/Basic.lean:52
inductive HasType : Nat → ServiceEnv → Context → Proc → Prop where
| nil {n : Nat} {Γ : ServiceEnv} {Δ : Context} :
Δ.Completed → (∀ e ∈ Δ, e.name.ClosedAt n) → Separated Γ Δ → HasType n Γ Δ .nil
| outName {n : Nat} {Γ : ServiceEnv} {Δ : Context} {e : Key} {c : Capability}
{b : Name} {s : Protocol} {p : Proc} :
GuardMin Δ e c.rank → Separated Γ Δ → Δ.lookup e = some c →
c.protocol.unfold = .sendName s → e.name.ClosedAt n → b.ClosedAt n →
HasType n Γ (Δ.insert e ⟨c.rank, s⟩) p → HasType n Γ Δ (.out e.name b p)
| inpName {n : Nat} {Γ : ServiceEnv} {Δ : Context} {e : Key} {c : Capability}
{s : Protocol} {p : Proc} :
GuardMin Δ e c.rank → Separated Γ Δ → Δ.lookup e = some c →
c.protocol.unfold = .recvName s → e.name.ClosedAt n →
⋯
CSLibExt/Languages/SessionTypes/Endpoint/SharedServices.lean:32
def ServiceTemplate (Γ : ServiceEnv) : Proc → Prop
| .nil => True
| .inp a _ => ∃ s, a = .const s ∧ s ∈ Γ
| .par p q => ServiceTemplate Γ p ∧ ServiceTemplate Γ q
| .nu p | .repl p => ServiceTemplate Γ p
| .out .. | .sum .. => False
CSLibExt/Languages/SessionTypes/Endpoint/ServiceTemplates.lean:29
def Separated (Γ : ServiceEnv) (Δ : Context) : Prop :=
∀ e c, Δ.lookup e = some c → ∀ s sig, Γ.lookup s = some sig → e.name ≠ .const s
CSLibExt/Languages/SessionTypes/Endpoint/SharedEnvironment.lean:36
Uses 37 · Used by 2
TheoremTyped service templates retype at empty ownership#✓fully proved
Clearing completed template annotations produces the EXACT empty BODY required by replica admission; this is not unconditional active-resource erasure.
theorem HasType.template_empty {n : Nat} {Γ : ServiceEnv} {Δ : Context} {p : Proc}
(h : HasType n Γ Δ p) (ht : ServiceTemplate Γ p) : HasType n Γ ∅ p
abbrev ServiceEnv := Finmap (fun _ : Nat => ServiceSignature)
CSLibExt/Languages/SessionTypes/Endpoint/SharedEnvironment.lean:33
abbrev Context := Finmap (fun _ : Key => Capability)
CSLibExt/Languages/SessionTypes/Endpoint/Context.lean:32
inductive Proc where
| nil : Proc
| out (a b : Name) (p : Proc) : Proc
| inp (a : Name) (p : Proc) : Proc
| par (p q : Proc) : Proc
| nu (p : Proc) : Proc
| repl (p : Proc) : Proc
| sum (p q : Proc) : Proc
deriving DecidableEq, Repr
CSLibExt/Languages/PiCalculus/Basic.lean:52
inductive HasType : Nat → ServiceEnv → Context → Proc → Prop where
| nil {n : Nat} {Γ : ServiceEnv} {Δ : Context} :
Δ.Completed → (∀ e ∈ Δ, e.name.ClosedAt n) → Separated Γ Δ → HasType n Γ Δ .nil
| outName {n : Nat} {Γ : ServiceEnv} {Δ : Context} {e : Key} {c : Capability}
{b : Name} {s : Protocol} {p : Proc} :
GuardMin Δ e c.rank → Separated Γ Δ → Δ.lookup e = some c →
c.protocol.unfold = .sendName s → e.name.ClosedAt n → b.ClosedAt n →
HasType n Γ (Δ.insert e ⟨c.rank, s⟩) p → HasType n Γ Δ (.out e.name b p)
| inpName {n : Nat} {Γ : ServiceEnv} {Δ : Context} {e : Key} {c : Capability}
{s : Protocol} {p : Proc} :
GuardMin Δ e c.rank → Separated Γ Δ → Δ.lookup e = some c →
c.protocol.unfold = .recvName s → e.name.ClosedAt n →
⋯
CSLibExt/Languages/SessionTypes/Endpoint/SharedServices.lean:32
def ServiceTemplate (Γ : ServiceEnv) : Proc → Prop
| .nil => True
| .inp a _ => ∃ s, a = .const s ∧ s ∈ Γ
| .par p q => ServiceTemplate Γ p ∧ ServiceTemplate Γ q
| .nu p | .repl p => ServiceTemplate Γ p
| .out .. | .sum .. => False
CSLibExt/Languages/SessionTypes/Endpoint/ServiceTemplates.lean:29
Uses 12 · Used by 1
TheoremRemoving a restriction around nil preserves runtime typing#✓fully proved
Removing a nil restriction retains its actual completed/scoped/separated ambient.
theorem HasType.nu_nil_elim {n : Nat} {Γ : ServiceEnv} {Δ : Context}
(h : HasType n Γ Δ (.nu .nil)) : HasType n Γ Δ .nil
abbrev ServiceEnv := Finmap (fun _ : Nat => ServiceSignature)
CSLibExt/Languages/SessionTypes/Endpoint/SharedEnvironment.lean:33
abbrev Context := Finmap (fun _ : Key => Capability)
CSLibExt/Languages/SessionTypes/Endpoint/Context.lean:32
inductive HasType : Nat → ServiceEnv → Context → Proc → Prop where
| nil {n : Nat} {Γ : ServiceEnv} {Δ : Context} :
Δ.Completed → (∀ e ∈ Δ, e.name.ClosedAt n) → Separated Γ Δ → HasType n Γ Δ .nil
| outName {n : Nat} {Γ : ServiceEnv} {Δ : Context} {e : Key} {c : Capability}
{b : Name} {s : Protocol} {p : Proc} :
GuardMin Δ e c.rank → Separated Γ Δ → Δ.lookup e = some c →
c.protocol.unfold = .sendName s → e.name.ClosedAt n → b.ClosedAt n →
HasType n Γ (Δ.insert e ⟨c.rank, s⟩) p → HasType n Γ Δ (.out e.name b p)
| inpName {n : Nat} {Γ : ServiceEnv} {Δ : Context} {e : Key} {c : Capability}
{s : Protocol} {p : Proc} :
GuardMin Δ e c.rank → Separated Γ Δ → Δ.lookup e = some c →
c.protocol.unfold = .recvName s → e.name.ClosedAt n →
⋯
CSLibExt/Languages/SessionTypes/Endpoint/SharedServices.lean:32
Uses 13 · Used by 1
TheoremAdding a restriction around nil preserves runtime typing#✓fully proved
Introducing a nil restriction chooses a genuinely completed literal-dual pair.
theorem HasType.nu_nil_intro {n : Nat} {Γ : ServiceEnv} {Δ : Context}
(h : HasType n Γ Δ .nil) : HasType n Γ Δ (.nu .nil)
abbrev ServiceEnv := Finmap (fun _ : Nat => ServiceSignature)
CSLibExt/Languages/SessionTypes/Endpoint/SharedEnvironment.lean:33
abbrev Context := Finmap (fun _ : Key => Capability)
CSLibExt/Languages/SessionTypes/Endpoint/Context.lean:32
inductive HasType : Nat → ServiceEnv → Context → Proc → Prop where
| nil {n : Nat} {Γ : ServiceEnv} {Δ : Context} :
Δ.Completed → (∀ e ∈ Δ, e.name.ClosedAt n) → Separated Γ Δ → HasType n Γ Δ .nil
| outName {n : Nat} {Γ : ServiceEnv} {Δ : Context} {e : Key} {c : Capability}
{b : Name} {s : Protocol} {p : Proc} :
GuardMin Δ e c.rank → Separated Γ Δ → Δ.lookup e = some c →
c.protocol.unfold = .sendName s → e.name.ClosedAt n → b.ClosedAt n →
HasType n Γ (Δ.insert e ⟨c.rank, s⟩) p → HasType n Γ Δ (.out e.name b p)
| inpName {n : Nat} {Γ : ServiceEnv} {Δ : Context} {e : Key} {c : Capability}
{s : Protocol} {p : Proc} :
GuardMin Δ e c.rank → Separated Γ Δ → Δ.lookup e = some c →
c.protocol.unfold = .recvName s → e.name.ClosedAt n →
⋯
CSLibExt/Languages/SessionTypes/Endpoint/SharedServices.lean:32
Uses 30 · Used by 1
Loading dependency explorer…
The dependency explorer needs JavaScript and its graph data.