1
我已經試過證明樂趣bubble_main
是有序的,但沒有辦法似乎工作。請問這裏有人能幫我證明引理is_ordered (bubble_main L)
。證明氣泡排序是由詞條排序
我剛剛刪除了我以前的所有引理,因爲似乎沒有任何幫助Isabelle找到一個證明。 這裏是我的代碼/理論:
所有的text{*check if the list is ordered ascendant*}
fun is_sorted :: "nat list ⇒ bool" where
"is_sorted (x1 # x2 # xs) = (x1 < x2 ∧ is_sorted (x2 # xs))" |
"is_sorted x = True"
fun bubble_once :: "nat list ⇒ nat list" where
"bubble_once (x1 # x2 # xs) = (if x1 < x2
then x1 # bubble_once (x2 # xs)
else x2 # bubble_once (x1 # xs))" |
"bubble_once xs = xs"
text{*calls fun bubble_once *}
fun bubble_all where
"bubble_all 0 L = L"|
"bubble_all (Suc n) L = burbuja_all n (bubble_once L)"
text{*main function *}
fun bubble_main where
"bubble_main L = bubble_main (length L) L"
text{*-----prove by induction-----*}
lemma "is_sorted (bubble_main L)"
apply (induction L)
apply auto
quickcheck
oops
爲什麼應該isabelle跳過一些證明,這是因爲一些引理給isabelle一條不穩定的路徑?我試圖導入L,並跳過了長度的事實。另一個疑問是,證明另一個引理可以幫助isabelle或者你提到的上面兩個是足夠的嗎? 我的意見是試圖證明最後一個元素永遠是列表中最大的nat。不好的問題? –
當然,伊莎貝爾最終不會跳過證據,「對不起」只能用於證明開發和實驗。我插入各種'抱歉'給你一些你可能需要的屬性的提示。當然,你必須證明最後一個元素是最大的,比較。屬性'x_large'。 –