A simple AI programming language
Project description
Silu Programming Language
斯路编程语言
A simple AI-first interpreted programming language with Python-like syntax, designed as a foundation for advanced AI reasoning capabilities.
Vision & AI Roadmap
Silu aims to become a platform for developing AI systems that can:
- Combine rigorous logical reasoning with probabilistic reasoning
- Achieve self-bootstrapping and self-correction capabilities
- Conduct autonomous hypothesis testing and experimentation
- Discover inconsistencies and drive curiosity-based learning
Development Stages
- 2025-2028: Logic mastery (CFG, data flow, SMT verification)
- 2028-2032: Logic + probabilistic reasoning fusion
- 2032-2036: Self-bootstrapping and self-correction
- 2036-2040: Hypothesis-driven experimentation
- 2040+: Inconsistency detection and curiosity-driven knowledge creation
See AI Development Plan for detailed roadmap and benchmarks.
Quick Start
Installation
# Using pip
pip install -e .
# Using uv (recommended for development)
uv sync && uv pip install -e .
Basic Usage
# Run a Silu program
silu hello.si
# Check if Python code is compatible with Silu
silu check program.py
# Interactive execution
silu interpret --source "print('Hello, World!')"
# Generate LLVM IR for native compilation
silu ir hello.si --output hello.ir.json
silu llvm hello.ir.json --output hello.ll
Compilation to Native Code
Silu now supports compilation to native machine code via LLVM IR:
# Complete compilation workflow
silu ir program.si --output program.ir.json # Generate Silu IR
silu llvm program.ir.json --output program.ll # Convert to LLVM IR
llc program.ll -o program.s # Compile to assembly
clang program.s -o program # Link to executable
./program # Run native executable
Hello World Example
Create hello.si:
# Variables and basic operations
name = "Silu"
version = 1.0
print("Hello from", name, version)
# Functions
def greet(person):
return "Welcome to " + person + "!"
message = greet("Silu Programming")
print(message)
Run it:
silu hello.si
Key Features
- Simple Syntax: Python-like syntax that's easy to learn
- Multiple Execution Modes:
- Direct interpretation
- Python compatibility checking
- IR (Intermediate Representation) generation and execution
- Symbolic execution for program analysis
- Rich Data Types: int, float, str, bool, bytes, lists, dictionaries
- Control Flow: if/elif/else, while loops, for loops with range()
- Advanced For Loops: Support for tuple unpacking (
for key, value in dict.items()) - Functions: User-defined functions with parameters, return values, and closures
- Built-in Functions:
print(),type(),isinstance(), type conversions,len() - Dictionary Operations: Full dictionary support with
.keys(),.values(),.items()methods
Advanced Usage
Check Python Compatibility
# Check if a Python file can be interpreted by Silu
silu check program.py
# Output: program.py ok (or program.py bad: specific error reason)
# Examples of error messages:
# program.py bad: syntax error: expected ':' at line 4
# program.py bad: name error: Name 'undefined_var' is not defined
# program.py bad: runtime error: division by zero
# program.py bad: type error: can only concatenate str (not "int") to str
# program.py bad: empty file
# program.py bad: file not found
Generate Intermediate Representation
silu ir program.si --format json --output program.ir
Symbolic Execution Analysis
silu symbolic program.si
Execute IR Directly
silu exec program.ir
LLVM IR Generation and Native Compilation
# Generate LLVM IR from Silu IR
silu llvm program.ir.json --output program.ll
# Complete compilation pipeline
silu ir program.si --output program.ir.json # Generate Silu IR
silu llvm program.ir.json --output program.ll # Convert to LLVM IR
llc program.ll -o program.s # Compile to assembly
clang program.s -o program # Link to executable
# Run demo workflow
python demo_silu_to_llvm.py --save-files
Documentation
- AI Development Plan - Long-term AI reasoning roadmap and benchmarks
- CLI Usage Guide - Complete command-line reference
- Language Features - Syntax and examples
- Development Guide - Setup, testing, and contributing
- Symbolic Execution - Program analysis capabilities
- IR Design - Intermediate representation format
- LLVM IR Generation - Native code compilation via LLVM
- Interpreter Specification - Core implementation details
Examples
Demo Programs
The repository includes comprehensive demo programs showcasing all language features:
# Run the main demo (variables, functions, control flow)
silu demo.si
# Complex programming patterns
silu complex_example.si
# Symbolic execution analysis
silu symbolic symbolic_demo.si
Performance Comparison
Compare different execution modes:
# Interpretation vs IR execution
time silu interpret demo.si
silu ir demo.si --output demo.ir.json --format json
time silu exec demo.ir.json
Contributing
We welcome contributions! See the Development Guide for setup instructions and coding guidelines.
License
MIT License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pysilu-0.1.6.tar.gz.
File metadata
- Download URL: pysilu-0.1.6.tar.gz
- Upload date:
- Size: 148.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4c20a130490a594b24bf5fe33329af7ae1283b88cb53aab94c7ce18a493b3993
|
|
| MD5 |
98d1915987cc2c131355d96f195c8a70
|
|
| BLAKE2b-256 |
d1b2fbdca365b41f3140b1e7ab95b5375ec33c553f326f86327ef5dc2257e1e1
|
File details
Details for the file pysilu-0.1.6-py3-none-any.whl.
File metadata
- Download URL: pysilu-0.1.6-py3-none-any.whl
- Upload date:
- Size: 104.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5732e9ad29f63d8ec944d52a924caec9cf9da1033e9ca456031255d8fded69da
|
|
| MD5 |
899a12f5b7a953eddfdddbf190efc05e
|
|
| BLAKE2b-256 |
866a6975255f0ed95c121b6ead945f4f55a17987ee4fe541b6362d3a76b88c7f
|