Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
9ca0323
WIP: Dissolution upstream P2 — std/collection.dag Wave-A2 List non_em…
briansrls May 18, 2026
d856703
Merge remote-tracking branch 'origin/main' into session/lively-otter-673
briansrls May 18, 2026
adfe71b
Merge remote-tracking branch 'origin/main' into session/lively-otter-673
briansrls May 18, 2026
f3ee559
Merge remote-tracking branch 'origin/main' into session/lively-otter-673
briansrls May 18, 2026
3521ae4
v4 std algebra: route FreeMonoid helpers through fold
briansrls May 18, 2026
ae05351
Merge remote-tracking branch 'origin/main' into session/lively-otter-673
briansrls May 18, 2026
3a688fd
Merge remote-tracking branch 'origin/main' into session/lively-otter-673
briansrls May 18, 2026
ad08330
Merge remote-tracking branch 'origin/main' into session/lively-otter-673
briansrls May 18, 2026
aa4af40
Merge remote-tracking branch 'origin/main' into session/lively-otter-673
briansrls May 18, 2026
8a7013e
Merge remote-tracking branch 'origin/main' into session/lively-otter-673
briansrls May 18, 2026
f09fbe5
Merge remote-tracking branch 'origin/main' into session/lively-otter-673
briansrls May 18, 2026
dbe22b1
Merge remote-tracking branch 'origin/main' into session/lively-otter-673
briansrls May 18, 2026
771ddad
v4 decisions: mark NonEmptyList enforcement yellow
briansrls May 18, 2026
c94aec6
Merge remote-tracking branch 'origin/main' into session/lively-otter-673
briansrls May 18, 2026
b0755fe
Merge remote-tracking branch 'origin/main' into session/lively-otter-673
briansrls May 18, 2026
2a9f16b
v4 collection: keep NonEmptyList scaffold documented
briansrls May 18, 2026
bd207b2
Merge remote-tracking branch 'origin/main' into session/lively-otter-673
briansrls May 18, 2026
8b9a06f
Merge remote-tracking branch 'origin/main' into session/lively-otter-673
briansrls May 18, 2026
9bde770
Merge remote-tracking branch 'origin/main' into session/lively-otter-673
briansrls May 18, 2026
2c7542a
WIP: Dissolution upstream P2 — std/collection.dag Wave-A2 List non_em…
briansrls May 18, 2026
f2a01bd
Merge origin/main into session/lively-otter-673
briansrls May 18, 2026
27a0f6a
v4 algebra: list unique state in owns header
briansrls May 18, 2026
aba61fd
WIP: Dissolution upstream P2 — std/collection.dag Wave-A2 List non_em…
briansrls May 18, 2026
1a74fa8
Merge origin/main into session/lively-otter-673
briansrls May 18, 2026
bbabc73
v4 algebra: align helpers with right fold
briansrls May 18, 2026
bd31f5a
WIP: Dissolution upstream P2 — std/collection.dag Wave-A2 List non_em…
briansrls May 18, 2026
4531a91
WIP: Dissolution upstream P2 — std/collection.dag Wave-A2 List non_em…
briansrls May 18, 2026
9ea897e
Merge remote-tracking branch 'origin/main' into session/lively-otter-673
briansrls May 18, 2026
7fae068
Merge remote-tracking branch 'origin/main' into session/lively-otter-673
briansrls May 18, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/v4/DECISIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ remain boundary indexes until the named substrate support lands.
| `std/cardinality.dag` | `Never`, `Unit` | Green opaque atoms | Canonical 0- and 1-inhabitance anchors in shared vocabulary: `Never` (empty), `Unit` (singleton). Rust `!` / `()` name **external** encodings of those facts, not identities proved in this row. **D2-REV:** per-language never/unit primitives (e.g. `NeverScalar`) remain **spec fact-bundles** in `extdeps/`; this ledger does **not** assert a bare alias into `std/`—deduplication to these carriers only on **structurally evidenced coincidence** authored elsewhere. Opaque atoms carry no fields; `std/` must not mint a parallel second empty/unit authority. |
| `std/cardinality.dag` | `NonZeroNat` | Green proof record | Structural strictly-positive natural: `prev: Nat` denotes `Succ { prev }` (same witness field name as `Nat`’s successor case) — excludes `Zero` by construction (no separate ordering predicate). Use for positive counts/widths (e.g. “at least one”) without kernel-ambient `Int` width payloads. |
| `std/cardinality.dag` | `UpperBoundedNat` | Yellow value-refinement scaffold | Both fields are honest Peano `Nat` spines; the substrate cannot yet express `value ≤ inclusive_max` structurally (total order / compare witness on `Nat` is not a `cardinality.dag` citizen yet). Bounded use: producers MUST validate the ordering relation before treating the pair as a bound witness (LLVM bit-width, non-negative dimension ceilings). Trigger: `Nat` ordering witness + structural proof, or merge with T-25-core constructor validation at the refinement boundary. |
| `std/collection.dag` | `NonEmptyList<T>` | Yellow refinement scaffold | `NonEmptyList<T> = List<T> where non_empty` is the canonical future shared shape over the `List<T> = FreeMonoid<T>` carrier, not a second head/tail inhabitant family. It is not exported from `std/collection.dag` yet because `src/v3/compiler/src/lower.rs` lowers registered `non_empty` predicates through the placeholder path rather than a Bool body tied to `free_monoid_non_empty`. Bounded use: consumers must not rely on this alias to reject empty lists yet. Trigger: bootstrap lowerer synthesizes/enforces `non_empty` for `List` carriers through the landed FreeMonoid predicate, then `std/collection.dag` may publish `NonEmptyList<T>` and downstream non-empty-list sites may rewrite to it. |
| `std/collection.dag` | `Set<T>` finite-cardinality refinement | Yellow refinement scaffold | Documented: bare `Set<T> = PointwisePower<T>` is an arbitrary subset/characteristic-function carrier and does not encode finiteness. Bounded use: consumers needing finite subsets must wait on the refinement, not infer finiteness from `Set<T>`. Trigger: cardinality/enumerability substrate (`Multiplicity` plus an enumerability `Witness`) lands and adds `FiniteSet<T>` or equivalent. |
| `std/diagnostic.dag` | `Extent.ByteRange` | Yellow value-refinement scaffold | Documented: `ByteRange { start: Int, end: Int }` is an honest bridge carrier because current substrate syntax cannot exclude negative offsets or `start > end`. Bounded use: producers must validate textual spans before constructing diagnostics that rely on byte-range validity. Trigger: bounded/non-negative ordered span carrier or equivalent substrate refinement. |
| `std/diagnostic.dag` | `Extent`, `Locus`, `NoCorrectionReason`, `Correction`, `Outcome<T>` | Green coproducts | `Extent` is terminal as whole-file vs byte-range, with the raw-offset gap isolated in the ByteRange yellow row. `Locus` is the closed set of diagnostic pointing sites. `NoCorrectionReason` is the exhaustive no-fix partition. `Correction` is the typed show-correct-code sum, not `Option<Node>`. `Outcome<T>` is the two-case produced vs fail-closed rejected carrier beside `Diagnostic`. |
Expand Down Expand Up @@ -1301,7 +1302,7 @@ Verbatim `//` lines from merge-base `verilog.dag` (lines **2156–2311**):
//
```

**Dissolution trigger:** `std/collection.dag` Wave-A2 `List<T> where non_empty` (merge-base enumeration of 26 sites).
**Dissolution trigger:** partially landed upstream as the canonical `std/collection.dag` Wave-A2 predicate substrate (`non_empty` backed by `free_monoid_non_empty`), but the `NonEmptyList<T> = List<T> where non_empty` alias is not exported and consumer rewrites remain blocked until `src/v3/compiler/src/lower.rs` synthesizes/enforces the registered `non_empty` predicate for `List` carriers through the landed FreeMonoid predicate. Until then, the merge-base `List<T>` sites stay producer-side invariants rather than API-enforced refinements.

### SL-3229-VERILOG-D3200 — #3200 consumer-independent 🟡 coproducts (first-consumer decomposition)

Expand Down
59 changes: 55 additions & 4 deletions src/v4/std/algebra.dag
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// src/v4/std/algebra.dag
// Scope: algebraic structures and canonical carrier constructions.
// Anchor: https://en.wikipedia.org/wiki/Algebraic_structure
// Owns: Magma, Semigroup, Monoid, CommutativeMonoid, Group, AbelianGroup, Semiring, CommutativeSemiring, Ring, CommutativeRing, OrderedRing, Field, ApproximateField, Lattice, BoundedLattice, BooleanAlgebra, FreeMonoid, free_monoid_fold, free_monoid_is_empty, free_monoid_length, PointwisePower, Ordering, Homomorphism.
// Owns: Magma, Semigroup, Monoid, CommutativeMonoid, Group, AbelianGroup, Semiring, CommutativeSemiring, Ring, CommutativeRing, OrderedRing, Field, ApproximateField, Lattice, BoundedLattice, BooleanAlgebra, FreeMonoid, FreeMonoidUniqueState, free_monoid_fold, free_monoid_is_empty, free_monoid_non_empty, free_monoid_length, free_monoid_forall, free_monoid_count_where, free_monoid_count_equal, free_monoid_unique, PointwisePower, Ordering, Homomorphism.
// Consumes: none.
// Status: T-2 modeled.
// Ledger: DECISIONS.md Part 6 — SL-P6-FREEMONOID-IS-EMPTY-VPRED.
Expand Down Expand Up @@ -74,10 +74,14 @@ type BooleanAlgebra<T> {
type FreeMonoid<T>
= Empty
| Cons { head: T, tail: FreeMonoid<T> }
fn free_monoid_fold<T, A>(xs: FreeMonoid<T>, empty: A, cons: fn(T, A) -> A) -> A {
type FreeMonoidUniqueState<T> {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BLOCKING: FreeMonoidUniqueState exposes fold-local uniqueness cache as std substrate, and unique can diverge from seen, violating INVARIANTS P2 illegal-states-unrepresentable and Practice 5 single authority.

seen: FreeMonoid<T>
unique: Bool
}
fn free_monoid_fold<T, A>(xs: FreeMonoid<T>, empty: A, cons: fn(A, T) -> A) -> A {
match xs {
Empty => empty
Cons { head: h, tail: t } => cons(h, free_monoid_fold(xs: t, empty: empty, cons: cons))
Cons { head: h, tail: t } => free_monoid_fold(xs: t, empty: cons(empty, h), cons: cons)
}
}
// 🟡 gated — predicate-dissolution interim (docs/modeling-discipline.md Practice 10) — feature: coproduct variant-discriminant predicate substrate — bind node://adhoc-2145db6b-69a — dissolve-on-arrival: substrate-derived Empty-variant discriminant projection; forbidden: free_monoid_fold laundering.
Expand All @@ -89,8 +93,55 @@ fn free_monoid_is_empty<T>(xs: FreeMonoid<T>) -> Bool {
}


fn free_monoid_non_empty<T>(xs: FreeMonoid<T>) -> Bool {

This comment was marked as resolved.

match free_monoid_is_empty(xs: xs) {
true => false
false => true
}
}


fn free_monoid_length<T>(xs: FreeMonoid<T>) -> Int {
free_monoid_fold(xs: xs, empty: 0, cons: fn(_, acc) { 1 + acc })
free_monoid_fold(xs: xs, empty: 0, cons: fn(count, _) { count + 1 })
}


fn free_monoid_forall<T>(xs: FreeMonoid<T>, predicate: fn(T) -> Bool) -> Bool {
free_monoid_fold(xs: xs, empty: true, cons: fn(acc, item) {
match acc {
true => predicate(item)
false => false
}
})
}


fn free_monoid_count_where<T>(xs: FreeMonoid<T>, predicate: fn(T) -> Bool) -> Int {
free_monoid_fold(xs: xs, empty: 0, cons: fn(count, item) {
match predicate(item) {
true => count + 1
false => count
}
})
}


fn free_monoid_count_equal<T>(xs: FreeMonoid<T>, item: T, eq: fn(T, T) -> Bool) -> Int {
free_monoid_count_where(xs: xs, predicate: fn(candidate) { eq(candidate, item) })
}


fn free_monoid_unique<T>(xs: FreeMonoid<T>, eq: fn(T, T) -> Bool) -> Bool {
let state = free_monoid_fold(xs: xs, empty: FreeMonoidUniqueState { seen: Empty, unique: true }, cons: fn(acc, item) {
match acc.unique {
true => match free_monoid_count_equal(xs: acc.seen, item: item, eq: eq) {
0 => FreeMonoidUniqueState { seen: Cons { head: item, tail: acc.seen }, unique: true }
_ => FreeMonoidUniqueState { seen: acc.seen, unique: false }
}
false => acc
}
})
state.unique
}
type PointwisePower<T> {
member: fn(T) -> Bool
Expand Down
7 changes: 5 additions & 2 deletions src/v4/std/collection.dag
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
// src/v4/std/collection.dag
// Scope: container carriers grounded in algebraic constructions.
// Anchor: https://en.wikipedia.org/wiki/Free_monoid
// Owns: List, Set, Map.
// Owns: List, non_empty, Set, Map.
// Consumes: std algebra, std witness.
// Status: T-3 modeled; substrate-extension rule in src/v4/STRUCTURE.md.


module v4.std.collection


import v4.std.algebra { FreeMonoid, PointwisePower }
import v4.std.algebra { FreeMonoid, PointwisePower, free_monoid_non_empty }
import v4.std.witness { Witness }
type List<T> = FreeMonoid<T>
fn non_empty<T>(xs: List<T>) -> Bool {
free_monoid_non_empty(xs: xs)
}
type Set<T> = PointwisePower<T>
type Map<K, V> {
lookup: fn(K) -> Witness<V>
Expand Down
Loading