Created
June 13, 2013 11:32
-
-
Save kgabis/5773025 to your computer and use it in GitHub Desktop.
List in lotos
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| specification LIST : noexit | |
| library NATURAL endlib | |
| library BOOLEAN endlib | |
| type LIST is NATURAL | |
| sorts | |
| LIST (*! implementedby LIST | |
| comparedby CMP_LIST | |
| iteratedby ENUM_FIRST_LIST and ENUM_NEXT_LIST | |
| printedby PRINT_LIST *) | |
| opns | |
| <> (*! implementedby EMPTY constructor *) : -> LIST | |
| _+_ (*! implementedby ADD constructor *) : NAT, LIST -> LIST | |
| _++_ (*! implementedby CONCAT *) : LIST, LIST -> LIST | |
| REVERSE (*! implementedby REVERSE *) : LIST -> LIST | |
| FIRST (*! implementedby FIRST *) : LIST -> NAT | |
| LAST (*! implementedby LAST *) : LIST -> NAT | |
| LENGTH (*! implementedby LENGTH *) : LIST -> NAT | |
| eqns forall s, t : LIST, | |
| x, y : NAT | |
| ofsort LIST | |
| <> ++ s = s; | |
| (y + s) ++ t = y + (s ++ t); | |
| REVERSE(<>) = <>; | |
| REVERSE(y + s) = REVERSE(s) ++ (y + <>); | |
| ofsort NAT | |
| LENGTH(<>) = 0; | |
| LENGTH(y + s) = SUCC(LENGTH(s)); | |
| FIRST (y + s) = y; | |
| LAST (y + <>) = y; | |
| LAST (y + s) = LAST (s); | |
| endtype | |
| behavior | |
| stop | |
| endspec | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment