The final page keeps governance and future-facing material out of the core spec. It covers bounded improvement protocols, the Apple Swift reference implementation, release history, Capsulang, contribution priorities, safety boundaries, and the practical download path.
TensorLang is a good abstraction for bounded, inspectable AI improvement workflows: it makes artifacts, metrics, search spaces, eval suites, effects, gates, and loop bounds explicit. It is not an unrestricted recursive-self-improvement runtime.
(module examples.bounded_trace_improvement (tensorlang "1.9") (artifact base_trace_model (kind model) (schema trace-classifier-v1) (hash "sha256:...") (source "build/artifacts/base-trace-model.json")) (artifact improved_trace_model (kind model) (schema trace-classifier-v1) (hash "sha256:...") (source "build/artifacts/improved-trace-model.json")) (artifact trace_dataset_v3 (kind dataset) (schema semantic-traces-v1) (hash "sha256:...") (source "build/datasets/semantic-traces-v3.json") (split train validation test)) (metric validation_f1 (type F64) (source trace_eval) (direction maximize)) (objective improve_trace_classifier (maximize validation_f1) (subject-to (>= validation_f1 0.92))) (search-space trace_model_search (choice embedding_dim [16 32 64]) (choice learning_rate [0.1 0.03 0.01])) (eval-suite trace_eval (dataset trace_dataset_v3) (holdout test) (metrics validation_f1) (seed 1337) (deterministic true)) (candidate trace_model_candidate (parent base_trace_model) (search-space trace_model_search) (produces improved_trace_model) (changes embedding_dim learning_rate)) (effect train_model (reads base_trace_model trace_dataset_v3) (writes improved_trace_model) (network false) (max-cpu-seconds 600) (max-memory-mb 4096)) (gate promote_trace_model (candidate trace_model_candidate) (requires (> validation_f1 parent.validation_f1)) (requires (>= validation_f1 0.92)) (requires (approval human))) (improvement-loop trace_classifier_loop (start base_trace_model) (candidate trace_model_candidate) (evaluate trace_eval) (promote-if promote_trace_model) (effects train_model) (max-iterations 5) (rollback-on regression) (emit-trace true)))
tl check examples/40_bounded_trace_improvement.tl --static-only tl improvement-ledger examples/40_bounded_trace_improvement.tl trace_classifier_loop tl check examples/41_bad_unapproved_promotion.tl --static-only --json
Immutable models, datasets, programs, eval reports, checkpoints, traces, and ledgers are named with schema, source, and hash metadata.
Metrics declare type, source, and direction; objectives separate optimization targets from promotion constraints.
Candidate generation is finite and typed, with checker errors when a candidate changes knobs outside the declared space.
Heldout splits, metric lists, seeds, and determinism are explicit instead of hidden in orchestration code.
External runtimes must declare reads, writes, network policy, CPU/memory/step budgets, and determinism expectations.
A successor is not accepted merely because it exists; gates record metric thresholds, regression checks, and approval requirements.
v1.9 validates and records a protocol; it does not autonomously invent objectives, rewrite source, call tools, train at scale, deploy, or promote successors. The ledger is a deterministic audit skeleton for an external governed runtime, with human or policy approval represented as an explicit gate requirement.
The native Apple implementation is canonical source in the parent TensorLang repo at apple/TensorLang. The web site documents it; the web repo does not own, vendor, or duplicate the Swift package.
TensorLangKit is a Foundation-only Swift Package Manager library target intended for macOS, iOS, iPadOS, tvOS, watchOS, and visionOS apps. The package also ships a native Swift tlexecutable target for developer workstations and CI.
Current scope is the TensorLang v0.3 checker/conformance subset. That makes it a portable Apple reference and compatibility target, but not yet a complete Swift port of every Python v2.0 runtime feature.
# canonical source lives in the parent TensorLang repo
cd apple/TensorLang
swift test
swift build -c release
Scripts/check-apple-reference.sh
.build/release/tl check Examples/*.tl
.build/release/tl check --json Examples/markov_chain.tl
# formal sidecar, when Lean is installed
cd ../../formal/Lean
lake buildimport TensorLangKit let result = TensorLang.check(sourceText, file: "EditorBuffer.tl") for diagnostic in result.diagnostics { print(diagnostic.formatted()) } let project = TensorLang.checkProject([ SourceFile(path: "family.tl", text: familySource), SourceFile(path: "ancestor.tl", text: ancestorSource), ])
import Combine import Foundation import TensorLangKit @MainActor final class TensorLangDocumentChecker: ObservableObject { @Published private(set) var diagnostics: [Diagnostic] = [] @Published private(set) var modules: [CheckResult] = [] func check(source: String, fileName: String) { let result = TensorLang.check(source, file: fileName) diagnostics = result.diagnostics modules = [result] } }
After cloning the parent repo, add apple/TensorLang as a local Swift package in Xcode.
Link the TensorLangKit product to the app target; do not ship the CLI.
Run TensorLang.check for one document or checkProject for imports.
Bind Diagnostic values to an issue list, use formatted() for logs, and jump by line/column.
Cards tagged done are implemented in the current repository. v2.0 moves the previous production research items into scoped, test-covered reference capabilities.
Capsulang is a sibling research language — unrelated to any existing product of that name — that explores capsule-based reasoning orchestration on top of a tensor-equation core like TensorLang.
+----------------+ manifest +-----------------+ | Capsulang | <------------------- | TensorLang | | reasoner | tensors / domains / | core runtime | | orchestrator | semirings / proofs | | +----------------+ +-----------------+
TensorLang is an early research prototype. Issues, design notes, and small reproducible programs are the most useful contributions right now.
Add fixtures that compare named-axis semiring-einsum, explicit join/project, sparse COO materialization, and relational backend output.
Grow fixtures beyond the v1.6 baseline that compare reference, in-memory, SQLite, Datalog text, and TypeDB text without claiming formal backend proof.
Expand the SMT lowering for Bool/Nat tensors, add bounded model-checking for fixed-point reachability, and surface counter-models in the CLI.
Stabilise the discrete and explicit-Euler step semantics, add symplectic and implicit integrators, and standardise trace export for offline analysis.
Move from the tiny causal LM to transformer blocks, reverse-mode autodiff lowering, tokenizer/dataset pipelines, and sharded checkpoints.
Broaden SQL, Datalog, TypeDB, JAX, and PyTorch integrations around small, stable IR contracts, with external validators remaining optional.
Carrier laws, normalisation, and interaction with fixpoints. Open questions around inference vs. simulation duality.
Identify the largest sub-language with well-defined gradients across semirings; relate to existing autodiff IRs.
The reference implementation ships as a small CLI and a library. Programs are .tl S-expression files; the toolchain provides parsing, type checking, sparse COO materialization, named-axis einsum, semiring lowering, finite verification, backend execution, structured training, evidence reports, fixture-backed datasets, foundation-model training/generation, and simulation.
Released under CC0 as an archived starter bundle. For current coverage, use the repository examples and the CLI commands on this page.
; 1. check the v1.8 tensor-logic, relational, autodiff, and lowering path tl check examples/32_tensor_logic_primitives.tl tl lower-relalg examples/32_tensor_logic_primitives.tl user_role_action tl emit-datalog examples/29_rel_backend_policy.tl can_do tl lower-autodiff examples/17_training_linear_regression.tl fit tl lower-accelerator examples/17_training_linear_regression.tl mse --target gpu tl run-accelerator examples/17_training_linear_regression.tl mse --target numpy ; 2. validate a bounded improvement protocol tl check examples/40_bounded_trace_improvement.tl --static-only tl improvement-ledger examples/40_bounded_trace_improvement.tl trace_classifier_loop ; 3. run the evidence suite tl evidence-suite --out build/evidence --quick --json ; 4. train a structured tensor model tl train examples/26_kg_link_prediction_train.tl fit \ --backend auto \ --save-artifact build/kg_model.tla.json \ --json ; 5. train and sample the tiny foundation LM tl foundation-train \ --text "tensorlang trains local language models." \ --steps 80 \ --save-artifact build/foundation.tlf.json \ --json tl foundation-generate \ --artifact build/foundation.tlf.json \ --prompt tensorlang \ --tokens 32 \ --json tl foundation-optimizer-state \ --artifact build/foundation.tlf.json \ --out build/foundation.optimizer.json \ --ranks 2 ; 6. run v2.0 production capability surfaces tl foundation-pretrain-plan \ --layers 24 \ --heads 16 \ --model-dim 2048 \ --ff-dim 8192 \ --training-tokens 10000000000 \ --json tl foundation-distributed-train \ --text "tensorlang synchronizes gradients." \ --workers 2 \ --steps 2 \ --json tl theorem-prove examples/43_theorem_prover_family.tl ; 7. run executable backend, proof, and foundation checks tl rel-compare examples/30_rel_backend_reachability.tl reachable --json tl proof-calculus examples/11_properties_family.tl tl benchmark foundation-lm --json