{"id":29996714,"url":"https://github.com/arademaker/fad","last_synced_at":"2025-08-05T02:53:58.406Z","repository":{"id":286678732,"uuid":"951506080","full_name":"arademaker/fad","owner":"arademaker","description":"Functional Algorithms Design","archived":false,"fork":false,"pushed_at":"2025-07-18T00:15:42.000Z","size":168,"stargazers_count":3,"open_issues_count":4,"forks_count":1,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-07-18T04:58:35.475Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/arademaker.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.org","funding":null,"license":"LICENSE.txt","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,"zenodo":null}},"created_at":"2025-03-19T19:35:57.000Z","updated_at":"2025-07-18T00:15:43.000Z","dependencies_parsed_at":"2025-05-13T14:43:34.443Z","dependency_job_id":"c370c365-76eb-4734-aac0-06934de0dd35","html_url":"https://github.com/arademaker/fad","commit_stats":null,"previous_names":["emap-taa-20251/fad","arademaker/fad"],"tags_count":0,"template":true,"template_full_name":null,"purl":"pkg:github/arademaker/fad","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arademaker%2Ffad","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arademaker%2Ffad/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arademaker%2Ffad/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arademaker%2Ffad/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/arademaker","download_url":"https://codeload.github.com/arademaker/fad/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arademaker%2Ffad/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268825561,"owners_count":24313264,"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","status":"online","status_checked_at":"2025-08-05T02:00:12.334Z","response_time":2576,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":"2025-08-05T02:53:57.121Z","updated_at":"2025-08-05T02:53:58.376Z","avatar_url":"https://github.com/arademaker.png","language":"Lean","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# Functional Algorithms Design \u003ca href='#'\u003e\u003cimg src=\"img/cover.jpeg\" align=\"right\" height=\"168\" /\u003e\u003c/a\u003e\n\n[![Lean Action CI](https://github.com/emap-taa-20251/fad/actions/workflows/lean_action_ci.yml/badge.svg)](https://github.com/emap-taa-20251/fad/actions/workflows/lean_action_ci.yml)\n[![Lean Version](https://img.shields.io/badge/Lean-4.20.0-blue)](https://lean-lang.org/)\n[![Mathlib](https://img.shields.io/badge/Mathlib-✓-green)](https://github.com/leanprover-community/mathlib4)\n\n\u003e *\"Algorithm design meets formal verification\"*\n\n## Introduction\n\nThis [Lean](https://lean-lang.org/) adaptation of [Algorithm Design with Haskell](https://www.cs.ox.ac.uk/publications/books/adwh/) reinterprets five essential principles of algorithm design—divide and conquer, greedy algorithms, thinning, dynamic programming, and exhaustive search—within a dependently typed setting. All examples are reimplemented in Lean, a functional language and proof assistant based on dependent type theory. More than a translation, this version makes explicit the informal equational reasoning of the original by turning it into fully formal, machine-checked proofs.\n\nThe main goals of this adaptation are:\n\n- to demonstrate the expressive power of dependent types in representing and reasoning about algorithms,\n- to show how informal proofs can be systematically formalized,\n- to explore how different refinements of the same algorithm can be proven equivalent.\n- and to explore how to proof termination of functional algorithms.\n\nAlong the way, readers gain experience not only in algorithm design, but also in writing correct-by-construction programs and proving their properties rigorously. This book invites students and practitioners to see algorithmics not just as a matter of clever ideas, but also as a foundation for precise, verifiable software.\n\n## Table of Contents\n\n### Part One: Basics\n\n1.  Functional programming\n\n    - [x] 1.1 Basic types and functions\n    - [x] 1.2 Processing lists\n    - [x] 1.3 Inductive and recursive definitions\n    - [x] 1.4 Fusion\n    - [x] 1.5 Accumulating and tupling\n    - [x] Exercises\n\n2.  Timing\n\n    - [ ] 2.1 Asymptotic notation\n    - [ ] 2.2 Estimating running times\n    - [ ] 2.3 Running times in context\n    - [ ] 2.4 Amortised running times\n    - [ ] Exercises\n\n3.  Useful data structures\n\n    - [x] 3.1 Symmetric lists\n    - [x] 3.2 Random-access lists\n    - [x] 3.3 Arrays\n    - [ ] Exercises\n\n### Part Two: Divide And Conquer\n\n1.  Binary search\n\n    - [x] 4.1 A one‑dimensional search problem\n    - [x] 4.2 A two‑dimensional search problem\n    - [x] 4.3 Binary search trees\n    - [x] 4.4 Dynamic sets\n    - [ ] Exercises\n\n2.  Sorting\n\n    - [x] 5.1 Quicksort\n    - [x] 5.2 Mergesort\n    - [x] 5.3 Heapsort\n    - [x] 5.4 Bucketsort and Radixsort\n    - [x] 5.5 Sorting sums\n    - [ ] Exercises\n\n3.  Selection\n\n    - [x] 6.1 Minimum and maximum\n    - [x] 6.2 Selection from one set\n    - [ ] 6.3 Selection from two sets\n    - [ ] 6.4 Selection from the complement of a set\n    - [ ] Exercises\n\n### Part Three: Greedy Algorithms\n\n1.  Greedy algorithms on lists\n\n    - [x] 7.1 A generic greedy algorithm\n    - [x] 7.2 Greedy sorting algorithms\n    - [x] 7.3 Coin‑changing\n    - [ ] 7.4 Decimal fractions in TeX\n    - [ ] 7.5 Nondeterministic functions and refinement\n    - [ ] Exercises\n\n2.  Greedy algorithms on trees\n\n    - [x] 8.1 Minimum‑height trees\n    - [x] 8.2 Huffman coding trees\n    - [x] 8.3 Priority queues\n    - [ ] Exercises\n\n3.  Greedy algorithms on graphs\n\n    - [ ] 9.1 Graphs and spanning trees\n    - [ ] 9.2 Kruskal\\'s algorithm\n    - [ ] 9.3 Disjoint sets and the union--find algorithm\n    - [ ] 9.4 Prim\\'s algorithm\n    - [ ] 9.5 Single‑source shortest paths\n    - [ ] 9.6 Dijkstra\\'s algorithm\n    - [ ] 9.7 The jogger\\'s problem\n    - [ ] Exercises\n\n### Part Four: Thinning Algorithms\n\n1.  Introduction to thinning\n\n    - [ ] 10.1 Theory\n    - [ ] 10.2 Paths in a layered network\n    - [ ] 10.3 Coin‑changing revisited\n    - [ ] 10.4 The knapsack problem\n    - [ ] 10.5 A general thinning algorithm\n    - [ ] Exercises\n\n2.  Segments and subsequences\n\n    - [ ] 11.1 The longest upsequence\n    - [ ] 11.2 The longest common subsequence\n    - [ ] 11.3 A short segment with maximum sum\n    - [ ] Exercises\n\n3.  Partitions\n\n    - [x] 12.1 Ways of generating partitions\n    - [ ] 12.2 Managing two bank accounts\n    - [x] 12.3 The paragraph problem\n    - [ ] Exercises\n\n### Part Five: Dynamic Programming\n\n1.  Efficient recursions\n\n    - [ ] 13.1 Two numeric examples\n    - [ ] 13.2 Knapsack revisited\n    - [ ] 13.3 Minimum‑cost edit sequences\n    - [ ] 13.4 Longest common subsequence revisited\n    - [ ] 13.5 The shuttle‑bus problem\n    - [ ] Exercises\n\n2.  Optimum bracketing\n\n    - [ ] 14.1 A cubic‑time algorithm\n    - [ ] 14.2 A quadratic‑time algorithm\n    - [ ] 14.3 Examples\n    - [ ] 14.4 Proof of monotonicity\n    - [ ] 14.5 Optimum binary search trees\n    - [ ] 14.6 The Garsia--Wachs algorithm\n    - [ ] Exercises\n\n## Part Six: Exhaustive Search\n\n1.  Ways of searching\n\n    - [ ] 15.1 Implicit search and the n‑queens problem\n    - [ ] 15.2 Expressions with a given sum\n    - [ ] 15.3 Depth‑first and breadth‑first search\n    - [ ] 15.4 Lunar Landing\n    - [ ] 15.5 Forward planning\n    - [ ] 15.6 Rush Hour\n    - [ ] Exercises\n\n2.  Heuristic search\n\n    - [ ] 16.1 Searching with an optimistic heuristic\n    - [ ] 16.2 Searching with a monotonic heuristic\n    - [ ] 16.3 Navigating a warehouse\n    - [ ] 16.4 The 8‑puzzle\n    - [ ] Exercises\n\n\n## :handshake: Contributing\n\nPlease see [CONTRIBUTING.org](CONTRIBUTING.org) for guidelines on how to contribute to this project.\n\n## :book: References\n\n- [Algorithm Design with Haskell](https://www.cs.ox.ac.uk/publications/books/adwh/) - The original book this adaptation is based on\n\n- [Lean 4 Manual](https://lean-lang.org/lean4/doc/) - Official Lean 4 documentation\n\n## :pushpin: License\n\nThis project is licensed under Apache License 2.0. See LICENSE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farademaker%2Ffad","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farademaker%2Ffad","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farademaker%2Ffad/lists"}