Documentation

CslibFrontier.DataStructure.StateTransition.ClientMap

Mapping the result of a deterministic client #

A result map g <$> p runs p and applies g to its answer. StateTransitionSpec.runClient_map evaluates the map over the entire run, including the final state and the operation history, and StateTransitionSpec.clientResult_map, StateTransitionSpec.clientState_map and StateTransitionSpec.clientHistory_map are its answer, state and history. The run, the answer, the state and the history (as StateTransitionSpec.fst_snd_runClient_map and StateTransitionSpec.snd_snd_runClient_map, the forms simp indexes) are in client_simps, together with PFunctor.FreeM.map_eq_map, so simp only [client_simps] handles both spellings g <$> p and p.map g.

Main results #

theorem Cslib.DataStructure.StateTransitionSpec.runClient_map {D : StateTransitionSpec} {step : D.State → (o : D.Op) → D.State × D.Result o} [D.HasStepFn step] {α β : Type x} (p : D.Client α) (g : α → β) (s : D.State) :
D.runClient s (g <$> p) = (g (D.clientResult s p), D.clientState s p, D.clientHistory s p)

A result map applies the function to the answer and preserves the final state and history.

theorem Cslib.DataStructure.StateTransitionSpec.clientResult_map {D : StateTransitionSpec} {step : D.State → (o : D.Op) → D.State × D.Result o} [D.HasStepFn step] {α β : Type x} (p : D.Client α) (g : α → β) (s : D.State) :
D.clientResult s (g <$> p) = g (D.clientResult s p)

A mapped client answers with the function applied to the client's answer.

theorem Cslib.DataStructure.StateTransitionSpec.clientState_map {D : StateTransitionSpec} {step : D.State → (o : D.Op) → D.State × D.Result o} [D.HasStepFn step] {α β : Type x} (p : D.Client α) (g : α → β) (s : D.State) :
D.clientState s (g <$> p) = D.clientState s p

A mapped client stops where the client stops.

theorem Cslib.DataStructure.StateTransitionSpec.fst_snd_runClient_map {D : StateTransitionSpec} {step : D.State → (o : D.Op) → D.State × D.Result o} [D.HasStepFn step] {α β : Type x} (p : D.Client α) (g : α → β) (s : D.State) :
(D.runClient s (g <$> p)).2.1 = D.clientState s p

clientState_map, stated in the form that simp indexes (see fst_snd_runClient_bind).

theorem Cslib.DataStructure.StateTransitionSpec.clientHistory_map {D : StateTransitionSpec} {step : D.State → (o : D.Op) → D.State × D.Result o} [D.HasStepFn step] {α β : Type x} (p : D.Client α) (g : α → β) (s : D.State) :

A mapped client issues the client's operations.

theorem Cslib.DataStructure.StateTransitionSpec.snd_snd_runClient_map {D : StateTransitionSpec} {step : D.State → (o : D.Op) → D.State × D.Result o} [D.HasStepFn step] {α β : Type x} (p : D.Client α) (g : α → β) (s : D.State) :
(D.runClient s (g <$> p)).2.2 = D.clientHistory s p

clientHistory_map, stated in the form that simp indexes (see snd_snd_runClient_bind).

theorem Cslib.DataStructure.StateTransitionSpec.validHistory_map {D : StateTransitionSpec} {step : D.State → (o : D.Op) → D.State × D.Result o} [D.HasStepFn step] {α β : Type x} {p : D.Client α} {g : α → β} {s : D.State} (hp : D.ValidHistory s (D.clientHistory s p)) :

A mapped client is admissible when the client is.