LODA is an assembly language, a computational model, and toolset for discovering and analyzing integer sequences. It is especially useful for mining programs that generate sequences from the On-Line Encyclopedia of Integer Sequences® (OEIS®).
This repository, loda-cpp, provides a C++ implementation of the LODA language, including an interpreter, optimizer, and miner. The miner can automatically generate LODA programs for OEIS sequences, which are stored in the loda-programs repository.
To install LODA, please follow the official installation instructions.
For a quick test, run loda eval A000045
to compute the first terms of the Fibonacci sequence.
Initialize your LODA home directory with loda setup
.
To mine programs for OEIS sequences, use loda mine
(single-core) or loda mine -p
(multi-core).
The loda
command-line tool supports the following commands and options:
Welcome to LODA developer version. More information at https://loda-lang.org/
Usage: loda <command> <options>
Commands:
eval <program> Evaluate an integer sequence program (see -t,-b,-s)
check <program> Verify correctness of an integer sequence program (see -b)
mine Mine programs for integer sequences (see -i,-p,-P,-H)
submit <file> [id] Submit an integer sequence program to the central repository
export <program> Export a program and print the result (see -o,-t)
optimize <program> Optimize a program and print the result
minimize <program> Minimize a program and print the result (see -t)
profile <program> Measure program evaluation time (see -t)
fold <program> <id> Fold a subprogram given by ID into a seq-operation
unfold <program> Unfold the first seq-operation of a program
mutate <program> Mutate a program to mine for integer sequences
setup Run interactive setup to configure LODA
update Update integer sequence and program data
upgrade Check for and install the latest LODA version
Targets:
<file> Path to a LODA file (file extension: *.asm)
<id> ID of an integer sequence (example: A000045)
<program> Either an <file> or an <id>
Options:
-t <number> Number of sequence terms (default: 8)
-b Print result in the OEIS b-file format
-o <string> Export format (formula,loda,pari,range)
-d Export with dependencies to other programs
-s Evaluate program and return number of execution steps
-c <number> Maximum number of execution steps (no limit: -1)
-m <number> Maximum number of used memory cells (no limit: -1)
-z <number> Maximum evaluation time in seconds (no limit: -1)
-l <string> Log level (values: debug,info,warn,error,alert)
-i <string> Name of miner configuration from miners.json
-p Parallel mining using default number of instances
-P <number> Parallel mining using custom number of instances
-H <number> Number of mining hours (default: unlimited)
Evaluate a LODA program to produce an integer sequence. You can specify either the path to a program file (.asm
) or the ID of an integer sequence as the argument. For example, run loda eval A000045
to generate the first terms of the Fibonacci sequence. Use the -t
option to set the number of terms, -b
to output the sequence row-by-row in the OEIS b-file format, and -c -1
to allow unlimited execution cycles (steps).
Optimize a LODA program and print the optimized version. Optimization is performed using static code analysis and does not require program execution. This process is guaranteed to preserve the semantics of the entire integer sequence.
Minimize a LODA program and print the minimized version. Minimization first applies optimization, then attempts to further shorten the program by removing operations through brute-force trial and error. The resulting program is guaranteed to produce the same integer sequence, but only up to the number of terms specified with -t
. Unlike optimization, minimization does not guarantee semantic preservation for the entire sequence, but it often yields much shorter programs. For best results, use a larger number of terms to increase the likelihood of correctness.
Measure the evaluation time of a LODA program. The profile
command runs the specified program and reports how long it takes to compute the sequence terms. This is useful for benchmarking program performance and identifying bottlenecks. You can use the -t
option to set the number of terms to evaluate.
Run the interactive configuration wizard.
Use the loda mine
command to automatically search for LODA programs that generate OEIS integer sequences. The miner continuously generates and tests candidate programs, saving any successful matches to your local programs folder. In client mode, discovered programs are also submitted to a central API server and integrated into the global loda-programs repository.
By default, mining uses a single CPU core. To utilize multiple cores, run loda mine -p
to launch several miner instances in parallel. You can adjust the number of instances by running loda setup
or using the -P
option.
Several miner profiles are defined in miners.json. Select a profile with the -i
option, for example: loda mine -i mutate
.
Verify the correctness of a program for a given OEIS sequence. For interactive output, use -b
to enable b-file printing. Use -c -1
to allow unlimited execution cycles.
Submit a LODA program for an integer sequence to the central repository. The submit
command uploads your program file for review and inclusion in the global loda-programs collection. This helps share new or improved programs with the LODA community. The command automatically verifies your program for correctness before the submission.