<!-- Sema documentation — Examples Overview
     Sema is a new AI-native, neurosymbolic programming language most models
     have not been trained on. Full corpus: https://sema.49.12.246.95.sslip.io/llms-full.txt
     Install language support: https://sema.49.12.246.95.sslip.io/install-skill/ -->

# Examples Overview

> A tour of the worked Sema projects — governance and finance, agents and reasoning, interop and the SDK, and language features — each a runnable project you can check, run, and assure.

Sema ships a corpus of **worked example projects** under `examples/`. Each one is
a real, runnable Sema project — a directory with `src/*.sema` (entry:
`main()` in `main.sema`) — not a snippet. Because they are projects, you can put
each one through the full toolchain:

```bash
sema check examples/finops-ledger              # static checks
SEMA_STRICT=1 sema run examples/finops-ledger  # execute, failing hard on any degradation
sema assure examples/finops-ledger --grade gold  # run tests + fuzz properties + mutation-test
```

They run hermetically under the opt-in deterministic engine (`[engine]
deterministic = true` in `sema.toml`, or `SEMA_DETERMINISTIC=1`) — no model
download, no network — so the deterministic core of every example is
reproducible. Where a
project uses generative constructs (`simulate def`, `semantic.*`, `~=`), those
calls are covered by contracts (`ensure` / `check semantics`) rather than by
exact-output comparison.

Every top-level project also has a generated gallery page under
[Reference › Examples API](/reference/examples-api/finops-ledger/), reflected
directly from its source — signatures, effect rows, structs, and docstrings.

:::tip
New to the language? Start with [First Program](/start/first-program/) and the
[Mental Model](/start/mental-model/), then read `polymorphism` and `research-agent`
below — the two most self-contained end-to-end programs.
:::

## Governance & finance

Regulated, high-stakes workflows: policy-confined capabilities, adversarial
inputs, trust labeling, audit trails, and monitored public output.

- **[finops-ledger](/reference/examples-api/finops-ledger/)** — Regulated payment
  reconciliation and anomaly review. Adversarial documents, taint/endorsement,
  typed SQL, tap collectors, native config/DI, and native parallel map/search.
  Assured at `gold`.
- **[trial-safety](/reference/examples-api/trial-safety/)** — Clinical-trial
  adverse-event review. PII policy, human adjudication, calibrated extraction, and
  a deliberate no-autonomous-medical-action stance. Assured at `gold`.
- **[crisis-logistics](/reference/examples-api/crisis-logistics/)** — Multi-agency
  disaster-response dispatch. Cross-agency policy, semantic deduplication, route
  planning, and monitored public briefings.
- **[robotics-cell](/reference/examples-api/robotics-cell/)** — Warehouse robotics
  recovery and maintenance. Physical monitors, session-typed protocols, structured
  concurrency, and patch-scoped `supervise`/`heal`. Assured at `gold`.

## Agents & reasoning

Native typed agents, durable circuits, and the lower-level neurosymbolic pieces
for building custom reasoning loops. Start with the
[Native Agents and Durable Circuits guide](/guides/agents-and-circuits/).

- **[agent-research](/reference/examples-api/agent-research/)** — Native
  research fan-out/fan-in with `parallel [agent(x) for x in xs]`, bounded model
  calls, ordered evidence, and typed synthesis.
- **[agent-software](/reference/examples-api/agent-software/)** — An
  explorer→engineer→hardener circuit with an owned spawned task and typed patch
  handoff.
- **[agent-scientific](/reference/examples-api/agent-scientific/)** — A failed
  theorem/experiment path dynamically admits a bounded proof auditor under an
  `AgentEnvelope`; deterministic verification gates publication.

- **[research-agent](/reference/examples-api/research-agent/)** — A compact
  search-then-write pipeline built entirely on the Sema standard library:
  provenance citation ids, `semantic.dedup`, a belief-driven `loop_until`, ambient
  `with meter`, and typed-report rendering (`std.document`).
- **[semantic-library](/reference/examples-api/semantic-library/)** — Book and
  paper knowledge operations. User-defined semantic operators, native prompt
  templates, and role-aware `context` state machines. Assured at `gold`.

## Interop & SDK

Reusing existing ecosystems and driving real models through native Sema surfaces.

- **[hybrid-interop](/reference/examples-api/hybrid-interop/)** — Existing
  Python/TypeScript/C code wrapped by Sema. Typed `bridge` membranes, inline
  foreign glue, holistic `sem` descriptors, and re-validation at the boundary.
  Assured at `gold`.
- **[graphrag](/reference/examples-api/graphrag/)** — A GraphRAG backend in Sema,
  one-to-one with a Python reference and bit-comparable. Proper module/namespace
  layout and in-process host entry points for a Python/TS bridge.
- **[sdk-demo](/reference/examples-api/sdk-demo/)** — Using the Sema SDK
  (`ai.sema`): text generation, embedding similarity, and a tool-using agent where
  your Sema functions *are* the tools.
- **[sdk-multimodal](/reference/examples-api/sdk-multimodal/)** — End-to-end
  multimodal via the SDK: captioning, OCR, VQA, and a TTS→STT speech round-trip
  behind native Sema functions (real small HF models once the extras are installed).

## Language features

Focused tours of the surface syntax and the native AI capabilities.

- **[polymorphism](/reference/examples-api/polymorphism/)** — The whole trait trio
  in one runnable program: header conformance, out-of-line `impl`, enum
  conformance, bounded generics, default methods, supertraits, and trait objects —
  in a functional style. No classes; traits and ADTs only.
- **[ai-console](/reference/examples-api/ai-console/)** — A deterministic tour of
  the native AI surface: prompt templates and composition debugging, multimodal
  messages, token streaming, batched/distributed generation, reduced-precision
  numeric widths, and operator overloading.

## The neurosymbolic port

`examples/neurosymbolic-port/` is a special corpus: it ports patterns from the
Python **SymbolicAI** framework and a deep-research agent to Sema
and **proves the ports are equivalent** to the originals on their deterministic
cores. Each pattern lives in its own subproject with a `src/main.sema` whose
`main()` returns a vector compared against a golden emitted by the Python
reference (`reference/<name>_ref.py`), asserted in
`crates/sema-runtime/tests/equiv_neurosymbolic.rs` — with no Python or network
needed at test time.

The subprojects (`belief/`, `provenance/`, `usage/`, `budget/`, `cache/`,
`loop/`, `document/`, `meter/`, `dedup/`, `purify/`) each replace a chunk of
hand-threaded Python — a `BeliefTracker`, a `MetadataTracker`, `(result, usage)`
tuples, a ~300-line agentic while-loop — with a Sema standard-library construct or
a native scope. Because the ports now `import` from `std.*`, the equivalence tests
prove the **standard library itself** matches the reference Python. Each subproject
is a runnable Sema project:

```bash
sema run examples/neurosymbolic-port/loop
sema check examples/neurosymbolic-port/dedup
```

:::note
The `neurosymbolic-port` subprojects are equivalence-test fixtures and do not have
individual gallery pages under Reference › Examples API. Read them directly under
`examples/neurosymbolic-port/`, or see the worked application built on the same
standard library in [research-agent](/reference/examples-api/research-agent/).
:::

## Next

- [Reference › Examples API](/reference/examples-api/ai-console/) — the generated,
  reflected page for each project.
- [CLI reference](/reference/cli/) — every `sema` command and flag.
- [Verification](/neurosymbolic/verification/) — the model behind `sema assure`.
