Skip to content

Quickstart

rfi-irfos edited this page Apr 14, 2026 · 6 revisions

Quick Start

This page provides the minimal setup and execution workflow for Ternlang and the Ternary Intelligence Stack (TIS).

The objective is to:

  • install the CLI
  • run a .tern file
  • validate ternary state execution
  • compile BET bytecode
  • verify local toolchain integrity

Requirements

Before starting, ensure the following tools are available:

  • Rust toolchain (cargo, stable)
  • terminal environment (Linux / macOS / Windows)
  • Git (optional, for source build)

Verify Cargo:

cargo --version

Install the CLI

Install the Ternlang CLI via Cargo:

cargo install ternlang-cli

Validate installation:

ternlang --help

Expected command groups include:

run
build
repl
fmt
audit
translate

Create a Minimal Program

Create a new file:

touch quickstart.tern

Insert the following:

fn classify(signal: trit) -> trit {
    match signal {
        reject => { return reject; }
        tend   => { return tend;   }
        affirm => { return affirm; }
    }
}

let output: trit = classify(affirm);

match output {
    reject => { return reject; }
    tend   => { return tend;   }
    affirm => { return affirm; }
}

This defines a minimal ternary classification flow.


Run the Program

Execute:

ternlang run quickstart.tern

Expected output:

affirm

This validates:

  • parser
  • AST generation
  • exhaustive ternary match logic
  • BET VM execution

Ternary State Space

Trit State Interpretation
reject negative block / veto
tend neutral uncertainty / hold
affirm positive accept / proceed

The tend state acts as a formal uncertainty carrier.


Use the REPL

Launch the interactive shell:

ternlang repl

Example:

consensus(affirm, tend)

Expected output:

tend

This performs a minimal ternary aggregation.


Compile to BET Bytecode

Build bytecode output:

ternlang build quickstart.tern --output quickstart.bet

This validates:

  • frontend compilation
  • opcode lowering
  • bytecode serialization

Output artifact:

quickstart.bet

Explore the Standard Library

Browse the full standard library modules:

https://github.com/eriirfos-eng/ternary-intelligence-stack/tree/main/ternlang-root/stdlib

This includes:

  • std::*
  • ml::*
  • nn::*
  • stats::*
  • vision::*
  • qnn::*

Run an Example Program

Execute a built-in example:

ternlang run examples/05_medical_triage.tern

Browse the full example collection:

https://github.com/eriirfos-eng/ternary-intelligence-stack/tree/fd4f3f9417385396760ff62d52fda86ab0cb4b2b/ternlang-root/examples

Examples include:

  • medical triage
  • aerospace systems
  • infrastructure control
  • finance
  • AI agent workflows

Recommended Validation Workflow

ternlang run quickstart.tern
ternlang fmt quickstart.tern --write
ternlang build quickstart.tern --output quickstart.bet
ternlang repl

Clone this wiki locally