speckl/out/KafkaKRaft.smt2
Scott Scoble 8b520284cb TS generator: fix #12 (5 expression patterns) + #11 (opaque record types)
#12: All 5 untranslated SpeckDL patterns now emit valid JS:
  - notIn → !.has(), old() → drop, union → Set spread,
    set diff → filter, append() → [...X, Y], length() → .length
  - ==/!= operator replacement fixed (word-boundary regression)
  - Postcondition object comparisons get @ts-expect-error TS2839

#11: Generator auto-detects opaque identifier types used in state
  variables and action params, emits 'type X = any' before class.
  - State properties use ! (non-null assertion) for strict mode

TigerBeetleLedger → tsc --noEmit = 0 errors. 37/37 tests pass.
2026-05-11 10:16:15 -07:00

2492 lines
72 KiB
Text

; SpeckDL: KafkaKRaft — Z3 Verification
; Generated by speckl-compile Z3 backend
; Bounded model checking depth: 10
(set-logic ALL)
(set-option :produce-models true)
(declare-fun speckl_len_Int ( (Array Int Int) ) Int)
(declare-sort State 0)
(declare-sort Option_NodeId 0)
(declare-sort LogEntry 0)
(declare-sort NodeId 0)
; --- State Variables ---
(declare-const currentTerm Int)
(declare-const state State)
(declare-const votedFor Option_NodeId)
(declare-const log (Array Int LogEntry))
(declare-const commitIndex Int)
(declare-const nextIndex (Array NodeId Int))
(declare-const matchIndex (Array NodeId Int))
(declare-const votesGranted (Array NodeId Bool))
(declare-const currentTerm_post Int)
(declare-const state_post State)
(declare-const votedFor_post Option_NodeId)
(declare-const log_post (Array Int LogEntry))
(declare-const commitIndex_post Int)
(declare-const nextIndex_post (Array NodeId Int))
(declare-const matchIndex_post (Array NodeId Int))
(declare-const votesGranted_post (Array NodeId Bool))
; --- Invariants ---
(define-fun ElectionSafety () Bool
(and
(=> (= state Leader) (> currentTerm 0))
)
)
(define-fun LeaderCompleteness () Bool
(and
commitIndex <= (speckl_len_Int log)
)
)
(define-fun LogMatching () Bool
(and
(forall ((i Int)) (=> (and (> i 0) (and i <= (speckl_len_Int log) (select log (- i 1)).term = (select log (- i 1)).term)) (select log (- i 1)).value = (select log (- i 1)).value))
)
)
(define-fun LeaderAppendOnly () Bool
(and
(speckl_len_Int log_post) >= (speckl_len_Int log)
)
)
(define-fun TermMonotonicity () Bool
(and
(>= currentTerm_post currentTerm)
)
)
(define-fun CommitSafety () Bool
(and
commitIndex <= (speckl_len_Int log)
)
)
; --- Action Transition Predicates ---
(define-fun RequestVoteEnabled () Bool
(and
(= state Candidate)
(>= currentTerm lastLogTerm)
)
)
(define-fun RequestVoteStep () Bool
(and
(= votesGranted_post (store votesGranted candidate true))
)
)
(define-fun HandleRequestVoteRequestEnabled () Bool
(and
(>= currentTerm candidateTerm)
)
)
(define-fun HandleRequestVoteRequestStep () Bool
(and
(= votedFor_post Some(candidate))
)
)
(define-fun BecomeLeaderEnabled () Bool
(and
(= state Candidate)
votesGranted_size() >= 3
)
)
(define-fun BecomeLeaderStep () Bool
(and
(= state_post Leader)
(= commitIndex_post (speckl_len_Int log))
)
)
(define-fun AppendEntriesEnabled () Bool
(and
(= state Leader)
)
)
(define-fun AppendEntriesStep () Bool
(and
(= log_post append(log, newEntry))
)
)
; Next transition relation: RequestVote | HandleRequestVoteRequest | BecomeLeader | AppendEntries
(define-fun Next () Bool
(or
(and (RequestVoteEnabled) (RequestVoteStep))
(and (HandleRequestVoteRequestEnabled) (HandleRequestVoteRequestStep))
(and (BecomeLeaderEnabled) (BecomeLeaderStep))
(and (AppendEntriesEnabled) (AppendEntriesStep))
; Stuttering step
(and
(= currentTerm_post currentTerm)
(= state_post state)
(= votedFor_post votedFor)
(= log_post log)
(= commitIndex_post commitIndex)
(= nextIndex_post nextIndex)
(= matchIndex_post matchIndex)
(= votesGranted_post votesGranted)
)
)
)
; --- Bounded Model Checking ---
; Verification: Always(TermMonotonicity)
; BMC depth: 10
; Declare state copies for 10 steps
(declare-const currentTerm_0 Int)
(declare-const currentTerm_1 Int)
(declare-const currentTerm_2 Int)
(declare-const currentTerm_3 Int)
(declare-const currentTerm_4 Int)
(declare-const currentTerm_5 Int)
(declare-const currentTerm_6 Int)
(declare-const currentTerm_7 Int)
(declare-const currentTerm_8 Int)
(declare-const currentTerm_9 Int)
(declare-const currentTerm_10 Int)
(declare-const state_0 State)
(declare-const state_1 State)
(declare-const state_2 State)
(declare-const state_3 State)
(declare-const state_4 State)
(declare-const state_5 State)
(declare-const state_6 State)
(declare-const state_7 State)
(declare-const state_8 State)
(declare-const state_9 State)
(declare-const state_10 State)
(declare-const votedFor_0 Option_NodeId)
(declare-const votedFor_1 Option_NodeId)
(declare-const votedFor_2 Option_NodeId)
(declare-const votedFor_3 Option_NodeId)
(declare-const votedFor_4 Option_NodeId)
(declare-const votedFor_5 Option_NodeId)
(declare-const votedFor_6 Option_NodeId)
(declare-const votedFor_7 Option_NodeId)
(declare-const votedFor_8 Option_NodeId)
(declare-const votedFor_9 Option_NodeId)
(declare-const votedFor_10 Option_NodeId)
(declare-const log_0 (Array Int LogEntry))
(declare-const log_1 (Array Int LogEntry))
(declare-const log_2 (Array Int LogEntry))
(declare-const log_3 (Array Int LogEntry))
(declare-const log_4 (Array Int LogEntry))
(declare-const log_5 (Array Int LogEntry))
(declare-const log_6 (Array Int LogEntry))
(declare-const log_7 (Array Int LogEntry))
(declare-const log_8 (Array Int LogEntry))
(declare-const log_9 (Array Int LogEntry))
(declare-const log_10 (Array Int LogEntry))
(declare-const commitIndex_0 Int)
(declare-const commitIndex_1 Int)
(declare-const commitIndex_2 Int)
(declare-const commitIndex_3 Int)
(declare-const commitIndex_4 Int)
(declare-const commitIndex_5 Int)
(declare-const commitIndex_6 Int)
(declare-const commitIndex_7 Int)
(declare-const commitIndex_8 Int)
(declare-const commitIndex_9 Int)
(declare-const commitIndex_10 Int)
(declare-const nextIndex_0 (Array NodeId Int))
(declare-const nextIndex_1 (Array NodeId Int))
(declare-const nextIndex_2 (Array NodeId Int))
(declare-const nextIndex_3 (Array NodeId Int))
(declare-const nextIndex_4 (Array NodeId Int))
(declare-const nextIndex_5 (Array NodeId Int))
(declare-const nextIndex_6 (Array NodeId Int))
(declare-const nextIndex_7 (Array NodeId Int))
(declare-const nextIndex_8 (Array NodeId Int))
(declare-const nextIndex_9 (Array NodeId Int))
(declare-const nextIndex_10 (Array NodeId Int))
(declare-const matchIndex_0 (Array NodeId Int))
(declare-const matchIndex_1 (Array NodeId Int))
(declare-const matchIndex_2 (Array NodeId Int))
(declare-const matchIndex_3 (Array NodeId Int))
(declare-const matchIndex_4 (Array NodeId Int))
(declare-const matchIndex_5 (Array NodeId Int))
(declare-const matchIndex_6 (Array NodeId Int))
(declare-const matchIndex_7 (Array NodeId Int))
(declare-const matchIndex_8 (Array NodeId Int))
(declare-const matchIndex_9 (Array NodeId Int))
(declare-const matchIndex_10 (Array NodeId Int))
(declare-const votesGranted_0 (Array NodeId Bool))
(declare-const votesGranted_1 (Array NodeId Bool))
(declare-const votesGranted_2 (Array NodeId Bool))
(declare-const votesGranted_3 (Array NodeId Bool))
(declare-const votesGranted_4 (Array NodeId Bool))
(declare-const votesGranted_5 (Array NodeId Bool))
(declare-const votesGranted_6 (Array NodeId Bool))
(declare-const votesGranted_7 (Array NodeId Bool))
(declare-const votesGranted_8 (Array NodeId Bool))
(declare-const votesGranted_9 (Array NodeId Bool))
(declare-const votesGranted_10 (Array NodeId Bool))
; Initial state constraints
(assert
(and
(>= currentTerm_0 0)
(>= commitIndex_0 0)
)
)
; Transition constraints
(assert ; Step 0 → 1
(or
(and ; Action: RequestVote
(= state_0 Candidate)
(>= currentTerm_0 lastLogTerm)
(= votesGranted_1 (store votesGranted_0 candidate true))
(= currentTerm_1 currentTerm_0)
(= state_1 state_0)
(= votedFor_1 votedFor_0)
(= log_1 log_0)
(= commitIndex_1 commitIndex_0)
(= nextIndex_1 nextIndex_0)
(= matchIndex_1 matchIndex_0)
)
(and ; Action: HandleRequestVoteRequest
(>= currentTerm_0 candidateTerm)
(= votedFor_1 Some(candidate))
(= currentTerm_1 currentTerm_0)
(= state_1 state_0)
(= log_1 log_0)
(= commitIndex_1 commitIndex_0)
(= nextIndex_1 nextIndex_0)
(= matchIndex_1 matchIndex_0)
(= votesGranted_1 votesGranted_0)
)
(and ; Action: BecomeLeader
(= state_0 Candidate)
votesGranted_size() >= 3
(= state_1 Leader)
(= commitIndex_1 (speckl_len_Int log))
(= currentTerm_1 currentTerm_0)
(= votedFor_1 votedFor_0)
(= log_1 log_0)
(= nextIndex_1 nextIndex_0)
(= matchIndex_1 matchIndex_0)
(= votesGranted_1 votesGranted_0)
)
(and ; Action: AppendEntries
(= state_0 Leader)
(= log_1 append(log_0, newEntry))
(= currentTerm_1 currentTerm_0)
(= state_1 state_0)
(= votedFor_1 votedFor_0)
(= commitIndex_1 commitIndex_0)
(= nextIndex_1 nextIndex_0)
(= matchIndex_1 matchIndex_0)
(= votesGranted_1 votesGranted_0)
)
; Stuttering
(and
(= currentTerm_1 currentTerm_0)
(= state_1 state_0)
(= votedFor_1 votedFor_0)
(= log_1 log_0)
(= commitIndex_1 commitIndex_0)
(= nextIndex_1 nextIndex_0)
(= matchIndex_1 matchIndex_0)
(= votesGranted_1 votesGranted_0)
)
)
)
(assert ; Step 1 → 2
(or
(and ; Action: RequestVote
(= state_1 Candidate)
(>= currentTerm_1 lastLogTerm)
(= votesGranted_2 (store votesGranted_1 candidate true))
(= currentTerm_2 currentTerm_1)
(= state_2 state_1)
(= votedFor_2 votedFor_1)
(= log_2 log_1)
(= commitIndex_2 commitIndex_1)
(= nextIndex_2 nextIndex_1)
(= matchIndex_2 matchIndex_1)
)
(and ; Action: HandleRequestVoteRequest
(>= currentTerm_1 candidateTerm)
(= votedFor_2 Some(candidate))
(= currentTerm_2 currentTerm_1)
(= state_2 state_1)
(= log_2 log_1)
(= commitIndex_2 commitIndex_1)
(= nextIndex_2 nextIndex_1)
(= matchIndex_2 matchIndex_1)
(= votesGranted_2 votesGranted_1)
)
(and ; Action: BecomeLeader
(= state_1 Candidate)
votesGranted_size() >= 3
(= state_2 Leader)
(= commitIndex_2 (speckl_len_Int log))
(= currentTerm_2 currentTerm_1)
(= votedFor_2 votedFor_1)
(= log_2 log_1)
(= nextIndex_2 nextIndex_1)
(= matchIndex_2 matchIndex_1)
(= votesGranted_2 votesGranted_1)
)
(and ; Action: AppendEntries
(= state_1 Leader)
(= log_2 append(log_1, newEntry))
(= currentTerm_2 currentTerm_1)
(= state_2 state_1)
(= votedFor_2 votedFor_1)
(= commitIndex_2 commitIndex_1)
(= nextIndex_2 nextIndex_1)
(= matchIndex_2 matchIndex_1)
(= votesGranted_2 votesGranted_1)
)
; Stuttering
(and
(= currentTerm_2 currentTerm_1)
(= state_2 state_1)
(= votedFor_2 votedFor_1)
(= log_2 log_1)
(= commitIndex_2 commitIndex_1)
(= nextIndex_2 nextIndex_1)
(= matchIndex_2 matchIndex_1)
(= votesGranted_2 votesGranted_1)
)
)
)
(assert ; Step 2 → 3
(or
(and ; Action: RequestVote
(= state_2 Candidate)
(>= currentTerm_2 lastLogTerm)
(= votesGranted_3 (store votesGranted_2 candidate true))
(= currentTerm_3 currentTerm_2)
(= state_3 state_2)
(= votedFor_3 votedFor_2)
(= log_3 log_2)
(= commitIndex_3 commitIndex_2)
(= nextIndex_3 nextIndex_2)
(= matchIndex_3 matchIndex_2)
)
(and ; Action: HandleRequestVoteRequest
(>= currentTerm_2 candidateTerm)
(= votedFor_3 Some(candidate))
(= currentTerm_3 currentTerm_2)
(= state_3 state_2)
(= log_3 log_2)
(= commitIndex_3 commitIndex_2)
(= nextIndex_3 nextIndex_2)
(= matchIndex_3 matchIndex_2)
(= votesGranted_3 votesGranted_2)
)
(and ; Action: BecomeLeader
(= state_2 Candidate)
votesGranted_size() >= 3
(= state_3 Leader)
(= commitIndex_3 (speckl_len_Int log))
(= currentTerm_3 currentTerm_2)
(= votedFor_3 votedFor_2)
(= log_3 log_2)
(= nextIndex_3 nextIndex_2)
(= matchIndex_3 matchIndex_2)
(= votesGranted_3 votesGranted_2)
)
(and ; Action: AppendEntries
(= state_2 Leader)
(= log_3 append(log_2, newEntry))
(= currentTerm_3 currentTerm_2)
(= state_3 state_2)
(= votedFor_3 votedFor_2)
(= commitIndex_3 commitIndex_2)
(= nextIndex_3 nextIndex_2)
(= matchIndex_3 matchIndex_2)
(= votesGranted_3 votesGranted_2)
)
; Stuttering
(and
(= currentTerm_3 currentTerm_2)
(= state_3 state_2)
(= votedFor_3 votedFor_2)
(= log_3 log_2)
(= commitIndex_3 commitIndex_2)
(= nextIndex_3 nextIndex_2)
(= matchIndex_3 matchIndex_2)
(= votesGranted_3 votesGranted_2)
)
)
)
(assert ; Step 3 → 4
(or
(and ; Action: RequestVote
(= state_3 Candidate)
(>= currentTerm_3 lastLogTerm)
(= votesGranted_4 (store votesGranted_3 candidate true))
(= currentTerm_4 currentTerm_3)
(= state_4 state_3)
(= votedFor_4 votedFor_3)
(= log_4 log_3)
(= commitIndex_4 commitIndex_3)
(= nextIndex_4 nextIndex_3)
(= matchIndex_4 matchIndex_3)
)
(and ; Action: HandleRequestVoteRequest
(>= currentTerm_3 candidateTerm)
(= votedFor_4 Some(candidate))
(= currentTerm_4 currentTerm_3)
(= state_4 state_3)
(= log_4 log_3)
(= commitIndex_4 commitIndex_3)
(= nextIndex_4 nextIndex_3)
(= matchIndex_4 matchIndex_3)
(= votesGranted_4 votesGranted_3)
)
(and ; Action: BecomeLeader
(= state_3 Candidate)
votesGranted_size() >= 3
(= state_4 Leader)
(= commitIndex_4 (speckl_len_Int log))
(= currentTerm_4 currentTerm_3)
(= votedFor_4 votedFor_3)
(= log_4 log_3)
(= nextIndex_4 nextIndex_3)
(= matchIndex_4 matchIndex_3)
(= votesGranted_4 votesGranted_3)
)
(and ; Action: AppendEntries
(= state_3 Leader)
(= log_4 append(log_3, newEntry))
(= currentTerm_4 currentTerm_3)
(= state_4 state_3)
(= votedFor_4 votedFor_3)
(= commitIndex_4 commitIndex_3)
(= nextIndex_4 nextIndex_3)
(= matchIndex_4 matchIndex_3)
(= votesGranted_4 votesGranted_3)
)
; Stuttering
(and
(= currentTerm_4 currentTerm_3)
(= state_4 state_3)
(= votedFor_4 votedFor_3)
(= log_4 log_3)
(= commitIndex_4 commitIndex_3)
(= nextIndex_4 nextIndex_3)
(= matchIndex_4 matchIndex_3)
(= votesGranted_4 votesGranted_3)
)
)
)
(assert ; Step 4 → 5
(or
(and ; Action: RequestVote
(= state_4 Candidate)
(>= currentTerm_4 lastLogTerm)
(= votesGranted_5 (store votesGranted_4 candidate true))
(= currentTerm_5 currentTerm_4)
(= state_5 state_4)
(= votedFor_5 votedFor_4)
(= log_5 log_4)
(= commitIndex_5 commitIndex_4)
(= nextIndex_5 nextIndex_4)
(= matchIndex_5 matchIndex_4)
)
(and ; Action: HandleRequestVoteRequest
(>= currentTerm_4 candidateTerm)
(= votedFor_5 Some(candidate))
(= currentTerm_5 currentTerm_4)
(= state_5 state_4)
(= log_5 log_4)
(= commitIndex_5 commitIndex_4)
(= nextIndex_5 nextIndex_4)
(= matchIndex_5 matchIndex_4)
(= votesGranted_5 votesGranted_4)
)
(and ; Action: BecomeLeader
(= state_4 Candidate)
votesGranted_size() >= 3
(= state_5 Leader)
(= commitIndex_5 (speckl_len_Int log))
(= currentTerm_5 currentTerm_4)
(= votedFor_5 votedFor_4)
(= log_5 log_4)
(= nextIndex_5 nextIndex_4)
(= matchIndex_5 matchIndex_4)
(= votesGranted_5 votesGranted_4)
)
(and ; Action: AppendEntries
(= state_4 Leader)
(= log_5 append(log_4, newEntry))
(= currentTerm_5 currentTerm_4)
(= state_5 state_4)
(= votedFor_5 votedFor_4)
(= commitIndex_5 commitIndex_4)
(= nextIndex_5 nextIndex_4)
(= matchIndex_5 matchIndex_4)
(= votesGranted_5 votesGranted_4)
)
; Stuttering
(and
(= currentTerm_5 currentTerm_4)
(= state_5 state_4)
(= votedFor_5 votedFor_4)
(= log_5 log_4)
(= commitIndex_5 commitIndex_4)
(= nextIndex_5 nextIndex_4)
(= matchIndex_5 matchIndex_4)
(= votesGranted_5 votesGranted_4)
)
)
)
(assert ; Step 5 → 6
(or
(and ; Action: RequestVote
(= state_5 Candidate)
(>= currentTerm_5 lastLogTerm)
(= votesGranted_6 (store votesGranted_5 candidate true))
(= currentTerm_6 currentTerm_5)
(= state_6 state_5)
(= votedFor_6 votedFor_5)
(= log_6 log_5)
(= commitIndex_6 commitIndex_5)
(= nextIndex_6 nextIndex_5)
(= matchIndex_6 matchIndex_5)
)
(and ; Action: HandleRequestVoteRequest
(>= currentTerm_5 candidateTerm)
(= votedFor_6 Some(candidate))
(= currentTerm_6 currentTerm_5)
(= state_6 state_5)
(= log_6 log_5)
(= commitIndex_6 commitIndex_5)
(= nextIndex_6 nextIndex_5)
(= matchIndex_6 matchIndex_5)
(= votesGranted_6 votesGranted_5)
)
(and ; Action: BecomeLeader
(= state_5 Candidate)
votesGranted_size() >= 3
(= state_6 Leader)
(= commitIndex_6 (speckl_len_Int log))
(= currentTerm_6 currentTerm_5)
(= votedFor_6 votedFor_5)
(= log_6 log_5)
(= nextIndex_6 nextIndex_5)
(= matchIndex_6 matchIndex_5)
(= votesGranted_6 votesGranted_5)
)
(and ; Action: AppendEntries
(= state_5 Leader)
(= log_6 append(log_5, newEntry))
(= currentTerm_6 currentTerm_5)
(= state_6 state_5)
(= votedFor_6 votedFor_5)
(= commitIndex_6 commitIndex_5)
(= nextIndex_6 nextIndex_5)
(= matchIndex_6 matchIndex_5)
(= votesGranted_6 votesGranted_5)
)
; Stuttering
(and
(= currentTerm_6 currentTerm_5)
(= state_6 state_5)
(= votedFor_6 votedFor_5)
(= log_6 log_5)
(= commitIndex_6 commitIndex_5)
(= nextIndex_6 nextIndex_5)
(= matchIndex_6 matchIndex_5)
(= votesGranted_6 votesGranted_5)
)
)
)
(assert ; Step 6 → 7
(or
(and ; Action: RequestVote
(= state_6 Candidate)
(>= currentTerm_6 lastLogTerm)
(= votesGranted_7 (store votesGranted_6 candidate true))
(= currentTerm_7 currentTerm_6)
(= state_7 state_6)
(= votedFor_7 votedFor_6)
(= log_7 log_6)
(= commitIndex_7 commitIndex_6)
(= nextIndex_7 nextIndex_6)
(= matchIndex_7 matchIndex_6)
)
(and ; Action: HandleRequestVoteRequest
(>= currentTerm_6 candidateTerm)
(= votedFor_7 Some(candidate))
(= currentTerm_7 currentTerm_6)
(= state_7 state_6)
(= log_7 log_6)
(= commitIndex_7 commitIndex_6)
(= nextIndex_7 nextIndex_6)
(= matchIndex_7 matchIndex_6)
(= votesGranted_7 votesGranted_6)
)
(and ; Action: BecomeLeader
(= state_6 Candidate)
votesGranted_size() >= 3
(= state_7 Leader)
(= commitIndex_7 (speckl_len_Int log))
(= currentTerm_7 currentTerm_6)
(= votedFor_7 votedFor_6)
(= log_7 log_6)
(= nextIndex_7 nextIndex_6)
(= matchIndex_7 matchIndex_6)
(= votesGranted_7 votesGranted_6)
)
(and ; Action: AppendEntries
(= state_6 Leader)
(= log_7 append(log_6, newEntry))
(= currentTerm_7 currentTerm_6)
(= state_7 state_6)
(= votedFor_7 votedFor_6)
(= commitIndex_7 commitIndex_6)
(= nextIndex_7 nextIndex_6)
(= matchIndex_7 matchIndex_6)
(= votesGranted_7 votesGranted_6)
)
; Stuttering
(and
(= currentTerm_7 currentTerm_6)
(= state_7 state_6)
(= votedFor_7 votedFor_6)
(= log_7 log_6)
(= commitIndex_7 commitIndex_6)
(= nextIndex_7 nextIndex_6)
(= matchIndex_7 matchIndex_6)
(= votesGranted_7 votesGranted_6)
)
)
)
(assert ; Step 7 → 8
(or
(and ; Action: RequestVote
(= state_7 Candidate)
(>= currentTerm_7 lastLogTerm)
(= votesGranted_8 (store votesGranted_7 candidate true))
(= currentTerm_8 currentTerm_7)
(= state_8 state_7)
(= votedFor_8 votedFor_7)
(= log_8 log_7)
(= commitIndex_8 commitIndex_7)
(= nextIndex_8 nextIndex_7)
(= matchIndex_8 matchIndex_7)
)
(and ; Action: HandleRequestVoteRequest
(>= currentTerm_7 candidateTerm)
(= votedFor_8 Some(candidate))
(= currentTerm_8 currentTerm_7)
(= state_8 state_7)
(= log_8 log_7)
(= commitIndex_8 commitIndex_7)
(= nextIndex_8 nextIndex_7)
(= matchIndex_8 matchIndex_7)
(= votesGranted_8 votesGranted_7)
)
(and ; Action: BecomeLeader
(= state_7 Candidate)
votesGranted_size() >= 3
(= state_8 Leader)
(= commitIndex_8 (speckl_len_Int log))
(= currentTerm_8 currentTerm_7)
(= votedFor_8 votedFor_7)
(= log_8 log_7)
(= nextIndex_8 nextIndex_7)
(= matchIndex_8 matchIndex_7)
(= votesGranted_8 votesGranted_7)
)
(and ; Action: AppendEntries
(= state_7 Leader)
(= log_8 append(log_7, newEntry))
(= currentTerm_8 currentTerm_7)
(= state_8 state_7)
(= votedFor_8 votedFor_7)
(= commitIndex_8 commitIndex_7)
(= nextIndex_8 nextIndex_7)
(= matchIndex_8 matchIndex_7)
(= votesGranted_8 votesGranted_7)
)
; Stuttering
(and
(= currentTerm_8 currentTerm_7)
(= state_8 state_7)
(= votedFor_8 votedFor_7)
(= log_8 log_7)
(= commitIndex_8 commitIndex_7)
(= nextIndex_8 nextIndex_7)
(= matchIndex_8 matchIndex_7)
(= votesGranted_8 votesGranted_7)
)
)
)
(assert ; Step 8 → 9
(or
(and ; Action: RequestVote
(= state_8 Candidate)
(>= currentTerm_8 lastLogTerm)
(= votesGranted_9 (store votesGranted_8 candidate true))
(= currentTerm_9 currentTerm_8)
(= state_9 state_8)
(= votedFor_9 votedFor_8)
(= log_9 log_8)
(= commitIndex_9 commitIndex_8)
(= nextIndex_9 nextIndex_8)
(= matchIndex_9 matchIndex_8)
)
(and ; Action: HandleRequestVoteRequest
(>= currentTerm_8 candidateTerm)
(= votedFor_9 Some(candidate))
(= currentTerm_9 currentTerm_8)
(= state_9 state_8)
(= log_9 log_8)
(= commitIndex_9 commitIndex_8)
(= nextIndex_9 nextIndex_8)
(= matchIndex_9 matchIndex_8)
(= votesGranted_9 votesGranted_8)
)
(and ; Action: BecomeLeader
(= state_8 Candidate)
votesGranted_size() >= 3
(= state_9 Leader)
(= commitIndex_9 (speckl_len_Int log))
(= currentTerm_9 currentTerm_8)
(= votedFor_9 votedFor_8)
(= log_9 log_8)
(= nextIndex_9 nextIndex_8)
(= matchIndex_9 matchIndex_8)
(= votesGranted_9 votesGranted_8)
)
(and ; Action: AppendEntries
(= state_8 Leader)
(= log_9 append(log_8, newEntry))
(= currentTerm_9 currentTerm_8)
(= state_9 state_8)
(= votedFor_9 votedFor_8)
(= commitIndex_9 commitIndex_8)
(= nextIndex_9 nextIndex_8)
(= matchIndex_9 matchIndex_8)
(= votesGranted_9 votesGranted_8)
)
; Stuttering
(and
(= currentTerm_9 currentTerm_8)
(= state_9 state_8)
(= votedFor_9 votedFor_8)
(= log_9 log_8)
(= commitIndex_9 commitIndex_8)
(= nextIndex_9 nextIndex_8)
(= matchIndex_9 matchIndex_8)
(= votesGranted_9 votesGranted_8)
)
)
)
(assert ; Step 9 → 10
(or
(and ; Action: RequestVote
(= state_9 Candidate)
(>= currentTerm_9 lastLogTerm)
(= votesGranted_10 (store votesGranted_9 candidate true))
(= currentTerm_10 currentTerm_9)
(= state_10 state_9)
(= votedFor_10 votedFor_9)
(= log_10 log_9)
(= commitIndex_10 commitIndex_9)
(= nextIndex_10 nextIndex_9)
(= matchIndex_10 matchIndex_9)
)
(and ; Action: HandleRequestVoteRequest
(>= currentTerm_9 candidateTerm)
(= votedFor_10 Some(candidate))
(= currentTerm_10 currentTerm_9)
(= state_10 state_9)
(= log_10 log_9)
(= commitIndex_10 commitIndex_9)
(= nextIndex_10 nextIndex_9)
(= matchIndex_10 matchIndex_9)
(= votesGranted_10 votesGranted_9)
)
(and ; Action: BecomeLeader
(= state_9 Candidate)
votesGranted_size() >= 3
(= state_10 Leader)
(= commitIndex_10 (speckl_len_Int log))
(= currentTerm_10 currentTerm_9)
(= votedFor_10 votedFor_9)
(= log_10 log_9)
(= nextIndex_10 nextIndex_9)
(= matchIndex_10 matchIndex_9)
(= votesGranted_10 votesGranted_9)
)
(and ; Action: AppendEntries
(= state_9 Leader)
(= log_10 append(log_9, newEntry))
(= currentTerm_10 currentTerm_9)
(= state_10 state_9)
(= votedFor_10 votedFor_9)
(= commitIndex_10 commitIndex_9)
(= nextIndex_10 nextIndex_9)
(= matchIndex_10 matchIndex_9)
(= votesGranted_10 votesGranted_9)
)
; Stuttering
(and
(= currentTerm_10 currentTerm_9)
(= state_10 state_9)
(= votedFor_10 votedFor_9)
(= log_10 log_9)
(= commitIndex_10 commitIndex_9)
(= nextIndex_10 nextIndex_9)
(= matchIndex_10 matchIndex_9)
(= votesGranted_10 votesGranted_9)
)
)
)
; Property assertion: not(invariant at some step)
(assert
(or
(not (TermMonotonicity_0))
(not (TermMonotonicity_1))
(not (TermMonotonicity_2))
(not (TermMonotonicity_3))
(not (TermMonotonicity_4))
(not (TermMonotonicity_5))
(not (TermMonotonicity_6))
(not (TermMonotonicity_7))
(not (TermMonotonicity_8))
(not (TermMonotonicity_9))
(not (TermMonotonicity_10))
)
)
(define-fun TermMonotonicity_0 () Bool
(and
(>= currentTerm_post currentTerm_0)
)
)
(define-fun TermMonotonicity_1 () Bool
(and
(>= currentTerm_post currentTerm_1)
)
)
(define-fun TermMonotonicity_2 () Bool
(and
(>= currentTerm_post currentTerm_2)
)
)
(define-fun TermMonotonicity_3 () Bool
(and
(>= currentTerm_post currentTerm_3)
)
)
(define-fun TermMonotonicity_4 () Bool
(and
(>= currentTerm_post currentTerm_4)
)
)
(define-fun TermMonotonicity_5 () Bool
(and
(>= currentTerm_post currentTerm_5)
)
)
(define-fun TermMonotonicity_6 () Bool
(and
(>= currentTerm_post currentTerm_6)
)
)
(define-fun TermMonotonicity_7 () Bool
(and
(>= currentTerm_post currentTerm_7)
)
)
(define-fun TermMonotonicity_8 () Bool
(and
(>= currentTerm_post currentTerm_8)
)
)
(define-fun TermMonotonicity_9 () Bool
(and
(>= currentTerm_post currentTerm_9)
)
)
(define-fun TermMonotonicity_10 () Bool
(and
(>= currentTerm_post currentTerm_10)
)
)
(echo "Checking: Always(TermMonotonicity) for 10 steps")
(check-sat)
(get-model)
; Verification: Always(CommitSafety)
; BMC depth: 10
; Declare state copies for 10 steps
(declare-const currentTerm_0 Int)
(declare-const currentTerm_1 Int)
(declare-const currentTerm_2 Int)
(declare-const currentTerm_3 Int)
(declare-const currentTerm_4 Int)
(declare-const currentTerm_5 Int)
(declare-const currentTerm_6 Int)
(declare-const currentTerm_7 Int)
(declare-const currentTerm_8 Int)
(declare-const currentTerm_9 Int)
(declare-const currentTerm_10 Int)
(declare-const state_0 State)
(declare-const state_1 State)
(declare-const state_2 State)
(declare-const state_3 State)
(declare-const state_4 State)
(declare-const state_5 State)
(declare-const state_6 State)
(declare-const state_7 State)
(declare-const state_8 State)
(declare-const state_9 State)
(declare-const state_10 State)
(declare-const votedFor_0 Option_NodeId)
(declare-const votedFor_1 Option_NodeId)
(declare-const votedFor_2 Option_NodeId)
(declare-const votedFor_3 Option_NodeId)
(declare-const votedFor_4 Option_NodeId)
(declare-const votedFor_5 Option_NodeId)
(declare-const votedFor_6 Option_NodeId)
(declare-const votedFor_7 Option_NodeId)
(declare-const votedFor_8 Option_NodeId)
(declare-const votedFor_9 Option_NodeId)
(declare-const votedFor_10 Option_NodeId)
(declare-const log_0 (Array Int LogEntry))
(declare-const log_1 (Array Int LogEntry))
(declare-const log_2 (Array Int LogEntry))
(declare-const log_3 (Array Int LogEntry))
(declare-const log_4 (Array Int LogEntry))
(declare-const log_5 (Array Int LogEntry))
(declare-const log_6 (Array Int LogEntry))
(declare-const log_7 (Array Int LogEntry))
(declare-const log_8 (Array Int LogEntry))
(declare-const log_9 (Array Int LogEntry))
(declare-const log_10 (Array Int LogEntry))
(declare-const commitIndex_0 Int)
(declare-const commitIndex_1 Int)
(declare-const commitIndex_2 Int)
(declare-const commitIndex_3 Int)
(declare-const commitIndex_4 Int)
(declare-const commitIndex_5 Int)
(declare-const commitIndex_6 Int)
(declare-const commitIndex_7 Int)
(declare-const commitIndex_8 Int)
(declare-const commitIndex_9 Int)
(declare-const commitIndex_10 Int)
(declare-const nextIndex_0 (Array NodeId Int))
(declare-const nextIndex_1 (Array NodeId Int))
(declare-const nextIndex_2 (Array NodeId Int))
(declare-const nextIndex_3 (Array NodeId Int))
(declare-const nextIndex_4 (Array NodeId Int))
(declare-const nextIndex_5 (Array NodeId Int))
(declare-const nextIndex_6 (Array NodeId Int))
(declare-const nextIndex_7 (Array NodeId Int))
(declare-const nextIndex_8 (Array NodeId Int))
(declare-const nextIndex_9 (Array NodeId Int))
(declare-const nextIndex_10 (Array NodeId Int))
(declare-const matchIndex_0 (Array NodeId Int))
(declare-const matchIndex_1 (Array NodeId Int))
(declare-const matchIndex_2 (Array NodeId Int))
(declare-const matchIndex_3 (Array NodeId Int))
(declare-const matchIndex_4 (Array NodeId Int))
(declare-const matchIndex_5 (Array NodeId Int))
(declare-const matchIndex_6 (Array NodeId Int))
(declare-const matchIndex_7 (Array NodeId Int))
(declare-const matchIndex_8 (Array NodeId Int))
(declare-const matchIndex_9 (Array NodeId Int))
(declare-const matchIndex_10 (Array NodeId Int))
(declare-const votesGranted_0 (Array NodeId Bool))
(declare-const votesGranted_1 (Array NodeId Bool))
(declare-const votesGranted_2 (Array NodeId Bool))
(declare-const votesGranted_3 (Array NodeId Bool))
(declare-const votesGranted_4 (Array NodeId Bool))
(declare-const votesGranted_5 (Array NodeId Bool))
(declare-const votesGranted_6 (Array NodeId Bool))
(declare-const votesGranted_7 (Array NodeId Bool))
(declare-const votesGranted_8 (Array NodeId Bool))
(declare-const votesGranted_9 (Array NodeId Bool))
(declare-const votesGranted_10 (Array NodeId Bool))
; Initial state constraints
(assert
(and
(>= currentTerm_0 0)
(>= commitIndex_0 0)
)
)
; Transition constraints
(assert ; Step 0 → 1
(or
(and ; Action: RequestVote
(= state_0 Candidate)
(>= currentTerm_0 lastLogTerm)
(= votesGranted_1 (store votesGranted_0 candidate true))
(= currentTerm_1 currentTerm_0)
(= state_1 state_0)
(= votedFor_1 votedFor_0)
(= log_1 log_0)
(= commitIndex_1 commitIndex_0)
(= nextIndex_1 nextIndex_0)
(= matchIndex_1 matchIndex_0)
)
(and ; Action: HandleRequestVoteRequest
(>= currentTerm_0 candidateTerm)
(= votedFor_1 Some(candidate))
(= currentTerm_1 currentTerm_0)
(= state_1 state_0)
(= log_1 log_0)
(= commitIndex_1 commitIndex_0)
(= nextIndex_1 nextIndex_0)
(= matchIndex_1 matchIndex_0)
(= votesGranted_1 votesGranted_0)
)
(and ; Action: BecomeLeader
(= state_0 Candidate)
votesGranted_size() >= 3
(= state_1 Leader)
(= commitIndex_1 (speckl_len_Int log))
(= currentTerm_1 currentTerm_0)
(= votedFor_1 votedFor_0)
(= log_1 log_0)
(= nextIndex_1 nextIndex_0)
(= matchIndex_1 matchIndex_0)
(= votesGranted_1 votesGranted_0)
)
(and ; Action: AppendEntries
(= state_0 Leader)
(= log_1 append(log_0, newEntry))
(= currentTerm_1 currentTerm_0)
(= state_1 state_0)
(= votedFor_1 votedFor_0)
(= commitIndex_1 commitIndex_0)
(= nextIndex_1 nextIndex_0)
(= matchIndex_1 matchIndex_0)
(= votesGranted_1 votesGranted_0)
)
; Stuttering
(and
(= currentTerm_1 currentTerm_0)
(= state_1 state_0)
(= votedFor_1 votedFor_0)
(= log_1 log_0)
(= commitIndex_1 commitIndex_0)
(= nextIndex_1 nextIndex_0)
(= matchIndex_1 matchIndex_0)
(= votesGranted_1 votesGranted_0)
)
)
)
(assert ; Step 1 → 2
(or
(and ; Action: RequestVote
(= state_1 Candidate)
(>= currentTerm_1 lastLogTerm)
(= votesGranted_2 (store votesGranted_1 candidate true))
(= currentTerm_2 currentTerm_1)
(= state_2 state_1)
(= votedFor_2 votedFor_1)
(= log_2 log_1)
(= commitIndex_2 commitIndex_1)
(= nextIndex_2 nextIndex_1)
(= matchIndex_2 matchIndex_1)
)
(and ; Action: HandleRequestVoteRequest
(>= currentTerm_1 candidateTerm)
(= votedFor_2 Some(candidate))
(= currentTerm_2 currentTerm_1)
(= state_2 state_1)
(= log_2 log_1)
(= commitIndex_2 commitIndex_1)
(= nextIndex_2 nextIndex_1)
(= matchIndex_2 matchIndex_1)
(= votesGranted_2 votesGranted_1)
)
(and ; Action: BecomeLeader
(= state_1 Candidate)
votesGranted_size() >= 3
(= state_2 Leader)
(= commitIndex_2 (speckl_len_Int log))
(= currentTerm_2 currentTerm_1)
(= votedFor_2 votedFor_1)
(= log_2 log_1)
(= nextIndex_2 nextIndex_1)
(= matchIndex_2 matchIndex_1)
(= votesGranted_2 votesGranted_1)
)
(and ; Action: AppendEntries
(= state_1 Leader)
(= log_2 append(log_1, newEntry))
(= currentTerm_2 currentTerm_1)
(= state_2 state_1)
(= votedFor_2 votedFor_1)
(= commitIndex_2 commitIndex_1)
(= nextIndex_2 nextIndex_1)
(= matchIndex_2 matchIndex_1)
(= votesGranted_2 votesGranted_1)
)
; Stuttering
(and
(= currentTerm_2 currentTerm_1)
(= state_2 state_1)
(= votedFor_2 votedFor_1)
(= log_2 log_1)
(= commitIndex_2 commitIndex_1)
(= nextIndex_2 nextIndex_1)
(= matchIndex_2 matchIndex_1)
(= votesGranted_2 votesGranted_1)
)
)
)
(assert ; Step 2 → 3
(or
(and ; Action: RequestVote
(= state_2 Candidate)
(>= currentTerm_2 lastLogTerm)
(= votesGranted_3 (store votesGranted_2 candidate true))
(= currentTerm_3 currentTerm_2)
(= state_3 state_2)
(= votedFor_3 votedFor_2)
(= log_3 log_2)
(= commitIndex_3 commitIndex_2)
(= nextIndex_3 nextIndex_2)
(= matchIndex_3 matchIndex_2)
)
(and ; Action: HandleRequestVoteRequest
(>= currentTerm_2 candidateTerm)
(= votedFor_3 Some(candidate))
(= currentTerm_3 currentTerm_2)
(= state_3 state_2)
(= log_3 log_2)
(= commitIndex_3 commitIndex_2)
(= nextIndex_3 nextIndex_2)
(= matchIndex_3 matchIndex_2)
(= votesGranted_3 votesGranted_2)
)
(and ; Action: BecomeLeader
(= state_2 Candidate)
votesGranted_size() >= 3
(= state_3 Leader)
(= commitIndex_3 (speckl_len_Int log))
(= currentTerm_3 currentTerm_2)
(= votedFor_3 votedFor_2)
(= log_3 log_2)
(= nextIndex_3 nextIndex_2)
(= matchIndex_3 matchIndex_2)
(= votesGranted_3 votesGranted_2)
)
(and ; Action: AppendEntries
(= state_2 Leader)
(= log_3 append(log_2, newEntry))
(= currentTerm_3 currentTerm_2)
(= state_3 state_2)
(= votedFor_3 votedFor_2)
(= commitIndex_3 commitIndex_2)
(= nextIndex_3 nextIndex_2)
(= matchIndex_3 matchIndex_2)
(= votesGranted_3 votesGranted_2)
)
; Stuttering
(and
(= currentTerm_3 currentTerm_2)
(= state_3 state_2)
(= votedFor_3 votedFor_2)
(= log_3 log_2)
(= commitIndex_3 commitIndex_2)
(= nextIndex_3 nextIndex_2)
(= matchIndex_3 matchIndex_2)
(= votesGranted_3 votesGranted_2)
)
)
)
(assert ; Step 3 → 4
(or
(and ; Action: RequestVote
(= state_3 Candidate)
(>= currentTerm_3 lastLogTerm)
(= votesGranted_4 (store votesGranted_3 candidate true))
(= currentTerm_4 currentTerm_3)
(= state_4 state_3)
(= votedFor_4 votedFor_3)
(= log_4 log_3)
(= commitIndex_4 commitIndex_3)
(= nextIndex_4 nextIndex_3)
(= matchIndex_4 matchIndex_3)
)
(and ; Action: HandleRequestVoteRequest
(>= currentTerm_3 candidateTerm)
(= votedFor_4 Some(candidate))
(= currentTerm_4 currentTerm_3)
(= state_4 state_3)
(= log_4 log_3)
(= commitIndex_4 commitIndex_3)
(= nextIndex_4 nextIndex_3)
(= matchIndex_4 matchIndex_3)
(= votesGranted_4 votesGranted_3)
)
(and ; Action: BecomeLeader
(= state_3 Candidate)
votesGranted_size() >= 3
(= state_4 Leader)
(= commitIndex_4 (speckl_len_Int log))
(= currentTerm_4 currentTerm_3)
(= votedFor_4 votedFor_3)
(= log_4 log_3)
(= nextIndex_4 nextIndex_3)
(= matchIndex_4 matchIndex_3)
(= votesGranted_4 votesGranted_3)
)
(and ; Action: AppendEntries
(= state_3 Leader)
(= log_4 append(log_3, newEntry))
(= currentTerm_4 currentTerm_3)
(= state_4 state_3)
(= votedFor_4 votedFor_3)
(= commitIndex_4 commitIndex_3)
(= nextIndex_4 nextIndex_3)
(= matchIndex_4 matchIndex_3)
(= votesGranted_4 votesGranted_3)
)
; Stuttering
(and
(= currentTerm_4 currentTerm_3)
(= state_4 state_3)
(= votedFor_4 votedFor_3)
(= log_4 log_3)
(= commitIndex_4 commitIndex_3)
(= nextIndex_4 nextIndex_3)
(= matchIndex_4 matchIndex_3)
(= votesGranted_4 votesGranted_3)
)
)
)
(assert ; Step 4 → 5
(or
(and ; Action: RequestVote
(= state_4 Candidate)
(>= currentTerm_4 lastLogTerm)
(= votesGranted_5 (store votesGranted_4 candidate true))
(= currentTerm_5 currentTerm_4)
(= state_5 state_4)
(= votedFor_5 votedFor_4)
(= log_5 log_4)
(= commitIndex_5 commitIndex_4)
(= nextIndex_5 nextIndex_4)
(= matchIndex_5 matchIndex_4)
)
(and ; Action: HandleRequestVoteRequest
(>= currentTerm_4 candidateTerm)
(= votedFor_5 Some(candidate))
(= currentTerm_5 currentTerm_4)
(= state_5 state_4)
(= log_5 log_4)
(= commitIndex_5 commitIndex_4)
(= nextIndex_5 nextIndex_4)
(= matchIndex_5 matchIndex_4)
(= votesGranted_5 votesGranted_4)
)
(and ; Action: BecomeLeader
(= state_4 Candidate)
votesGranted_size() >= 3
(= state_5 Leader)
(= commitIndex_5 (speckl_len_Int log))
(= currentTerm_5 currentTerm_4)
(= votedFor_5 votedFor_4)
(= log_5 log_4)
(= nextIndex_5 nextIndex_4)
(= matchIndex_5 matchIndex_4)
(= votesGranted_5 votesGranted_4)
)
(and ; Action: AppendEntries
(= state_4 Leader)
(= log_5 append(log_4, newEntry))
(= currentTerm_5 currentTerm_4)
(= state_5 state_4)
(= votedFor_5 votedFor_4)
(= commitIndex_5 commitIndex_4)
(= nextIndex_5 nextIndex_4)
(= matchIndex_5 matchIndex_4)
(= votesGranted_5 votesGranted_4)
)
; Stuttering
(and
(= currentTerm_5 currentTerm_4)
(= state_5 state_4)
(= votedFor_5 votedFor_4)
(= log_5 log_4)
(= commitIndex_5 commitIndex_4)
(= nextIndex_5 nextIndex_4)
(= matchIndex_5 matchIndex_4)
(= votesGranted_5 votesGranted_4)
)
)
)
(assert ; Step 5 → 6
(or
(and ; Action: RequestVote
(= state_5 Candidate)
(>= currentTerm_5 lastLogTerm)
(= votesGranted_6 (store votesGranted_5 candidate true))
(= currentTerm_6 currentTerm_5)
(= state_6 state_5)
(= votedFor_6 votedFor_5)
(= log_6 log_5)
(= commitIndex_6 commitIndex_5)
(= nextIndex_6 nextIndex_5)
(= matchIndex_6 matchIndex_5)
)
(and ; Action: HandleRequestVoteRequest
(>= currentTerm_5 candidateTerm)
(= votedFor_6 Some(candidate))
(= currentTerm_6 currentTerm_5)
(= state_6 state_5)
(= log_6 log_5)
(= commitIndex_6 commitIndex_5)
(= nextIndex_6 nextIndex_5)
(= matchIndex_6 matchIndex_5)
(= votesGranted_6 votesGranted_5)
)
(and ; Action: BecomeLeader
(= state_5 Candidate)
votesGranted_size() >= 3
(= state_6 Leader)
(= commitIndex_6 (speckl_len_Int log))
(= currentTerm_6 currentTerm_5)
(= votedFor_6 votedFor_5)
(= log_6 log_5)
(= nextIndex_6 nextIndex_5)
(= matchIndex_6 matchIndex_5)
(= votesGranted_6 votesGranted_5)
)
(and ; Action: AppendEntries
(= state_5 Leader)
(= log_6 append(log_5, newEntry))
(= currentTerm_6 currentTerm_5)
(= state_6 state_5)
(= votedFor_6 votedFor_5)
(= commitIndex_6 commitIndex_5)
(= nextIndex_6 nextIndex_5)
(= matchIndex_6 matchIndex_5)
(= votesGranted_6 votesGranted_5)
)
; Stuttering
(and
(= currentTerm_6 currentTerm_5)
(= state_6 state_5)
(= votedFor_6 votedFor_5)
(= log_6 log_5)
(= commitIndex_6 commitIndex_5)
(= nextIndex_6 nextIndex_5)
(= matchIndex_6 matchIndex_5)
(= votesGranted_6 votesGranted_5)
)
)
)
(assert ; Step 6 → 7
(or
(and ; Action: RequestVote
(= state_6 Candidate)
(>= currentTerm_6 lastLogTerm)
(= votesGranted_7 (store votesGranted_6 candidate true))
(= currentTerm_7 currentTerm_6)
(= state_7 state_6)
(= votedFor_7 votedFor_6)
(= log_7 log_6)
(= commitIndex_7 commitIndex_6)
(= nextIndex_7 nextIndex_6)
(= matchIndex_7 matchIndex_6)
)
(and ; Action: HandleRequestVoteRequest
(>= currentTerm_6 candidateTerm)
(= votedFor_7 Some(candidate))
(= currentTerm_7 currentTerm_6)
(= state_7 state_6)
(= log_7 log_6)
(= commitIndex_7 commitIndex_6)
(= nextIndex_7 nextIndex_6)
(= matchIndex_7 matchIndex_6)
(= votesGranted_7 votesGranted_6)
)
(and ; Action: BecomeLeader
(= state_6 Candidate)
votesGranted_size() >= 3
(= state_7 Leader)
(= commitIndex_7 (speckl_len_Int log))
(= currentTerm_7 currentTerm_6)
(= votedFor_7 votedFor_6)
(= log_7 log_6)
(= nextIndex_7 nextIndex_6)
(= matchIndex_7 matchIndex_6)
(= votesGranted_7 votesGranted_6)
)
(and ; Action: AppendEntries
(= state_6 Leader)
(= log_7 append(log_6, newEntry))
(= currentTerm_7 currentTerm_6)
(= state_7 state_6)
(= votedFor_7 votedFor_6)
(= commitIndex_7 commitIndex_6)
(= nextIndex_7 nextIndex_6)
(= matchIndex_7 matchIndex_6)
(= votesGranted_7 votesGranted_6)
)
; Stuttering
(and
(= currentTerm_7 currentTerm_6)
(= state_7 state_6)
(= votedFor_7 votedFor_6)
(= log_7 log_6)
(= commitIndex_7 commitIndex_6)
(= nextIndex_7 nextIndex_6)
(= matchIndex_7 matchIndex_6)
(= votesGranted_7 votesGranted_6)
)
)
)
(assert ; Step 7 → 8
(or
(and ; Action: RequestVote
(= state_7 Candidate)
(>= currentTerm_7 lastLogTerm)
(= votesGranted_8 (store votesGranted_7 candidate true))
(= currentTerm_8 currentTerm_7)
(= state_8 state_7)
(= votedFor_8 votedFor_7)
(= log_8 log_7)
(= commitIndex_8 commitIndex_7)
(= nextIndex_8 nextIndex_7)
(= matchIndex_8 matchIndex_7)
)
(and ; Action: HandleRequestVoteRequest
(>= currentTerm_7 candidateTerm)
(= votedFor_8 Some(candidate))
(= currentTerm_8 currentTerm_7)
(= state_8 state_7)
(= log_8 log_7)
(= commitIndex_8 commitIndex_7)
(= nextIndex_8 nextIndex_7)
(= matchIndex_8 matchIndex_7)
(= votesGranted_8 votesGranted_7)
)
(and ; Action: BecomeLeader
(= state_7 Candidate)
votesGranted_size() >= 3
(= state_8 Leader)
(= commitIndex_8 (speckl_len_Int log))
(= currentTerm_8 currentTerm_7)
(= votedFor_8 votedFor_7)
(= log_8 log_7)
(= nextIndex_8 nextIndex_7)
(= matchIndex_8 matchIndex_7)
(= votesGranted_8 votesGranted_7)
)
(and ; Action: AppendEntries
(= state_7 Leader)
(= log_8 append(log_7, newEntry))
(= currentTerm_8 currentTerm_7)
(= state_8 state_7)
(= votedFor_8 votedFor_7)
(= commitIndex_8 commitIndex_7)
(= nextIndex_8 nextIndex_7)
(= matchIndex_8 matchIndex_7)
(= votesGranted_8 votesGranted_7)
)
; Stuttering
(and
(= currentTerm_8 currentTerm_7)
(= state_8 state_7)
(= votedFor_8 votedFor_7)
(= log_8 log_7)
(= commitIndex_8 commitIndex_7)
(= nextIndex_8 nextIndex_7)
(= matchIndex_8 matchIndex_7)
(= votesGranted_8 votesGranted_7)
)
)
)
(assert ; Step 8 → 9
(or
(and ; Action: RequestVote
(= state_8 Candidate)
(>= currentTerm_8 lastLogTerm)
(= votesGranted_9 (store votesGranted_8 candidate true))
(= currentTerm_9 currentTerm_8)
(= state_9 state_8)
(= votedFor_9 votedFor_8)
(= log_9 log_8)
(= commitIndex_9 commitIndex_8)
(= nextIndex_9 nextIndex_8)
(= matchIndex_9 matchIndex_8)
)
(and ; Action: HandleRequestVoteRequest
(>= currentTerm_8 candidateTerm)
(= votedFor_9 Some(candidate))
(= currentTerm_9 currentTerm_8)
(= state_9 state_8)
(= log_9 log_8)
(= commitIndex_9 commitIndex_8)
(= nextIndex_9 nextIndex_8)
(= matchIndex_9 matchIndex_8)
(= votesGranted_9 votesGranted_8)
)
(and ; Action: BecomeLeader
(= state_8 Candidate)
votesGranted_size() >= 3
(= state_9 Leader)
(= commitIndex_9 (speckl_len_Int log))
(= currentTerm_9 currentTerm_8)
(= votedFor_9 votedFor_8)
(= log_9 log_8)
(= nextIndex_9 nextIndex_8)
(= matchIndex_9 matchIndex_8)
(= votesGranted_9 votesGranted_8)
)
(and ; Action: AppendEntries
(= state_8 Leader)
(= log_9 append(log_8, newEntry))
(= currentTerm_9 currentTerm_8)
(= state_9 state_8)
(= votedFor_9 votedFor_8)
(= commitIndex_9 commitIndex_8)
(= nextIndex_9 nextIndex_8)
(= matchIndex_9 matchIndex_8)
(= votesGranted_9 votesGranted_8)
)
; Stuttering
(and
(= currentTerm_9 currentTerm_8)
(= state_9 state_8)
(= votedFor_9 votedFor_8)
(= log_9 log_8)
(= commitIndex_9 commitIndex_8)
(= nextIndex_9 nextIndex_8)
(= matchIndex_9 matchIndex_8)
(= votesGranted_9 votesGranted_8)
)
)
)
(assert ; Step 9 → 10
(or
(and ; Action: RequestVote
(= state_9 Candidate)
(>= currentTerm_9 lastLogTerm)
(= votesGranted_10 (store votesGranted_9 candidate true))
(= currentTerm_10 currentTerm_9)
(= state_10 state_9)
(= votedFor_10 votedFor_9)
(= log_10 log_9)
(= commitIndex_10 commitIndex_9)
(= nextIndex_10 nextIndex_9)
(= matchIndex_10 matchIndex_9)
)
(and ; Action: HandleRequestVoteRequest
(>= currentTerm_9 candidateTerm)
(= votedFor_10 Some(candidate))
(= currentTerm_10 currentTerm_9)
(= state_10 state_9)
(= log_10 log_9)
(= commitIndex_10 commitIndex_9)
(= nextIndex_10 nextIndex_9)
(= matchIndex_10 matchIndex_9)
(= votesGranted_10 votesGranted_9)
)
(and ; Action: BecomeLeader
(= state_9 Candidate)
votesGranted_size() >= 3
(= state_10 Leader)
(= commitIndex_10 (speckl_len_Int log))
(= currentTerm_10 currentTerm_9)
(= votedFor_10 votedFor_9)
(= log_10 log_9)
(= nextIndex_10 nextIndex_9)
(= matchIndex_10 matchIndex_9)
(= votesGranted_10 votesGranted_9)
)
(and ; Action: AppendEntries
(= state_9 Leader)
(= log_10 append(log_9, newEntry))
(= currentTerm_10 currentTerm_9)
(= state_10 state_9)
(= votedFor_10 votedFor_9)
(= commitIndex_10 commitIndex_9)
(= nextIndex_10 nextIndex_9)
(= matchIndex_10 matchIndex_9)
(= votesGranted_10 votesGranted_9)
)
; Stuttering
(and
(= currentTerm_10 currentTerm_9)
(= state_10 state_9)
(= votedFor_10 votedFor_9)
(= log_10 log_9)
(= commitIndex_10 commitIndex_9)
(= nextIndex_10 nextIndex_9)
(= matchIndex_10 matchIndex_9)
(= votesGranted_10 votesGranted_9)
)
)
)
; Property assertion: not(invariant at some step)
(assert
(or
(not (CommitSafety_0))
(not (CommitSafety_1))
(not (CommitSafety_2))
(not (CommitSafety_3))
(not (CommitSafety_4))
(not (CommitSafety_5))
(not (CommitSafety_6))
(not (CommitSafety_7))
(not (CommitSafety_8))
(not (CommitSafety_9))
(not (CommitSafety_10))
)
)
(define-fun CommitSafety_0 () Bool
(and
commitIndex_0 <= (speckl_len_Int log)
)
)
(define-fun CommitSafety_1 () Bool
(and
commitIndex_1 <= (speckl_len_Int log)
)
)
(define-fun CommitSafety_2 () Bool
(and
commitIndex_2 <= (speckl_len_Int log)
)
)
(define-fun CommitSafety_3 () Bool
(and
commitIndex_3 <= (speckl_len_Int log)
)
)
(define-fun CommitSafety_4 () Bool
(and
commitIndex_4 <= (speckl_len_Int log)
)
)
(define-fun CommitSafety_5 () Bool
(and
commitIndex_5 <= (speckl_len_Int log)
)
)
(define-fun CommitSafety_6 () Bool
(and
commitIndex_6 <= (speckl_len_Int log)
)
)
(define-fun CommitSafety_7 () Bool
(and
commitIndex_7 <= (speckl_len_Int log)
)
)
(define-fun CommitSafety_8 () Bool
(and
commitIndex_8 <= (speckl_len_Int log)
)
)
(define-fun CommitSafety_9 () Bool
(and
commitIndex_9 <= (speckl_len_Int log)
)
)
(define-fun CommitSafety_10 () Bool
(and
commitIndex_10 <= (speckl_len_Int log)
)
)
(echo "Checking: Always(CommitSafety) for 10 steps")
(check-sat)
(get-model)
; Verification: Always(LeaderCompleteness)
; BMC depth: 10
; Declare state copies for 10 steps
(declare-const currentTerm_0 Int)
(declare-const currentTerm_1 Int)
(declare-const currentTerm_2 Int)
(declare-const currentTerm_3 Int)
(declare-const currentTerm_4 Int)
(declare-const currentTerm_5 Int)
(declare-const currentTerm_6 Int)
(declare-const currentTerm_7 Int)
(declare-const currentTerm_8 Int)
(declare-const currentTerm_9 Int)
(declare-const currentTerm_10 Int)
(declare-const state_0 State)
(declare-const state_1 State)
(declare-const state_2 State)
(declare-const state_3 State)
(declare-const state_4 State)
(declare-const state_5 State)
(declare-const state_6 State)
(declare-const state_7 State)
(declare-const state_8 State)
(declare-const state_9 State)
(declare-const state_10 State)
(declare-const votedFor_0 Option_NodeId)
(declare-const votedFor_1 Option_NodeId)
(declare-const votedFor_2 Option_NodeId)
(declare-const votedFor_3 Option_NodeId)
(declare-const votedFor_4 Option_NodeId)
(declare-const votedFor_5 Option_NodeId)
(declare-const votedFor_6 Option_NodeId)
(declare-const votedFor_7 Option_NodeId)
(declare-const votedFor_8 Option_NodeId)
(declare-const votedFor_9 Option_NodeId)
(declare-const votedFor_10 Option_NodeId)
(declare-const log_0 (Array Int LogEntry))
(declare-const log_1 (Array Int LogEntry))
(declare-const log_2 (Array Int LogEntry))
(declare-const log_3 (Array Int LogEntry))
(declare-const log_4 (Array Int LogEntry))
(declare-const log_5 (Array Int LogEntry))
(declare-const log_6 (Array Int LogEntry))
(declare-const log_7 (Array Int LogEntry))
(declare-const log_8 (Array Int LogEntry))
(declare-const log_9 (Array Int LogEntry))
(declare-const log_10 (Array Int LogEntry))
(declare-const commitIndex_0 Int)
(declare-const commitIndex_1 Int)
(declare-const commitIndex_2 Int)
(declare-const commitIndex_3 Int)
(declare-const commitIndex_4 Int)
(declare-const commitIndex_5 Int)
(declare-const commitIndex_6 Int)
(declare-const commitIndex_7 Int)
(declare-const commitIndex_8 Int)
(declare-const commitIndex_9 Int)
(declare-const commitIndex_10 Int)
(declare-const nextIndex_0 (Array NodeId Int))
(declare-const nextIndex_1 (Array NodeId Int))
(declare-const nextIndex_2 (Array NodeId Int))
(declare-const nextIndex_3 (Array NodeId Int))
(declare-const nextIndex_4 (Array NodeId Int))
(declare-const nextIndex_5 (Array NodeId Int))
(declare-const nextIndex_6 (Array NodeId Int))
(declare-const nextIndex_7 (Array NodeId Int))
(declare-const nextIndex_8 (Array NodeId Int))
(declare-const nextIndex_9 (Array NodeId Int))
(declare-const nextIndex_10 (Array NodeId Int))
(declare-const matchIndex_0 (Array NodeId Int))
(declare-const matchIndex_1 (Array NodeId Int))
(declare-const matchIndex_2 (Array NodeId Int))
(declare-const matchIndex_3 (Array NodeId Int))
(declare-const matchIndex_4 (Array NodeId Int))
(declare-const matchIndex_5 (Array NodeId Int))
(declare-const matchIndex_6 (Array NodeId Int))
(declare-const matchIndex_7 (Array NodeId Int))
(declare-const matchIndex_8 (Array NodeId Int))
(declare-const matchIndex_9 (Array NodeId Int))
(declare-const matchIndex_10 (Array NodeId Int))
(declare-const votesGranted_0 (Array NodeId Bool))
(declare-const votesGranted_1 (Array NodeId Bool))
(declare-const votesGranted_2 (Array NodeId Bool))
(declare-const votesGranted_3 (Array NodeId Bool))
(declare-const votesGranted_4 (Array NodeId Bool))
(declare-const votesGranted_5 (Array NodeId Bool))
(declare-const votesGranted_6 (Array NodeId Bool))
(declare-const votesGranted_7 (Array NodeId Bool))
(declare-const votesGranted_8 (Array NodeId Bool))
(declare-const votesGranted_9 (Array NodeId Bool))
(declare-const votesGranted_10 (Array NodeId Bool))
; Initial state constraints
(assert
(and
(>= currentTerm_0 0)
(>= commitIndex_0 0)
)
)
; Transition constraints
(assert ; Step 0 → 1
(or
(and ; Action: RequestVote
(= state_0 Candidate)
(>= currentTerm_0 lastLogTerm)
(= votesGranted_1 (store votesGranted_0 candidate true))
(= currentTerm_1 currentTerm_0)
(= state_1 state_0)
(= votedFor_1 votedFor_0)
(= log_1 log_0)
(= commitIndex_1 commitIndex_0)
(= nextIndex_1 nextIndex_0)
(= matchIndex_1 matchIndex_0)
)
(and ; Action: HandleRequestVoteRequest
(>= currentTerm_0 candidateTerm)
(= votedFor_1 Some(candidate))
(= currentTerm_1 currentTerm_0)
(= state_1 state_0)
(= log_1 log_0)
(= commitIndex_1 commitIndex_0)
(= nextIndex_1 nextIndex_0)
(= matchIndex_1 matchIndex_0)
(= votesGranted_1 votesGranted_0)
)
(and ; Action: BecomeLeader
(= state_0 Candidate)
votesGranted_size() >= 3
(= state_1 Leader)
(= commitIndex_1 (speckl_len_Int log))
(= currentTerm_1 currentTerm_0)
(= votedFor_1 votedFor_0)
(= log_1 log_0)
(= nextIndex_1 nextIndex_0)
(= matchIndex_1 matchIndex_0)
(= votesGranted_1 votesGranted_0)
)
(and ; Action: AppendEntries
(= state_0 Leader)
(= log_1 append(log_0, newEntry))
(= currentTerm_1 currentTerm_0)
(= state_1 state_0)
(= votedFor_1 votedFor_0)
(= commitIndex_1 commitIndex_0)
(= nextIndex_1 nextIndex_0)
(= matchIndex_1 matchIndex_0)
(= votesGranted_1 votesGranted_0)
)
; Stuttering
(and
(= currentTerm_1 currentTerm_0)
(= state_1 state_0)
(= votedFor_1 votedFor_0)
(= log_1 log_0)
(= commitIndex_1 commitIndex_0)
(= nextIndex_1 nextIndex_0)
(= matchIndex_1 matchIndex_0)
(= votesGranted_1 votesGranted_0)
)
)
)
(assert ; Step 1 → 2
(or
(and ; Action: RequestVote
(= state_1 Candidate)
(>= currentTerm_1 lastLogTerm)
(= votesGranted_2 (store votesGranted_1 candidate true))
(= currentTerm_2 currentTerm_1)
(= state_2 state_1)
(= votedFor_2 votedFor_1)
(= log_2 log_1)
(= commitIndex_2 commitIndex_1)
(= nextIndex_2 nextIndex_1)
(= matchIndex_2 matchIndex_1)
)
(and ; Action: HandleRequestVoteRequest
(>= currentTerm_1 candidateTerm)
(= votedFor_2 Some(candidate))
(= currentTerm_2 currentTerm_1)
(= state_2 state_1)
(= log_2 log_1)
(= commitIndex_2 commitIndex_1)
(= nextIndex_2 nextIndex_1)
(= matchIndex_2 matchIndex_1)
(= votesGranted_2 votesGranted_1)
)
(and ; Action: BecomeLeader
(= state_1 Candidate)
votesGranted_size() >= 3
(= state_2 Leader)
(= commitIndex_2 (speckl_len_Int log))
(= currentTerm_2 currentTerm_1)
(= votedFor_2 votedFor_1)
(= log_2 log_1)
(= nextIndex_2 nextIndex_1)
(= matchIndex_2 matchIndex_1)
(= votesGranted_2 votesGranted_1)
)
(and ; Action: AppendEntries
(= state_1 Leader)
(= log_2 append(log_1, newEntry))
(= currentTerm_2 currentTerm_1)
(= state_2 state_1)
(= votedFor_2 votedFor_1)
(= commitIndex_2 commitIndex_1)
(= nextIndex_2 nextIndex_1)
(= matchIndex_2 matchIndex_1)
(= votesGranted_2 votesGranted_1)
)
; Stuttering
(and
(= currentTerm_2 currentTerm_1)
(= state_2 state_1)
(= votedFor_2 votedFor_1)
(= log_2 log_1)
(= commitIndex_2 commitIndex_1)
(= nextIndex_2 nextIndex_1)
(= matchIndex_2 matchIndex_1)
(= votesGranted_2 votesGranted_1)
)
)
)
(assert ; Step 2 → 3
(or
(and ; Action: RequestVote
(= state_2 Candidate)
(>= currentTerm_2 lastLogTerm)
(= votesGranted_3 (store votesGranted_2 candidate true))
(= currentTerm_3 currentTerm_2)
(= state_3 state_2)
(= votedFor_3 votedFor_2)
(= log_3 log_2)
(= commitIndex_3 commitIndex_2)
(= nextIndex_3 nextIndex_2)
(= matchIndex_3 matchIndex_2)
)
(and ; Action: HandleRequestVoteRequest
(>= currentTerm_2 candidateTerm)
(= votedFor_3 Some(candidate))
(= currentTerm_3 currentTerm_2)
(= state_3 state_2)
(= log_3 log_2)
(= commitIndex_3 commitIndex_2)
(= nextIndex_3 nextIndex_2)
(= matchIndex_3 matchIndex_2)
(= votesGranted_3 votesGranted_2)
)
(and ; Action: BecomeLeader
(= state_2 Candidate)
votesGranted_size() >= 3
(= state_3 Leader)
(= commitIndex_3 (speckl_len_Int log))
(= currentTerm_3 currentTerm_2)
(= votedFor_3 votedFor_2)
(= log_3 log_2)
(= nextIndex_3 nextIndex_2)
(= matchIndex_3 matchIndex_2)
(= votesGranted_3 votesGranted_2)
)
(and ; Action: AppendEntries
(= state_2 Leader)
(= log_3 append(log_2, newEntry))
(= currentTerm_3 currentTerm_2)
(= state_3 state_2)
(= votedFor_3 votedFor_2)
(= commitIndex_3 commitIndex_2)
(= nextIndex_3 nextIndex_2)
(= matchIndex_3 matchIndex_2)
(= votesGranted_3 votesGranted_2)
)
; Stuttering
(and
(= currentTerm_3 currentTerm_2)
(= state_3 state_2)
(= votedFor_3 votedFor_2)
(= log_3 log_2)
(= commitIndex_3 commitIndex_2)
(= nextIndex_3 nextIndex_2)
(= matchIndex_3 matchIndex_2)
(= votesGranted_3 votesGranted_2)
)
)
)
(assert ; Step 3 → 4
(or
(and ; Action: RequestVote
(= state_3 Candidate)
(>= currentTerm_3 lastLogTerm)
(= votesGranted_4 (store votesGranted_3 candidate true))
(= currentTerm_4 currentTerm_3)
(= state_4 state_3)
(= votedFor_4 votedFor_3)
(= log_4 log_3)
(= commitIndex_4 commitIndex_3)
(= nextIndex_4 nextIndex_3)
(= matchIndex_4 matchIndex_3)
)
(and ; Action: HandleRequestVoteRequest
(>= currentTerm_3 candidateTerm)
(= votedFor_4 Some(candidate))
(= currentTerm_4 currentTerm_3)
(= state_4 state_3)
(= log_4 log_3)
(= commitIndex_4 commitIndex_3)
(= nextIndex_4 nextIndex_3)
(= matchIndex_4 matchIndex_3)
(= votesGranted_4 votesGranted_3)
)
(and ; Action: BecomeLeader
(= state_3 Candidate)
votesGranted_size() >= 3
(= state_4 Leader)
(= commitIndex_4 (speckl_len_Int log))
(= currentTerm_4 currentTerm_3)
(= votedFor_4 votedFor_3)
(= log_4 log_3)
(= nextIndex_4 nextIndex_3)
(= matchIndex_4 matchIndex_3)
(= votesGranted_4 votesGranted_3)
)
(and ; Action: AppendEntries
(= state_3 Leader)
(= log_4 append(log_3, newEntry))
(= currentTerm_4 currentTerm_3)
(= state_4 state_3)
(= votedFor_4 votedFor_3)
(= commitIndex_4 commitIndex_3)
(= nextIndex_4 nextIndex_3)
(= matchIndex_4 matchIndex_3)
(= votesGranted_4 votesGranted_3)
)
; Stuttering
(and
(= currentTerm_4 currentTerm_3)
(= state_4 state_3)
(= votedFor_4 votedFor_3)
(= log_4 log_3)
(= commitIndex_4 commitIndex_3)
(= nextIndex_4 nextIndex_3)
(= matchIndex_4 matchIndex_3)
(= votesGranted_4 votesGranted_3)
)
)
)
(assert ; Step 4 → 5
(or
(and ; Action: RequestVote
(= state_4 Candidate)
(>= currentTerm_4 lastLogTerm)
(= votesGranted_5 (store votesGranted_4 candidate true))
(= currentTerm_5 currentTerm_4)
(= state_5 state_4)
(= votedFor_5 votedFor_4)
(= log_5 log_4)
(= commitIndex_5 commitIndex_4)
(= nextIndex_5 nextIndex_4)
(= matchIndex_5 matchIndex_4)
)
(and ; Action: HandleRequestVoteRequest
(>= currentTerm_4 candidateTerm)
(= votedFor_5 Some(candidate))
(= currentTerm_5 currentTerm_4)
(= state_5 state_4)
(= log_5 log_4)
(= commitIndex_5 commitIndex_4)
(= nextIndex_5 nextIndex_4)
(= matchIndex_5 matchIndex_4)
(= votesGranted_5 votesGranted_4)
)
(and ; Action: BecomeLeader
(= state_4 Candidate)
votesGranted_size() >= 3
(= state_5 Leader)
(= commitIndex_5 (speckl_len_Int log))
(= currentTerm_5 currentTerm_4)
(= votedFor_5 votedFor_4)
(= log_5 log_4)
(= nextIndex_5 nextIndex_4)
(= matchIndex_5 matchIndex_4)
(= votesGranted_5 votesGranted_4)
)
(and ; Action: AppendEntries
(= state_4 Leader)
(= log_5 append(log_4, newEntry))
(= currentTerm_5 currentTerm_4)
(= state_5 state_4)
(= votedFor_5 votedFor_4)
(= commitIndex_5 commitIndex_4)
(= nextIndex_5 nextIndex_4)
(= matchIndex_5 matchIndex_4)
(= votesGranted_5 votesGranted_4)
)
; Stuttering
(and
(= currentTerm_5 currentTerm_4)
(= state_5 state_4)
(= votedFor_5 votedFor_4)
(= log_5 log_4)
(= commitIndex_5 commitIndex_4)
(= nextIndex_5 nextIndex_4)
(= matchIndex_5 matchIndex_4)
(= votesGranted_5 votesGranted_4)
)
)
)
(assert ; Step 5 → 6
(or
(and ; Action: RequestVote
(= state_5 Candidate)
(>= currentTerm_5 lastLogTerm)
(= votesGranted_6 (store votesGranted_5 candidate true))
(= currentTerm_6 currentTerm_5)
(= state_6 state_5)
(= votedFor_6 votedFor_5)
(= log_6 log_5)
(= commitIndex_6 commitIndex_5)
(= nextIndex_6 nextIndex_5)
(= matchIndex_6 matchIndex_5)
)
(and ; Action: HandleRequestVoteRequest
(>= currentTerm_5 candidateTerm)
(= votedFor_6 Some(candidate))
(= currentTerm_6 currentTerm_5)
(= state_6 state_5)
(= log_6 log_5)
(= commitIndex_6 commitIndex_5)
(= nextIndex_6 nextIndex_5)
(= matchIndex_6 matchIndex_5)
(= votesGranted_6 votesGranted_5)
)
(and ; Action: BecomeLeader
(= state_5 Candidate)
votesGranted_size() >= 3
(= state_6 Leader)
(= commitIndex_6 (speckl_len_Int log))
(= currentTerm_6 currentTerm_5)
(= votedFor_6 votedFor_5)
(= log_6 log_5)
(= nextIndex_6 nextIndex_5)
(= matchIndex_6 matchIndex_5)
(= votesGranted_6 votesGranted_5)
)
(and ; Action: AppendEntries
(= state_5 Leader)
(= log_6 append(log_5, newEntry))
(= currentTerm_6 currentTerm_5)
(= state_6 state_5)
(= votedFor_6 votedFor_5)
(= commitIndex_6 commitIndex_5)
(= nextIndex_6 nextIndex_5)
(= matchIndex_6 matchIndex_5)
(= votesGranted_6 votesGranted_5)
)
; Stuttering
(and
(= currentTerm_6 currentTerm_5)
(= state_6 state_5)
(= votedFor_6 votedFor_5)
(= log_6 log_5)
(= commitIndex_6 commitIndex_5)
(= nextIndex_6 nextIndex_5)
(= matchIndex_6 matchIndex_5)
(= votesGranted_6 votesGranted_5)
)
)
)
(assert ; Step 6 → 7
(or
(and ; Action: RequestVote
(= state_6 Candidate)
(>= currentTerm_6 lastLogTerm)
(= votesGranted_7 (store votesGranted_6 candidate true))
(= currentTerm_7 currentTerm_6)
(= state_7 state_6)
(= votedFor_7 votedFor_6)
(= log_7 log_6)
(= commitIndex_7 commitIndex_6)
(= nextIndex_7 nextIndex_6)
(= matchIndex_7 matchIndex_6)
)
(and ; Action: HandleRequestVoteRequest
(>= currentTerm_6 candidateTerm)
(= votedFor_7 Some(candidate))
(= currentTerm_7 currentTerm_6)
(= state_7 state_6)
(= log_7 log_6)
(= commitIndex_7 commitIndex_6)
(= nextIndex_7 nextIndex_6)
(= matchIndex_7 matchIndex_6)
(= votesGranted_7 votesGranted_6)
)
(and ; Action: BecomeLeader
(= state_6 Candidate)
votesGranted_size() >= 3
(= state_7 Leader)
(= commitIndex_7 (speckl_len_Int log))
(= currentTerm_7 currentTerm_6)
(= votedFor_7 votedFor_6)
(= log_7 log_6)
(= nextIndex_7 nextIndex_6)
(= matchIndex_7 matchIndex_6)
(= votesGranted_7 votesGranted_6)
)
(and ; Action: AppendEntries
(= state_6 Leader)
(= log_7 append(log_6, newEntry))
(= currentTerm_7 currentTerm_6)
(= state_7 state_6)
(= votedFor_7 votedFor_6)
(= commitIndex_7 commitIndex_6)
(= nextIndex_7 nextIndex_6)
(= matchIndex_7 matchIndex_6)
(= votesGranted_7 votesGranted_6)
)
; Stuttering
(and
(= currentTerm_7 currentTerm_6)
(= state_7 state_6)
(= votedFor_7 votedFor_6)
(= log_7 log_6)
(= commitIndex_7 commitIndex_6)
(= nextIndex_7 nextIndex_6)
(= matchIndex_7 matchIndex_6)
(= votesGranted_7 votesGranted_6)
)
)
)
(assert ; Step 7 → 8
(or
(and ; Action: RequestVote
(= state_7 Candidate)
(>= currentTerm_7 lastLogTerm)
(= votesGranted_8 (store votesGranted_7 candidate true))
(= currentTerm_8 currentTerm_7)
(= state_8 state_7)
(= votedFor_8 votedFor_7)
(= log_8 log_7)
(= commitIndex_8 commitIndex_7)
(= nextIndex_8 nextIndex_7)
(= matchIndex_8 matchIndex_7)
)
(and ; Action: HandleRequestVoteRequest
(>= currentTerm_7 candidateTerm)
(= votedFor_8 Some(candidate))
(= currentTerm_8 currentTerm_7)
(= state_8 state_7)
(= log_8 log_7)
(= commitIndex_8 commitIndex_7)
(= nextIndex_8 nextIndex_7)
(= matchIndex_8 matchIndex_7)
(= votesGranted_8 votesGranted_7)
)
(and ; Action: BecomeLeader
(= state_7 Candidate)
votesGranted_size() >= 3
(= state_8 Leader)
(= commitIndex_8 (speckl_len_Int log))
(= currentTerm_8 currentTerm_7)
(= votedFor_8 votedFor_7)
(= log_8 log_7)
(= nextIndex_8 nextIndex_7)
(= matchIndex_8 matchIndex_7)
(= votesGranted_8 votesGranted_7)
)
(and ; Action: AppendEntries
(= state_7 Leader)
(= log_8 append(log_7, newEntry))
(= currentTerm_8 currentTerm_7)
(= state_8 state_7)
(= votedFor_8 votedFor_7)
(= commitIndex_8 commitIndex_7)
(= nextIndex_8 nextIndex_7)
(= matchIndex_8 matchIndex_7)
(= votesGranted_8 votesGranted_7)
)
; Stuttering
(and
(= currentTerm_8 currentTerm_7)
(= state_8 state_7)
(= votedFor_8 votedFor_7)
(= log_8 log_7)
(= commitIndex_8 commitIndex_7)
(= nextIndex_8 nextIndex_7)
(= matchIndex_8 matchIndex_7)
(= votesGranted_8 votesGranted_7)
)
)
)
(assert ; Step 8 → 9
(or
(and ; Action: RequestVote
(= state_8 Candidate)
(>= currentTerm_8 lastLogTerm)
(= votesGranted_9 (store votesGranted_8 candidate true))
(= currentTerm_9 currentTerm_8)
(= state_9 state_8)
(= votedFor_9 votedFor_8)
(= log_9 log_8)
(= commitIndex_9 commitIndex_8)
(= nextIndex_9 nextIndex_8)
(= matchIndex_9 matchIndex_8)
)
(and ; Action: HandleRequestVoteRequest
(>= currentTerm_8 candidateTerm)
(= votedFor_9 Some(candidate))
(= currentTerm_9 currentTerm_8)
(= state_9 state_8)
(= log_9 log_8)
(= commitIndex_9 commitIndex_8)
(= nextIndex_9 nextIndex_8)
(= matchIndex_9 matchIndex_8)
(= votesGranted_9 votesGranted_8)
)
(and ; Action: BecomeLeader
(= state_8 Candidate)
votesGranted_size() >= 3
(= state_9 Leader)
(= commitIndex_9 (speckl_len_Int log))
(= currentTerm_9 currentTerm_8)
(= votedFor_9 votedFor_8)
(= log_9 log_8)
(= nextIndex_9 nextIndex_8)
(= matchIndex_9 matchIndex_8)
(= votesGranted_9 votesGranted_8)
)
(and ; Action: AppendEntries
(= state_8 Leader)
(= log_9 append(log_8, newEntry))
(= currentTerm_9 currentTerm_8)
(= state_9 state_8)
(= votedFor_9 votedFor_8)
(= commitIndex_9 commitIndex_8)
(= nextIndex_9 nextIndex_8)
(= matchIndex_9 matchIndex_8)
(= votesGranted_9 votesGranted_8)
)
; Stuttering
(and
(= currentTerm_9 currentTerm_8)
(= state_9 state_8)
(= votedFor_9 votedFor_8)
(= log_9 log_8)
(= commitIndex_9 commitIndex_8)
(= nextIndex_9 nextIndex_8)
(= matchIndex_9 matchIndex_8)
(= votesGranted_9 votesGranted_8)
)
)
)
(assert ; Step 9 → 10
(or
(and ; Action: RequestVote
(= state_9 Candidate)
(>= currentTerm_9 lastLogTerm)
(= votesGranted_10 (store votesGranted_9 candidate true))
(= currentTerm_10 currentTerm_9)
(= state_10 state_9)
(= votedFor_10 votedFor_9)
(= log_10 log_9)
(= commitIndex_10 commitIndex_9)
(= nextIndex_10 nextIndex_9)
(= matchIndex_10 matchIndex_9)
)
(and ; Action: HandleRequestVoteRequest
(>= currentTerm_9 candidateTerm)
(= votedFor_10 Some(candidate))
(= currentTerm_10 currentTerm_9)
(= state_10 state_9)
(= log_10 log_9)
(= commitIndex_10 commitIndex_9)
(= nextIndex_10 nextIndex_9)
(= matchIndex_10 matchIndex_9)
(= votesGranted_10 votesGranted_9)
)
(and ; Action: BecomeLeader
(= state_9 Candidate)
votesGranted_size() >= 3
(= state_10 Leader)
(= commitIndex_10 (speckl_len_Int log))
(= currentTerm_10 currentTerm_9)
(= votedFor_10 votedFor_9)
(= log_10 log_9)
(= nextIndex_10 nextIndex_9)
(= matchIndex_10 matchIndex_9)
(= votesGranted_10 votesGranted_9)
)
(and ; Action: AppendEntries
(= state_9 Leader)
(= log_10 append(log_9, newEntry))
(= currentTerm_10 currentTerm_9)
(= state_10 state_9)
(= votedFor_10 votedFor_9)
(= commitIndex_10 commitIndex_9)
(= nextIndex_10 nextIndex_9)
(= matchIndex_10 matchIndex_9)
(= votesGranted_10 votesGranted_9)
)
; Stuttering
(and
(= currentTerm_10 currentTerm_9)
(= state_10 state_9)
(= votedFor_10 votedFor_9)
(= log_10 log_9)
(= commitIndex_10 commitIndex_9)
(= nextIndex_10 nextIndex_9)
(= matchIndex_10 matchIndex_9)
(= votesGranted_10 votesGranted_9)
)
)
)
; Property assertion: not(invariant at some step)
(assert
(or
(not (LeaderCompleteness_0))
(not (LeaderCompleteness_1))
(not (LeaderCompleteness_2))
(not (LeaderCompleteness_3))
(not (LeaderCompleteness_4))
(not (LeaderCompleteness_5))
(not (LeaderCompleteness_6))
(not (LeaderCompleteness_7))
(not (LeaderCompleteness_8))
(not (LeaderCompleteness_9))
(not (LeaderCompleteness_10))
)
)
(define-fun LeaderCompleteness_0 () Bool
(and
commitIndex_0 <= (speckl_len_Int log)
)
)
(define-fun LeaderCompleteness_1 () Bool
(and
commitIndex_1 <= (speckl_len_Int log)
)
)
(define-fun LeaderCompleteness_2 () Bool
(and
commitIndex_2 <= (speckl_len_Int log)
)
)
(define-fun LeaderCompleteness_3 () Bool
(and
commitIndex_3 <= (speckl_len_Int log)
)
)
(define-fun LeaderCompleteness_4 () Bool
(and
commitIndex_4 <= (speckl_len_Int log)
)
)
(define-fun LeaderCompleteness_5 () Bool
(and
commitIndex_5 <= (speckl_len_Int log)
)
)
(define-fun LeaderCompleteness_6 () Bool
(and
commitIndex_6 <= (speckl_len_Int log)
)
)
(define-fun LeaderCompleteness_7 () Bool
(and
commitIndex_7 <= (speckl_len_Int log)
)
)
(define-fun LeaderCompleteness_8 () Bool
(and
commitIndex_8 <= (speckl_len_Int log)
)
)
(define-fun LeaderCompleteness_9 () Bool
(and
commitIndex_9 <= (speckl_len_Int log)
)
)
(define-fun LeaderCompleteness_10 () Bool
(and
commitIndex_10 <= (speckl_len_Int log)
)
)
(echo "Checking: Always(LeaderCompleteness) for 10 steps")
(check-sat)
(get-model)