Skip to content

Generalization-producing anti_unify (the produce core). Upgrade v2.lens.simulated_relationship's congruent (Bool) to RETURN the minimal form: the anti-unification generalization of a statement chain = a common template Node (with ^HOLE markers where steps differ) + the per-element substitution list. - #5599

Merged
briansrls merged 6 commits into
mainfrom
session/bright-otter-452
Jun 23, 2026

Conversation

@briansrls

@briansrls briansrls commented Jun 23, 2026 •

Copy link
Copy Markdown
Contributor

What

Upgrade v2.lens.simulated_relationship from a Bool congruence check into a derivation over the produced minimal form of a statement chain: the anti-unification (least-general) generalization = a common template Node carrying ^HOLE leaves where steps differ + the per-element substitution list.

The producer is a new domain-agnostic shared kernel, v2.std.anti_unification:

  • anti_unify(a, b) — full LGG over any two Nodes. Always succeeds: a structural divergence (leaf-vs-leaf differ, leaf-vs-internal, kind/arity/label mismatch) becomes a ^HOLE, never a failure.
  • extract_fillings(template, element) — the subtree each element placed at each hole, in template order.
  • anti_unify_chain(steps) — whole-chain template + per_element substitution list.
  • template_has_hole / fillings_all_leaves — consumer-side produced-form predicates.

The kernel is domain-agnostic over Node: a statement chain and a type-decl forest anti-unify by the same rules; only the binder (which Nodes are the peers to generalize) differs and lives at the caller. structural_similarity (type-decl layer) and the apply-half reuse this engine.

The lens is now thin: chain_is_simulated = length>=3 AND template_has_hole AND fillings_all_leaves.

Semantics change (not a silent shift)

chain_is_simulated is now whole-chain anti-unification (one template common to all steps) instead of the prior adjacent-pairwise congruence. Whole-chain is the stricter, more correct notion. All 6 prior witnesses stay green by derivation.

Load-bearing additions (flagged for review)

Both are additive, following existing patterns — no existing algebra/node semantics modified:

  1. src/v2/std/algebra.dag: two generic combinators zip_map (pairing sibling of zip_eq) and reduce_or (seed-from-first reduce). FreeMonoid variant match kept inside algebra per the cross-module generic-variant-pattern weakness.
  2. src/v2/std/anti_unification.dag: new module, sibling of exact_structural_equality_zip_fold_predicate.

Verification (by execution)

claim_batch --source-root src/v2 over the lens_unit witnesses:

  • 6 original boolean witnesses: green by derivation.
  • 5 new discriminating produced-form witnesses pin the exact template + substitution list (red on a wrong hole/kept-leaf/dropped-filling/mis-order — confirmed by a control flip that turned them red, then reverted).
  • Downstream intent_linearity lens (consumes chain_is_simulated): 6/6 green.

Design + placement signed off by the lens author (parent, #5584 author).

Brian Searls and others added 3 commits June 23, 2026 01:45
…ngs; derive simulated_relationship from it

Upgrade v2.lens.simulated_relationship from an adjacent-pairwise congruence Bool
to a derivation over the produced minimal form.

New shared kernel v2.std.anti_unification (domain-agnostic over Node; the type-decl
forest binder reuses it):
- anti_unify(a, b): full least-general generalization -> a template Node carrying
  ^HOLE leaves at every divergence (always succeeds; divergence becomes a hole).
- extract_fillings(template, element): the per-element substitution at each hole.
- anti_unify_chain(steps): whole-chain template + per-element substitution list.
- template_has_hole / fillings_all_leaves: consumer-side produced-form predicates.

Additive std (flagged for review): two new generic combinators in algebra.dag
(zip_map, reduce_or; FreeMonoid variant match kept inside algebra) and the new
anti_unification module (sibling of exact_structural_equality_zip_fold_predicate).
No existing algebra/node semantics modified.

Semantics: chain_is_simulated is now whole-chain LGG (one template common to ALL
steps) instead of adjacent-pairwise congruence -- stricter and more correct; all 6
prior witnesses stay green by derivation. Added 5 discriminating produced-form
witnesses (exact template + substitution list; falsified by a control flip).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@gunbai-bot
gunbai-bot Bot marked this pull request as ready for review June 23, 2026 01:52
Brian Searls and others added 3 commits June 23, 2026 01:59
…y/for_all

Parent §3 review: a linearity enforcer must not itself re-spell a combinator. Both
were hand-rolled folds -- chain_is_redundant is a disjunction-fold (= algebra.any),
body_is_linear a conjunction-fold (= algebra.for_all). Replace with the existing
single authorities (not reduce_or, which is a generic binary reduce, a different
shape). Behavior identical; intent_linearity 6/6 + simulated_relationship 11/11
green by execution.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Resolve conflicts in the two lens files by keeping the #5599 anti_unify refactor
(simulated_relationship now derives chain_is_simulated from the produced whole-chain
generalization; intent_linearity uses algebra any/for_all) over main's prior congruent
logic. Strip // comments from the 5 touched .dag files to satisfy the post-#5567
parser-wall (line comments are FailClosed on ingest); no in-string // present.
All 17 lens_unit witnesses (11 simulated_relationship + 6 intent_linearity) green by
execution on the merged tree.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@briansrls
briansrls merged commit b72107b into main Jun 23, 2026
2 checks passed
@briansrls
briansrls deleted the session/bright-otter-452 branch June 23, 2026 03:12
briansrls added a commit that referenced this pull request Jun 23, 2026
…td.anti_unification kernel

#5599 extracted anti-unification into v2.std.anti_unification (anti_unify_chain ->
ChainGeneralization, fillings_all_leaves, template_has_hole) and removed
simulated_relationship's congruent. Rebuild the type-decl binder on the shared kernel:
a forest collapses to one generic iff fillings_all_leaves (all variance at leaf positions
that become type parameters). Unlike the term binder, template_has_hole is NOT required, so
byte-identical decls (the hole-free section-3 nickname) are still flagged. Reconcile
intent_linearity with main's any/for_all refactor while keeping the Representation-tagged
two-binder registry.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
briansrls added a commit that referenced this pull request Jun 23, 2026
…as a row (one engine, two binders) (#5594)

* WIP: Consolidate structural_similarity into the intent_linearity registry as

* intent_linearity: make the binder first-class (Representation) so the type-decl row stays off term-chain projections

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* Integrate main (#5579 .dag comment-wall): strip // comments from the consolidation files, fold key prose into construction_justification carriers

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* Integrate main (#5599): rebuild structural_similarity on the new v2.std.anti_unification kernel

#5599 extracted anti-unification into v2.std.anti_unification (anti_unify_chain ->
ChainGeneralization, fillings_all_leaves, template_has_hole) and removed
simulated_relationship's congruent. Rebuild the type-decl binder on the shared kernel:
a forest collapses to one generic iff fillings_all_leaves (all variance at leaf positions
that become type parameters). Unlike the term binder, template_has_hole is NOT required, so
byte-identical decls (the hole-free section-3 nickname) are still flagged. Reconcile
intent_linearity with main's any/for_all refactor while keeping the Representation-tagged
two-binder registry.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* WIP: Consolidate structural_similarity into the intent_linearity registry as

---------

Co-authored-by: Brian Searls <briansrls@gunb.ai>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant