This document is a quick operational guide for contributors and coding agents working in this repository.
- Name:
MathSymK - Type: Kotlin/JVM library for symbolic math and algebraic structures
- Build system: Gradle Kotlin DSL (single module)
- Group/Version:
io.github.ezrnest/0.0.2 - Java toolchain: 25
- Kotlin plugin: 2.3.10
- Gradle wrapper: 9.1.0
Primary source roots:
src/main/kotlinsrc/test/kotlinsrc/samples/kotlin
Top-level package: io.github.ezrnest.mathsymk
Major domains:
structure: abstract algebra interfaces and laws (Group,Ring,Field, etc.)model: concrete math models (Fraction,Complex,Polynomial,Multinomial, etc.)linear: linear algebra and tensors (Vector,Matrix,Tensor)symbolic: symbolic expression system, rewrite/match/transform rulesnumTh: number theory utilitiesdiscrete: combinatorics and permutationsgeometry: plane/space primitivesfunction,util: shared utilities and helpers
Tests are under src/test/kotlin and currently cover:
- model layer: fractions/complex/polynomial/multinomial/quaternion
- linear layer: matrix/vector/tensor
- discrete and number theory utilities
Samples are under src/samples/kotlin.
A dedicated samples source set is configured and depends on main output.
Use wrapper commands from repository root.
- Run all tests:
sh gradlew test
- Build jars:
sh gradlew build
- Clean + test:
sh gradlew clean test
Notes:
gradlewmay not have execute bit in some environments;sh gradlew ...is safe.tasks.testuses JUnit Platform.
Current configured repositories:
mavenCentral()- Aliyun public mirror
jitpack.io
Publishing-related config exists for Maven Central (OSSRH), but signing/publication credentials are placeholders in gradle.properties.
Do not commit real secrets.
- Build is currently configured for Java toolchain 25.
- Gradle/Kotlin have been upgraded in build scripts (Kotlin 2.3.10, Gradle 9.1.0).
- If future dependency upgrades are done, re-run full tests before release.
- Read
build.gradle.ktsand affected package(s) before editing. - Prefer minimal, localized changes; preserve API behavior unless task requires breaking change.
- Run
sh gradlew testafter code changes. - For API-facing changes, update README/sample snippets if impacted.
- Avoid touching signing/publishing secrets and local proxy config unless explicitly requested.
symbolicrewrite/matching logic: behavior-sensitive and easy to introduce subtle regressions.lineartensor indexing/slicing/einsum operations: edge cases and shape compatibility.- Generic algebraic abstractions in
structure/model: type constraints and operator overload consistency.
When modifying these areas, add or adjust tests in the corresponding package.
Symbolic-related tests now include:
src/test/kotlin/symbolic/NodeTest.kt- Node symbol mapping behavior (
Node1/Node2/Node3.mapSymbol).
- Node symbol mapping behavior (
src/test/kotlin/symbolic/MatcherTest.kt- Reference binding consistency for repeated matcher refs.
src/test/kotlin/symbolic/RuleSetDSLTest.kt- DSL validation for unbound references in rule results.
- No-op rule (
x -> x) should not be registered.
src/test/kotlin/symbolic/TreeDispatcherTest.kt- Wildcard/fixed/branch dispatch basics and early-stop behavior.
src/test/kotlin/symbolic/AlgReduceTest.kt- Core algebraic reduction smoke tests for
ComputePow, trig special angles, and product merge.
- Core algebraic reduction smoke tests for
symbolic/Node.kt:mapSymbolcorrectness is critical (node symbol + child symbol mapping).symbolic/SimRuleDSL.kt: rule target/result reference consistency must be enforced.symbolic/TreeDispatcher.kt: dispatch semantics differ by matcher category (wildcard/fixed/branch).
When semantics are not finalized (example: 0^0), do not lock tests to current behavior.
- Prefer asserting stable identities only (e.g.,
0^positive -> 0). - Leave explicitly underspecified cases unconstrained, with a short comment in test code.
- If product/design decisions later define those semantics, add strict assertions then.
- Add/adjust focused symbolic tests first.
- Run targeted symbolic tests:
sh gradlew test --tests 'symbolic.*'
- Then run full suite:
sh gradlew test
- If a test reveals a real bug, prefer a minimal fix and keep regression coverage.