| Algorithm 1 ExVerus Pipeline 1: procedure ExVerus ( P,Φ,model,MaxAttempts,\textscMaxZ3,k ) 2: Π0←\textscInitProofGen(P,Φ,model) 3: (st,ℓ)←\textscVerify(P,Φ,Π0) 4: if st=\textscPass then 5: return { Π0 , status= Pass , phase=init_gen} 6: end if 7: Π←Π0 8: for t←1 to MaxAttempts do 9: (st,ℓ)←\textscVerify(P,Φ,Π) ▹ st,ℓ refer to status and verification log 10: if st=\textscPass then 11: return { Π , status= Pass , phase=cex_repair} 12: end if 13: if st=\textscCompileError then 14: Π←\textscCompilationFixer(Π,ℓ,model) 15: continue 16: end if 17: et←\textscExtractAndPrioritizeErr(ℓ) 18: Σt←\textscCexGen(Π,et,model,k,\textscMaxZ3) 19: if \textscIsInvariantErr(et)∧Σt=∅ then ▹ Check if et is an invariant bug and Σt is not empty 20: Σtval←\textscValidateCex(P,Φ,Π,et,Σt) 21: else 22: Σtval←Σt 23: end if 24: Π′←\textscMutValRepair(Π,et,Σtval,model) 25: if Π′=∅ then 26: continue 27: else 28: Π←Π′ 29: end if 30: end for 31: (st,ℓ)←\textscVerify(P,Φ,Π) 32: if st=\textscPass then 33: return { Π , status= Pass , phase=cex_repair} 34: else 35: return { Π , status= Fail , phase=cex_repair} 36: end if 37: end procedure | Algorithm 2 Counterexample Generation ( Σt=\textscSolve(z3pyt) ) 1: procedure CexGen ( Πt,et,model,k,\textscMaxZ3 ) 2: for i←1 to MaxZ3 do 3: Qt←\textscMakeCexPrompt(Πt,et,k) ▹ Qt is a query-generation prompt 4: z3pyt←\textscQuerySyn(Qt,model) ▹ LLM translates Qt to a Z3Py script 5: (status,raw)←\textscRunZ3(z3pyt) 6: if status=\textscsat then 7: Qt←\textscFeedback(Qt,status) 8: continue 9: end if 10: norm←\textscNormalize(raw) ▹ normalize format 11: if ¬\textscSemanticValid(norm,Πt) or ∣norm∣<k/2 then 12: Qt←\textscFeedback(Qt,\textscgatefail) 13: continue 14: end if 15: return \textscMakeCEX(norm,et) ▹ returns Σt 16: end for 17: return ∅ 18: end procedure Algorithm 3 Mutation-based Counterexample-guided Repair 1: procedure MutValRepair ( Πt,et,Σtval,model ) 2: (vt,rt)←\textscErrorTriage(Πt,et,Σtval,model) 3: Mt←\textscMutatorSelect(Mall,vt) 4: Ct←\textscApplyMutator(Mt,Πt,et,Σtval,rt,model) 5: if Ct=∅ then 6: return ∅ 7: end if 8: Ct←\textscFilterCompilable(Ct) 9: if \textscAnyPass(Ct) then 10: return \textscFirstPass(Ct) 11: end if 12: return \textscRankTop(Ct,Σtval,et) 13: end procedure |