Finite sessions with unrestricted name data
InductiveFinite binary session types#✓fully proved
Finite binary protocols carrying unrestricted, passive names.
inductive SessionType where
| end : SessionType
| send (next : SessionType) : SessionType
| recv (next : SessionType) : SessionType
deriving DecidableEq, Repr
Used by 31
DefinitionDual of a session type#✓fully proved
Exchange the endpoint's send and receive obligations.
def SessionType.dual : SessionType → SessionType
| .end => .end
| .send s => .recv s.dual
| .recv s => .send s.dual
inductive SessionType where
| end : SessionType
| send (next : SessionType) : SessionType
| recv (next : SessionType) : SessionType
deriving DecidableEq, Repr
CSLibExt/Languages/SessionTypes/Basic.lean:63
Uses 1 · Used by 11
TheoremSession type duality is an involution#✓fully proved
Duality is an involution, including at completion.
@[simp] theorem SessionType.dual_dual (s : SessionType) :
s.dual.dual = s
inductive SessionType where
| end : SessionType
| send (next : SessionType) : SessionType
| recv (next : SessionType) : SessionType
deriving DecidableEq, Repr
CSLibExt/Languages/SessionTypes/Basic.lean:63
Uses 2
DefinitionLength of a session type#✓fully proved
Number of communication actions remaining in a finite protocol.
def SessionType.length : SessionType → Nat
| .end => 0
| .send s => s.length + 1
| .recv s => s.length + 1
inductive SessionType where
| end : SessionType
| send (next : SessionType) : SessionType
| recv (next : SessionType) : SessionType
deriving DecidableEq, Repr
CSLibExt/Languages/SessionTypes/Basic.lean:63
Uses 1 · Used by 1
TheoremDual session types have equal length#✓fully proved
Opposite endpoint roles have the same number of actions.
@[simp] theorem SessionType.length_dual (s : SessionType) :
s.dual.length = s.length
inductive SessionType where
| end : SessionType
| send (next : SessionType) : SessionType
| recv (next : SessionType) : SessionType
deriving DecidableEq, Repr
CSLibExt/Languages/SessionTypes/Basic.lean:63
Uses 3
AbbreviationPer-channel session context of a thread#✓fully proved
One linear endpoint obligation per physical channel in a thread.
abbrev Context := Nat → SessionType
inductive SessionType where
| end : SessionType
| send (next : SessionType) : SessionType
| recv (next : SessionType) : SessionType
deriving DecidableEq, Repr
CSLibExt/Languages/SessionTypes/Basic.lean:63
Uses 1 · Used by 29
DefinitionAdvancing one endpoint of a session context#✓fully proved
Advance just the communicating endpoint; other obligations are unchanged.
def advance (Γ : Context) (a : Nat) (s : SessionType) : Context :=
fun c => if c = a then s else Γ c
abbrev Context := Nat → SessionType
CSLibExt/Languages/SessionTypes/Basic.lean:92
inductive SessionType where
| end : SessionType
| send (next : SessionType) : SessionType
| recv (next : SessionType) : SessionType
deriving DecidableEq, Repr
CSLibExt/Languages/SessionTypes/Basic.lean:63
Uses 2 · Used by 14
DefinitionPointwise dual of a session context#✓fully proved
The opposite endpoint roles, pointwise.
def dualContext (Γ : Context) : Context := fun c => (Γ c).dual
abbrev Context := Nat → SessionType
CSLibExt/Languages/SessionTypes/Basic.lean:92
Uses 2 · Used by 8
TheoremDualizing a context commutes with advancing an endpoint#✓fully proved
Advancing dual endpoints preserves pointwise compatibility.
theorem dualContext_advance (Γ : Context) (a : Nat) (s : SessionType) :
dualContext (advance Γ a s) = advance (dualContext Γ) a s.dual
abbrev Context := Nat → SessionType
CSLibExt/Languages/SessionTypes/Basic.lean:92
inductive SessionType where
| end : SessionType
| send (next : SessionType) : SessionType
| recv (next : SessionType) : SessionType
deriving DecidableEq, Repr
CSLibExt/Languages/SessionTypes/Basic.lean:63
def dualContext (Γ : Context) : Context := fun c => (Γ c).dual
CSLibExt/Languages/SessionTypes/Basic.lean:99
def advance (Γ : Context) (a : Nat) (s : SessionType) : Context :=
fun c => if c = a then s else Γ c
CSLibExt/Languages/SessionTypes/Basic.lean:95
Uses 5 · Used by 2
InductiveLinear session typing of sequential threads#✓fully proved
Linear typing of finite sequential threads in the existing π syntax.
nil consumes only completed obligations. Input-bound names are unrestricted
payloads, never session subjects; there is no parallel duplication rule.
inductive HasType : Nat → Context → Proc → Prop where
| nil {n : Nat} {Γ : Context} : (∀ c, Γ c = .end) → HasType n Γ .nil
| out {n a : Nat} {Γ : Context} {b : Name} {s : SessionType} {p : Proc} :
Γ a = .send s → b.ClosedAt n → HasType n (advance Γ a s) p →
HasType n Γ (.out (.const a) b p)
| inp {n a : Nat} {Γ : Context} {s : SessionType} {p : Proc} :
Γ a = .recv s → HasType (n + 1) (advance Γ a s) p →
HasType n Γ (.inp (.const a) p)
abbrev Context := Nat → SessionType
CSLibExt/Languages/SessionTypes/Basic.lean:92
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 SessionType where
| end : SessionType
| send (next : SessionType) : SessionType
| recv (next : SessionType) : SessionType
deriving DecidableEq, Repr
CSLibExt/Languages/SessionTypes/Basic.lean:63
def advance (Γ : Context) (a : Nat) (s : SessionType) : Context :=
fun c => if c = a then s else Γ c
CSLibExt/Languages/SessionTypes/Basic.lean:95
Uses 6 · Used by 14
TheoremPayload substitution at any cutoff preserves session typing#✓fully proved
Capture-avoiding payload substitution preserves every linear obligation, including through nested input binders and at nonzero cutoffs.
theorem HasType.substProc {n k : Nat} {Γ : Context} {p : Proc} {b : Name}
(h : HasType (n + 1) Γ p) (hb : b.ClosedAt n) (hk : k ≤ n) :
HasType n Γ (PiCalculus.substProc b k p)
abbrev Context := Nat → SessionType
CSLibExt/Languages/SessionTypes/Basic.lean:92
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 HasType : Nat → Context → Proc → Prop where
| nil {n : Nat} {Γ : Context} : (∀ c, Γ c = .end) → HasType n Γ .nil
| out {n a : Nat} {Γ : Context} {b : Name} {s : SessionType} {p : Proc} :
Γ a = .send s → b.ClosedAt n → HasType n (advance Γ a s) p →
HasType n Γ (.out (.const a) b p)
| inp {n a : Nat} {Γ : Context} {s : SessionType} {p : Proc} :
Γ a = .recv s → HasType (n + 1) (advance Γ a s) p →
HasType n Γ (.inp (.const a) p)
CSLibExt/Languages/SessionTypes/Basic.lean:111
def substProc (n : Name) : ℕ → Proc → Proc
| _, .nil => .nil
| cutoff, .out a b p =>
.out (substName n cutoff a) (substName n cutoff b) (substProc n cutoff p)
| cutoff, .inp a p =>
.inp (substName n cutoff a) (substProc (liftName 0 n) (cutoff + 1) p)
| cutoff, .par p q => .par (substProc n cutoff p) (substProc n cutoff q)
| cutoff, .nu p => .nu (substProc (liftName 0 n) (cutoff + 1) p)
| cutoff, .repl p => .repl (substProc n cutoff p)
| cutoff, .sum p q => .sum (substProc n cutoff p) (substProc n cutoff q)
CSLibExt/Languages/PiCalculus/Basic.lean:96
Uses 12 · Used by 1
TheoremReceiving a closed name preserves session typing#✓fully proved
Receiving a closed name preserves the residual thread's typing.
theorem HasType.subst {Γ : Context} {p : Proc} {b : Name}
(h : HasType 1 Γ p) (hb : b.ClosedAt 0) :
HasType 0 Γ (PiCalculus.subst p b)
abbrev Context := Nat → SessionType
CSLibExt/Languages/SessionTypes/Basic.lean:92
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 HasType : Nat → Context → Proc → Prop where
| nil {n : Nat} {Γ : Context} : (∀ c, Γ c = .end) → HasType n Γ .nil
| out {n a : Nat} {Γ : Context} {b : Name} {s : SessionType} {p : Proc} :
Γ a = .send s → b.ClosedAt n → HasType n (advance Γ a s) p →
HasType n Γ (.out (.const a) b p)
| inp {n a : Nat} {Γ : Context} {s : SessionType} {p : Proc} :
Γ a = .recv s → HasType (n + 1) (advance Γ a s) p →
HasType n Γ (.inp (.const a) p)
CSLibExt/Languages/SessionTypes/Basic.lean:111
def subst (p : Proc) (n : Name) : Proc := substProc n 0 p
CSLibExt/Languages/PiCalculus/Basic.lean:108
TheoremSession typing derivations have finite support#✓fully proved
A derivation has only finitely many active channel obligations: above some bound every channel is completed. Contexts are total functions.
theorem HasType.finite_support {n : Nat} {Γ : Context} {p : Proc}
(h : HasType n Γ p) : ∃ bound, ∀ c, bound ≤ c → Γ c = .end
abbrev Context := Nat → SessionType
CSLibExt/Languages/SessionTypes/Basic.lean:92
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 → Context → Proc → Prop where
| nil {n : Nat} {Γ : Context} : (∀ c, Γ c = .end) → HasType n Γ .nil
| out {n a : Nat} {Γ : Context} {b : Name} {s : SessionType} {p : Proc} :
Γ a = .send s → b.ClosedAt n → HasType n (advance Γ a s) p →
HasType n Γ (.out (.const a) b p)
| inp {n a : Nat} {Γ : Context} {s : SessionType} {p : Proc} :
Γ a = .recv s → HasType (n + 1) (advance Γ a s) p →
HasType n Γ (.inp (.const a) p)
CSLibExt/Languages/SessionTypes/Basic.lean:111
TheoremSession-typed threads are well scoped#✓fully proved
Every typed thread satisfies the shared π name/process scoping predicate. Free session constants remain permitted; this is not ν-closedness.
theorem HasType.closedAt {n : Nat} {Γ : Context} {p : Proc}
(h : HasType n Γ p) : p.ClosedAt n
abbrev Context := Nat → SessionType
CSLibExt/Languages/SessionTypes/Basic.lean:92
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 → Context → Proc → Prop where
| nil {n : Nat} {Γ : Context} : (∀ c, Γ c = .end) → HasType n Γ .nil
| out {n a : Nat} {Γ : Context} {b : Name} {s : SessionType} {p : Proc} :
Γ a = .send s → b.ClosedAt n → HasType n (advance Γ a s) p →
HasType n Γ (.out (.const a) b p)
| inp {n a : Nat} {Γ : Context} {s : SessionType} {p : Proc} :
Γ a = .recv s → HasType (n + 1) (advance Γ a s) p →
HasType n Γ (.inp (.const a) p)
CSLibExt/Languages/SessionTypes/Basic.lean:111
Loading dependency explorer…
The dependency explorer needs JavaScript and its graph data.