Weakening conversion ranked typing by a disjoint completed context to Adding a role unused by the partner preserves conversion ranked typing
TheoremWeakening conversion ranked typing by a disjoint completed context#✓fully proved
Reattaching a disjoint completed finite context preserves all guards.
theorem RankedType.weaken_completed_union {n : Nat} {Δ Θ : Context} {p : Proc}
(h : RankedType n Δ p) (hd : Finmap.Disjoint Δ Θ) (hc : Θ.Completed)
(hs : ∀ e ∈ Θ, e.name.ClosedAt n) : RankedType n (Δ ∪ Θ) p
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 RankedType : Nat → Context → Proc → Prop where
| nil {n : Nat} {Δ : Context} :
Δ.Completed → (∀ e ∈ Δ, e.name.ClosedAt n) → RankedType n Δ .nil
| outName {n : Nat} {Δ : Context} {e : Key} {c : Capability}
{b : Name} {s : Protocol} {p : Proc} :
GuardMin Δ e c.rank → Δ.lookup e = some c → c.protocol.unfold = .sendName s →
e.name.ClosedAt n → b.ClosedAt n →
RankedType n (Δ.insert e ⟨c.rank, s⟩) p → RankedType n Δ (.out e.name b p)
| inpName {n : Nat} {Δ : Context} {e : Key} {c : Capability}
{s : Protocol} {p : Proc} :
GuardMin Δ e c.rank → Δ.lookup e = some c → c.protocol.unfold = .recvName s →
e.name.ClosedAt n →
⋯
CSLibExt/Languages/SessionTypes/Endpoint/RankedConversionTyping.lean:30
Uses 14 · Used by 1
TheoremEquivalent contexts preserve the guard condition#✓fully proved
Same domains, literal cap ranks and actual done equivalence preserve GuardMin.
theorem GuardMin.retype {Δ Ξ : Context} {e : Key} {k : Nat} (hg : GuardMin Δ e k)
(he : ContextEquivalent Δ Ξ) : GuardMin Ξ e k
abbrev Context := Finmap (fun _ : Key => Capability)
CSLibExt/Languages/SessionTypes/Endpoint/Context.lean:32
structure Key where
name : PiCalculus.Name
role : Role
deriving DecidableEq, Repr
CSLibExt/Languages/SessionTypes/Endpoint/Identity.lean:30
def GuardMin (Δ : Context) (e : Key) (rank : Nat) : Prop :=
∀ d c, Δ.lookup d = some c → c.protocol.unfold ≠ .done →
d ≠ e → rank < c.rank
CSLibExt/Languages/SessionTypes/Endpoint/Priority.lean:26
def ContextEquivalent (Δ Ξ : Context) : Prop :=
∀ e, Option.Rel Capability.Equivalent (Δ.lookup e) (Ξ.lookup e)
CSLibExt/Languages/SessionTypes/Endpoint/ContextEquivalence.lean:28
Uses 14 · Used by 2
TheoremEquivalent contexts preserve conversion ranked typing#✓fully proved
GENERAL arbitrary-depth, arbitrary-context retyping, by all seven typing constructors. Target ownership, ranks and every unfolded branch are derived.
theorem RankedType.retype {n : Nat} {Δ Ξ : Context} {p : Proc}
(h : RankedType n Δ p) (he : ContextEquivalent Δ Ξ) : RankedType n Ξ p
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 RankedType : Nat → Context → Proc → Prop where
| nil {n : Nat} {Δ : Context} :
Δ.Completed → (∀ e ∈ Δ, e.name.ClosedAt n) → RankedType n Δ .nil
| outName {n : Nat} {Δ : Context} {e : Key} {c : Capability}
{b : Name} {s : Protocol} {p : Proc} :
GuardMin Δ e c.rank → Δ.lookup e = some c → c.protocol.unfold = .sendName s →
e.name.ClosedAt n → b.ClosedAt n →
RankedType n (Δ.insert e ⟨c.rank, s⟩) p → RankedType n Δ (.out e.name b p)
| inpName {n : Nat} {Δ : Context} {e : Key} {c : Capability}
{s : Protocol} {p : Proc} :
GuardMin Δ e c.rank → Δ.lookup e = some c → c.protocol.unfold = .recvName s →
e.name.ClosedAt n →
⋯
CSLibExt/Languages/SessionTypes/Endpoint/RankedConversionTyping.lean:30
def ContextEquivalent (Δ Ξ : Context) : Prop :=
∀ e, Option.Rel Capability.Equivalent (Δ.lookup e) (Ξ.lookup e)
CSLibExt/Languages/SessionTypes/Endpoint/ContextEquivalence.lean:28
Uses 32 · Used by 2
TheoremContext equivalence transports conversion ranked typing both ways#✓fully proved
Equivalence transports typing in BOTH directions at the same process/depth.
theorem RankedType.retype_iff {n : Nat} {Δ Ξ : Context} {p : Proc}
(he : ContextEquivalent Δ Ξ) : RankedType n Δ p ↔ RankedType n Ξ p
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 RankedType : Nat → Context → Proc → Prop where
| nil {n : Nat} {Δ : Context} :
Δ.Completed → (∀ e ∈ Δ, e.name.ClosedAt n) → RankedType n Δ .nil
| outName {n : Nat} {Δ : Context} {e : Key} {c : Capability}
{b : Name} {s : Protocol} {p : Proc} :
GuardMin Δ e c.rank → Δ.lookup e = some c → c.protocol.unfold = .sendName s →
e.name.ClosedAt n → b.ClosedAt n →
RankedType n (Δ.insert e ⟨c.rank, s⟩) p → RankedType n Δ (.out e.name b p)
| inpName {n : Nat} {Δ : Context} {e : Key} {c : Capability}
{s : Protocol} {p : Proc} :
GuardMin Δ e c.rank → Δ.lookup e = some c → c.protocol.unfold = .recvName s →
e.name.ClosedAt n →
⋯
CSLibExt/Languages/SessionTypes/Endpoint/RankedConversionTyping.lean:30
TheoremCollision-free renaming preserves conversion ranked typing#✓fully proved
GENERAL name transport with collision freedom on actual owned keys and canonical ambient name scope; protocol codes, roles and ranks stay exact.
theorem RankedType.rename {n m : Nat} {Δ : Context} {p : Proc} {f : Name → Name}
(h : RankedType n Δ p) (hscope : ∀ a, a.ClosedAt n → (f a).ClosedAt m)
(hf : Set.InjOn (Key.mapName f) {e | e ∈ Δ}) :
RankedType m (Context.rekey (Key.mapName f) Δ hf) (mapProc f p)
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 Name where
| const (n : ℕ) : Name
| var (i : ℕ) : Name
deriving DecidableEq, Repr
CSLibExt/Languages/PiCalculus/Basic.lean:45
inductive RankedType : Nat → Context → Proc → Prop where
| nil {n : Nat} {Δ : Context} :
Δ.Completed → (∀ e ∈ Δ, e.name.ClosedAt n) → RankedType n Δ .nil
| outName {n : Nat} {Δ : Context} {e : Key} {c : Capability}
{b : Name} {s : Protocol} {p : Proc} :
GuardMin Δ e c.rank → Δ.lookup e = some c → c.protocol.unfold = .sendName s →
e.name.ClosedAt n → b.ClosedAt n →
RankedType n (Δ.insert e ⟨c.rank, s⟩) p → RankedType n Δ (.out e.name b p)
| inpName {n : Nat} {Δ : Context} {e : Key} {c : Capability}
{s : Protocol} {p : Proc} :
GuardMin Δ e c.rank → Δ.lookup e = some c → c.protocol.unfold = .recvName s →
e.name.ClosedAt n →
⋯
CSLibExt/Languages/SessionTypes/Endpoint/RankedConversionTyping.lean:30
def Key.mapName (f : PiCalculus.Name → PiCalculus.Name) (e : Key) : Key :=
⟨f e.name, e.role⟩
CSLibExt/Languages/SessionTypes/Endpoint/Identity.lean:60
def Context.rekey (f : Key → Key) (Δ : Context)
(hf : Set.InjOn f {e | e ∈ Δ}) : Context where
entries := Δ.entries.map (fun x => ⟨f x.1, x.2⟩)
nodupKeys := by
apply Multiset.nodup_keys.mp
have h := Multiset.Nodup.map_on hf Δ.nodupKeys.nodup_keys
simpa [Multiset.keys, Multiset.map_map, Function.comp_def] using h
CSLibExt/Languages/SessionTypes/Endpoint/Context.lean:45
def mapProc (f : Name → Name) : Proc → Proc
| .nil => .nil
| .out a b p => .out (f a) (f b) (mapProc f p)
| .inp a p => .inp (f a) (mapProc (under f) p)
| .par p q => .par (mapProc f p) (mapProc f q)
| .nu p => .nu (mapProc (under f) p)
| .repl p => .repl (mapProc f p)
| .sum p q => .sum (mapProc f p) (mapProc f q)
CSLibExt/Languages/SessionTypes/Endpoint/Renaming.lean:39
Uses 35 · Used by 5
TheoremBinder lifting preserves conversion ranked typing#✓fully proved
Lift uses the canonical cutoff-aware name and process operations.
theorem RankedType.lift {n : Nat} {Δ : Context} {p : Proc} (h : RankedType n Δ p) (k : Nat) :
RankedType (n + 1) (Context.lift k Δ) (liftProc k p)
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 RankedType : Nat → Context → Proc → Prop where
| nil {n : Nat} {Δ : Context} :
Δ.Completed → (∀ e ∈ Δ, e.name.ClosedAt n) → RankedType n Δ .nil
| outName {n : Nat} {Δ : Context} {e : Key} {c : Capability}
{b : Name} {s : Protocol} {p : Proc} :
GuardMin Δ e c.rank → Δ.lookup e = some c → c.protocol.unfold = .sendName s →
e.name.ClosedAt n → b.ClosedAt n →
RankedType n (Δ.insert e ⟨c.rank, s⟩) p → RankedType n Δ (.out e.name b p)
| inpName {n : Nat} {Δ : Context} {e : Key} {c : Capability}
{s : Protocol} {p : Proc} :
GuardMin Δ e c.rank → Δ.lookup e = some c → c.protocol.unfold = .recvName s →
e.name.ClosedAt n →
⋯
CSLibExt/Languages/SessionTypes/Endpoint/RankedConversionTyping.lean:30
def Context.lift (k : Nat) (Δ : Context) : Context :=
rekey (Key.mapName (liftName k)) Δ
(fun _ _ _ _ h => Key.mapName_injective (liftName_injective k) h)
CSLibExt/Languages/SessionTypes/Endpoint/ContextTransport.lean:28
def liftProc (cutoff : ℕ) : Proc → Proc
| .nil => .nil
| .out a b p => .out (liftName cutoff a) (liftName cutoff b) (liftProc cutoff p)
| .inp a p => .inp (liftName cutoff a) (liftProc (cutoff + 1) p)
| .par p q => .par (liftProc cutoff p) (liftProc cutoff q)
| .nu p => .nu (liftProc (cutoff + 1) p)
| .repl p => .repl (liftProc cutoff p)
| .sum p q => .sum (liftProc cutoff p) (liftProc cutoff q)
CSLibExt/Languages/PiCalculus/Basic.lean:70
Uses 18 · Used by 1
TheoremBinder swap preserves conversion ranked typing#✓fully proved
Swap retains roles, protocols and ranks while permuting two ambient binders.
theorem RankedType.swap {n k : Nat} {Δ : Context} {p : Proc}
(h : RankedType n Δ p) (hk : k + 1 < n) :
RankedType n (Context.swap k Δ) (swapProc k p)
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 RankedType : Nat → Context → Proc → Prop where
| nil {n : Nat} {Δ : Context} :
Δ.Completed → (∀ e ∈ Δ, e.name.ClosedAt n) → RankedType n Δ .nil
| outName {n : Nat} {Δ : Context} {e : Key} {c : Capability}
{b : Name} {s : Protocol} {p : Proc} :
GuardMin Δ e c.rank → Δ.lookup e = some c → c.protocol.unfold = .sendName s →
e.name.ClosedAt n → b.ClosedAt n →
RankedType n (Δ.insert e ⟨c.rank, s⟩) p → RankedType n Δ (.out e.name b p)
| inpName {n : Nat} {Δ : Context} {e : Key} {c : Capability}
{s : Protocol} {p : Proc} :
GuardMin Δ e c.rank → Δ.lookup e = some c → c.protocol.unfold = .recvName s →
e.name.ClosedAt n →
⋯
CSLibExt/Languages/SessionTypes/Endpoint/RankedConversionTyping.lean:30
def Context.swap (k : Nat) (Δ : Context) : Context :=
rekey (Key.mapName (swapNameAt k)) Δ
(fun _ _ _ _ h => Key.mapName_injective (swapNameAt_injective k) h)
CSLibExt/Languages/SessionTypes/Endpoint/SwapTyping.lean:25
def swapProc (cutoff : ℕ) : Proc → Proc
| .nil => .nil
| .out a b p => .out (swapNameAt cutoff a) (swapNameAt cutoff b) (swapProc cutoff p)
| .inp a p => .inp (swapNameAt cutoff a) (swapProc (cutoff + 1) p)
| .par p q => .par (swapProc cutoff p) (swapProc cutoff q)
| .nu p => .nu (swapProc (cutoff + 1) p)
| .repl p => .repl (swapProc cutoff p)
| .sum p q => .sum (swapProc cutoff p) (swapProc cutoff q)
CSLibExt/Languages/PiCalculus/Basic.lean:119
Uses 18
TheoremEndpoint substitution preserves conversion ranked typing#✓fully proved
GENERAL endpoint substitution: retain the ACTUAL transmitted capability's code and rank at the sent polarized key, allowing its opposite-role alias. Collision freedom is needed only for that exact key and canonical substitution.
theorem RankedType.subst_endpoint {n : Nat} {Δ : Context} {b : Name} {r : Role}
{c v : Capability} {p : Proc}
(h : RankedType (n + 1) ((Context.lift 0 Δ).insert ⟨.var 0, r⟩ c) p)
(he : v.Equivalent c) (hb : b.ClosedAt n) (hfresh : (⟨b, r⟩ : Key) ∉ Δ) :
RankedType n (Δ.insert ⟨b, r⟩ v) (PiCalculus.subst p b)
abbrev Context := Finmap (fun _ : Key => Capability)
CSLibExt/Languages/SessionTypes/Endpoint/Context.lean:32
inductive Name where
| const (n : ℕ) : Name
| var (i : ℕ) : Name
deriving DecidableEq, Repr
CSLibExt/Languages/PiCalculus/Basic.lean:45
inductive Role where
| positive
| negative
deriving DecidableEq, Repr
CSLibExt/Languages/SessionTypes/Endpoint/Identity.lean:24
structure Capability where
rank : Nat
protocol : Protocol
CSLibExt/Languages/SessionTypes/Endpoint/Context.lean:27
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 RankedType : Nat → Context → Proc → Prop where
| nil {n : Nat} {Δ : Context} :
Δ.Completed → (∀ e ∈ Δ, e.name.ClosedAt n) → RankedType n Δ .nil
| outName {n : Nat} {Δ : Context} {e : Key} {c : Capability}
{b : Name} {s : Protocol} {p : Proc} :
GuardMin Δ e c.rank → Δ.lookup e = some c → c.protocol.unfold = .sendName s →
e.name.ClosedAt n → b.ClosedAt n →
RankedType n (Δ.insert e ⟨c.rank, s⟩) p → RankedType n Δ (.out e.name b p)
| inpName {n : Nat} {Δ : Context} {e : Key} {c : Capability}
{s : Protocol} {p : Proc} :
GuardMin Δ e c.rank → Δ.lookup e = some c → c.protocol.unfold = .recvName s →
e.name.ClosedAt n →
⋯
CSLibExt/Languages/SessionTypes/Endpoint/RankedConversionTyping.lean:30
def Context.lift (k : Nat) (Δ : Context) : Context :=
rekey (Key.mapName (liftName k)) Δ
(fun _ _ _ _ h => Key.mapName_injective (liftName_injective k) h)
CSLibExt/Languages/SessionTypes/Endpoint/ContextTransport.lean:28
structure Key where
name : PiCalculus.Name
role : Role
deriving DecidableEq, Repr
CSLibExt/Languages/SessionTypes/Endpoint/Identity.lean:30
def subst (p : Proc) (n : Name) : Proc := substProc n 0 p
CSLibExt/Languages/PiCalculus/Basic.lean:108
Uses 25 · Used by 1
TheoremSplit-derived freshness for conversion endpoint substitution#✓fully proved
GENERAL split-derived freshness: actual payload ownership and the receiver's already-owned carrier derive non-aliasing even after advancement.
theorem RankedType.subst_endpoint_from_split {n : Nat} {Γ Θ : Context} {b : Name} {r : Role}
{c v old next : Capability} {e : Key} {p : Proc}
(hd : Finmap.Disjoint Γ Θ) (hv : Γ.lookup ⟨b, r⟩ = some v)
(hc : Θ.lookup e = some old)
(h : RankedType (n + 1) ((Context.lift 0 (Θ.insert e next)).insert ⟨.var 0, r⟩ c) p)
(he : v.Equivalent c) (hb : b.ClosedAt n) :
RankedType n ((Θ.insert e next).insert ⟨b, r⟩ v) (PiCalculus.subst p b)
abbrev Context := Finmap (fun _ : Key => Capability)
CSLibExt/Languages/SessionTypes/Endpoint/Context.lean:32
inductive Name where
| const (n : ℕ) : Name
| var (i : ℕ) : Name
deriving DecidableEq, Repr
CSLibExt/Languages/PiCalculus/Basic.lean:45
inductive Role where
| positive
| negative
deriving DecidableEq, Repr
CSLibExt/Languages/SessionTypes/Endpoint/Identity.lean:24
structure Capability where
rank : Nat
protocol : Protocol
CSLibExt/Languages/SessionTypes/Endpoint/Context.lean:27
structure Key where
name : PiCalculus.Name
role : Role
deriving DecidableEq, Repr
CSLibExt/Languages/SessionTypes/Endpoint/Identity.lean:30
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 RankedType : Nat → Context → Proc → Prop where
| nil {n : Nat} {Δ : Context} :
Δ.Completed → (∀ e ∈ Δ, e.name.ClosedAt n) → RankedType n Δ .nil
| outName {n : Nat} {Δ : Context} {e : Key} {c : Capability}
{b : Name} {s : Protocol} {p : Proc} :
GuardMin Δ e c.rank → Δ.lookup e = some c → c.protocol.unfold = .sendName s →
e.name.ClosedAt n → b.ClosedAt n →
RankedType n (Δ.insert e ⟨c.rank, s⟩) p → RankedType n Δ (.out e.name b p)
| inpName {n : Nat} {Δ : Context} {e : Key} {c : Capability}
{s : Protocol} {p : Proc} :
GuardMin Δ e c.rank → Δ.lookup e = some c → c.protocol.unfold = .recvName s →
e.name.ClosedAt n →
⋯
CSLibExt/Languages/SessionTypes/Endpoint/RankedConversionTyping.lean:30
def Context.lift (k : Nat) (Δ : Context) : Context :=
rekey (Key.mapName (liftName k)) Δ
(fun _ _ _ _ h => Key.mapName_injective (liftName_injective k) h)
CSLibExt/Languages/SessionTypes/Endpoint/ContextTransport.lean:28
def subst (p : Proc) (n : Name) : Proc := substProc n 0 p
CSLibExt/Languages/PiCalculus/Basic.lean:108
Uses 14 · Used by 1
TheoremPassive substitution preserves conversion ranked typing#✓fully proved
GENERAL passive substitution transports all scoped positions but adds NO capability. The input context contains only lifted outer ownership.
theorem RankedType.subst_passive {n : Nat} {Δ : Context} {p : Proc} {b : Name}
(h : RankedType (n + 1) (Context.lift 0 Δ) p) (hb : b.ClosedAt n) :
RankedType n Δ (PiCalculus.subst p b)
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 Name where
| const (n : ℕ) : Name
| var (i : ℕ) : Name
deriving DecidableEq, Repr
CSLibExt/Languages/PiCalculus/Basic.lean:45
inductive RankedType : Nat → Context → Proc → Prop where
| nil {n : Nat} {Δ : Context} :
Δ.Completed → (∀ e ∈ Δ, e.name.ClosedAt n) → RankedType n Δ .nil
| outName {n : Nat} {Δ : Context} {e : Key} {c : Capability}
{b : Name} {s : Protocol} {p : Proc} :
GuardMin Δ e c.rank → Δ.lookup e = some c → c.protocol.unfold = .sendName s →
e.name.ClosedAt n → b.ClosedAt n →
RankedType n (Δ.insert e ⟨c.rank, s⟩) p → RankedType n Δ (.out e.name b p)
| inpName {n : Nat} {Δ : Context} {e : Key} {c : Capability}
{s : Protocol} {p : Proc} :
GuardMin Δ e c.rank → Δ.lookup e = some c → c.protocol.unfold = .recvName s →
e.name.ClosedAt n →
⋯
CSLibExt/Languages/SessionTypes/Endpoint/RankedConversionTyping.lean:30
def Context.lift (k : Nat) (Δ : Context) : Context :=
rekey (Key.mapName (liftName k)) Δ
(fun _ _ _ _ h => Key.mapName_injective (liftName_injective k) h)
CSLibExt/Languages/SessionTypes/Endpoint/ContextTransport.lean:28
def subst (p : Proc) (n : Name) : Proc := substProc n 0 p
CSLibExt/Languages/PiCalculus/Basic.lean:108
Uses 19 · Used by 2
TheoremInversion of conversion-ranked input typing#✓fully proved
Input inversion retains its actual advertised code and typed continuation.
theorem RankedType.inp_inv {n : Nat} {Δ : Context} {a : Name} {p : Proc}
(h : RankedType n Δ (.inp a p)) :
∃ e c, e.name = a ∧ Δ.lookup e = some c ∧
((∃ s, c.protocol.unfold = .recvName s ∧
RankedType (n + 1) (Context.lift 0 (Δ.insert e ⟨c.rank, s⟩)) p) ∨
∃ r k t s, c.protocol.unfold = .recvEndpoint r k t s ∧
RankedType (n + 1)
((Context.lift 0 (Δ.insert e ⟨c.rank, s⟩)).insert ⟨.var 0, r⟩ ⟨k, t⟩) p)
abbrev Context := Finmap (fun _ : Key => Capability)
CSLibExt/Languages/SessionTypes/Endpoint/Context.lean:32
inductive Name where
| const (n : ℕ) : Name
| var (i : ℕ) : Name
deriving DecidableEq, Repr
CSLibExt/Languages/PiCalculus/Basic.lean:45
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 RankedType : Nat → Context → Proc → Prop where
| nil {n : Nat} {Δ : Context} :
Δ.Completed → (∀ e ∈ Δ, e.name.ClosedAt n) → RankedType n Δ .nil
| outName {n : Nat} {Δ : Context} {e : Key} {c : Capability}
{b : Name} {s : Protocol} {p : Proc} :
GuardMin Δ e c.rank → Δ.lookup e = some c → c.protocol.unfold = .sendName s →
e.name.ClosedAt n → b.ClosedAt n →
RankedType n (Δ.insert e ⟨c.rank, s⟩) p → RankedType n Δ (.out e.name b p)
| inpName {n : Nat} {Δ : Context} {e : Key} {c : Capability}
{s : Protocol} {p : Proc} :
GuardMin Δ e c.rank → Δ.lookup e = some c → c.protocol.unfold = .recvName s →
e.name.ClosedAt n →
⋯
CSLibExt/Languages/SessionTypes/Endpoint/RankedConversionTyping.lean:30
def Context.lift (k : Nat) (Δ : Context) : Context :=
rekey (Key.mapName (liftName k)) Δ
(fun _ _ _ _ h => Key.mapName_injective (liftName_injective k) h)
CSLibExt/Languages/SessionTypes/Endpoint/ContextTransport.lean:28
Uses 15 · Used by 3
TheoremPassive head communication preserves conversion ranked typing#✓fully proved
GENERAL passive communicating-head preservation at a semantically compatible actual split, with literal receiver-tail and rank evidence.
theorem ranked_passive_head_preservation {n : Nat} {Γ Θ : Context} {e : Key} {c : Capability}
{s : Protocol} {b : Name} {p q : Proc}
(hd : Finmap.Disjoint Γ Θ) (hc : Γ.lookup e = some c)
(hh : c.protocol.unfold = .sendName s)
(hp : RankedType n (Γ.insert e ⟨c.rank, s⟩) p) (hq : RankedType n Θ (.inp e.name q))
(hb : b.ClosedAt n) (hco : Compatible (Γ ∪ Θ)) :
∃ d u, Θ.lookup e.opposite = some d ∧ d.rank = c.rank ∧
d.protocol.unfold = .recvName u ∧ u.TreeEquiv s.dual ∧
RankedType n (((Γ ∪ Θ).insert e ⟨c.rank, s⟩).insert e.opposite ⟨d.rank, u⟩)
(.par p (PiCalculus.subst q b))
abbrev Context := Finmap (fun _ : Key => Capability)
CSLibExt/Languages/SessionTypes/Endpoint/Context.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
inductive Protocol where
| done
| sendName (next : Protocol)
| recvName (next : Protocol)
| sendEndpoint (role : Role) (rank : Nat) (payload next : Protocol)
| recvEndpoint (role : Role) (rank : Nat) (payload next : Protocol)
| regular (graph : Graph) (cursor : Fin graph.size) (reversed : Bool)
CSLibExt/Languages/SessionTypes/Endpoint/Protocol.lean:26
inductive Name where
| const (n : ℕ) : Name
| var (i : ℕ) : Name
deriving DecidableEq, Repr
CSLibExt/Languages/PiCalculus/Basic.lean:45
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 RankedType : Nat → Context → Proc → Prop where
| nil {n : Nat} {Δ : Context} :
Δ.Completed → (∀ e ∈ Δ, e.name.ClosedAt n) → RankedType n Δ .nil
| outName {n : Nat} {Δ : Context} {e : Key} {c : Capability}
{b : Name} {s : Protocol} {p : Proc} :
GuardMin Δ e c.rank → Δ.lookup e = some c → c.protocol.unfold = .sendName s →
e.name.ClosedAt n → b.ClosedAt n →
RankedType n (Δ.insert e ⟨c.rank, s⟩) p → RankedType n Δ (.out e.name b p)
| inpName {n : Nat} {Δ : Context} {e : Key} {c : Capability}
{s : Protocol} {p : Proc} :
GuardMin Δ e c.rank → Δ.lookup e = some c → c.protocol.unfold = .recvName s →
e.name.ClosedAt n →
⋯
CSLibExt/Languages/SessionTypes/Endpoint/RankedConversionTyping.lean:30
def Compatible (Δ : Context) : Prop :=
∀ e c d, Δ.lookup e = some c → Δ.lookup e.opposite = some d → d.Equivalent c.dual
CSLibExt/Languages/SessionTypes/Endpoint/ConversionTyping.lean:57
def subst (p : Proc) (n : Name) : Proc := substProc n 0 p
CSLibExt/Languages/PiCalculus/Basic.lean:108
Uses 26 · Used by 1
TheoremEndpoint head communication preserves conversion ranked typing#✓fully proved
At an initially semantically compatible disjoint split, endpoint head communication transfers EXACT v, retaining the receiver's separately equivalent advertised payload/tail codes.
theorem ranked_endpoint_head_preservation {n k : Nat} {Γ Θ : Context} {e f : Key}
{c v : Capability} {t s : Protocol} {p q : Proc}
(hd : Finmap.Disjoint Γ Θ) (hc : Γ.lookup e = some c)
(hh : c.protocol.unfold = .sendEndpoint f.role k t s)
(hv : Γ.lookup f = some v) (hvt : v.Equivalent ⟨k, t⟩) (hne : e ≠ f)
(hp : RankedType n ((Γ.erase f).insert e ⟨c.rank, s⟩) p)
(hq : RankedType n Θ (.inp e.name q)) (hb : f.name.ClosedAt n)
(hco : Compatible (Γ ∪ Θ)) :
∃ d t' u, Θ.lookup e.opposite = some d ∧ d.rank = c.rank ∧
d.protocol.unfold = .recvEndpoint f.role k t' u ∧ t'.TreeEquiv t ∧ u.TreeEquiv s.dual ∧
RankedType n (((Γ ∪ Θ).insert e ⟨c.rank, s⟩).insert e.opposite ⟨d.rank, u⟩)
(.par p (PiCalculus.subst q f.name))
abbrev Context := Finmap (fun _ : Key => Capability)
CSLibExt/Languages/SessionTypes/Endpoint/Context.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
inductive Protocol where
| done
| sendName (next : Protocol)
| recvName (next : Protocol)
| sendEndpoint (role : Role) (rank : Nat) (payload next : Protocol)
| recvEndpoint (role : Role) (rank : Nat) (payload next : Protocol)
| regular (graph : Graph) (cursor : Fin graph.size) (reversed : Bool)
CSLibExt/Languages/SessionTypes/Endpoint/Protocol.lean:26
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 RankedType : Nat → Context → Proc → Prop where
| nil {n : Nat} {Δ : Context} :
Δ.Completed → (∀ e ∈ Δ, e.name.ClosedAt n) → RankedType n Δ .nil
| outName {n : Nat} {Δ : Context} {e : Key} {c : Capability}
{b : Name} {s : Protocol} {p : Proc} :
GuardMin Δ e c.rank → Δ.lookup e = some c → c.protocol.unfold = .sendName s →
e.name.ClosedAt n → b.ClosedAt n →
RankedType n (Δ.insert e ⟨c.rank, s⟩) p → RankedType n Δ (.out e.name b p)
| inpName {n : Nat} {Δ : Context} {e : Key} {c : Capability}
{s : Protocol} {p : Proc} :
GuardMin Δ e c.rank → Δ.lookup e = some c → c.protocol.unfold = .recvName s →
e.name.ClosedAt n →
⋯
CSLibExt/Languages/SessionTypes/Endpoint/RankedConversionTyping.lean:30
def Compatible (Δ : Context) : Prop :=
∀ e c d, Δ.lookup e = some c → Δ.lookup e.opposite = some d → d.Equivalent c.dual
CSLibExt/Languages/SessionTypes/Endpoint/ConversionTyping.lean:57
def subst (p : Proc) (n : Name) : Proc := substProc n 0 p
CSLibExt/Languages/PiCalculus/Basic.lean:108
Uses 28 · Used by 1
TheoremHead preservation for a conversion-ranked opposite pair#✓fully proved
A typed opposite-head pair at an initially semantically compatible interface yields packed literal-head preservation. Both actual heads and payload/tail correspondence are conclusions, not fields in a protocol or admission predicate.
theorem RankedType.head_preservation {n : Nat} {Δ : Context} {a b : Name} {p q : Proc}
(h : RankedType n Δ (.par (.out a b p) (.inp a q))) (hco : Compatible Δ) :
∃ e c d s u, e.name = a ∧ Δ.lookup e = some c ∧ Δ.lookup e.opposite = some d ∧
d.rank = c.rank ∧ u.TreeEquiv s.dual ∧
((c.protocol.unfold = .sendName s ∧ d.protocol.unfold = .recvName u) ∨
∃ f v k t t', f.name = b ∧ Δ.lookup f = some v ∧ v.Equivalent ⟨k, t⟩ ∧
c.protocol.unfold = .sendEndpoint f.role k t s ∧
d.protocol.unfold = .recvEndpoint f.role k t' u ∧ t'.TreeEquiv t) ∧
RankedType n ((Δ.insert e ⟨c.rank, s⟩).insert e.opposite ⟨d.rank, u⟩)
(.par p (PiCalculus.subst q b))
abbrev Context := Finmap (fun _ : Key => Capability)
CSLibExt/Languages/SessionTypes/Endpoint/Context.lean:32
inductive Name where
| const (n : ℕ) : Name
| var (i : ℕ) : Name
deriving DecidableEq, Repr
CSLibExt/Languages/PiCalculus/Basic.lean:45
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 RankedType : Nat → Context → Proc → Prop where
| nil {n : Nat} {Δ : Context} :
Δ.Completed → (∀ e ∈ Δ, e.name.ClosedAt n) → RankedType n Δ .nil
| outName {n : Nat} {Δ : Context} {e : Key} {c : Capability}
{b : Name} {s : Protocol} {p : Proc} :
GuardMin Δ e c.rank → Δ.lookup e = some c → c.protocol.unfold = .sendName s →
e.name.ClosedAt n → b.ClosedAt n →
RankedType n (Δ.insert e ⟨c.rank, s⟩) p → RankedType n Δ (.out e.name b p)
| inpName {n : Nat} {Δ : Context} {e : Key} {c : Capability}
{s : Protocol} {p : Proc} :
GuardMin Δ e c.rank → Δ.lookup e = some c → c.protocol.unfold = .recvName s →
e.name.ClosedAt n →
⋯
CSLibExt/Languages/SessionTypes/Endpoint/RankedConversionTyping.lean:30
def Compatible (Δ : Context) : Prop :=
∀ e c d, Δ.lookup e = some c → Δ.lookup e.opposite = some d → d.Equivalent c.dual
CSLibExt/Languages/SessionTypes/Endpoint/ConversionTyping.lean:57
def subst (p : Proc) (n : Name) : Proc := substProc n 0 p
CSLibExt/Languages/PiCalculus/Basic.lean:108
Uses 22 · Used by 1
TheoremConversion head communication yields a semantic advance#✓fully proved
For a ranked-typed opposite-head pair at an initially semantically compatible interface, head preservation constructs a faithful semantic advance and a compatible ranked residual.
theorem RankedType.head_advance {n : Nat} {Δ : Context} {a b : Name} {p q : Proc}
(h : RankedType n Δ (.par (.out a b p) (.inp a q))) (hc : Compatible Δ) :
∃ Ξ, RankedType n Ξ (.par p (PiCalculus.subst q b)) ∧ Compatible Ξ ∧ SemanticAdvance Δ Ξ
abbrev Context := Finmap (fun _ : Key => Capability)
CSLibExt/Languages/SessionTypes/Endpoint/Context.lean:32
inductive Name where
| const (n : ℕ) : Name
| var (i : ℕ) : Name
deriving DecidableEq, Repr
CSLibExt/Languages/PiCalculus/Basic.lean:45
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 RankedType : Nat → Context → Proc → Prop where
| nil {n : Nat} {Δ : Context} :
Δ.Completed → (∀ e ∈ Δ, e.name.ClosedAt n) → RankedType n Δ .nil
| outName {n : Nat} {Δ : Context} {e : Key} {c : Capability}
{b : Name} {s : Protocol} {p : Proc} :
GuardMin Δ e c.rank → Δ.lookup e = some c → c.protocol.unfold = .sendName s →
e.name.ClosedAt n → b.ClosedAt n →
RankedType n (Δ.insert e ⟨c.rank, s⟩) p → RankedType n Δ (.out e.name b p)
| inpName {n : Nat} {Δ : Context} {e : Key} {c : Capability}
{s : Protocol} {p : Proc} :
GuardMin Δ e c.rank → Δ.lookup e = some c → c.protocol.unfold = .recvName s →
e.name.ClosedAt n →
⋯
CSLibExt/Languages/SessionTypes/Endpoint/RankedConversionTyping.lean:30
def Compatible (Δ : Context) : Prop :=
∀ e c d, Δ.lookup e = some c → Δ.lookup e.opposite = some d → d.Equivalent c.dual
CSLibExt/Languages/SessionTypes/Endpoint/ConversionTyping.lean:57
def subst (p : Proc) (n : Name) : Proc := substProc n 0 p
CSLibExt/Languages/PiCalculus/Basic.lean:108
inductive SemanticAdvance : Context → Context → Prop where
| matched {Δ : Context} {e : Key} {c d : Capability} {s u : Protocol} :
Δ.lookup e = some c → Δ.lookup e.opposite = some d → d.Equivalent c.dual →
CommunicationHeads c d s u → u.TreeEquiv s.dual →
SemanticAdvance Δ ((Δ.insert e ⟨c.rank, s⟩).insert e.opposite ⟨d.rank, u⟩)
CSLibExt/Languages/SessionTypes/Endpoint/SemanticAdvance.lean:38
Uses 20 · Used by 1
TheoremSame-name conversion guards are opposite and communicate#✓fully proved
For disjoint ranked-typed same-name leaves at a semantically compatible combined interface, literal guard shapes have opposite directions and yield an actual canonical Step.
theorem same_name_guards_step {n : Nat} {Γ Θ : Context} {g h : Proc} {a : Name}
(hg : RankedType n Γ g) (hh : RankedType n Θ h)
(hd : Finmap.Disjoint Γ Θ) (hc : Compatible (Γ ∪ Θ))
(sg : (∃ b p, g = .out a b p) ∨ (∃ p, g = .inp a p))
(sh : (∃ b p, h = .out a b p) ∨ (∃ p, h = .inp a p)) :
∃ q, PiCalculus.Step (.par g h) q
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 Name where
| const (n : ℕ) : Name
| var (i : ℕ) : Name
deriving DecidableEq, Repr
CSLibExt/Languages/PiCalculus/Basic.lean:45
inductive RankedType : Nat → Context → Proc → Prop where
| nil {n : Nat} {Δ : Context} :
Δ.Completed → (∀ e ∈ Δ, e.name.ClosedAt n) → RankedType n Δ .nil
| outName {n : Nat} {Δ : Context} {e : Key} {c : Capability}
{b : Name} {s : Protocol} {p : Proc} :
GuardMin Δ e c.rank → Δ.lookup e = some c → c.protocol.unfold = .sendName s →
e.name.ClosedAt n → b.ClosedAt n →
RankedType n (Δ.insert e ⟨c.rank, s⟩) p → RankedType n Δ (.out e.name b p)
| inpName {n : Nat} {Δ : Context} {e : Key} {c : Capability}
{s : Protocol} {p : Proc} :
GuardMin Δ e c.rank → Δ.lookup e = some c → c.protocol.unfold = .recvName s →
e.name.ClosedAt n →
⋯
CSLibExt/Languages/SessionTypes/Endpoint/RankedConversionTyping.lean:30
def Compatible (Δ : Context) : Prop :=
∀ e c d, Δ.lookup e = some c → Δ.lookup e.opposite = some d → d.Equivalent c.dual
CSLibExt/Languages/SessionTypes/Endpoint/ConversionTyping.lean:57
inductive Step : Proc → Proc → Prop
| commSelect {a : Name} {b : Name} {p' q' p q : Proc} :
Select p (.out a b p') → Select q (.inp a q') →
Step (.par p q) (.par p' (subst q' b))
| parL {p p' q : Proc} : Step p p' → Step (.par p q) (.par p' q)
| parR {p p' q : Proc} : Step p p' → Step (.par q p) (.par q p')
| nu {p p' : Proc} : Step p p' → Step (.nu p) (.nu p')
| cong {p p' q q' : Proc} : Cong p p' → Step p' q' → Cong q' q →
Step p q
CSLibExt/Languages/PiCalculus/Basic.lean:172
Uses 29 · Used by 1
TheoremProgress for semantically balanced conversion frontiers#✓fully proved
GENERAL balanced ranked frontier progress. A minimum over ALL active owned roles exposes two distinct opposite subject leaves, from which actual canonical communication follows. Completion is process-level Cong to nil.
theorem GuardFrontier.progress {n : Nat} {Δ : Context} {p : Proc}
(hf : GuardFrontier p) (ht : RankedType n Δ p) (hb : Balanced Δ) :
Cong p .nil ∨ ∃ q, PiCalculus.Step p q
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 GuardFrontier : Proc → Prop where
| nil : GuardFrontier .nil
| out (a b : Name) (p : Proc) : GuardFrontier (.out a b p)
| inp (a : Name) (p : Proc) : GuardFrontier (.inp a p)
| par {p q : Proc} : GuardFrontier p → GuardFrontier q → GuardFrontier (.par p q)
CSLibExt/Languages/SessionTypes/Endpoint/FrontierNormalization.lean:29
inductive RankedType : Nat → Context → Proc → Prop where
| nil {n : Nat} {Δ : Context} :
Δ.Completed → (∀ e ∈ Δ, e.name.ClosedAt n) → RankedType n Δ .nil
| outName {n : Nat} {Δ : Context} {e : Key} {c : Capability}
{b : Name} {s : Protocol} {p : Proc} :
GuardMin Δ e c.rank → Δ.lookup e = some c → c.protocol.unfold = .sendName s →
e.name.ClosedAt n → b.ClosedAt n →
RankedType n (Δ.insert e ⟨c.rank, s⟩) p → RankedType n Δ (.out e.name b p)
| inpName {n : Nat} {Δ : Context} {e : Key} {c : Capability}
{s : Protocol} {p : Proc} :
GuardMin Δ e c.rank → Δ.lookup e = some c → c.protocol.unfold = .recvName s →
e.name.ClosedAt n →
⋯
CSLibExt/Languages/SessionTypes/Endpoint/RankedConversionTyping.lean:30
def Balanced (Δ : Context) : Prop :=
∀ e c, Δ.lookup e = some c → ∃ d, Δ.lookup e.opposite = some d ∧ d.Equivalent c.dual
CSLibExt/Languages/SessionTypes/Endpoint/SemanticAdvance.lean:45
inductive Cong : Proc → Proc → Prop
| refl (p : Proc) : Cong p p
| symm {p q : Proc} : Cong p q → Cong q p
| trans {p q r : Proc} : Cong p q → Cong q r → Cong p r
| par_comm (p q : Proc) : Cong (.par p q) (.par q p)
| par_assoc (p q r : Proc) : Cong (.par (.par p q) r) (.par p (.par q r))
| par_nil (p : Proc) : Cong (.par p .nil) p
| par_cong {p p' q q' : Proc} : Cong p p' → Cong q q' →
Cong (.par p q) (.par p' q')
| nu_cong {p p' : Proc} : Cong p p' → Cong (.nu p) (.nu p')
| scope (p q : Proc) :
Cong (.par (.nu p) q) (.nu (.par p (liftProc 0 q)))
⋯
CSLibExt/Languages/PiCalculus/Basic.lean:137
inductive Step : Proc → Proc → Prop
| commSelect {a : Name} {b : Name} {p' q' p q : Proc} :
Select p (.out a b p') → Select q (.inp a q') →
Step (.par p q) (.par p' (subst q' b))
| parL {p p' q : Proc} : Step p p' → Step (.par p q) (.par p' q)
| parR {p p' q : Proc} : Step p p' → Step (.par q p) (.par q p')
| nu {p p' : Proc} : Step p p' → Step (.nu p) (.nu p')
| cong {p p' q q' : Proc} : Cong p p' → Step p' q' → Cong q' q →
Step p q
CSLibExt/Languages/PiCalculus/Basic.lean:172
Uses 28 · Used by 1
TheoremConversion ranked typing descends from a lifted process#✓fully proved
Reflection of an actual lifted term recovers every priority and context entry.
theorem RankedType.unlift {n : Nat} {Γ : Context} {q : Proc}
(h : RankedType (n + 1) Γ (liftProc 0 q)) (hΓ : ∀ e ∈ Γ, e.name ≠ .var 0) :
RankedType n (Context.lower Γ hΓ) q
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 RankedType : Nat → Context → Proc → Prop where
| nil {n : Nat} {Δ : Context} :
Δ.Completed → (∀ e ∈ Δ, e.name.ClosedAt n) → RankedType n Δ .nil
| outName {n : Nat} {Δ : Context} {e : Key} {c : Capability}
{b : Name} {s : Protocol} {p : Proc} :
GuardMin Δ e c.rank → Δ.lookup e = some c → c.protocol.unfold = .sendName s →
e.name.ClosedAt n → b.ClosedAt n →
RankedType n (Δ.insert e ⟨c.rank, s⟩) p → RankedType n Δ (.out e.name b p)
| inpName {n : Nat} {Δ : Context} {e : Key} {c : Capability}
{s : Protocol} {p : Proc} :
GuardMin Δ e c.rank → Δ.lookup e = some c → c.protocol.unfold = .recvName s →
e.name.ClosedAt n →
⋯
CSLibExt/Languages/SessionTypes/Endpoint/RankedConversionTyping.lean:30
def liftProc (cutoff : ℕ) : Proc → Proc
| .nil => .nil
| .out a b p => .out (liftName cutoff a) (liftName cutoff b) (liftProc cutoff p)
| .inp a p => .inp (liftName cutoff a) (liftProc (cutoff + 1) p)
| .par p q => .par (liftProc cutoff p) (liftProc cutoff q)
| .nu p => .nu (liftProc (cutoff + 1) p)
| .repl p => .repl (liftProc cutoff p)
| .sum p q => .sum (liftProc cutoff p) (liftProc cutoff q)
CSLibExt/Languages/PiCalculus/Basic.lean:70
def Context.lower (Γ : Context) (hΓ : ∀ e ∈ Γ, e.name ≠ .var 0) : Context :=
Context.rekey (Key.mapName (substName (.const 0) 0)) Γ (Context.injOn_lower hΓ)
CSLibExt/Languages/SessionTypes/Endpoint/UnliftContext.lean:53
Uses 14 · Used by 1
TheoremForward scope extrusion preserves conversion ranked typing#✓fully proved
Extrusion lifts the partner's real ownership while retaining every guard.
theorem RankedType.scope_forward {n : Nat} {Δ : Context} {p q : Proc}
(h : RankedType n Δ (.par (.nu p) q)) :
RankedType n Δ (.nu (.par p (liftProc 0 q)))
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 RankedType : Nat → Context → Proc → Prop where
| nil {n : Nat} {Δ : Context} :
Δ.Completed → (∀ e ∈ Δ, e.name.ClosedAt n) → RankedType n Δ .nil
| outName {n : Nat} {Δ : Context} {e : Key} {c : Capability}
{b : Name} {s : Protocol} {p : Proc} :
GuardMin Δ e c.rank → Δ.lookup e = some c → c.protocol.unfold = .sendName s →
e.name.ClosedAt n → b.ClosedAt n →
RankedType n (Δ.insert e ⟨c.rank, s⟩) p → RankedType n Δ (.out e.name b p)
| inpName {n : Nat} {Δ : Context} {e : Key} {c : Capability}
{s : Protocol} {p : Proc} :
GuardMin Δ e c.rank → Δ.lookup e = some c → c.protocol.unfold = .recvName s →
e.name.ClosedAt n →
⋯
CSLibExt/Languages/SessionTypes/Endpoint/RankedConversionTyping.lean:30
def liftProc (cutoff : ℕ) : Proc → Proc
| .nil => .nil
| .out a b p => .out (liftName cutoff a) (liftName cutoff b) (liftProc cutoff p)
| .inp a p => .inp (liftName cutoff a) (liftProc (cutoff + 1) p)
| .par p q => .par (liftProc cutoff p) (liftProc cutoff q)
| .nu p => .nu (liftProc (cutoff + 1) p)
| .repl p => .repl (liftProc cutoff p)
| .sum p q => .sum (liftProc cutoff p) (liftProc cutoff q)
CSLibExt/Languages/PiCalculus/Basic.lean:70
Uses 15 · Used by 1
TheoremAdding a role unused by the partner preserves conversion ranked typing#✓fully proved
Moving a partner-owned role back requires actual absence to DERIVE completion from conversion typing before refined completed weakening is applied.
theorem RankedType.insert_from_absent_partner {n : Nat} {Γ Ξ : Context} {p q : Proc}
{e : Key} {c : Capability} (hp : RankedType n Γ p) (hq : RankedType n Ξ q)
(hc : (Γ ∪ Ξ).lookup e = some c) (hab : NameAbsent e.name q)
(he : e.name.ClosedAt n) : RankedType n (Γ.insert e c) p
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
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
inductive RankedType : Nat → Context → Proc → Prop where
| nil {n : Nat} {Δ : Context} :
Δ.Completed → (∀ e ∈ Δ, e.name.ClosedAt n) → RankedType n Δ .nil
| outName {n : Nat} {Δ : Context} {e : Key} {c : Capability}
{b : Name} {s : Protocol} {p : Proc} :
GuardMin Δ e c.rank → Δ.lookup e = some c → c.protocol.unfold = .sendName s →
e.name.ClosedAt n → b.ClosedAt n →
RankedType n (Δ.insert e ⟨c.rank, s⟩) p → RankedType n Δ (.out e.name b p)
| inpName {n : Nat} {Δ : Context} {e : Key} {c : Capability}
{s : Protocol} {p : Proc} :
GuardMin Δ e c.rank → Δ.lookup e = some c → c.protocol.unfold = .recvName s →
e.name.ClosedAt n →
⋯
CSLibExt/Languages/SessionTypes/Endpoint/RankedConversionTyping.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 13 · Used by 1
Loading dependency explorer…
The dependency explorer needs JavaScript and its graph data.