Skip to content

Can I use lemmas for constraining types for initial functions? #2618

Discussion options

You must be logged in to vote

Yes, you can simply define it to be the other mergeSort and use the lemma to conclude:

assume val _mergeSort (l : list int) : list int

let cmp (x y : int) = x < y

assume val sortReturnsSorted (l : list int) : Lemma (sorted cmp (_mergeSort l))

let mergeSort (l : list int) : (r : list int { sorted cmp r }) =
  sortReturnsSorted l ;
  _mergeSort l

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@WhiteBlackGoose
Comment options

@TheoWinterhalter
Comment options

@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