{"schema_version":"ocme-site-results-v1","locale":"zh-Hant","page_type":"derivations","facts":{"questions":36000,"reviewed":36000,"display_candidates":0,"knowledge":302,"guides":299,"paths":59,"batches":360,"families":1441,"atlas":302,"core":80,"evidence":9,"formal_evidence":5,"formal_subjects":4,"lean_files":6,"lean_toolchain":"leanprover/lean4:v4.30.0","question_state":"candidate","english_state":"ai_candidate","question_Lean":"NOT_RUN","canonical_truth_promotion":false},"filters":{"q":"mko-algorithm-correctness"},"kind":"guides","total":1,"pages":1,"page":1,"entries":[{"id":"derivation-mko-algorithm-correctness-01","title":{"zh-Hant":"算法正確性：非確定性相鄰交換排序的部分正確、終止與總正確","en":"Algorithm correctness: partial correctness, termination and total correctness of nondeterministic adjacent-swap sorting"},"summary":{"zh-Hant":"在有限狀態模型 M 中，狀態是 (1,2,3) 的六個排列，初始狀態 (3,2,1)，每步可非確定性地交換任一個相鄰逆序對，Halt={(1,2,3)}。以後置條件「遞增排列且為輸入的重排」證明 M 的部分正確性、終止性與總正確性：用排名函數 inv（逆序數）證明每條執行至多 3 步，且每條極大執行停在 Halt。再以變體 M′（允許交換任何相鄰對）說明一條成功路徑與部分正確都不足以得到總正確，以變體 M″（錯誤的停止條件）說明終止不足以得到正確。","en":"In a finite-state model M whose states are the six permutations of (1,2,3), with initial state (3,2,1), each step may nondeterministically swap any adjacent inverted pair, and Halt={(1,2,3)}. With the postcondition 'increasing, and a rearrangement of the input', prove partial correctness, termination and total correctness of M, using the ranking function inv (the number of inversions) to show every execution takes at most 3 steps and every maximal execution stops in Halt. Then use the variant M′ (any adjacent pair may be swapped) to show that one successful path and partial correctness do not give total correctness, and the variant M″ (a wrong halting condition) to show that termination does not give correctness."},"mko_ids":["mko-algorithm-correctness"]}],"title":"概念推導導讀"}
