Ltac coinductive_case CIH :=
    apply W_tl; simpl in *; auto;
    apply CIH; simpl in *; auto.

(* Specifications: *)
Lemma Nth_app : forall A (l : list A) l' a n, Nth l n a -> Nth (l ++ l') n a.
Lemma Nth_tl : forall A (l : list A) a n, Nth l (S n) a -> Nth (List.tl l) n a.
Lemma clients_only_move_up_in_queue : forall n c s, lb_step_execution lb_step_async s -> Nth (queue (nwState (evt_a (hd s)) Server)) (S n) c -> weak_until (fun s => Nth (queue (nwState (evt_a (hd s)) Server)) (S n) c) (next (fun s => Nth (queue (nwState (evt_a (hd s)) Server)) n c /\ (n = 0 -> In (mkPacket Server (Client c) Locked) (nwPackets (evt_a (hd s)))))) s.
Lemma MsgUnlock_moves_client : forall n c s, lb_step_execution lb_step_async s -> Nth (queue (nwState (evt_a (hd s)) Server)) (S n) c -> now (occurred MsgUnlock) s -> next (fun s => Nth (queue (nwState (evt_a (hd s)) Server)) n c /\ (n = 0 -> In (mkPacket Server (Client c) Locked) (nwPackets (evt_a (hd s))))) s.
Lemma Unlock_enables_MsgUnlock : forall n, message_enables_label (mkPacket n Server Unlock) MsgUnlock.
Lemma Unlock_delivered_MsgUnlock : forall n, message_delivered_label (mkPacket n Server Unlock) MsgUnlock.
Lemma Unlock_in_network_eventually_MsgUnlock : forall c s, lb_step_execution lb_step_async s -> weak_fairness lb_step_async label_silent s -> In (mkPacket c Server Unlock) (nwPackets (evt_a (hd s))) -> eventually (now (occurred MsgUnlock)) s.
Lemma Nth_something_at_head : forall A (l : list A) n x, Nth l n x -> exists y l', l = y :: l'.
Lemma InputUnlock_held : forall s c, lb_step_execution lb_step_async s -> held (nwState (evt_a (hd s)) (Client c)) = true -> now (occurred (InputUnlock c)) s -> next (fun s => In (mkPacket (Client c) Server Unlock) (nwPackets (evt_a (hd s)))) s.
Lemma InputHandler_Client_Unlock : forall c sigma, exists sigma' os ms, InputHandler (Client c) Unlock sigma = (InputUnlock c, os, sigma', ms).
Lemma InputUnlock_enabled : forall s c, lb_step_execution lb_step_async s -> now (enabled lb_step_async (InputUnlock c)) s.
Lemma InputUnlock_continuously_enabled : forall s c, lb_step_execution lb_step_async s -> cont_enabled lb_step_async (InputUnlock c) s.
Lemma held_until_Unlock : forall c s, lb_step_execution lb_step_async s -> held (nwState (evt_a (hd s)) (Client c)) = true -> weak_until (fun s => held (nwState (evt_a (hd s)) (Client c)) = true) (next (fun s => In (mkPacket (Client c) Server Unlock) (nwPackets (evt_a (hd s))))) s.
Lemma held_eventually_InputUnlock : forall c s, lb_step_execution lb_step_async s -> weak_fairness lb_step_async label_silent s -> eventually (now (occurred (InputUnlock c))) s.
Lemma held_eventually_Unlock : forall s c, lb_step_execution lb_step_async s -> weak_fairness lb_step_async label_silent s -> held (nwState (evt_a (hd s)) (Client c)) = true -> eventually (fun s => In (mkPacket (Client c) Server Unlock) (nwPackets (evt_a (hd s)))) s.
Lemma Locked_enables_MsgLocked : forall i, message_enables_label {| pSrc := Server; pDst := Client i; pBody := Locked |} (MsgLocked i).
Lemma Locked_delivered_MsgLocked : forall i, message_delivered_label {| pSrc := Server; pDst := Client i; pBody := Locked |} (MsgLocked i).
Lemma Locked_in_network_eventually_MsgLocked : forall i s, lb_step_execution lb_step_async s -> weak_fairness lb_step_async label_silent s -> In (mkPacket Server (Client i) Locked) (nwPackets (evt_a (hd s))) -> eventually (now (occurred (MsgLocked i))) s.
Lemma MsgLocked_held : forall s c, lb_step_execution lb_step_async s -> now (occurred (MsgLocked c)) s -> next (fun s => held (nwState (evt_a (hd s)) (Client c)) = true) s.
Lemma eventually_Unlock : forall n c s, event_step_star step_async step_async_init (hd s) -> lb_step_execution lb_step_async s -> weak_fairness lb_step_async label_silent s -> Nth (queue (nwState (evt_a (hd s)) Server)) (S n) c -> exists c, eventually (fun s => In (mkPacket c Server Unlock) (nwPackets (evt_a (hd s)))) s.
Lemma eventually_MsgUnlock : forall n c s, event_step_star step_async step_async_init (hd s) -> lb_step_execution lb_step_async s -> weak_fairness lb_step_async label_silent s -> Nth (queue (nwState (evt_a (hd s)) Server)) (S n) c -> eventually (now (occurred MsgUnlock)) s.
Lemma clients_move_up_in_queue : forall n c s, event_step_star step_async step_async_init (hd s) -> lb_step_execution lb_step_async s -> weak_fairness lb_step_async label_silent s -> Nth (queue (nwState (evt_a (hd s)) Server)) (S n) c -> eventually (fun s => Nth (queue (nwState (evt_a (hd s)) Server)) n c /\ (n = 0 -> In (mkPacket Server (Client c) Locked) (nwPackets (evt_a (hd s))))) s.
Lemma clients_move_way_up_in_queue : forall n n' c s, n' <= n -> event_step_star step_async step_async_init (hd s) -> lb_step_execution lb_step_async s -> weak_fairness lb_step_async label_silent s -> (Nth (queue (nwState (evt_a (hd s)) Server)) (S n) c /\ (S n = 0 -> In (mkPacket Server (Client c) Locked) (nwPackets (evt_a (hd s))))) -> eventually (fun s => Nth (queue (nwState (evt_a (hd s)) Server)) n' c /\ (n' = 0 -> In (mkPacket Server (Client c) Locked) (nwPackets (evt_a (hd s))))) s.
Lemma clients_get_lock_messages : forall n c s, event_step_star step_async step_async_init (hd s) -> lb_step_execution lb_step_async s -> weak_fairness lb_step_async label_silent s -> Nth (queue (nwState (evt_a (hd s)) Server)) (S n) c -> eventually (fun s => In (mkPacket Server (Client c) Locked) (nwPackets (evt_a (hd s)))) s.
Lemma InputLock_Lock : forall s c, lb_step_execution lb_step_async s -> now (occurred (InputLock c)) s -> next (fun s => In (mkPacket (Client c) Server Lock) (nwPackets (evt_a (hd s)))) s.
Lemma Lock_in_network_eventually_MsgLock : forall c s, lb_step_execution lb_step_async s -> weak_fairness lb_step_async label_silent s -> In (mkPacket (Client c) Server Lock) (nwPackets (evt_a (hd s))) -> eventually (now (occurred (MsgLock c))) s.
Lemma InputLock_eventually_MsgLock : forall c s, lb_step_execution lb_step_async s -> weak_fairness lb_step_async label_silent s -> now (occurred (InputLock c)) s -> eventually (now (occurred (MsgLock c))) s.
Lemma MsgLock_in_queue_or_Locked : forall c s, lb_step_execution lb_step_async s -> weak_fairness lb_step_async label_silent s -> now (occurred (MsgLock c)) s -> next (fun s => In (mkPacket Server (Client c) Locked) (nwPackets (evt_a (hd s)))) s \/ exists n, next (fun s => Nth (queue (nwState (evt_a (hd s)) Server)) (S n) c) s.
Lemma MsgLock_Locked : forall c s, event_step_star step_async step_async_init (hd s) -> lb_step_execution lb_step_async s -> weak_fairness lb_step_async label_silent s -> now (occurred (MsgLock c)) s -> eventually (fun s => In (mkPacket Server (Client c) Locked) (nwPackets (evt_a (hd s)))) s.
Lemma MsgLock_eventually_MsgLocked : forall c s, event_step_star step_async step_async_init (hd s) -> lb_step_execution lb_step_async s -> weak_fairness lb_step_async label_silent s -> now (occurred (MsgLock c)) s -> eventually (now (occurred (MsgLocked c))) s.
Theorem locking_clients_eventually_receive_lock_lb : forall c s, event_step_star step_async step_async_init (hd s) -> lb_step_execution lb_step_async s -> weak_fairness lb_step_async label_silent s -> now (occurred (InputLock c)) s -> eventually (now (occurred (MsgLocked c))) s.
Theorem locking_clients_eventually_receive_lock_st : forall c s, event_step_star step_async step_async_init (hd s) -> lb_step_execution lb_step_async s -> weak_fairness lb_step_async label_silent s -> now (occurred (InputLock c)) s -> eventually (fun s => held (nwState (evt_a (hd s)) (Client c)) = true) s.