{"id":13992823,"url":"https://github.com/paulch42/lean-spec","last_synced_at":"2025-07-22T16:32:18.339Z","repository":{"id":176396642,"uuid":"602463166","full_name":"paulch42/lean-spec","owner":"paulch42","description":"Program Specification in Lean 4","archived":false,"fork":false,"pushed_at":"2024-01-15T05:41:09.000Z","size":286,"stargazers_count":12,"open_issues_count":2,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-08-10T14:11:41.559Z","etag":null,"topics":["dependent-types","formal-specification","lean4"],"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/paulch42.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,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2023-02-16T09:07:27.000Z","updated_at":"2024-05-08T08:00:22.000Z","dependencies_parsed_at":null,"dependency_job_id":"162af0be-61d4-4200-aeb9-4aec70850c6c","html_url":"https://github.com/paulch42/lean-spec","commit_stats":null,"previous_names":["paulch42/lean-spec"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paulch42%2Flean-spec","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paulch42%2Flean-spec/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paulch42%2Flean-spec/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paulch42%2Flean-spec/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/paulch42","download_url":"https://codeload.github.com/paulch42/lean-spec/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227133905,"owners_count":17735823,"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":["dependent-types","formal-specification","lean4"],"created_at":"2024-08-09T14:02:08.883Z","updated_at":"2024-11-29T13:31:22.026Z","avatar_url":"https://github.com/paulch42.png","language":"Lean","funding_links":[],"categories":["Lean"],"sub_categories":[],"readme":"# Specification in Lean\n\n[Lean](https://leanprover.github.io) is a dependently typed functional programming language that incorporates\nthe correspondence between propositions and types (and between proofs and programs).\nAs such it is able to serve as a basis for the formalisation of mathematics (i.e., the\nstatement and proof of theorems). Indeed, a considerable body of mathematics has\nbeen formalised in Lean, and is packaged as\n[mathlib4](https://github.com/leanprover-community/mathlib4). A good introduction to the\nuse of Lean for the formalisation of mathematics is\n[Theorem Proving in Lean](https://leanprover.github.io/theorem_proving_in_lean4/).\n\nThe programming language component of Lean (version 4) is a comprehensive functional programming language, in the style\nof [Haskell](https://www.haskell.org). A good introduction to the\nuse of Lean as a programming language is\n[Functional Programming in Lean](https://leanprover.github.io/functional_programming_in_lean/). While Haskell has a more traditional type system, the dependently typed system of Lean\nand its underlying logic bring a number of benefits from a software perspective:\n* Lean is a fully featured specification language. It can be used to specify the\nfunctionality of software that can be implemented in Lean or other languages.\n* Lean software can be verified in Lean itself (using the same logic employed for\nmathematical proof).\n* When a Lean specification is viewed as a theorem in the Lean logic, a proof of that\ntheorem yields a program that satisfies the specification.\n\nThe cost of this capability is that the type system is undecidable: the system cannot,\ngiven a program and a type (specification), determine automatically whether the program\nmeets the specification. A proof is required. When the dependent type theory of Lean is\nused to its full capacity, _type correctness = program correctness_.\n\nThis tutorial is an introduction to the use of Lean for the specification of software\nfunctionality. The aim is to express what a function is intended to achieve, not how\nit is achieved. How one might verify or derive a program that meets a specification using the Lean\nlogic is not addressed here. The contents of this tutorial are:\n\n|   |   |\n| - | - |\n| [Introduction](md/Introduction.md)    | Introduction to Lean as a specification language |\n| [Quotient \u0026 Remainder](md/QuotRem.md) | Quotient and remainder on division |\n| [Sort](md/Sort.md)                    | Sorting a list of items |\n| [Knapsack](md/Knapsack.md)            | Knapsack: an optimisation problem |\n| [Graph](md/Graph.md)                  | Graph searching |\n| [TMI](md/TMI.md)                      | A scheduling example from the aviation industry |\n| [Flight Planning](md/FPL.md)          | Flight planning message processing example from the aviation industry |\n\nThe following supplementary modules support the example specifications:\n\n|   |   |\n| - | - |\n| [Util](md/lib/Util.md)         | General purpose functions that could in future appear in a standard library |\n| [Temporal](md/lib/Temporal.md) | A simple theory of dates, times, durations and intervals |\n| [Geo](md/lib/Geo.md)           | Basic geospatial entities |\n\nSome discussion on the use of Lean for specifications is [here](Discussion.md) (__to do__).\n\n## Creating The Markdown Files\n\nThe files are Lean scripts from which markdown is generated using the [mdgen](https://github.com/Seasawher/mdgen) tool.\n\nBuild the markdown files with `lake exe mdgen LeanSpec md`.\n\n## Acknowledgement\n\nThanks to Kevin Buzzard, Mario Caneiro and Partick Massot for their valuable comments.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpaulch42%2Flean-spec","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpaulch42%2Flean-spec","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpaulch42%2Flean-spec/lists"}