{"id":13993121,"url":"https://github.com/kmill/lean4-raytracer","last_synced_at":"2026-03-04T15:30:50.406Z","repository":{"id":37459260,"uuid":"334742710","full_name":"kmill/lean4-raytracer","owner":"kmill","description":"A simple raytracer written in Lean 4","archived":false,"fork":false,"pushed_at":"2024-05-16T18:10:48.000Z","size":10321,"stargazers_count":134,"open_issues_count":0,"forks_count":5,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-03-26T14:18:48.488Z","etag":null,"topics":["lean4","raytracing"],"latest_commit_sha":null,"homepage":"","language":"Lean","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kmill.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"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}},"created_at":"2021-01-31T19:48:50.000Z","updated_at":"2025-03-06T05:59:06.000Z","dependencies_parsed_at":"2024-11-29T14:32:05.673Z","dependency_job_id":"bfdaaef6-114d-40e1-8329-53c5fb4a6363","html_url":"https://github.com/kmill/lean4-raytracer","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/kmill/lean4-raytracer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kmill%2Flean4-raytracer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kmill%2Flean4-raytracer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kmill%2Flean4-raytracer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kmill%2Flean4-raytracer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kmill","download_url":"https://codeload.github.com/kmill/lean4-raytracer/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kmill%2Flean4-raytracer/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30084953,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-04T13:22:36.021Z","status":"ssl_error","status_checked_at":"2026-03-04T13:20:45.750Z","response_time":59,"last_error":"SSL_read: 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":["lean4","raytracing"],"created_at":"2024-08-09T14:02:14.405Z","updated_at":"2026-03-04T15:30:50.386Z","avatar_url":"https://github.com/kmill.png","language":"Lean","funding_links":[],"categories":["Lean"],"sub_categories":[],"readme":"# Simple raytracer in Lean 4\n\n[Lean 4](https://github.com/leanprover/lean4) is a dependently typed programming language, and \nit can be used both as a proof assistant and for practical programs.\n\nThis repository implements the ray tracer described in \n[_Ray Tracing in One Weekend_](https://raytracing.github.io/books/RayTracingInOneWeekend.html).\nCode for writing PPM files originally came from\n[TOTBWF/lean4-raytrace](https://github.com/TOTBWF/lean4-raytrace).\n\nThe raytracer uses `Task`s to render in parallel.  Part of a raytracer is using supersampling\nto better estimate the amount of light entering each pixel, so it is trivial to parallelize:\nthe entire image is rendered multiple times, and the results are averaged together.\n\n![final test image](https://github.com/kmill/lean4-raytracer/blob/master/output/test13.png?raw=true)\n\n(8 minutes 10 seconds with 10 threads on an Apple M2 Max. 500x333 pixels, 80 total samples per pixel, max depth 30.)\n\n![final test image, higher resolution](https://github.com/kmill/lean4-raytracer/blob/master/output/test13.bigger.png?raw=true)\n\n(2 hours with 16 threads on an Intel Xeon E5-2665. 800x533 pixels, 480 total samples per pixel, max depth 50.)\n\n## Running the code\n\nAssuming you already have Lean 4 setup, this builds an executable and runs it:\n```\n$ lake build \u0026\u0026 time lake exe render test.ppm\n```\nThe rendering settings are hard-coded in `writeTestImage` in `render.lean`.\n\n## C benchmark\n\nThe `c` folder contains an implementation of the raytracer in C, hand translated from Lean using C idioms.\nThis is not meant to be a fair comparison, and I spent more time thinking about optimizing the C version.\nThe only purpose here is to get some idea of the relative speed of my Lean code.\n\nThe first test image in C took 5.9 seconds with the same configuration,\nand the second test image took 1 minute 19 seconds (but with Apple M2 Max).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkmill%2Flean4-raytracer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkmill%2Flean4-raytracer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkmill%2Flean4-raytracer/lists"}