├── .cargo
└── config.toml
├── .github
├── ISSUE_TEMPLATE
│ ├── bug_report.md
│ └── feature_request.md
├── dependabot.yaml
├── labels.yaml
├── pull_request_template.md
├── settings.yaml
└── workflows
│ ├── book.yaml
│ ├── release.yaml
│ ├── rust.yaml
│ └── sync_labels.yaml
├── .gitignore
├── .release-plz.toml
├── .rustfmt.toml
├── .taplo.toml
├── CONTRIBUTING.md
├── Cargo.lock
├── Cargo.toml
├── LICENSE
├── README.md
├── SUMMARY.md
├── book.toml
├── cova-algebra
├── .cargo
│ └── config.toml
├── CHANGELOG.md
├── Cargo.toml
├── README.md
├── katex-header.html
└── src
│ ├── algebras
│ ├── boolean.rs
│ ├── clifford.rs
│ └── mod.rs
│ ├── arithmetic
│ ├── mod.rs
│ ├── modular.rs
│ └── primitive.rs
│ ├── category.rs
│ ├── groups.rs
│ ├── lib.rs
│ ├── modules
│ ├── mod.rs
│ ├── trivial.rs
│ └── tropical.rs
│ ├── rings.rs
│ └── tensors
│ ├── dynamic
│ ├── matrix.rs
│ ├── mod.rs
│ └── vector.rs
│ ├── fixed.rs
│ └── mod.rs
├── cova-space
├── .cargo
│ └── config.toml
├── CHANGELOG.md
├── Cargo.toml
├── README.md
├── katex-header.html
└── src
│ ├── cloud.rs
│ ├── complexes
│ ├── cubical.rs
│ ├── mod.rs
│ └── simplicial.rs
│ ├── definitions.rs
│ ├── filtration
│ ├── mod.rs
│ └── vietoris_rips.rs
│ ├── graph.rs
│ ├── homology.rs
│ ├── lattice.rs
│ ├── lib.rs
│ ├── set.rs
│ └── sheaf.rs
├── cova
├── .cargo
│ └── config.toml
├── CHANGELOG.md
├── Cargo.toml
├── README.md
├── katex-header.html
└── src
│ └── lib.rs
├── examples
├── README.md
└── vietoris_web
│ ├── Cargo.lock
│ ├── Cargo.toml
│ ├── README.md
│ ├── build-optimized.sh
│ ├── index.html
│ └── src
│ ├── lib.rs
│ └── main.rs
├── justfile
├── katex-header.html
└── rust-toolchain.toml
/.cargo/config.toml:
--------------------------------------------------------------------------------
1 | [build]
2 | rustdocflags = ["--html-in-header", "./katex-header.html"]
3 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug Report
3 | about: Report a bug to help us improve
4 | title: 'bug(area): brief description of the bug'
5 | labels: 'type: enhancement'
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Title Format**
11 | Please use the following format for your title:
12 | ```
13 | fix(area): brief description of the bug
14 | ```
15 | Where `area` is one of: `algebra`, `space`
16 |
17 | **Describe the Bug**
18 | A clear and concise description of what the bug is.
19 |
20 | **To Reproduce**
21 | Steps to reproduce the behavior:
22 | 1. Use function/method '...'
23 | 2. With parameters '....'
24 | 3. See error
25 |
26 | **Expected Behavior**
27 | A clear and concise description of what you expected to happen.
28 |
29 | **Environment**
30 | - OS: [e.g. Ubuntu 20.04]
31 | - Rust Version: [e.g. 1.75.0]
32 | - Crate Version: [e.g. 0.1.0]
33 |
34 | **Additional Context**
35 | Add any other context about the problem here.
36 |
37 | **Labels to Consider**
38 | - `area: algebra` or `area: space` (based on affected component)
39 | - `priority: critical/high/medium/low` (based on impact)
40 | - `tech: performance` (if performance related)
41 | - `tech: security` (if security related)
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature Request
3 | about: Suggest an idea for this project
4 | title: 'feat(area): brief description of the feature'
5 | labels: 'type: enhancement'
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Title Format**
11 | Please use the following format for your title:
12 | ```
13 | feat(area): brief description of the feature
14 | ```
15 | Where `area` is one of: `algebra`, `space`
16 |
17 | **Feature Description**
18 | A clear and concise description of what you want to happen.
19 |
20 | **Motivation**
21 | Why is this feature needed? What problems does it solve?
22 |
23 | **Implementation Details**
24 | If applicable, describe the technical approach to implementing this feature:
25 | - [ ] Task 1
26 | - [ ] Task 2
27 | - [ ] Task 3
28 |
29 | **Dependencies**
30 | List any dependencies or prerequisites needed for this feature.
31 |
32 | **Additional Context**
33 | Add any other context or screenshots about the feature request here.
34 |
35 | **Labels to Consider**
36 | - `area: algebra` or `area: space` (based on component)
37 | - `priority: critical/high/medium/low` (based on importance)
38 | - `tech: performance` (if performance related)
39 | - `community: help-wanted` (if seeking contributors)
--------------------------------------------------------------------------------
/.github/dependabot.yaml:
--------------------------------------------------------------------------------
1 | version: 2
2 | updates:
3 | - package-ecosystem: "cargo"
4 | directory: "/"
5 | schedule:
6 | interval: "monthly"
7 | # Group all updates together
8 | groups:
9 | all-updates:
10 | patterns:
11 | - "*"
12 | # Specify rules for version updates
13 | open-pull-requests-limit: 10
14 | # Assign reviewers (optional)
15 | reviewers:
16 | - "autoparallel"
17 | # Labels for PRs (optional)
18 | labels:
19 | - "dependencies"
20 | - "automated pr"
21 | # Configure commit message
22 | commit-message:
23 | prefix: "chore"
24 | include: "scope"
25 | # Only allow certain update types (optional)
26 | allow:
27 | # Allow both direct and indirect updates for all packages
28 | - dependency-type: "all"
--------------------------------------------------------------------------------
/.github/labels.yaml:
--------------------------------------------------------------------------------
1 | # Priority Levels (Red to Green)
2 | - name: "priority: critical"
3 | color: "b60205"
4 | description: "Must be addressed immediately"
5 |
6 | - name: "priority: high"
7 | color: "d93f0b"
8 | description: "High priority tasks"
9 |
10 | - name: "priority: medium"
11 | color: "fbca04"
12 | description: "Medium priority tasks"
13 |
14 | - name: "priority: low"
15 | color: "0e8a16"
16 | description: "Low priority tasks"
17 |
18 | # Areas of Codebase (Blues)
19 | - name: "area: algebra"
20 | color: "0052cc"
21 | description: "Algebra related changes"
22 |
23 | - name: "area: space"
24 | color: "006b75"
25 | description: "Space related changes"
26 |
27 | # Task Types (Purples)
28 | - name: "type: refactor"
29 | color: "6f42c1"
30 | description: "Code refactoring and restructuring"
31 |
32 | - name: "type: enhancement"
33 | color: "7057ff"
34 | description: "Improvements to existing features"
35 |
36 | - name: "type: maintenance"
37 | color: "8a63d2"
38 | description: "Maintenance and cleanup tasks"
39 |
40 | # Technical Categories (Oranges)
41 | - name: "tech: security"
42 | color: "d93f0b"
43 | description: "Security-related changes"
44 |
45 | - name: "tech: performance"
46 | color: "fbca04"
47 | description: "Performance improvements"
48 |
49 | - name: "tech: testing"
50 | color: "ff7619"
51 | description: "Testing related changes"
52 |
53 | # Process Labels (Greens)
54 | - name: "status: needs-review"
55 | color: "0e8a16"
56 | description: "Needs review from maintainers"
57 |
58 | - name: "status: blocked"
59 | color: "44cc11"
60 | description: "Blocked by other issues"
61 |
62 | - name: "status: in-progress"
63 | color: "1a7f37"
64 | description: "Currently being worked on"
65 |
66 | # Community Labels (Teals)
67 | - name: "community: good-first-issue"
68 | color: "008672"
69 | description: "Good for new contributors"
70 |
71 | - name: "community: help-wanted"
72 | color: "006b75"
73 | description: "Extra attention needed"
74 |
75 | # Documentation (Light Blue)
76 | - name: "docs"
77 | color: "0075ca"
78 | description: "Documentation updates"
79 |
80 | # Dependencies (Pink)
81 | - name: "dependencies"
82 | color: "cb7eed"
83 | description: "Dependency updates and maintenance"
84 |
85 | # CI/CD (Bright Green)
86 | - name: "ci/cd"
87 | color: "44cc11"
88 | description: "Continuous integration and deployment pipeline changes"
--------------------------------------------------------------------------------
/.github/pull_request_template.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Pull Request
3 | about: Create a pull request
4 | title: 'type(area): brief description of changes'
5 | assignees: ''
6 | ---
7 |
8 | **Title Format**
9 | Please use the following format for your title:
10 | ```
11 | type(area): brief description of changes
12 | ```
13 | Where:
14 | - `type` is one of: `feat`, `fix`, `refactor`, `docs`, `test`, `chore`
15 | - `area` is one of: `algebra`, `space`
16 |
17 | **Description**
18 | Please provide a clear description of your changes. If this PR closes any issues, please reference them here.
19 |
20 | **Changes Made**
21 | - [ ] Change 1
22 | - [ ] Change 2
23 | - [ ] Change 3
24 |
25 | **Testing**
26 | - [ ] Tests added/updated
27 | - [ ] All tests pass
28 |
29 | **Labels to Consider**
30 | - `area: algebra` or `area: space` (based on component)
31 | - `priority: critical/high/medium/low` (based on importance)
32 | - `type: enhancement` (for new features)
33 | - `type: refactor` (for refactoring)
34 | - `tech: performance` (if performance related)
35 | - `tech: testing` (if testing related)
36 | - `docs` (if documentation related)
37 |
38 | **Additional Notes**
39 | Add any additional context or notes here.
40 |
41 | ## 📝 Description
42 |
43 |
44 | ## 🔍 Changes include
45 |
46 | - [ ] 🐛 Bugfix
47 | - [ ] ✨ New feature
48 | - [ ] 📚 Documentation
49 | - [ ] ⚡ Performance improvement
50 | - [ ] 🔨 Refactoring
51 | - [ ] ✅ Test updates
52 |
53 | ## 🧪 Testing
54 |
55 |
56 | ## 📋 Checklist
57 | - [ ] I have tested the changes locally
58 | - [ ] I have updated the documentation accordingly
59 | - [ ] I have added tests that prove my fix/feature works
60 | - [ ] All tests pass locally
61 |
62 | ## 📸 Screenshots
63 |
64 |
65 | ## 🔗 Linked Issues
66 |
67 |
68 | closes #
--------------------------------------------------------------------------------
/.github/settings.yaml:
--------------------------------------------------------------------------------
1 | repository:
2 | # Enable all features
3 | has_issues: true
4 | has_projects: false
5 | has_wiki: false
6 | has_downloads: false
7 |
8 | # Default branch (recommended to use "main")
9 | default_branch: main
10 |
11 | # Enable vulnerability alerts
12 | enable_vulnerability_alerts: true
13 |
14 | # Allow squash merging only
15 | allow_squash_merge: true
16 | allow_merge_commit: false
17 | allow_rebase_merge: true
18 |
19 | # Use PR title as squash commit message
20 | squash_merge_commit_title: PR_TITLE
21 | squash_merge_commit_message: BLANK
22 |
23 | # Delete head branch after merge
24 | delete_branch_on_merge: true
25 |
26 | # Branch protection rules
27 | branches:
28 | - name: main
29 | protection:
30 | # Require pull request before merging
31 | required_pull_request_reviews:
32 | required_approving_review_count: 1
33 | dismiss_stale_reviews: true
34 | require_code_owner_reviews: false
35 |
36 | # Require status checks to pass
37 | required_status_checks:
38 | strict: true
39 | contexts: [] # Add your required status checks here
40 |
41 | # Prevent direct pushes to main
42 | enforce_admins: true
43 |
44 | # Restrict who can push to matching branches
45 | restrictions: null # Set to null to allow any user with push access
46 |
--------------------------------------------------------------------------------
/.github/workflows/book.yaml:
--------------------------------------------------------------------------------
1 | name: MDBook Build (and Deploy on Push)
2 |
3 | on:
4 | pull_request:
5 | branches: ["main"]
6 | push:
7 | branches: ["main"]
8 |
9 | permissions:
10 | contents: read
11 | pages: write
12 | id-token: write
13 |
14 | jobs:
15 | build:
16 | name: Build Documentation
17 | runs-on: ubuntu-latest
18 | steps:
19 | - uses: actions/checkout@v4
20 |
21 | - name: Install Rust
22 | uses: dtolnay/rust-toolchain@master
23 | with:
24 | toolchain: nightly-2025-05-25
25 |
26 | - name: Install mdbook
27 | uses: taiki-e/install-action@cargo-binstall
28 | with:
29 | tool: mdbook
30 |
31 | - name: Install mdbook-katex
32 | uses: taiki-e/install-action@cargo-binstall
33 | with:
34 | tool: mdbook-katex
35 |
36 | - name: Install mdbook-linkcheck
37 | uses: taiki-e/install-action@cargo-binstall
38 | with:
39 | tool: mdbook-linkcheck
40 |
41 | - name: Build mdBook
42 | run: mdbook build
43 |
44 | - name: Upload artifact
45 | uses: actions/upload-pages-artifact@v3
46 | with:
47 | path: ./docs/html
48 |
49 | deploy:
50 | environment:
51 | name: github-pages
52 | url: ${{ steps.deployment.outputs.page_url }}
53 | runs-on: ubuntu-latest
54 | needs: build
55 | if: github.event_name == 'push' && github.ref == 'refs/heads/main'
56 | steps:
57 | - name: Deploy to GitHub Pages
58 | id: deployment
59 | uses: actions/deploy-pages@v4
--------------------------------------------------------------------------------
/.github/workflows/release.yaml:
--------------------------------------------------------------------------------
1 | name: Release
2 |
3 | permissions:
4 | pull-requests: write
5 | contents: write
6 |
7 | on:
8 | push:
9 | branches:
10 | - main
11 |
12 | jobs:
13 | release:
14 | name: release
15 | runs-on: ubuntu-latest
16 | steps:
17 | - name: Checkout repository
18 | uses: actions/checkout@v4
19 | with:
20 | fetch-depth: 0
21 |
22 | - name: Install Rust toolchain
23 | uses: dtolnay/rust-toolchain@master
24 | with:
25 | toolchain: nightly-2025-05-25
26 |
27 | - name: Rust Cache
28 | uses: Swatinem/rust-cache@v2
29 |
30 | - name: Install cargo-semver-checks
31 | uses: taiki-e/install-action@cargo-binstall
32 | with:
33 | tool: cargo-semver-checks
34 |
35 | - name: Check semver
36 | run: cargo semver-checks check-release
37 | continue-on-error: true
38 |
39 | - name: Update Cargo.lock
40 | uses: stefanzweifel/git-auto-commit-action@v5
41 | with:
42 | commit_message: "chore: update Cargo.lock"
43 | file_pattern: "Cargo.lock"
44 |
45 | - name: Run release-plz
46 | uses: MarcoIeni/release-plz-action@v0.5.41
47 | env:
48 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
49 | CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
--------------------------------------------------------------------------------
/.github/workflows/rust.yaml:
--------------------------------------------------------------------------------
1 | name: Rust
2 | concurrency:
3 | group: ${{ github.workflow }}-${{ github.ref }}
4 | cancel-in-progress: true
5 |
6 | on:
7 | push:
8 | branches: [ main ]
9 | pull_request:
10 | branches: [ main ]
11 |
12 | env:
13 | CARGO_TERM_COLOR: always
14 |
15 | jobs:
16 | rust-fmt:
17 | name: rustfmt
18 | runs-on: ubuntu-latest
19 | steps:
20 | - uses: actions/checkout@v4
21 |
22 | - name: Install Rust
23 | uses: dtolnay/rust-toolchain@master
24 | with:
25 | toolchain: nightly-2025-05-25
26 | components: rustfmt
27 |
28 | - name: Rust Cache
29 | uses: Swatinem/rust-cache@v2
30 | with:
31 | key: rust/rustfmt
32 |
33 | - name: Run Rust fmt
34 | run: cargo fmt --all -- --check
35 |
36 | toml-fmt:
37 | name: taplo
38 | runs-on: ubuntu-latest
39 | steps:
40 | - uses: actions/checkout@v4
41 |
42 | - name: Install Rust
43 | uses: dtolnay/rust-toolchain@master
44 | with:
45 | toolchain: nightly-2025-05-25
46 |
47 | - name: Install taplo
48 | uses: taiki-e/install-action@cargo-binstall
49 | with:
50 | tool: taplo-cli
51 |
52 | - name: Rust Cache
53 | uses: Swatinem/rust-cache@v2
54 | with:
55 | key: rust/taplo
56 |
57 | - name: Run TOML fmt
58 | run: taplo fmt --check
59 |
60 | check:
61 | name: check
62 | runs-on: ubuntu-latest
63 | steps:
64 | - uses: actions/checkout@v4
65 |
66 | - name: Install Rust
67 | uses: dtolnay/rust-toolchain@master
68 | with:
69 | toolchain: nightly-2025-05-25
70 |
71 | - name: Rust Cache
72 | uses: Swatinem/rust-cache@v2
73 | with:
74 | key: rust/check
75 |
76 | - name: Run cargo check
77 | run: cargo check --workspace
78 |
79 | check-wasm:
80 | name: check-wasm
81 | runs-on: ubuntu-latest
82 | steps:
83 | - uses: actions/checkout@v4
84 |
85 | - name: Install Rust
86 | uses: dtolnay/rust-toolchain@master
87 | with:
88 | toolchain: nightly-2025-05-25
89 |
90 | - name: Rust Cache
91 | uses: Swatinem/rust-cache@v2
92 | with:
93 | key: rust/check-wasm
94 |
95 | - name: Install WASM target
96 | run: rustup target add wasm32-unknown-unknown
97 |
98 | - name: Run cargo check for WASM
99 | run: cargo check --workspace --target wasm32-unknown-unknown
100 |
101 | clippy:
102 | name: clippy
103 | runs-on: ubuntu-latest
104 | steps:
105 | - uses: actions/checkout@v4
106 |
107 | - name: Install Rust
108 | uses: dtolnay/rust-toolchain@master
109 | with:
110 | toolchain: nightly-2025-05-25
111 | components: clippy
112 |
113 | - name: Rust Cache
114 | uses: Swatinem/rust-cache@v2
115 | with:
116 | key: rust/clippy
117 |
118 | - name: Build
119 | run: cargo build --workspace
120 |
121 | - name: Clippy
122 | run: cargo clippy --all-targets --all-features -- --deny warnings
123 |
124 | clippy-wasm:
125 | name: clippy-wasm
126 | runs-on: ubuntu-latest
127 | steps:
128 | - uses: actions/checkout@v4
129 |
130 | - name: Install Rust
131 | uses: dtolnay/rust-toolchain@master
132 | with:
133 | toolchain: nightly-2025-05-25
134 | components: clippy
135 |
136 | - name: Rust Cache
137 | uses: Swatinem/rust-cache@v2
138 | with:
139 | key: rust/clippy-wasm
140 |
141 | - name: Install WASM target
142 | run: rustup target add wasm32-unknown-unknown
143 |
144 | - name: Clippy for WASM
145 | run: cargo clippy --target wasm32-unknown-unknown --all-features -- --deny warnings
146 |
147 | test:
148 | name: test
149 | runs-on: ubuntu-latest
150 | steps:
151 | - uses: actions/checkout@v4
152 |
153 | - name: Install Rust
154 | uses: dtolnay/rust-toolchain@master
155 | with:
156 | toolchain: nightly-2025-05-25
157 |
158 | - name: Rust Cache
159 | uses: Swatinem/rust-cache@v2
160 | with:
161 | key: rust/test
162 |
163 | - name: Run tests
164 | run: cargo test --verbose --workspace
165 |
166 | semver:
167 | name: semver
168 | runs-on: ubuntu-latest
169 | continue-on-error: true
170 | steps:
171 | - uses: actions/checkout@v4
172 | with:
173 | fetch-depth: 0
174 |
175 | - name: Install Rust
176 | uses: dtolnay/rust-toolchain@master
177 | with:
178 | toolchain: nightly-2025-05-25
179 |
180 | - name: Rust Cache
181 | uses: Swatinem/rust-cache@v2
182 | with:
183 | key: rust/semver
184 |
185 | - name: Install cargo-semver-checks
186 | uses: taiki-e/install-action@cargo-binstall
187 | with:
188 | tool: cargo-semver-checks
189 |
190 | - name: Check semver
191 | run: cargo semver-checks check-release
192 |
193 | udeps:
194 | name: udeps
195 | runs-on: ubuntu-latest
196 | steps:
197 | - uses: actions/checkout@v4
198 |
199 | - name: Install Rust
200 | uses: dtolnay/rust-toolchain@master
201 | with:
202 | toolchain: nightly-2025-05-25
203 |
204 | - name: Rust Cache
205 | uses: Swatinem/rust-cache@v2
206 | with:
207 | key: rust/udeps
208 |
209 | - name: Install cargo-udeps
210 | uses: taiki-e/install-action@cargo-binstall
211 | with:
212 | tool: cargo-udeps
213 |
214 | - name: Run cargo-udeps
215 | run: cargo udeps --workspace
216 |
217 | doc:
218 | name: doc
219 | runs-on: ubuntu-latest
220 | steps:
221 | - uses: actions/checkout@v4
222 |
223 | - name: Install Rust
224 | uses: dtolnay/rust-toolchain@master
225 | with:
226 | toolchain: nightly-2025-05-25
227 |
228 | - name: Rust Cache
229 | uses: Swatinem/rust-cache@v2
230 | with:
231 | key: rust/doc
232 |
233 | - name: Run cargo doc to check for warnings
234 | run: RUSTDOCFLAGS="-D warnings" cargo doc --no-deps --all-features
--------------------------------------------------------------------------------
/.github/workflows/sync_labels.yaml:
--------------------------------------------------------------------------------
1 | name: Sync Labels
2 |
3 | on:
4 | push:
5 | branches:
6 | - main
7 | paths:
8 | - '.github/labels.yaml'
9 | workflow_dispatch:
10 |
11 | permissions:
12 | issues: write
13 | pull-requests: write
14 |
15 | jobs:
16 | sync:
17 | runs-on: ubuntu-latest
18 | steps:
19 | - uses: actions/checkout@v4
20 |
21 | - uses: micnncim/action-label-syncer@v1
22 | env:
23 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
24 | with:
25 | manifest: .github/labels.yaml
26 | prune: true
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # OS generated files
2 | .DS_Store
3 | ._*
4 | .Spotlight-V100
5 | .Trashes
6 | ehthumbs.db
7 | Thumbs.db
8 |
9 | # Editor directories and files
10 | .idea/
11 | .vscode/
12 | *.swp
13 | *.swo
14 | *~
15 |
16 | # Log files
17 | *.log
18 |
19 | # Environment files
20 | .env
21 | .env.local
22 | .env.*.local
23 |
24 | # Temporary files
25 | *.tmp
26 | *.temp
27 | .cache/
28 |
29 | # Build output
30 | dist/
31 | build/
32 | out/
33 | target/
34 |
35 | # Mdbook
36 | docs/
37 |
--------------------------------------------------------------------------------
/.release-plz.toml:
--------------------------------------------------------------------------------
1 | [workspace]
2 | allow_dirty = false
3 | dependencies_update = false
4 | semver_check = true
5 |
6 | [[package]]
7 | name = "cova-algebra"
8 | publish = true
9 |
10 | [[package]]
11 | name = "cova-space"
12 | publish = true
13 |
14 | [[package]]
15 | name = "cova"
16 | publish = true
17 |
--------------------------------------------------------------------------------
/.rustfmt.toml:
--------------------------------------------------------------------------------
1 | # Opinionated whitespace and tabs. The most important of these are imports and width settings.
2 | # Others may want to borrow or change these to their own liking.
3 | # https://rust-lang.github.io/rustfmt
4 |
5 | # version-related
6 | edition = "2021" # redundant, fmt will read Cargo.toml for editor edition year
7 | unstable_features = true
8 | use_try_shorthand = true # replace any `try!` (2015 Rust) with `?`
9 |
10 | # misc formatting
11 | condense_wildcard_suffixes = true # replace: (a,b,_,_)=(1, 2, 3, 4); -> (a,b,..)=(1, 2, 3, 4);
12 | format_code_in_doc_comments = true # format code blocks in doc comments
13 | format_macro_matchers = true # $a: ident -> $a:ident
14 | format_strings = true # break and insert newlines for long string literals
15 | match_block_trailing_comma = true # include comma in match blocks after '}'
16 | normalize_comments = true # convert /*..*/ to //.. where possible
17 | reorder_impl_items = true # move `type` and `const` declarations to top of impl block
18 | struct_field_align_threshold = 20 # align struct arguments' types vertically
19 | use_field_init_shorthand = true # struct initialization short {x: x} -> {x}
20 |
21 | # reduce whitespace
22 | blank_lines_upper_bound = 1 # default: 1. Sometimes useful to change to 0 to condense a file.
23 | brace_style = "PreferSameLine" # prefer starting `{` without inserting extra \n
24 | fn_single_line = true # if it's a short 1-liner, let it be a short 1-liner
25 | match_arm_blocks = false # remove unnecessary {} in match arms
26 | newline_style = "Unix" # not auto, we won the culture war. \n over \r\n
27 | overflow_delimited_expr = true # prefer ]); to ]\n);
28 | where_single_line = true # put where on a single line if possible
29 |
30 | # imports preferences
31 | group_imports = "StdExternalCrate" # create import groupings for std, external libs, and internal deps
32 | imports_granularity = "Crate" # aggressively group imports
33 |
34 | # width settings: everything to 100
35 | comment_width = 100 # default: 80
36 | inline_attribute_width = 60 # inlines #[cfg(test)]\nmod test -> #[cfg(test)] mod test
37 | max_width = 100 # default: 100
38 | use_small_heuristics = "Max" # don't ever newline short of `max_width`.
39 | wrap_comments = true # wrap comments at `comment_width`
40 | # format_strings = true # wrap strings at `max_length`
41 |
42 | # tabs and spaces
43 | hard_tabs = false # (def: false) use spaces over tabs
44 | tab_spaces = 2 # 2 > 4, it's just math.
45 |
--------------------------------------------------------------------------------
/.taplo.toml:
--------------------------------------------------------------------------------
1 | # .toml file formatting settings for `taplo`
2 | # https://taplo.tamasfe.dev/configuration/formatter-options.html
3 |
4 | [formatting]
5 | # align entries vertically
6 | align_entries = true
7 | # allow up to 1 consecutive empty line (default: 2)
8 | allowed_blank_line = 1
9 | # collapse arrays into one line if they fit
10 | array_auto_collapse = true
11 | # alphabetically sort entries not separated by line breaks
12 | reorder_keys = true
13 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing to Cova
2 |
3 | Thank you for your interest in contributing to Cova! This document provides guidelines and instructions for contributing to the project.
4 |
5 | ## Table of Contents
6 | - [Code of Conduct](#code-of-conduct)
7 | - [Getting Started](#getting-started)
8 | - [Development Workflow](#development-workflow)
9 | - [Documentation](#documentation)
10 | - [Issue Guidelines](#issue-guidelines)
11 | - [Pull Request Guidelines](#pull-request-guidelines)
12 | - [Code Style](#code-style)
13 | - [Testing](#testing)
14 |
15 | ## Code of Conduct
16 |
17 | By participating in this project, you agree to abide by our Code of Conduct. Please be respectful and considerate of others.
18 |
19 | ## Getting Started
20 |
21 | 1. Fork the repository
22 | 2. Clone your fork:
23 | ```bash
24 | git clone https://github.com/yourusername/cova.git
25 | cd cova
26 | ```
27 | 3. Set up the development environment:
28 | ```bash
29 | # Install Rust (if not already installed)
30 | curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
31 |
32 | # Install development tools
33 | rustup component add rustfmt clippy
34 | ```
35 |
36 | ## Development Workflow
37 |
38 | 1. Create a new branch for your feature/fix:
39 | ```bash
40 | git checkout -b type/area/description
41 | # Example: git checkout -b feat/algebra/vector-spaces
42 | ```
43 |
44 | 2. Make your changes following the [Code Style](#code-style) guidelines
45 |
46 | 3. Run tests and checks:
47 | ```bash
48 | cargo test
49 | cargo fmt --all -- --check
50 | cargo clippy --all-targets --all-features -- -D warnings
51 | ```
52 |
53 | 4. Commit your changes following the [Commit Message Format](#commit-message-format)
54 |
55 | 5. Push your branch and create a Pull Request
56 |
57 | ## Documentation
58 |
59 | Harness provides two types of documentation that you should be familiar with:
60 |
61 | ### API Documentation
62 | The Rust API documentation for all crates can be viewed using:
63 | ```bash
64 | just docs
65 | ```
66 | This will build and open the Rust API documentation in your browser. This documentation is automatically generated from your code comments and should be kept up to date.
67 |
68 | ### Book Documentation
69 | The comprehensive book documentation can be viewed using:
70 | ```bash
71 | just book
72 | ```
73 | This will serve the book documentation locally and open it in your browser. The book includes detailed explanations of mathematical concepts, examples, and usage guides.
74 |
75 | When contributing, please:
76 | 1. Keep API documentation up to date with your code changes
77 | 2. Update the book documentation if you add new features or change existing behavior
78 | 3. Add examples to both API docs and the book where appropriate
79 | 4. Ensure mathematical definitions and references are accurate
80 |
81 | ## Issue Guidelines
82 |
83 | When creating issues, please use the provided templates and follow these guidelines:
84 |
85 | ### Title Format
86 | ```
87 | type(area): brief description
88 | ```
89 | Where:
90 | - `type` is one of: `feat`, `fix`, `refactor`, `docs`, `test`, `chore`
91 | - `area` is one of: `algebra`, `space`
92 |
93 | ### Labels
94 | Please use appropriate labels to categorize your issue:
95 | - Area labels: `area: algebra`, `area: space`
96 | - Priority labels: `priority: critical/high/medium/low`
97 | - Type labels: `type: enhancement`, `type: refactor`
98 | - Technical labels: `tech: performance`, `tech: security`, `tech: testing`
99 |
100 | ## Pull Request Guidelines
101 |
102 | 1. Use the provided PR template
103 | 2. Ensure your PR title follows the format: `type(area): description`
104 | 3. Link related issues using `closes #issue_number`
105 | 4. Keep PRs focused and small when possible
106 | 5. Include tests for new features or bug fixes
107 | 6. Update documentation as needed
108 |
109 | ## Code Style
110 |
111 | - Follow Rust's official style guide
112 | - Use `rustfmt` for formatting
113 | - Run `cargo clippy` to catch common mistakes
114 | - Document public APIs thoroughly
115 | - Use meaningful variable and function names
116 | - Keep functions focused and small
117 |
118 | ## Testing
119 |
120 | - Write unit tests for all new functionality
121 | - Include examples in documentation
122 | - Run all tests before submitting PRs
123 | - Consider edge cases and error conditions
124 |
125 | ## Commit Message Format
126 |
127 | Follow this format for commit messages:
128 | ```
129 | type(area): description
130 |
131 | [optional body]
132 |
133 | [optional footer]
134 | ```
135 |
136 | Where:
137 | - `type` is one of: `feat`, `fix`, `refactor`, `docs`, `test`, `chore`
138 | - `area` is one of: `algebra`, `space`
139 | - Description is a brief summary of changes
140 | - Body provides additional context if needed
141 | - Footer references issues or PRs
142 |
143 | ## Questions?
144 |
145 | If you have any questions, feel free to:
146 | 1. Open an issue with the `question` label
147 | 2. Join our community discussions
148 | 3. Contact the maintainers
--------------------------------------------------------------------------------
/Cargo.lock:
--------------------------------------------------------------------------------
1 | # This file is automatically @generated by Cargo.
2 | # It is not intended for manual editing.
3 | version = 4
4 |
5 | [[package]]
6 | name = "autocfg"
7 | version = "1.4.0"
8 | source = "registry+https://github.com/rust-lang/crates.io-index"
9 | checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26"
10 |
11 | [[package]]
12 | name = "bitflags"
13 | version = "2.9.0"
14 | source = "registry+https://github.com/rust-lang/crates.io-index"
15 | checksum = "5c8214115b7bf84099f1309324e63141d4c5d7cc26862f97a0a857dbefe165bd"
16 |
17 | [[package]]
18 | name = "cfg-if"
19 | version = "1.0.0"
20 | source = "registry+https://github.com/rust-lang/crates.io-index"
21 | checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
22 |
23 | [[package]]
24 | name = "cova"
25 | version = "0.1.3"
26 | dependencies = [
27 | "cova-algebra",
28 | "cova-space",
29 | "tempfile",
30 | ]
31 |
32 | [[package]]
33 | name = "cova-algebra"
34 | version = "0.1.2"
35 | dependencies = [
36 | "num-traits",
37 | ]
38 |
39 | [[package]]
40 | name = "cova-space"
41 | version = "0.2.0"
42 | dependencies = [
43 | "cova-algebra",
44 | "itertools",
45 | "num-traits",
46 | "rayon",
47 | "tempfile",
48 | ]
49 |
50 | [[package]]
51 | name = "crossbeam-deque"
52 | version = "0.8.6"
53 | source = "registry+https://github.com/rust-lang/crates.io-index"
54 | checksum = "9dd111b7b7f7d55b72c0a6ae361660ee5853c9af73f70c3c2ef6858b950e2e51"
55 | dependencies = [
56 | "crossbeam-epoch",
57 | "crossbeam-utils",
58 | ]
59 |
60 | [[package]]
61 | name = "crossbeam-epoch"
62 | version = "0.9.18"
63 | source = "registry+https://github.com/rust-lang/crates.io-index"
64 | checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e"
65 | dependencies = [
66 | "crossbeam-utils",
67 | ]
68 |
69 | [[package]]
70 | name = "crossbeam-utils"
71 | version = "0.8.21"
72 | source = "registry+https://github.com/rust-lang/crates.io-index"
73 | checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28"
74 |
75 | [[package]]
76 | name = "either"
77 | version = "1.15.0"
78 | source = "registry+https://github.com/rust-lang/crates.io-index"
79 | checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719"
80 |
81 | [[package]]
82 | name = "errno"
83 | version = "0.3.11"
84 | source = "registry+https://github.com/rust-lang/crates.io-index"
85 | checksum = "976dd42dc7e85965fe702eb8164f21f450704bdde31faefd6471dba214cb594e"
86 | dependencies = [
87 | "libc",
88 | "windows-sys",
89 | ]
90 |
91 | [[package]]
92 | name = "fastrand"
93 | version = "2.3.0"
94 | source = "registry+https://github.com/rust-lang/crates.io-index"
95 | checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be"
96 |
97 | [[package]]
98 | name = "getrandom"
99 | version = "0.3.2"
100 | source = "registry+https://github.com/rust-lang/crates.io-index"
101 | checksum = "73fea8450eea4bac3940448fb7ae50d91f034f941199fcd9d909a5a07aa455f0"
102 | dependencies = [
103 | "cfg-if",
104 | "libc",
105 | "r-efi",
106 | "wasi",
107 | ]
108 |
109 | [[package]]
110 | name = "itertools"
111 | version = "0.14.0"
112 | source = "registry+https://github.com/rust-lang/crates.io-index"
113 | checksum = "2b192c782037fadd9cfa75548310488aabdbf3d2da73885b31bd0abd03351285"
114 | dependencies = [
115 | "either",
116 | ]
117 |
118 | [[package]]
119 | name = "libc"
120 | version = "0.2.172"
121 | source = "registry+https://github.com/rust-lang/crates.io-index"
122 | checksum = "d750af042f7ef4f724306de029d18836c26c1765a54a6a3f094cbd23a7267ffa"
123 |
124 | [[package]]
125 | name = "linux-raw-sys"
126 | version = "0.9.4"
127 | source = "registry+https://github.com/rust-lang/crates.io-index"
128 | checksum = "cd945864f07fe9f5371a27ad7b52a172b4b499999f1d97574c9fa68373937e12"
129 |
130 | [[package]]
131 | name = "num-traits"
132 | version = "0.2.19"
133 | source = "registry+https://github.com/rust-lang/crates.io-index"
134 | checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841"
135 | dependencies = [
136 | "autocfg",
137 | ]
138 |
139 | [[package]]
140 | name = "once_cell"
141 | version = "1.21.3"
142 | source = "registry+https://github.com/rust-lang/crates.io-index"
143 | checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d"
144 |
145 | [[package]]
146 | name = "r-efi"
147 | version = "5.2.0"
148 | source = "registry+https://github.com/rust-lang/crates.io-index"
149 | checksum = "74765f6d916ee2faa39bc8e68e4f3ed8949b48cccdac59983d287a7cb71ce9c5"
150 |
151 | [[package]]
152 | name = "rayon"
153 | version = "1.10.0"
154 | source = "registry+https://github.com/rust-lang/crates.io-index"
155 | checksum = "b418a60154510ca1a002a752ca9714984e21e4241e804d32555251faf8b78ffa"
156 | dependencies = [
157 | "either",
158 | "rayon-core",
159 | ]
160 |
161 | [[package]]
162 | name = "rayon-core"
163 | version = "1.12.1"
164 | source = "registry+https://github.com/rust-lang/crates.io-index"
165 | checksum = "1465873a3dfdaa8ae7cb14b4383657caab0b3e8a0aa9ae8e04b044854c8dfce2"
166 | dependencies = [
167 | "crossbeam-deque",
168 | "crossbeam-utils",
169 | ]
170 |
171 | [[package]]
172 | name = "rustix"
173 | version = "1.0.7"
174 | source = "registry+https://github.com/rust-lang/crates.io-index"
175 | checksum = "c71e83d6afe7ff64890ec6b71d6a69bb8a610ab78ce364b3352876bb4c801266"
176 | dependencies = [
177 | "bitflags",
178 | "errno",
179 | "libc",
180 | "linux-raw-sys",
181 | "windows-sys",
182 | ]
183 |
184 | [[package]]
185 | name = "tempfile"
186 | version = "3.20.0"
187 | source = "registry+https://github.com/rust-lang/crates.io-index"
188 | checksum = "e8a64e3985349f2441a1a9ef0b853f869006c3855f2cda6862a94d26ebb9d6a1"
189 | dependencies = [
190 | "fastrand",
191 | "getrandom",
192 | "once_cell",
193 | "rustix",
194 | "windows-sys",
195 | ]
196 |
197 | [[package]]
198 | name = "wasi"
199 | version = "0.14.2+wasi-0.2.4"
200 | source = "registry+https://github.com/rust-lang/crates.io-index"
201 | checksum = "9683f9a5a998d873c0d21fcbe3c083009670149a8fab228644b8bd36b2c48cb3"
202 | dependencies = [
203 | "wit-bindgen-rt",
204 | ]
205 |
206 | [[package]]
207 | name = "windows-sys"
208 | version = "0.59.0"
209 | source = "registry+https://github.com/rust-lang/crates.io-index"
210 | checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b"
211 | dependencies = [
212 | "windows-targets",
213 | ]
214 |
215 | [[package]]
216 | name = "windows-targets"
217 | version = "0.52.6"
218 | source = "registry+https://github.com/rust-lang/crates.io-index"
219 | checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
220 | dependencies = [
221 | "windows_aarch64_gnullvm",
222 | "windows_aarch64_msvc",
223 | "windows_i686_gnu",
224 | "windows_i686_gnullvm",
225 | "windows_i686_msvc",
226 | "windows_x86_64_gnu",
227 | "windows_x86_64_gnullvm",
228 | "windows_x86_64_msvc",
229 | ]
230 |
231 | [[package]]
232 | name = "windows_aarch64_gnullvm"
233 | version = "0.52.6"
234 | source = "registry+https://github.com/rust-lang/crates.io-index"
235 | checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
236 |
237 | [[package]]
238 | name = "windows_aarch64_msvc"
239 | version = "0.52.6"
240 | source = "registry+https://github.com/rust-lang/crates.io-index"
241 | checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
242 |
243 | [[package]]
244 | name = "windows_i686_gnu"
245 | version = "0.52.6"
246 | source = "registry+https://github.com/rust-lang/crates.io-index"
247 | checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
248 |
249 | [[package]]
250 | name = "windows_i686_gnullvm"
251 | version = "0.52.6"
252 | source = "registry+https://github.com/rust-lang/crates.io-index"
253 | checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
254 |
255 | [[package]]
256 | name = "windows_i686_msvc"
257 | version = "0.52.6"
258 | source = "registry+https://github.com/rust-lang/crates.io-index"
259 | checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
260 |
261 | [[package]]
262 | name = "windows_x86_64_gnu"
263 | version = "0.52.6"
264 | source = "registry+https://github.com/rust-lang/crates.io-index"
265 | checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
266 |
267 | [[package]]
268 | name = "windows_x86_64_gnullvm"
269 | version = "0.52.6"
270 | source = "registry+https://github.com/rust-lang/crates.io-index"
271 | checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
272 |
273 | [[package]]
274 | name = "windows_x86_64_msvc"
275 | version = "0.52.6"
276 | source = "registry+https://github.com/rust-lang/crates.io-index"
277 | checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
278 |
279 | [[package]]
280 | name = "wit-bindgen-rt"
281 | version = "0.39.0"
282 | source = "registry+https://github.com/rust-lang/crates.io-index"
283 | checksum = "6f42320e61fe2cfd34354ecb597f86f413484a798ba44a8ca1165c58d42da6c1"
284 | dependencies = [
285 | "bitflags",
286 | ]
287 |
--------------------------------------------------------------------------------
/Cargo.toml:
--------------------------------------------------------------------------------
1 | [workspace]
2 | members = ["cova", "cova-space", "cova-algebra"]
3 | resolver = "2"
4 |
5 | [workspace.dependencies]
6 | # Local dependencies
7 | cova-algebra = { path = "cova-algebra", version = "=0.1.2" }
8 | cova-space = { path = "cova-space", version = "=0.2.0" }
9 |
10 | # External dependencies
11 | itertools = { version = "0.14", default-features = false }
12 | num-traits = { version = "0.2", default-features = false }
13 | rayon = { version = "1.10", default-features = false }
14 |
15 | # Development dependencies
16 | tempfile = { version = "3.20" }
17 |
18 | [profile.release]
19 | codegen-units = 1
20 | lto = true
21 | opt-level = 3
22 | panic = "abort"
23 | strip = true
24 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 | # Cova
28 |
29 | A Rust ecosystem for mathematical abstractions and computations, focusing on rigorous implementations of algebraic structures, topological spaces, and computational mathematics.
30 |
31 | ## Overview
32 |
33 | Cova provides a collection of crates that implement various mathematical structures and algorithms with a focus on type safety, correctness, and composability. The project aims to provide foundational mathematical tools that can be used in scientific computing, computational topology, abstract algebra, and other domains requiring robust mathematical implementations.
34 |
35 | ## Examples & Demos
36 |
37 | Cova includes interactive demos to help you get started:
38 |
39 | ### 🌐 Interactive Web Demos
40 |
41 | - **[Vietoris-Rips Complex Demo](examples/vietoris_web/README.md)**: An interactive WebAssembly demo showcasing real-time topological data analysis. Click to place points and watch simplicial complexes emerge as you adjust the distance threshold.
42 |
43 | ## Design Philosophy
44 |
45 | - **Type Safety**: Mathematical properties are encoded in the type system where possible
46 | - **Correctness**: Implementations prioritize mathematical correctness over performance
47 | - **Composability**: Structures are designed to work together seamlessly
48 | - **Documentation**: Extensive mathematical documentation and examples
49 |
50 | ## Crates
51 |
52 | ### `cova`
53 |
54 | The `cova` crate is a meta crate that re-exports the `cova-space` and `cova-algebra` crates.
55 |
56 |
57 | ### `cova-space`
58 |
59 | The `cova-space` crate implements topological spaces, simplicial complexes, and graph structures, providing a foundation for computational topology and geometry. It includes:
60 |
61 | - **Topological Spaces**: Sets, metric spaces, normed spaces, and inner product spaces
62 | - **Simplicial Complexes**: Simplex representation, chain complexes, and homology computations
63 | - **Graph Theory**: Flexible directed and undirected graph data structures
64 | - **Sheaf Theory**: Advanced categorical constructions for topology
65 | - **Filtrations**: Tools for persistent homology and topological data analysis
66 |
67 | ### `cova-algebra`
68 |
69 | The `cova-algebra` crate provides implementations of algebraic structures with proper type constraints and mathematical rigor. It includes:
70 |
71 | - **Modular Arithmetic**: Custom modular number types with the `modular!` macro
72 | - **Abstract Algebra**: Groups, rings, fields, modules, and vector spaces
73 | - **Category Theory**: Fundamental categorical constructions and morphisms
74 | - **Tensors**: Tensor algebra and operations
75 | - **Linear Algebra**: Vector spaces and linear transformations
76 |
77 | ## Getting Started
78 |
79 | ### Prerequisites
80 |
81 | Cova requires Rust 1.70 or later.
82 |
83 | ### Installation
84 |
85 | Add the desired crates to your `Cargo.toml`:
86 |
87 | ```toml
88 | [dependencies]
89 | cova = "*"
90 | # or if you only need one of the crates
91 | cova-space = "*"
92 | cova-algebra = "*"
93 | ```
94 |
95 | ### Development Setup
96 |
97 | 1. Clone the repository:
98 | ```bash
99 | git clone https://github.com/harnesslabs/cova.git
100 | cd cova
101 | ```
102 |
103 | 2. Install `just` (if not already installed):
104 | ```bash
105 | # macOS
106 | brew install just
107 |
108 | # Linux
109 | curl --proto '=https' --tlsv1.2 -sSf https://just.systems/install.sh | bash -s -- --to /usr/local/bin
110 | ```
111 |
112 | 3. Run the development setup:
113 | ```bash
114 | just setup
115 | ```
116 |
117 | 4. Build and test:
118 | ```bash
119 | just test
120 | ```
121 |
122 | ### Viewing Documentation
123 |
124 | The project provides two types of documentation:
125 |
126 | 1. **API Documentation**: View the Rust API documentation for all crates:
127 | ```bash
128 | just docs
129 | ```
130 | This will build and open the Rust API documentation in your browser.
131 |
132 | 2. **Book Documentation**: View the comprehensive book documentation:
133 | ```bash
134 | just book
135 | ```
136 | This will serve the book documentation locally and open it in your browser. The book includes detailed explanations of mathematical concepts, examples, and usage guides.
137 |
138 | For more development commands, run `just --list`.
139 |
140 | ## Documentation
141 |
142 | - [API Documentation - cova](https://docs.rs/cova)
143 | - [API Documentation - cova-space](https://docs.rs/cova-space)
144 | - [API Documentation - cova-algebra](https://docs.rs/cova-algebra)
145 | - [Book](https://book.harnesslabs.xyz)
146 |
147 | ## Contributing
148 |
149 | We welcome contributions! Please check our [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines on how to contribute to the project.
150 |
151 | ## License
152 |
153 | This project is licensed under the [AGPLv3 License](LICENSE).
154 |
155 |
--------------------------------------------------------------------------------
/SUMMARY.md:
--------------------------------------------------------------------------------
1 | - [Introduction](README.md)
2 | - [Algebra](cova-algebra/README.md)
3 | - [Space](cova-space/README.md)
4 | - [Examples](examples/README.md)
5 | - [Vietoris-Rips Complex Demo](examples/vietoris_web/README.md)
6 | - [Contributing](CONTRIBUTING.md)
--------------------------------------------------------------------------------
/book.toml:
--------------------------------------------------------------------------------
1 | [book]
2 | authors = ["Harness Lab"]
3 | description = "Cova: A Rust ecosystem for mathematical abstractions and computations, focusing on extensible implementations of mathematical structures and algorithms."
4 | language = "en"
5 | multilingual = false
6 | src = "."
7 | title = "Cova: Abstract Mathematics made Computational"
8 |
9 | [build]
10 | build-dir = "docs"
11 | create-missing = true
12 | use-default-preprocessors = false
13 |
14 | [preprocessor.links]
15 |
16 | [preprocessor.katex]
17 | after = ["links"]
18 |
19 | [output.linkcheck]
20 | follow-web-links = false # TODO (autoparallel): fix this
21 | traverse-parent-directories = true
22 | warning-policy = "ignore"
23 |
24 | # TODO (autoparallel): there's a bunch to fix with this
25 | # [preprocessor.keeper]
26 | # command ="mdbook-keeper"
27 |
28 | [output.html]
29 | default-theme = "dark"
30 | git-repository-url = "https://github.com/harnesslabs/cova"
31 | preferred-dark-theme = "ayu"
32 | site-url = "https://cova.harnesslabs.xyz"
33 |
34 | [output.html.playground]
35 | editable = true
36 | runnable = true
37 |
38 | [rust]
39 | edition = "2021"
40 |
--------------------------------------------------------------------------------
/cova-algebra/.cargo/config.toml:
--------------------------------------------------------------------------------
1 | [build]
2 | rustdocflags = ["--html-in-header", "./katex-header.html"]
3 |
--------------------------------------------------------------------------------
/cova-algebra/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Changelog
2 | All notable changes to this project will be documented in this file.
3 |
4 | The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5 | and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6 |
7 | ## [Unreleased]
8 |
9 | ## [0.1.2](https://github.com/harnesslabs/cova/compare/cova-algebra-v0.1.1...cova-algebra-v0.1.2) - 2025-05-24
10 |
11 | ### Fixed
12 | - book issues ([#72](https://github.com/harnesslabs/cova/pull/72))
13 |
14 | ### Other
15 | - update README with cova-banner ([#71](https://github.com/harnesslabs/cova/pull/71))
16 |
17 | ## [0.1.1](https://github.com/harnesslabs/cova/compare/cova-algebra-v0.1.0...cova-algebra-v0.1.1) - 2025-05-23
18 |
19 | ### Other
20 | - re-name, re-release, etc. ([#69](https://github.com/harnesslabs/cova/pull/69))
21 |
--------------------------------------------------------------------------------
/cova-algebra/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "cova-algebra"
3 |
4 | authors = ["Harness Labs"]
5 | description = "Cova's algebraic library"
6 | edition = "2021"
7 | keywords = ["mathematics", "algebra"]
8 | license = "AGPL-3.0"
9 | readme = "README.md"
10 | repository = "https://github.com/harnesslabs/cova"
11 | version = "0.1.2"
12 |
13 | [dependencies]
14 | num-traits = { workspace = true }
15 |
--------------------------------------------------------------------------------
/cova-algebra/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | # Cova Algebra
6 |
7 | A comprehensive Rust library for abstract algebra, providing rigorous implementations of algebraic structures from basic arithmetic to advanced category theory and tensor calculus.
8 |
9 | [](https://crates.io/crates/cova-algebra)
10 | [](https://docs.rs/cova-algebra)
11 | [](https://www.gnu.org/licenses/agpl-3.0)
12 |
13 | ## Overview
14 |
15 | Cova Algebra implements the fundamental structures of abstract algebra with a focus on mathematical correctness, type safety, and composability. The crate provides a hierarchical organization of algebraic concepts, from basic arithmetic operations to advanced constructions in algebra and category theory.
16 |
17 | ## Architecture
18 |
19 | The library is structured around core mathematical concepts, with each module building upon more fundamental structures:
20 |
21 | ### Core Modules
22 |
23 | #### [`arithmetic`](src/arithmetic/mod.rs)
24 | Foundation layer providing basic arithmetic operations and modular arithmetic. Includes the `modular!` macro for creating custom modular number types and fundamental arithmetic traits that serve as building blocks for higher-level structures.
25 |
26 | #### [`groups`](src/groups.rs)
27 | Group theory implementations covering both commutative (Abelian) and non-commutative groups. Provides the fundamental structure for understanding symmetry and transformation in algebra, with proper distinctions between additive and multiplicative group operations.
28 |
29 | #### [`rings`](src/rings.rs)
30 | Ring theory abstractions including rings, fields, and semirings. Establishes the algebraic foundation for structures that support both addition and multiplication, with fields providing division operations for advanced algebraic computations.
31 |
32 | #### [`modules`](src/modules/mod.rs)
33 | Module theory over rings, including vector spaces, semimodules, and specialized constructions like tropical modules. Provides the framework for linear algebra and generalizes vector spaces to work over arbitrary rings.
34 |
35 | ### Advanced Modules
36 |
37 | #### [`algebras`](src/algebras/mod.rs)
38 | Higher-order algebraic structures that combine vector spaces with multiplication operations. Includes Boolean algebra for logical operations and Clifford algebras for geometric applications in physics and computer graphics.
39 |
40 | #### [`tensors`](src/tensors/mod.rs)
41 | Multi-dimensional tensor implementations with both compile-time fixed dimensions and runtime dynamic sizing. Supports tensor operations fundamental to linear algebra, differential geometry, and machine learning applications.
42 |
43 | #### [`category`](src/category.rs)
44 | Category theory primitives providing abstract mathematical frameworks for composition and morphisms. Enables advanced mathematical constructions and provides a unifying language for describing mathematical structures and their relationships.
45 |
46 | ## Design Principles
47 |
48 | - **Mathematical Rigor**: All implementations follow strict mathematical definitions and maintain algebraic properties
49 | - **Type Safety**: Leverages Rust's type system to encode mathematical constraints and prevent invalid operations
50 | - **Composability**: Structures are designed to work together seamlessly, allowing complex mathematical constructions
51 | - **Performance**: Balances mathematical correctness with computational efficiency through careful API design
52 |
53 | ## Usage
54 |
55 | Add to your `Cargo.toml`:
56 |
57 | ```toml
58 | [dependencies]
59 | cova-algebra = "*"
60 | ```
61 |
62 | The crate provides a comprehensive prelude for convenient importing:
63 |
64 | ```rust
65 | use cova_algebra::prelude::*;
66 | ```
67 |
68 | ## Module Hierarchy
69 |
70 | The algebraic structures follow a natural mathematical hierarchy:
71 |
72 | ```
73 | Arithmetic Operations
74 | ├── Groups (symmetry and transformation)
75 | ├── Rings & Fields (number systems)
76 | └── Modules & Vector Spaces (linear structures)
77 | ├── Algebras (vector spaces with multiplication)
78 | ├── Tensors (multi-dimensional arrays)
79 | ```
80 |
81 | ## Documentation
82 |
83 | Complete API documentation is available on [docs.rs](https://docs.rs/cova-algebra).
84 |
85 | ## Contributing
86 |
87 | Contributions are welcome! Please ensure mathematical correctness and include appropriate documentation for any new algebraic structures.
88 |
89 | ## License
90 |
91 | This project is licensed under the AGPLv3 License - see the [LICENSE](../LICENSE) file for details.
92 |
93 |
--------------------------------------------------------------------------------
/cova-algebra/katex-header.html:
--------------------------------------------------------------------------------
1 |
3 |
6 |
9 |
--------------------------------------------------------------------------------
/cova-algebra/src/algebras/boolean.rs:
--------------------------------------------------------------------------------
1 | //! # Boolean Algebra Module
2 | //!
3 | //! This module provides an implementation of the Boolean field GF(2) through a wrapper
4 | //! around Rust's `bool` type.
5 | //!
6 | //! ## Mathematical Structure
7 | //!
8 | //! The Boolean field consists of two elements:
9 | //! - `false` (0): The additive identity
10 | //! - `true` (1): The multiplicative identity
11 | //!
12 | //! Operations are defined as:
13 | //! - Addition: Exclusive OR (XOR) operation
14 | //! - Multiplication: Logical AND operation
15 | //! - Negation: Identity operation (x = -x in GF(2))
16 | //! - Multiplicative inverse: Identity for non-zero elements
17 | //!
18 | //! ## Algebraic Properties
19 | //!
20 | //! The implementation satisfies multiple algebraic structures:
21 | //! - Field: A complete algebraic field with addition and multiplication
22 | //! - Abelian Group: Under addition with identity element `false`
23 | //! - Vector Space: Over itself as the scalar field
24 | //!
25 | //! ## Applications
26 | //!
27 | //! Boolean algebra has numerous applications in:
28 | //! - Digital circuit design
29 | //! - Logic operations
30 | //! - Cryptography (especially in finite field arithmetic)
31 | //! - Error correction codes
32 | //!
33 | //! ## Example
34 | //!
35 | //! ```
36 | //! use cova_algebra::algebras::boolean::Boolean;
37 | //!
38 | //! // Create Boolean values
39 | //! let a = Boolean(true); // 1
40 | //! let b = Boolean(false); // 0
41 | //!
42 | //! // Addition (XOR)
43 | //! assert_eq!(a + a, Boolean(false)); // 1 + 1 = 0
44 | //! assert_eq!(a + b, Boolean(true)); // 1 + 0 = 1
45 | //!
46 | //! // Multiplication (AND)
47 | //! assert_eq!(a * b, Boolean(false)); // 1 * 0 = 0
48 | //! assert_eq!(a * a, Boolean(true)); // 1 * 1 = 1
49 | //! ```
50 |
51 | use super::*;
52 |
53 | /// A wrapper around `bool` that implements algebraic operations.
54 | ///
55 | /// This type implements both [`Additive`] and [`Multiplicative`] traits using
56 | /// bitwise operations:
57 | /// - Addition is implemented as XOR (`^`)
58 | /// - Multiplication is implemented as AND (`&`)
59 | ///
60 | /// This makes `Boolean` a field with two elements, where:
61 | /// - `false` is the additive identity (0)
62 | /// - `true` is the multiplicative identity (1)
63 | ///
64 | /// # Examples
65 | ///
66 | /// ```
67 | /// use cova_algebra::algebras::boolean::Boolean;
68 | ///
69 | /// let a = Boolean(true);
70 | /// let b = Boolean(false);
71 | ///
72 | /// // Addition (XOR)
73 | /// assert_eq!(a + b, Boolean(true));
74 | /// assert_eq!(a + a, Boolean(false)); // a + a = 0
75 | ///
76 | /// // Multiplication (AND)
77 | /// assert_eq!(a * b, Boolean(false));
78 | /// assert_eq!(a * a, Boolean(true)); // a * a = a
79 | /// ```
80 | #[derive(Copy, Clone, Debug, PartialEq, Eq)]
81 | pub struct Boolean(pub bool);
82 |
83 | impl From for Boolean {
84 | fn from(b: bool) -> Self { Self(b) }
85 | }
86 |
87 | impl From for bool {
88 | fn from(b: Boolean) -> Self { b.0 }
89 | }
90 |
91 | impl One for Boolean {
92 | fn one() -> Self { Self(true) }
93 | }
94 |
95 | impl Zero for Boolean {
96 | fn zero() -> Self { Self(false) }
97 |
98 | fn is_zero(&self) -> bool { !self.0 }
99 | }
100 |
101 | impl Add for Boolean {
102 | type Output = Self;
103 |
104 | /// Implements addition as XOR operation.
105 | ///
106 | /// This corresponds to the addition operation in the field GF(2).
107 | #[allow(clippy::suspicious_arithmetic_impl)]
108 | fn add(self, rhs: Self) -> Self::Output { Self(self.0 ^ rhs.0) }
109 | }
110 |
111 | impl Sub for Boolean {
112 | type Output = Self;
113 |
114 | #[allow(clippy::suspicious_arithmetic_impl)]
115 | fn sub(self, rhs: Self) -> Self::Output { self + rhs }
116 | }
117 |
118 | impl Neg for Boolean {
119 | type Output = Self;
120 |
121 | fn neg(self) -> Self::Output { self }
122 | }
123 |
124 | impl SubAssign for Boolean {
125 | /// Implements subtraction assignment as XOR operation.
126 | #[allow(clippy::suspicious_op_assign_impl)]
127 | fn sub_assign(&mut self, rhs: Self) { self.0 ^= rhs.0; }
128 | }
129 |
130 | impl AddAssign for Boolean {
131 | /// Implements addition assignment as XOR operation.
132 | #[allow(clippy::suspicious_op_assign_impl)]
133 | fn add_assign(&mut self, rhs: Self) { self.0 ^= rhs.0; }
134 | }
135 |
136 | impl Mul for Boolean {
137 | type Output = Self;
138 |
139 | /// Implements multiplication as AND operation.
140 | ///
141 | /// This corresponds to the multiplication operation in the field GF(2).
142 | fn mul(self, rhs: Self) -> Self::Output { Self(self.0 && rhs.0) }
143 | }
144 |
145 | impl MulAssign for Boolean {
146 | /// Implements multiplication assignment as AND operation.
147 | #[allow(clippy::suspicious_op_assign_impl)]
148 | fn mul_assign(&mut self, rhs: Self) { self.0 &= rhs.0; }
149 | }
150 |
151 | impl Div for Boolean {
152 | type Output = Self;
153 |
154 | #[allow(clippy::suspicious_arithmetic_impl)]
155 | fn div(self, rhs: Self) -> Self::Output { self * rhs }
156 | }
157 |
158 | impl DivAssign for Boolean {
159 | /// Implements division assignment as AND operation.
160 | #[allow(clippy::suspicious_op_assign_impl)]
161 | fn div_assign(&mut self, rhs: Self) { self.0 &= rhs.0; }
162 | }
163 |
164 | impl Additive for Boolean {}
165 | impl Multiplicative for Boolean {}
166 |
167 | impl groups::Group for Boolean {
168 | fn identity() -> Self { Self(false) }
169 |
170 | fn inverse(&self) -> Self { Self(!self.0) }
171 | }
172 |
173 | impl groups::AbelianGroup for Boolean {}
174 |
175 | impl rings::Ring for Boolean {}
176 |
177 | impl rings::Field for Boolean {
178 | fn multiplicative_inverse(&self) -> Self { *self }
179 | }
180 |
181 | impl modules::LeftModule for Boolean {
182 | type Ring = Self;
183 | }
184 |
185 | impl modules::RightModule for Boolean {
186 | type Ring = Self;
187 | }
188 |
189 | impl modules::TwoSidedModule for Boolean {
190 | type Ring = Self;
191 | }
192 |
193 | impl modules::VectorSpace for Boolean {}
194 |
--------------------------------------------------------------------------------
/cova-algebra/src/algebras/mod.rs:
--------------------------------------------------------------------------------
1 | //! Implementation of an [`Algebra`] interface and various algebras
2 | //!
3 | //! This module provides implementations of different types of algebras, which are algebraic
4 | //! structures that combine the properties of vector spaces with multiplication operations. An
5 | //! algebra is a vector space equipped with a bilinear product that satisfies certain properties.
6 | //!
7 | //!
8 | //! # Key Concepts
9 | //!
10 | //! - **Algebra**: A vector space equipped with a bilinear product that is compatible with the
11 | //! vector space operations. The product must satisfy the distributive laws with respect to
12 | //! addition and scalar multiplication.
13 | //!
14 | //! - **Clifford Algebra**: A type of algebra that generalizes the real numbers, complex numbers,
15 | //! and quaternions. It is particularly useful in geometry and physics for representing rotations,
16 | //! reflections, and other transformations.
17 | //!
18 | //! # Implementations
19 | //!
20 | //! Currently, this module provides:
21 | //!
22 | //! - [`clifford`]: Implementation of Clifford algebras, which are useful for geometric computations
23 | //! and transformations in n-dimensional spaces.
24 | //! - [`boolean`]: Implementation of Boolean algebra, which is useful for logical operations and
25 | //! boolean logic.
26 |
27 | use super::*;
28 | use crate::{
29 | arithmetic::Multiplicative,
30 | modules::{TwoSidedModule, VectorSpace},
31 | rings::Field,
32 | };
33 |
34 | pub mod boolean;
35 | pub mod clifford;
36 |
37 | /// Trait defining the requirements for an algebra.
38 | ///
39 | /// An algebra is a vector space equipped with a bilinear product that satisfies:
40 | /// - Distributivity: a(b + c) = ab + ac and (a + b)c = ac + bc
41 | /// - Compatibility with scalar multiplication: (ka)b = k(ab) = a(kb)
42 | ///
43 | /// This trait combines the properties of a vector space with those of a multiplicative structure,
44 | /// ensuring that the algebra's operations are compatible with both the vector space and ring
45 | /// operations.
46 | pub trait Algebra: VectorSpace + Multiplicative
47 | where ::Ring: Field {
48 | }
49 |
--------------------------------------------------------------------------------
/cova-algebra/src/arithmetic/mod.rs:
--------------------------------------------------------------------------------
1 | //! Basic arithmetic traits and operations.
2 | //!
3 | //! This module provides fundamental arithmetic traits that are used throughout the algebra crate.
4 | //! It re-exports standard arithmetic operations from [`std::ops`] and numeric traits from
5 | //! [`num_traits`].
6 | //!
7 | //! # Examples
8 | //!
9 | //! ```
10 | //! use cova_algebra::arithmetic::{Additive, Multiplicative};
11 | //!
12 | //! // Types implementing Additive can be added and assigned
13 | //! fn add(a: T, b: T) -> T { a + b }
14 | //!
15 | //! // Types implementing Multiplicative can be multiplied and assigned
16 | //! fn multiply(a: T, b: T) -> T { a * b }
17 | //! ```
18 |
19 | use super::*;
20 |
21 | pub mod modular;
22 | pub mod primitive;
23 |
24 | /// A trait for types that support addition (and comparison) operations.
25 | ///
26 | /// This trait combines the basic requirements for types that can be added together:
27 | /// - Addition operation with [`Add`] trait
28 | /// - Addition assignment with [`AddAssign`] trait
29 | /// - Equality comparison with [`PartialEq`]
30 | ///
31 | /// # Examples
32 | /// - All primitive numeric types implement this trait
33 | /// - [`Boolean`](crate::algebras::boolean::Boolean) type implements this trait using bitwise
34 | /// [`std::ops::BitXor`]
35 | /// - Using the [`modular!`] macro, you can define a modular arithmetic type and it will implement
36 | /// this trait.
37 | /// - Using the [`prime_field!`] macro, you can define a prime field type and it will implement this
38 | /// trait.
39 | pub trait Additive: Add