{"id":25301614,"url":"https://github.com/p2js/set-theory","last_synced_at":"2025-04-07T01:27:45.706Z","repository":{"id":234241731,"uuid":"785797144","full_name":"p2js/set-theory","owner":"p2js","description":"rust type-system set theory","archived":false,"fork":false,"pushed_at":"2025-01-30T18:33:12.000Z","size":9,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-13T06:48:00.352Z","etag":null,"topics":["rust","rust-lang","set-theory","sets","type-system","type-systems"],"latest_commit_sha":null,"homepage":"","language":"Rust","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/p2js.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}},"created_at":"2024-04-12T16:38:01.000Z","updated_at":"2025-01-30T18:33:15.000Z","dependencies_parsed_at":"2024-04-18T16:18:53.265Z","dependency_job_id":"d9d15dbc-6c3b-4fa5-a4ee-ecaa45c2f748","html_url":"https://github.com/p2js/set-theory","commit_stats":null,"previous_names":["p2js/set-theory"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/p2js%2Fset-theory","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/p2js%2Fset-theory/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/p2js%2Fset-theory/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/p2js%2Fset-theory/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/p2js","download_url":"https://codeload.github.com/p2js/set-theory/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247576663,"owners_count":20961012,"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":["rust","rust-lang","set-theory","sets","type-system","type-systems"],"created_at":"2025-02-13T06:48:07.746Z","updated_at":"2025-04-07T01:27:45.689Z","avatar_url":"https://github.com/p2js.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# set-theory\n\nType-system set theory in rust. \n\nThis is a quick project thrown together in a couple hours to explore the representation of infinite sets and interoperability between different set types.\n\n## The Empty set\n\nThe `EmptySet` type represents an empty set. It is simply an empty `struct` that implements the `Set\u003cT\u003e` trait.\n\n```rs\nuse set_theory::sets::EmptySet;\n\nlet es = EmptySet::new();\n\nassert!(!es.contains(\u00260));\nassert!(!es.contains(\u00261.5));\n```\n\n## Finite and Infinite sets\n\nThe `FiniteSet\u003cT\u003e` type can store a set of finite values, and uses a `HashSet\u003cT\u003e` internally.\n\n```rs\nuse set_theory::sets::FiniteSet;\n\nlet fs = FiniteSet::new(\u0026[1, 2, 3]);\n\nassert!(fs.contains(\u00261));\nassert!(!fs.contains(\u00264));\n```\n\nThe `PredicateSet\u003cT\u003e` is meant to represent an infinite set as a list of predicates (functions that take in a single `T` argument and return a boolean), in a sort of emulation of set builder notation. A value will count as being in the set if all the predicates evaluate to true.\n\n```rs\nuse set_theory::sets::PredicateSet;\n\n// set of all even integers greater than 5\nlet ps = PredicateSet::new(\u0026[|\u0026x| x \u003e 5, |\u0026x| x % 2 == 0]);\n\nassert!(ps.contains(\u00266));\nassert!(!ps.contains(\u00267));\n```\n\n## Set operations\n\nThe library includes types for the unions, intersections, complements and cartesian products of two sets. It also includes a power set type, which will implement `Set\u003cFiniteSet\u003cT\u003e\u003e` for any `Set\u003cT\u003e` and will check for whether a set is in the powerset by checking that all the elements are contained in the original set.\n\nAll of these types use dynamic trait object references to allow for operations on different types of sets.\n\n```rs\nuse set_theory::operations::{Union, PowerSet};\nuse set_theory::sets::{FiniteSet, PredicateSet};\n\nlet a = FiniteSet::new(\u0026[1, 5]);\nlet b = PredicateSet::new(\u0026[|\u0026x| x \u003e 5, |\u0026x| x % 2 == 0]);\n\nlet aub = Union::of(\u0026a, \u0026b);\nassert!(aub.contains(\u00265));\nassert!(aub.contains(\u00266));\n\nlet pa = PowerSet::of(\u0026a);\nassert!(pa.contains(\u0026a));\nassert!(pa.contains(\u0026FiniteSet::new(\u0026[1])));\n```\n\n## Relations\n\nRelations can be used to encode relationships between elements in a set through a predicate.\n\n```rs\nuse set_theory::sets::PredicateSet;\nuse set_theory::relations::Relation;\n\nlet c = PredicateSet::\u003ci32\u003e::all();\n// \u003c= relation\nlet is_less_than = Relation::on(\u0026c, |a, b| b - a \u003e 0);\n\nassert!(is_less_than.relates(\u00262, \u00264));\nassert!(!is_less_than.relates(\u00262, \u00261));\n```\n\n## Interacting with sets\n\nAll set types in the library implement a common `Set\u003cT\u003e` trait. The trait only requires implementation of a [function to check whether a value is in the set](https://en.wikipedia.org/wiki/Indicator_function). This is because infinite sets do not store any values, so any method to access some list of values would be extremely difficult to impossible.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fp2js%2Fset-theory","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fp2js%2Fset-theory","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fp2js%2Fset-theory/lists"}