Conversation
…fting Co-authored-by: SkBlaz <10035780+SkBlaz@users.noreply.github.com>
Co-authored-by: SkBlaz <10035780+SkBlaz@users.noreply.github.com>
Co-authored-by: SkBlaz <10035780+SkBlaz@users.noreply.github.com>
Co-authored-by: SkBlaz <10035780+SkBlaz@users.noreply.github.com>
Co-authored-by: SkBlaz <10035780+SkBlaz@users.noreply.github.com>
Co-authored-by: SkBlaz <10035780+SkBlaz@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Implement semiring framework in py3plex
Implement semiring algebra layer for generic path computation and graph analysis
Jan 5, 2026
Owner
|
@copilot missing property tests |
- Add 21 property tests covering semiring laws, weight lifting, path algorithms, and closure - Test algebraic properties: additive identity, multiplicative identity, idempotence, commutativity, zero annihilator - Test weight lifting with various transforms and edge cases - Test path algorithm properties: determinism, correctness, max_hops - Test closure properties: reflexivity, transitivity, determinism - Test semiring registry properties - Test better() function properties: irreflexive, asymmetric - All tests use Hypothesis for property-based testing with 100+ examples per test Co-authored-by: SkBlaz <10035780+SkBlaz@users.noreply.github.com>
Contributor
Author
Added comprehensive property-based tests for semiring algebra in commit d4c0484. The new test file
All 21 tests pass with 100+ examples per test. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a comprehensive semiring framework enabling generic path algorithms (shortest paths, reachability, reliability, etc.) parameterized by algebraic operations. Integrates with DSL v2, multilayer networks, and layer algebra.
Core Implementation
New package:
py3plex/algebra/(8 modules, 800+ LOC)boolean(reachability),min_plus(shortest paths),max_times(reliability),max_plus(longest paths)log, custom functions)DSL v2 Integration
S builder namespace:
Features:
from_layers(L[...]))allowed,forbidden,penaltyProvenance & Determinism
All queries include comprehensive provenance metadata:
Stable ordering: Sorted layer names, sorted node IDs, deterministic tie-breaking via
semiring.better().AST Extensions
New nodes in
py3plex/dsl/ast.py:SemiringSpecNode- Semiring configurationWeightLiftSpecNode- Edge weight extractionSemiringPathStmt,SemiringClosureStmt- Query statementsCrossingLayersSpec- Multilayer edge handlingExecutor in
py3plex/dsl/executor_semiring.pyhandles S builder execution and provenance generation.Documentation
Updated AGENTS.md (+397 lines, section 28):
Example:
examples/network_analysis/example_semiring_algebra.pydemonstrates shortest paths, reachability, reliability, closure, and layer filtering.Testing
All core functionality passes. Minor QueryResult.to_pandas() limitations for custom targets noted but non-blocking.
Property-Based Testing
Added comprehensive property tests using Hypothesis (
tests/property/test_algebra_properties.py):Design Principles
Backward Compatibility
No breaking changes. P.shortest() can delegate to semiring engine internally (infrastructure ready). All existing DSL v2 tests unaffected.
Original prompt
This section details on the original issue you should resolve
<issue_title>semirings</issue_title>
<issue_description>You are implementing a comprehensive semiring/algebra layer in py3plex.
CRITICAL DOC RULES
SCOPE
Implement a semiring framework that integrates with:
NON-GOALS
================================================================================
A) IMPLEMENTATION PLAN (CODE)
A1) Create new algebra package (no docs files)
A2) Semiring core
TODO: Define Semiring interface (Protocol or ABC)
TODO: Implement built-in semirings with correct props
Add unit tests for identity laws and basic behavior.
A3) Semiring registry
TODO: Implement registry with safe overrides
Ensure deterministic ordering in list_semirings().
A4) Weight lifting
TODO: Implement WeightLiftSpec (serializable dataclass)
Fields:
Provide helpers:
A5) Multilayer integration assumptions
TODO: Define how an “edge” is represented for algebra engine:
Implement adapter functions in algebra layer that can iterate edges efficiently given:
Do NOT change core network representation unless necessary; prefer adapters.
A6) Generic semiring path engine (graph backend)
TODO: Implement core relax/DP engine in py3plex/algebra/paths.py
Features:
Algorithm selection based on semiring props:
Return:
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.