Skip to content

Convex algebra - #192

Open
adamv-symbolica wants to merge 14 commits into
Adam-Vandervorst:masterfrom
adamv-symbolica:codex/convex-algebra
Open

adamv-symbolica wants to merge 14 commits into
Adam-Vandervorst:masterfrom
adamv-symbolica:codex/convex-algebra

Conversation

@adamv-symbolica

Copy link
Copy Markdown
Contributor

When internal values are used, we may not want them to become external after a meet or subtract.
On master, such an invariant can not be upheld, or requires an expensive additional pass.
This PR introduces convex variants of meet and subtract, that trim internal paths that'd become hull paths.
Along with that, this PR adds all the supporting ops and laws:

  • "retain" is added, which together with "restrict" are the two coordinate projections of {(a,f) ∈ A×F | a ≼ f}
  • "hull" and "basis" are the "prefix-pruned" and "postfix-trimmed" versions of a space, and fix the meaning of convex meet and subtract as A ∩ B retain Hull(A) ∩ Hull(B) and A retain Hull(A) \ B
  • "divergences" and its closure "longest common path" (lcp) are added, where lcp can be lifted {lcp(a, b) a∈A b∈B} and L(A, B) = D(A, B) ∪ (A retain B) ∪ (B retain A) and D(A, B) = L(Hull(A), Hull(B)) \ (Hull(A) ∪ Hull(A)) hold
  • "hull and "basis" classify restrict and retain as ∀X. X restrict A = X restrict B iff Basis(A) = Basis(B) and ∀X. X retain A = X retain B iff Hull(A) = Hull(B)
  • "lcp" fixes the meaning of retain as A ∩ (A lcp B)

@imlvts imlvts left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

It's quite hard to review all code here, so I would ask for two things:

  1. separate Lean code related to convex stuff into a separate directory. this PR adds more files to the existing namespace than there are currently. as an example PrunedModel is in a separate directory.
  2. document where the definitions lay (def hull, def interior), something that we might inspect. the thing which a human might specify/inspect, from which the theorems/proofs can build.

Define prefix extrema and divergences on valued paths, with recursive
formulations and adapters to maps and zipper focuses. Prove their algebraic,
geometric, cardinality, and update laws; check finite counterexamples to
stronger claims.
Traverse valued paths with explicit stacks and restore all zipper focuses.
Termination does not count as a branch, and dangling structure supplies no
valued witness. Preserve source payloads for basis and hull.

Exercise the Lean law catalogue as Rust expressions and compare with an
independent path-set oracle, including movement-count and focus tests.
Select common original tips for meet and unmasked original tips for
subtraction. Retain the supporting interior values and prove equivalence to
pruning until stable, including termination and confluence.

Prove the semilattice, deletion-action, order, Boolean-pruning, geometric,
and morphism laws, with valued-support adapters to maps and zipper focuses.
Include counterexamples for laws requiring additional hypotheses.
Add native and zipper traversals that preserve left payloads, retain
supporting interiors, and share unchanged subtrees. Use direct byte/list
kernels with lazy reconstruction and explicit stacks for unary spines.

Check both traversals against independent repeated pruning, exercise every
native representation pairing, and cover dangling paths, focus restoration,
allocator differences, subtree sharing, and deep spines.
Rename the valued-prefix selection operation from live to retain throughout
the Lean model. Add map and zipper adapters and a Rust zipper traversal that
preserves candidate payloads and stops fringe scans at the first witness.

Prove Boolean filtering, exact mask composition, canonical hull/basis masks,
restriction dualities, extremum and divergence interactions, and the convex
connections. Record counterexamples to invalid stronger identities.

Use retain directly in the convex property tests, with exhaustive prefix
spaces, independent pruning, payload/focus checks, and traversal-work bounds.
Use canonical PrunedMap Unit spaces and the existing Zippy operations. Move the convex definitions, laws, and checks into PrunedModel/Convex, reuse canonical lookup and prefix lemmas, and remove the redundant list normalizer and mixed-map support implementation.

Keep the mixed program oracle connected through a projection adapter and include the new directory in the CI proof audit and Rust law-catalog check.
@imlvts
imlvts self-requested a review November 18, 2026 18:21
Tag the five allowlisted panic sites and classify their explicit identifiers instead of source coordinates. Preserve value-type and phase boundaries, and keep untagged panics unexpected with locations for diagnosis.

Add regression coverage for location shifts and unknown sites, and run the unit tests in the algebraic CI gate.
@ClarkeRemy

Copy link
Copy Markdown
Collaborator

I just had a first look at the code.
There is a lot there, but fortunately a lot of it is defining things that appear trivially true, but need to be made clear in the proof.

Do you have some particular part that you would like me to look at in particular?

@Adam-Vandervorst

Copy link
Copy Markdown
Owner

My original PR message highlights some of the things I think are important. I'd love feedback on organization and integration.

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.

4 participants