{"id":23280887,"url":"https://github.com/claby2/axiomatic-set-theory","last_synced_at":"2026-02-17T07:40:00.490Z","repository":{"id":263548343,"uuid":"888851705","full_name":"claby2/axiomatic-set-theory","owner":"claby2","description":"∃∀ Formalizing Enderton's \"Elements of Set Theory\" in Lean","archived":false,"fork":false,"pushed_at":"2024-12-14T21:55:36.000Z","size":75,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-24T20:48:49.609Z","etag":null,"topics":["enderton","lean","set-theory"],"latest_commit_sha":null,"homepage":"","language":"Lean","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/claby2.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-11-15T06:02:37.000Z","updated_at":"2025-09-29T21:53:50.000Z","dependencies_parsed_at":"2025-02-12T19:44:13.858Z","dependency_job_id":"a88adfbf-0120-40f0-9917-92d51444908a","html_url":"https://github.com/claby2/axiomatic-set-theory","commit_stats":null,"previous_names":["claby2/axiomatic-set-theory"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/claby2/axiomatic-set-theory","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/claby2%2Faxiomatic-set-theory","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/claby2%2Faxiomatic-set-theory/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/claby2%2Faxiomatic-set-theory/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/claby2%2Faxiomatic-set-theory/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/claby2","download_url":"https://codeload.github.com/claby2/axiomatic-set-theory/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/claby2%2Faxiomatic-set-theory/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29536918,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-17T05:00:25.817Z","status":"ssl_error","status_checked_at":"2026-02-17T04:57:16.126Z","response_time":100,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6: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":["enderton","lean","set-theory"],"created_at":"2024-12-19T23:39:32.423Z","updated_at":"2026-02-17T07:40:00.449Z","avatar_url":"https://github.com/claby2.png","language":"Lean","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Axiomatic Set Theory\n\nProject link: \u003chttps://github.com/claby2/axiomatic-set-theory\u003e\n\nThis project seeks to formalize an axiomatic approach to set theory within Lean.\nDrawing inspiration from Enderton's *Elements of Set Theory*, it begins with the fundamental axioms and proceeds to formalize selected theorems and exercises presented in the book. While this document provides a brief overview, the project's full details and implementations (including proofs to theorems and exercises) can be found in its source code.\n\n## Overview\n\nThe core of the project involves introducing a primitive notion of a set and a membership relation, and then building up the standard axioms of ZFC-like set theory.\nThe development proceeds through the formalization of sets, elementary constructions, and fundamental operations, eventually leading to the formalization of relations, functions, and the beginnings of natural number construction.\n\n### Basic Definitions\n\nFirst, a `Set` type is introduced as an axiom, along with a membership predicate `ElementOf`:\n\n```lean\naxiom Set : Type\n\naxiom ElementOf : Set -\u003e Set -\u003e Prop\ninfix:50 \" ∈ \" =\u003e ElementOf\ninfix:40 \" ∉ \" =\u003e λ x y =\u003e ¬ ElementOf x y\n```\n\nUsing this notion, the usual set-theoretic definitions are introduced:\n\n```lean\ndef Nonempty (A : Set) : Prop := ∃ (x : Set), x ∈ A\ndef SubsetOf (x a : Set) : Prop := ∀ (t : Set), t ∈ x → t ∈ a\n```\n\n### Axioms\n\nWith these fundamental ingredients in place, the axioms of set theory are stated.\nThese include the axiom of comprehension (sometimes called subset or separation), extensionality, the existence of an empty set, pairing, the power set, and union.\nEach axiom is stated as an existential claim that asserts the existence of a set satisfying a given property:\n\n```lean\naxiom comprehension (P : Set → Prop) (c : Set) :\n∃ (B : Set), ∀ (x : Set), x ∈ B ↔ x ∈ c ∧ P x\naxiom extensionality : ∀ (A B : Set), (∀ (x : Set), (x ∈ A ↔ x ∈ B)) → A = B\naxiom empty : ∃ (B : Set), ∀ (x : Set), x ∉ B\naxiom pairing : ∀ (u v : Set), ∃ (B: Set), ∀ (x : Set), x ∈ B ↔ x = u ∨ x = v\naxiom power : ∀ (a : Set), ∃ (B : Set), ∀ (x : Set), x ∈ B ↔ x ⊆ a\naxiom union_preliminary : ∀ (a b : Set), ∃ (B : Set), ∀ (x : Set), x ∈ B ↔ x ∈ a ∨ x ∈ b\naxiom union : ∀ (A : Set), ∃ (B : Set), ∀ (x : Set), x ∈ B ↔ (∃ (b : Set), b ∈ A ∧ x ∈ b)\n```\n\n### Constructing Specific Sets\n\nFrom these axioms, particular sets are constructed using the classical choice operator ([`Classical.choose`](https://leanprover-community.github.io/mathlib4_docs/Init/Classical.html#Classical.choose)).\nFor example, the empty set is defined as follows:\n\n```lean\nnoncomputable def Empty : Set := Classical.choose empty\nlemma Empty.Spec : ∀ x : Set, x ∉ Empty := Classical.choose_spec empty\nnotation \"∅\" =\u003e Empty\n```\n\nThis pattern -- defining a set using `Classical.choose` and then providing a lemma stating its properties -- recurs throughout the project.\nFor instance, the construction of pairs, singletons, unions, intersections, and power sets follows a similar methodology.\nUniqueness results can then be proven separately when necessary.\n\n### Relations and Functions\n\nOnce these basic building blocks are in place, the formalization extends to ordered pairs, products, relations, and functions.\nOrdered pairs are defined following Kuratowski's approach as outlined in Enderton:\n\n```lean\nnoncomputable def OrderedPair (x y : Set) : Set := Pair (Singleton x) (Pair x y)\nnotation:90 \"⟨\" x \", \" y \"⟩\" =\u003e OrderedPair x y\n```\n\nWith ordered pairs, we can proceed by defining products and products, along with domains, ranges, and fields of relations.\n\n```lean\nnoncomputable def Product (A B : Set) : Set := Classical.choose (OrderedPair.product A B)\ninfix:60 \" ⨯ \" =\u003e Product\ndef IsRelation (R : Set) : Prop := ∀ w, w ∈ R → ∃ x y, w = ⟨x, y⟩\nnoncomputable def Relation.Domain (R : Set) : Set :=\n  Classical.choose (comprehension (λ x ↦ ∃ (y : Set), ⟨x, y⟩ ∈ R) (⋃⋃R))\nnoncomputable def Relation.Range (R : Set) : Set :=\n  Classical.choose (comprehension (λ y ↦ ∃ (x : Set), ⟨x, y⟩ ∈ R) (⋃⋃R))\nnoncomputable def Relation.Field (R : Set) : Set := (dom R) ∪ (ran R)\n```\n\nA natural extension of relations is formalizing the notions of functions, which are defined as a special kind of relation. From Enderton, to be a function, a set must be a relation that satisfies the property that for each $x$ in the domain of the relation, there exists only one $y$ such that $xFy$.\nThis is expressed in Lean as follows:\n\n```lean\ndef IsFunction (F : Set) : Prop :=\n  IsRelation F ∧ ∀ x, x ∈ (dom F) → ∃! y, ⟨x, y⟩ ∈ F\n```\n\nFrom here, we can define function operations: inverse, composition, restriction, and image.\nTheir formalizations are as follows:\n\n```lean\nnoncomputable def Inverse (F : Set) :=\n  Classical.choose (comprehension (λ w ↦ ∃ (u v : Set), ⟨u, v⟩ ∈ F ∧ w = ⟨v, u⟩) ((ran F) ⨯ (dom F)))\npostfix:90 \"⁻¹\" =\u003e Inverse\nnoncomputable def Composition (F G : Set) :=\n  Classical.choose (comprehension\n    (λ w ↦ ∃ (u v t : Set), ⟨u, t⟩ ∈ G ∧ ⟨t, v⟩ ∈ F ∧ w = ⟨u, v⟩)\n    ((dom G) ⨯ (ran F)))\ninfixr:90 \" ∘ \" =\u003e Composition\nnoncomputable def Restriction (F : Set) (C : Set) :=\n  Classical.choose (comprehension (λ w ↦ ∃ (u v : Set), ⟨u, v⟩ ∈ F ∧ u ∈ C ∧ w = ⟨u, v⟩) F)\ninfixr:90 \" ↾ \" =\u003e Restriction\nnoncomputable def Image (F : Set) (C : Set) :=\n  ran (Restriction F C)\nnotation:90 F \"⟦\" A \"⟧\" =\u003e Image F A\n```\n\nAs noted in Enderton, this is formalized in a way that applies to all sets, not just sets that are functions.\n\n### Natural Numbers\n\nThe final part of the current work involves the beginnings of natural number construction.\nFollowing the standard set-theoretic approach, the successor operation is introduced, and inductive sets are defined.\nNatural numbers are then those sets contained in every inductive set.\n\n```lean\nnoncomputable def Successor (a : Set) : Set := a ∪ Singleton a\npostfix:90 \"⁺\" =\u003e Successor\ndef Inductive (A : Set) : Prop := ∅ ∈ A ∧ ∀ a, a ∈ A → a⁺ ∈ A\ndef Natural (n : Set) : Prop := ∀ (A : Set), Inductive A → n ∈ A\n```\n\n## Next Steps\n\nSo far, the project has developed the foundational machinery through the first few chapters of Enderton's *Elements of Set Theory*.\nMany theorems and exercises still remain to be formalized.\nA natural next step is to complete the formalization of the natural numbers, which will require invoking the recursion theorem.\nOnce natural numbers are fully treated, the path is open to formalizing arithmetic, real numbers, cardinal numbers, and ordinals.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclaby2%2Faxiomatic-set-theory","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fclaby2%2Faxiomatic-set-theory","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclaby2%2Faxiomatic-set-theory/lists"}