feat(hydro_lang): capture fold commutativity/idempotency in IR nodes#2925
feat(hydro_lang): capture fold commutativity/idempotency in IR nodes#2925jhellerstein wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR enhances hydro_lang’s IR so downstream compiler/analysis passes can directly determine whether a fold/fold_keyed accumulator was proven commutative and/or idempotent, without re-deriving those facts from types/proof annotations.
Changes:
- Add an
IsProvedtrait (withconst IS_PROVED: bool) for proof marker types (ProvedvsNotProved). - Extend
HydroNode::FoldandHydroNode::FoldKeyedwithis_commutative/is_idempotentboolean fields. - Capture and store proof status at fold construction sites in
Stream::foldandKeyedStream::fold.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| hydro_lang/src/properties/mod.rs | Introduces IsProved to reflect proof-marker status as a compile-time boolean. |
| hydro_lang/src/live_collections/stream/mod.rs | Records commutativity/idempotence proof status onto HydroNode::Fold at construction. |
| hydro_lang/src/live_collections/keyed_stream/mod.rs | Records commutativity/idempotence proof status onto HydroNode::FoldKeyed at construction. |
| hydro_lang/src/compile/ir/mod.rs | Adds is_commutative/is_idempotent fields to Fold IR nodes and preserves them through deep_clone. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
f26d93a to
feaf0f8
Compare
Deploying hydro with
|
| Latest commit: |
fb5d5ae
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://7e9258cb.hydroflow.pages.dev |
| Branch Preview URL: | https://feat-is-proved-fold-properti.hydroflow.pages.dev |
1d58e7b to
cc07401
Compare
cc07401 to
71bbf8b
Compare
Add IsProved trait to query proof status at compile time. Fold and FoldKeyed IR nodes now carry is_commutative and is_idempotent fields, set from the type-level proof markers (Proved vs NotProved) at construction time. This enables downstream analyses (coordination criterion, consistency checking) to distinguish lattice folds (c+i, monotone under lattice order) from overwrite folds (non-commutative, order-sensitive).
2dd09ab to
fb5d5ae
Compare
|
Hmm, so @Benjscho recently changed the IR generation so that for commutative (and maybe idempotent, I don't remember?) folds we no longer generate an The broader principle is that there are never unproven properties in the IR, either it's proven (perhaps weakly through |
|
@shadaj the nomenclature is certainly not helpful. All it's supposed to be doing is memoizing that the node was found to be commutative and/or idempotent. But your point I think is this:
Am I getting that right? |
|
Yes exactly! We try to avoid memoization directly within the IR if possible because it's easy to accidentally have rewrites that leave the IR inconsistent. |
Adds
IsProvedtrait to the properties module and records algebraic properties directly on fold/reduce IR nodes, enabling downstream analysis passes to distinguish lattice operations from non-commutative/non-idempotent ones without re-deriving properties from types.Changes:
properties/mod.rs:IsProvedtrait with constIS_PROVED: boolcompile/ir/mod.rs:is_commutative/is_idempotentfields onFold,FoldKeyed,Reduce,ReduceKeyed,ReduceKeyedWatermarkstream/mod.rs,keyed_stream/mod.rs:IsProvedbounds on fold/reduce, capture proof status at constructionviz/render.rs: pattern matches updated with..hydro_testand compile-fail stderrCherry-picked from the
coord-criterionbranch.