Skip to content

SuperInstance/flux-lang

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

FLUX — Constraint-Native Language Prototype

"Intention becomes calculation without loss."

FLUX is a constraint-native language where the constraint IS the computation. Variables aren't assigned — they're constrained. The Laplacian IS the type system. Conservation is enforced by the runtime.

Core Idea

In normal programming:

  1. You assign values to variables
  2. You check constraints after the fact
  3. Constraint violations are bugs

In FLUX:

  1. You declare constrained variables with domains
  2. You express conservation constraints
  3. The solver finds values that satisfy ALL constraints simultaneously
  4. Conservation guarantees satisfaction

Architecture

Constraint Graph → Laplacian Matrix → Eigenvectors → Solution
       ↓                  ↓                ↓            ↓
  (variables)       (structure)     (conservation)  (values)

The constraint graph's Laplacian encodes the structure of all constraints. The Fiedler vector (eigenvector for the second-smallest eigenvalue) gives the optimal partition of constraint space — the solution that maximizes conservation across all constraints.

Quick Start

cd flux-lang
pip install -e .
python -m flux_lang.repl          # Interactive REPL
python examples/music_harmony.py  # Music harmony example
python examples/scheduling.py     # Scheduling example
python examples/circuit.py        # Circuit design example

Example

from flux_lang import FluxLang

flux = FluxLang()
flux.var("key", ["C", "G", "D", "F"])
flux.var("mode", ["major", "minor"])
flux.var("chord1", ["I", "IV", "V", "vi"])
flux.var("chord2", ["I", "IV", "V", "vi"])

flux.constrain("chord1.tension + chord2.tension < 1.5")
flux.constrain("key.signature preserves mode")
flux.constrain("chord1 → chord2 follows circle_of_fifths")

solution = flux.solve()
assert flux.verify(solution)

Constraint Types

Type Description
tension Smoothness between successive values
conservation A quantity is preserved through transformation
smoothness Adjacent variables change gradually
structure Structural pattern (e.g., circle of fifths)

The Math

Given N variables each with a discrete domain, FLUX:

  1. Builds a constraint graph where edges encode pairwise constraints
  2. Constructs the graph Laplacian L = D - A
  3. Computes eigendecomposition of L
  4. The Fiedler vector gives the optimal solution in continuous space
  5. Projects back to discrete domains via nearest-neighbor snapping
  6. Verifies all constraints are satisfied (conservation check)

This is conservation-as-computation: the eigenvectors of the Laplacian are the modes that preserve the constraint structure.

Repository

github.com/SuperInstance/flux-lang

Part of the SuperInstance OpenConstruct ecosystem.

About

FLUX: A constraint-native language where the constraint IS the computation

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages