Skip to content

Cannot prove merge sort with tree recursion #2617

Answered by TWal
WhiteBlackGoose asked this question in Q&A
Discussion options

You must be logged in to vote

Hello!

Your call to sortReturnsSorted is wrong, here is how you should call them:

        sortReturnsSorted left;
        sortReturnsSorted right;

Otherwise in your current proof, what is proved by your recursive call is the fact sorted (sorted (mergeSort left)).

Another remark, which is more style-related: in your mergedCorrectly lemma, it is better to avoid using the implication ==> and use the requires / ensures construct. Like that, you won't be able to call this lemma if you can't prove that the input list aren't sorted!

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@WhiteBlackGoose
Comment options

Answer selected by WhiteBlackGoose
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants