{"id":19364352,"url":"https://github.com/davidfstr/idris-insertion-sort","last_synced_at":"2026-02-16T22:05:54.557Z","repository":{"id":28286220,"uuid":"31798587","full_name":"davidfstr/idris-insertion-sort","owner":"davidfstr","description":"Provably correct implementation of insertion sort in Idris.","archived":false,"fork":false,"pushed_at":"2021-04-23T14:00:26.000Z","size":6,"stargazers_count":30,"open_issues_count":0,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-24T03:36:36.489Z","etag":null,"topics":["idris","insertion-sort","proof"],"latest_commit_sha":null,"homepage":null,"language":"Idris","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/davidfstr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-03-07T02:45:53.000Z","updated_at":"2025-02-14T15:46:58.000Z","dependencies_parsed_at":"2022-07-08T11:01:36.992Z","dependency_job_id":null,"html_url":"https://github.com/davidfstr/idris-insertion-sort","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidfstr%2Fidris-insertion-sort","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidfstr%2Fidris-insertion-sort/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidfstr%2Fidris-insertion-sort/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidfstr%2Fidris-insertion-sort/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/davidfstr","download_url":"https://codeload.github.com/davidfstr/idris-insertion-sort/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240483765,"owners_count":19808636,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["idris","insertion-sort","proof"],"created_at":"2024-11-10T07:37:10.973Z","updated_at":"2025-10-13T16:12:35.645Z","avatar_url":"https://github.com/davidfstr.png","language":"Idris","readme":"# idris-insertion-sort\n\nThis is a provably correct implementation of insertion sort in Idris.\n\nSpecifically, it is an implementation of the following function definition:\n\n```\ninsertionSort :\n    Ord e =\u003e\n    (xs:Vect n e) -\u003e\n    (xs':Vect n e ** (IsSorted xs', ElemsAreSame xs xs'))\n```\n\nGiven a list of elements, this function will return:\n\n1. an output list,\n2. an `IsSorted` proof that the output list is sorted, and\n3. an `ElemsAreSame` proof that the input list and output lists contain\n   the same elements.\n\nThis program makes heavy use of proof terms, a special facility only available\nin dependently-typed programming languages like Idris.\n\n## Prerequisites\n\n* Idris 1.3.1 or later\n    - Probably any Idris 1.x will work.\n* Make\n\n## How to Run\n\n```\nmake run\n```\n\n## Example Output\n\n```\n$ make run\nidris -o InsertionSort InsertionSort.idr\n./InsertionSort\nPlease type a space-separated list of integers: \n3 2 1\nAfter sorting, the integers are: \n1 2 3\n```\n\n## See the Proof Term!\n\nAnother way to run the program is to run it directly using the Idris\ninterpreter. The advantage here is that you can see not just the resulting\nsorted output list but also the resulting proof terms of the algorithm.\n\n```\n$ idris --nobanner InsertionSort.idr\n*InsertionSort\u003e insertionSort [2,1]\nMkSigma [1, 2]\n        (IsSortedMany 1 2 [] Oh (IsSortedOne 2),\n         SamenessIsTransitive (PrependXIsPrependX 2\n                                                  (SamenessIsTransitive (PrependXIsPrependX 1\n                                                                                            NilIsNil)\n                                                                        (PrependXIsPrependX 1\n                                                                                            NilIsNil)))\n                              (PrependXYIsPrependYX 2\n                                                    1\n                                                    NilIsNil)) : Sigma (Vect 2\n                                                                             Integer)\n                                                                       (\\xs' =\u003e\n                                                                          (IsSorted xs',\n                                                                           ElemsAreSame [2,\n                                                                                         1]\n                                                                                        xs'))\n```\n\n## License\n\nCopyright (c) 2015 by David Foster\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavidfstr%2Fidris-insertion-sort","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdavidfstr%2Fidris-insertion-sort","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavidfstr%2Fidris-insertion-sort/lists"}