Documentation

CslibFrontier.Computability.Distributed.ConcurrentObjects.Linearizability.CallIndex

Sequential call indexing and completion helpers #

Shared internal lemmas on History, OpCall, nthProcPos, and sequential call indexing (opIdAt, countProcCalls) used across the locality, nonblocking, and register-separation modules.

Main definitions #

Main results #

theorem Cslib.Distributed.ConcurrentObjects.History.mem_of_mem_complete {P : Type u_1} {Obj : Type u_2} {Op : Obj → Type u_3} {Resp : Obj → Type u_4} [DecidableEq P] {M : History P Op Resp} {e : Event P Op Resp} (hm : e ∈ M.complete) :
e ∈ M

Every event retained in complete M belongs to M.

theorem Cslib.Distributed.ConcurrentObjects.History.isSequential_append_left {P : Type u_1} {Obj : Type u_2} {Op : Obj → Type u_3} {Resp : Obj → Type u_4} {L₁ L₂ : History P Op Resp} :
(L₁ ++ L₂).IsSequential → L₁.IsSequential

Prefix closure of IsSequential under ++.

theorem Cslib.Distributed.ConcurrentObjects.History.isSequential_flatMap_toEvents_append_inv {P : Type u_1} {Obj : Type u_2} {Op : Obj → Type u_3} {Resp : Obj → Type u_4} (cs : List (OpCall P Op Resp)) (p : P) (x : Obj) (op : Op x) :

Completed OpCalls followed by a single pending invocation form a sequential history.

theorem Cslib.Distributed.ConcurrentObjects.History.complete_flatMap_append_inv {P : Type u_1} {Obj : Type u_2} {Op : Obj → Type u_3} {Resp : Obj → Type u_4} [DecidableEq P] (cs : List (OpCall P Op Resp)) (q : P) (y : Obj) (op : Op y) :

complete drops a trailing pending invocation after a list of completed OpCalls.

theorem Cslib.Distributed.ConcurrentObjects.History.isCompletedOp_complete_iff {P : Type u_1} {Obj : Type u_2} {Op : Obj → Type u_3} {Resp : Obj → Type u_4} [DecidableEq P] {M : History P Op Resp} (hwf : M.WellFormed) (e : OpId P) :

Completing a well-formed history preserves the set of completed operations.

theorem Cslib.Distributed.ConcurrentObjects.History.even_length_of_equivalent_complete {P : Type u_1} {Obj : Type u_2} {Op : Obj → Type u_3} {Resp : Obj → Type u_4} [DecidableEq P] {H S : History P Op Resp} (hwf : H.WellFormed) (hseq : S.IsSequential) (heq : H.complete.Equivalent S) :

Any sequential history equivalent to complete H (for well-formed H) has even length.

theorem Cslib.Distributed.ConcurrentObjects.History.isRespList_eq_nil_of_isSequential_even {P : Type u_1} {Obj : Type u_2} {Op : Obj → Type u_3} {Resp : Obj → Type u_4} {L R : History P Op Resp} (hseq : L.IsSequential) (heven : List.length L % 2 = 0) (hresp : R.IsRespList) (hseq_app : (L ++ R).IsSequential) :
R = []

An even-length sequential history admits no nonempty response-only sequential suffix.

theorem Cslib.Distributed.ConcurrentObjects.History.isRespList_le_one_of_isSequential {P : Type u_1} {Obj : Type u_2} {Op : Obj → Type u_3} {Resp : Obj → Type u_4} {L R : History P Op Resp} (hseq : L.IsSequential) (hresp : R.IsRespList) (hseq_app : (L ++ R).IsSequential) :
R = [] ∨ ∃ (cs : List (OpCall P Op Resp)) (p : P) (x : Obj) (op : Op x) (res : Resp x), L = List.flatMap OpCall.toEvents cs ++ [Event.inv p x op] ∧ R = [Event.resp p x res]

A response-only sequential extension R of a sequential history L is either empty or a single matching response to L's trailing pending invocation.

theorem Cslib.Distributed.ConcurrentObjects.History.nthProcPos_isSome_iff {P : Type u_1} {Obj : Type u_2} {Op : Obj → Type u_3} {Resp : Obj → Type u_4} [DecidableEq P] (p : P) (H : History P Op Resp) (n : ℕ) :

nthProcPos p H n is some iff n < (H | p).length.

theorem Cslib.Distributed.ConcurrentObjects.History.nthProcPos_lt_length {P : Type u_1} {Obj : Type u_2} {Op : Obj → Type u_3} {Resp : Obj → Type u_4} [DecidableEq P] {p : P} {H : History P Op Resp} {n pos : ℕ} (h : nthProcPos p H n = some pos) :

Bounds and process projection at nthProcPos p H n = some pos.

theorem Cslib.Distributed.ConcurrentObjects.History.nthProcPos_getElem? {P : Type u_1} {Obj : Type u_2} {Op : Obj → Type u_3} {Resp : Obj → Type u_4} [DecidableEq P] {p : P} {H : History P Op Resp} {n pos : ℕ} (h : nthProcPos p H n = some pos) :

Lookup at nthProcPos p H n = some pos agrees with (H | p)[n]?.

theorem Cslib.Distributed.ConcurrentObjects.History.nthProcPos_strictMono {P : Type u_1} {Obj : Type u_2} {Op : Obj → Type u_3} {Resp : Obj → Type u_4} [DecidableEq P] {p : P} {H : History P Op Resp} {m n i j : ℕ} (hmn : m < n) (hm : nthProcPos p H m = some i) (hn : nthProcPos p H n = some j) :
i < j

nthProcPos p H is strictly monotone in the rank m < n.

theorem Cslib.Distributed.ConcurrentObjects.History.nthProcPos_append_left {P : Type u_1} {Obj : Type u_2} {Op : Obj → Type u_3} {Resp : Obj → Type u_4} [DecidableEq P] {p : P} {H₁ : History P Op Resp} (H₂ : History P Op Resp) {n : ℕ} (hn : n < List.length (H₁.procSubhistory p)) :
nthProcPos p (H₁ ++ H₂) n = nthProcPos p H₁ n

nthProcPos on H₁ ++ H₂ for ranks within H₁ | p.

theorem Cslib.Distributed.ConcurrentObjects.History.nthProcPos_append_right {P : Type u_1} {Obj : Type u_2} {Op : Obj → Type u_3} {Resp : Obj → Type u_4} [DecidableEq P] {p : P} (H₁ H₂ : History P Op Resp) {n : ℕ} (hn : List.length (H₁.procSubhistory p) ≤ n) :
nthProcPos p (H₁ ++ H₂) n = Option.map (fun (x : ℕ) => x + List.length H₁) (nthProcPos p H₂ (n - List.length (H₁.procSubhistory p)))

nthProcPos on H₁ ++ H₂ for ranks at or beyond (H₁ | p).length.

theorem Cslib.Distributed.ConcurrentObjects.History.nthProcPos_of_append_lt {P : Type u_1} {Obj : Type u_2} {Op : Obj → Type u_3} {Resp : Obj → Type u_4} [DecidableEq P] {p : P} {H₁ H₂ : History P Op Resp} {n pos : ℕ} (h : nthProcPos p (H₁ ++ H₂) n = some pos) (hlt : pos < List.length H₁) :
nthProcPos p H₁ n = some pos

Any nthProcPos match in H₁ ++ H₂ landing before H₁.length comes from H₁.

theorem Cslib.Distributed.ConcurrentObjects.flatMap_toEvents_injective {P : Type u_1} {Obj : Type u_2} {Op : Obj → Type u_3} {Resp : Obj → Type u_4} {cs₁ cs₂ : List (OpCall P Op Resp)} :

List.flatMap OpCall.toEvents is injective on call lists.

theorem Cslib.Distributed.ConcurrentObjects.flatMap_toEvents_getElem?_even {P : Type u_1} {Obj : Type u_2} {Op : Obj → Type u_3} {Resp : Obj → Type u_4} (cs : List (OpCall P Op Resp)) (k : ℕ) (hk : k < cs.length) :

Even positions 2 * k of cs.flatMap OpCall.toEvents hold the invocation of cs[k].

theorem Cslib.Distributed.ConcurrentObjects.isSequential_getElem?_even_isResp_false {P : Type u_1} {Obj : Type u_2} {Op : Obj → Type u_3} {Resp : Obj → Type u_4} {L : History P Op Resp} {k : ℕ} {ev : Event P Op Resp} (hseq : L.IsSequential) (hget : L[2 * k]? = some ev) :

Every event at an even index 2 * k of a sequential history is an invocation (isResp = false).

def Cslib.Distributed.ConcurrentObjects.countProcCalls {P : Type u_1} {Obj : Type u_2} {Op : Obj → Type u_3} {Resp : Obj → Type u_4} [DecidableEq P] (p : P) (calls : List (OpCall P Op Resp)) :

Number of calls in calls invoked by process p.

@[simp]
theorem Cslib.Distributed.ConcurrentObjects.countProcCalls_nil {P : Type u_1} {Obj : Type u_2} {Op : Obj → Type u_3} {Resp : Obj → Type u_4} [DecidableEq P] (p : P) :
theorem Cslib.Distributed.ConcurrentObjects.countProcCalls_cons {P : Type u_1} {Obj : Type u_2} {Op : Obj → Type u_3} {Resp : Obj → Type u_4} [DecidableEq P] (p : P) (c : OpCall P Op Resp) (rest : List (OpCall P Op Resp)) :
countProcCalls p (c :: rest) = if c.proc = p then countProcCalls p rest + 1 else countProcCalls p rest
def Cslib.Distributed.ConcurrentObjects.opIdAt {P : Type u_1} {Obj : Type u_2} {Op : Obj → Type u_3} {Resp : Obj → Type u_4} [DecidableEq P] (calls : List (OpCall P Op Resp)) (j : ℕ) (_hj : j < calls.length) :

Per-process OpId of the j-th completed call in calls.

theorem Cslib.Distributed.ConcurrentObjects.nthFilterPos_flatMap_toEvents {P : Type u_1} {Obj : Type u_2} {Op : Obj → Type u_3} {Resp : Obj → Type u_4} (pred : OpCall P Op Resp → Bool) (evPred : Event P Op Resp → Bool) (hinv_p : ∀ (c : OpCall P Op Resp), evPred (Event.inv c.proc c.obj c.op) = pred c) (hresp_p : ∀ (c : OpCall P Op Resp), evPred (Event.resp c.proc c.obj c.res) = pred c) (calls : List (OpCall P Op Resp)) (k : ℕ) (hk : k < calls.length) (hpk : pred calls[k] = true) :
List.nthFilterPos evPred (List.flatMap OpCall.toEvents calls) (2 * (List.filter pred (List.take k calls)).length) = some (2 * k) ∧ List.nthFilterPos evPred (List.flatMap OpCall.toEvents calls) (2 * (List.filter pred (List.take k calls)).length + 1) = some (2 * k + 1)

Filtered positions in calls.flatMap OpCall.toEvents of the invocation and response of calls[k] whenever pred calls[k] = true.

theorem Cslib.Distributed.ConcurrentObjects.invPos_respPos_opIdAt {P : Type u_1} {Obj : Type u_2} {Op : Obj → Type u_3} {Resp : Obj → Type u_4} [DecidableEq P] (calls : List (OpCall P Op Resp)) (j : ℕ) (hj : j < calls.length) :

Invocation and response positions of opIdAt calls j hj in calls.flatMap OpCall.toEvents are 2 * j and 2 * j + 1.

theorem Cslib.Distributed.ConcurrentObjects.opIdAt_injective {P : Type u_1} {Obj : Type u_2} {Op : Obj → Type u_3} {Resp : Obj → Type u_4} [DecidableEq P] {calls : List (OpCall P Op Resp)} {j₁ j₂ : ℕ} (hj₁ : j₁ < calls.length) (hj₂ : j₂ < calls.length) (heq : opIdAt calls j₁ hj₁ = opIdAt calls j₂ hj₂) :
j₁ = j₂

opIdAt calls is injective on valid call indices.

theorem Cslib.Distributed.ConcurrentObjects.prec_flatMap_toEvents_opIdAt_iff {P : Type u_1} {Obj : Type u_2} {Op : Obj → Type u_3} {Resp : Obj → Type u_4} [DecidableEq P] (calls : List (OpCall P Op Resp)) {j₁ j₂ : ℕ} (hj₁ : j₁ < calls.length) (hj₂ : j₂ < calls.length) :
History.prec (List.flatMap OpCall.toEvents calls) (opIdAt calls j₁ hj₁) (opIdAt calls j₂ hj₂) ↔ j₁ < j₂

Real-time precedence in calls.flatMap OpCall.toEvents agrees with call-index order j₁ < j₂.

theorem Cslib.Distributed.ConcurrentObjects.exists_opIdAt_of_lt_countProcCalls {P : Type u_1} {Obj : Type u_2} {Op : Obj → Type u_3} {Resp : Obj → Type u_4} [DecidableEq P] (calls : List (OpCall P Op Resp)) (e : OpId P) (hlt : e.idx < countProcCalls e.proc calls) :
∃ (j : ℕ) (hj : j < calls.length), opIdAt calls j hj = e

Surjectivity of opIdAt calls onto all e : OpId P with e.idx < countProcCalls e.proc calls.