Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
TL Programming Language
A tensor logic programming language with first-class tensor support, JIT-compiled to LLVM.
Features
- Tensor Operations:
tensor<f32>[128, 128],matmul,topk, etc. via Candle. - Logic Programming: Datalog-style rules with tensor integration.
- Hybrid Execution: Logic terms can access tensor data (
data[i]). - JIT Compilation: High-performance execution using LLVM (Inkwell).
- GPU Support: Metal (macOS) backend supported. CUDA support is planned for the future.
- Optimization: Aggressive JIT optimization and fast logic inference.
Installation
Install from crates.io:
This installs the tl command.
Prerequisites (macOS)
Before building, ensure you have the required dependencies installed via Homebrew.
-
Install LLVM 18 and OpenSSL:
-
Configure Environment Variables: Add the following to your shell configuration (e.g.,
~/.zshrc) to help the build system find LLVM 18:Reload your shell (
source ~/.zshrc) before running cargo commands.
Build & Run
# Run a specific example
# Use GPU (Metal on macOS)
[!WARNING] Metal users: Long-running loops may cause RSS (memory) growth due to Metal driver behavior, not TL memory leaks. For stable memory usage, use
TL_DEVICE=cpu. See Metal RSS Growth Notes for details.
Syntax
TL's syntax is very similar to Rust, but without lifetimes.
Basic Syntax
Tensor Operations
if Statement
while Statement
for Statement
Function Definition
Tensor Comprehension
For more details, see Tensor Comprehension
VSCode Extension
A syntax highlighting extension is provided in vscode-tl.
Installation
- Open the
vscode-tldirectory in VSCode. - Press F5 to verify syntax highlighting in a new window.
- Or install manually:
cd vscode-tlnpm install -g vsce(if needed)vsce packagecode --install-extension tensor-logic-0.1.0.vsix
Code Example: N-Queens Problem (Solved via Tensor Optimization)
TensorLogic can solve logical constraints as continuous optimization problems using tensor operations. Below is an example program that solves the N-Queens problem using gradient descent.
Code Example: Neuro-Symbolic AI (Spatial Reasoning)
The following example demonstrates how to fuse Vision (Tensor) and Reasoning (Logic). It detects spatial relationships from raw coordinates and infers hidden facts using logic rules (Transitivity).
// 1. Symbolic Knowledge Base (The "Mind")
// Define concepts (objects)
object.
object.
object.
// Recursive Logic Rule: Transitivity
// If X is on Y, then X is stacked on Y.
// If X is on Z, and Z is stacked on Y, then X is stacked on Y.
stacked_on :- on_top_of.
stacked_on :- on_top_of, stacked_on.
Documentation
- Advantages of TensorLogic
- Tensor Comprehension Design
- Language Specification
- API Reference
- Logic Programming
LICENSE
References
Development
- Testing Guide - How to run tests and verification scripts.