{"id":13649146,"url":"https://github.com/hwayne/lets-prove-leftpad","last_synced_at":"2026-02-01T22:31:35.023Z","repository":{"id":34766285,"uuid":"132528683","full_name":"hwayne/lets-prove-leftpad","owner":"hwayne","description":"Proving leftpad correct two-dozen different ways","archived":false,"fork":false,"pushed_at":"2025-04-21T18:36:41.000Z","size":490,"stargazers_count":677,"open_issues_count":5,"forks_count":64,"subscribers_count":16,"default_branch":"master","last_synced_at":"2025-06-25T09:46:00.838Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"SystemVerilog","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hwayne.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2018-05-07T23:48:37.000Z","updated_at":"2025-06-20T09:35:43.000Z","dependencies_parsed_at":"2024-01-05T02:28:56.246Z","dependency_job_id":"17f88da4-be3a-4cab-8db5-af3cc5d1b596","html_url":"https://github.com/hwayne/lets-prove-leftpad","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/hwayne/lets-prove-leftpad","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hwayne%2Flets-prove-leftpad","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hwayne%2Flets-prove-leftpad/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hwayne%2Flets-prove-leftpad/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hwayne%2Flets-prove-leftpad/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hwayne","download_url":"https://codeload.github.com/hwayne/lets-prove-leftpad/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hwayne%2Flets-prove-leftpad/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28993253,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-01T22:01:47.507Z","status":"ssl_error","status_checked_at":"2026-02-01T21:58:37.335Z","response_time":56,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":[],"created_at":"2024-08-02T01:04:48.308Z","updated_at":"2026-02-01T22:31:35.007Z","avatar_url":"https://github.com/hwayne.png","language":"SystemVerilog","funding_links":[],"categories":["SystemVerilog"],"sub_categories":[],"readme":"# Let's Prove Leftpad\n\nThis is a repository of provably-correct versions of Leftpad. You can read more about the project's motivations and history [here](https://www.hillelwayne.com/post/lpl/).\n\n## What is \"provably-correct\"?\n\n**Provably correct code** is code that you can totally guarantee does what you say it does. You do this by providing a [**proof** that a computer can check](https://en.wikipedia.org/wiki/Formal_methods). If the proof is wrong, the code won't compile.\n\nCompare to something like testing: even if you test your function for 1,000 different inputs, you still don't know _for sure_ that the 1,001st test will pass. With a proof, though, you know your function will work for all inputs, regardless of whether you try a thousand or ten trillion different test cases. Proving code correct is really, really powerful. It's also mindbogglingly hard, which is why most programmers don't do it.\n\nThis is a sampler of all the different tools we can use to prove code correct, standardized by all being proofs for Leftpad.\n\n## What is \"leftpad\"?\n\nLeftpad is a function that takes a character, a length, and a string, and pads the string to that length. It pads it by adding the character to the left. So it's adding *padding* on the *left*. Leftpad.\n\n```\n\u003e\u003e leftpad('!', 5, \"foo\")\n!!foo\n\u003e\u003e leftpad('!', 0, \"foo\")\nfoo\n```\n\n## Why are we proving leftpad?\n\nBecause it's funny.\n\nAnd because leftpad is a great demo for different proof techniques. The idea is simple, the implementation is simple, but the **specification** (what you actually, formally want it to do) is surprisingly tricky. Specifically, you need to prove things for it to be leftpad:\n\n1. The length of the output is `max(n, len(str))`\n2. The prefix of the output is padding characters and nothing but padding characters\n3. The suffix of the output is the original string.\n\nA proof of leftpad is going to be small enough to be (mostly) grokkable by Formal Methods outsiders, while being complex enough to differentiate the ways we prove code correct.\n\n## I want to contribute!\n\nWe'd love to have you! Please [read the contribution guidelines](https://github.com/hwayne/lets-prove-leftpad/blob/master/CONTRIBUTING.md), and then submit your favorite proofs!\n\n### Plug\n\nIf you want to learn more about formal methods, I shout at clouds on my [website](https://hillelwayne.com) and on [bluesky](https://bsky.app/profile/hillelwayne.com).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhwayne%2Flets-prove-leftpad","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhwayne%2Flets-prove-leftpad","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhwayne%2Flets-prove-leftpad/lists"}