{"id":20012182,"url":"https://github.com/joelgrus/constructive-mathematics-fsharp","last_synced_at":"2025-11-27T01:01:46.688Z","repository":{"id":145158044,"uuid":"12190589","full_name":"joelgrus/constructive-mathematics-fsharp","owner":"joelgrus","description":"constructive mathematics in F#","archived":false,"fork":false,"pushed_at":"2013-08-26T13:31:37.000Z","size":392,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-02T02:18:55.143Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"F#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/joelgrus.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-08-18T05:03:41.000Z","updated_at":"2022-05-02T14:00:14.000Z","dependencies_parsed_at":"2023-03-22T17:01:54.304Z","dependency_job_id":null,"html_url":"https://github.com/joelgrus/constructive-mathematics-fsharp","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/joelgrus/constructive-mathematics-fsharp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joelgrus%2Fconstructive-mathematics-fsharp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joelgrus%2Fconstructive-mathematics-fsharp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joelgrus%2Fconstructive-mathematics-fsharp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joelgrus%2Fconstructive-mathematics-fsharp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/joelgrus","download_url":"https://codeload.github.com/joelgrus/constructive-mathematics-fsharp/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joelgrus%2Fconstructive-mathematics-fsharp/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286079811,"owners_count":27282121,"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-11-26T02:00:06.075Z","response_time":193,"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":"2024-11-13T07:29:10.045Z","updated_at":"2025-11-27T01:01:46.670Z","avatar_url":"https://github.com/joelgrus.png","language":"F#","readme":"# Constructive Mathematics\n\nBlog post \u003ca href = \"http://joelgrus.com/2013/08/26/constructive-mathematics-in-f-and-clojure/\"\u003ehere\u003c/a\u003e\nClojure version \u003ca href = \"https://github.com/joelgrus/constructive-mathematics-clojure\"\u003ehere\u003c/a\u003e\n\nSome people play video games for fun, I implement mathematics from scratch in F#.  Although this mostly represents me monkeying around, I suppose it's not a bad way to learn a few things about mathematics and/or F#.\n\n## Comparison\n\n`Comparison.fs` just contains a discriminated union that's the result of comparing two numbers.\n\n## Natural Numbers\n\n`NaturalNumbers.fs` recursively implements the counting numbers One, Two, Three, ...  and the associated arithmetic operations.  It's pretty much complete.  As subtraction is only sometimes valid, it's implemented as a `TrySubtract` function that returns an option type.\n\n## Integers\n\nInspired by the lack of a robust 'Subtract' operation, `Integers.fs` extends the Natural Numbers to include Zero and Negatives.  It's mostly done as well (maybe it could use integer division), although its tests could be more complete.\n\n## Rational Numbers\n\nSimilarly, as many pairs of Integers cannot be divided, `Rationals.fs` extends the Integers to include all *ratios* of Integers (except for those with Zero in the denominator).  I won't call this one complete (although I don't have in mind any additional functionality to add), and I haven't written any tests yet, so there might be bugs in it.\n\n## Gaussian Integers\n\nInspired by the observation that there are no Integers whose squares are Negative, `GaussianIntegers.fs` adds an element `I` whose square is `MinusOne`.  I'm pretty sure the basic framework is correct, but it's very incomplete, and there are no tests yet.\n\n## Real Numbers\n\nThe Rational numbers have a (huge) number of gaps in them, which is a layman's way of saying [Cauchy Sequences](http://en.wikipedia.org/wiki/Cauchy_sequence) that don't converge.  In `RealNumbers.fs` I attempt to 'fill in' these gaps.  As the real numbers are [uncountable](http://www.proofwiki.org/wiki/Real_Numbers_are_Uncountable), it's impossible to do this absolutely correctly. \n\nI'm trying to use some variation on the method described [here](http://en.wikipedia.org/wiki/Constructivism_%28mathematics%29#Example_from_real_analysis), which represents a real number as a pair `(f,g)`, where `f` is a Cauchy sequence of Rational Numbers, and `g` is a function that gives the actual cutoffs for the Cauchy bounds at 1, 1/2, 1/3, 1/4, ...  I am not convinced that this is the best way to implement real numbers, although I've made more progress than every other way I've tried.  These are still totally a work in progress and may change entirely.","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoelgrus%2Fconstructive-mathematics-fsharp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoelgrus%2Fconstructive-mathematics-fsharp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoelgrus%2Fconstructive-mathematics-fsharp/lists"}