# Simple Logic - Getting Started Examples

> A pure logic example that demonstrates Tactus procedures without using any AI agents. This example shows: - How to define procedures with input and output schemas using field definitions - State management with the `state` primitive - Multiple BDD specifications testing different aspects of the pro…

Canonical: https://tactus.anth.us/examples/getting-started/simple-logic/

::band{columns="document-hero wide"}

[Examples](/examples/) / [Getting Started](/examples/getting-started/) / Simple Logic

# Simple Logic

- Has Specs

A pure logic example that demonstrates Tactus procedures without using any AI agents. This example shows: - How to define procedures with input and output schemas using field definitions - State management with the \`state\` primitive - Multiple BDD specifications testing different aspects of the procedure - Basic Lua control flow (loops, conditionals)

::band{tone="muted" columns="example"}

## Source Code

```lua
-- Simple Tactus procedure without agents for BDD testing
-- This example uses only state primitives, no LLM calls required

-- Procedure with input, output, and state defined inline
Procedure {
    input = {
        target_count = field.number{
            required = false,
            description = "Target counter value",
            default = 5,
        },
    },
    output = {
        final_count = field.number{required = true, description = "Final counter value"},
        message = field.string{required = true, description = "Status message"},
    },
    function(input)
        local target = input.target_count or 5
        for i = 1, target do
            state.counter = i
        end

        state.message = "complete"
        return {final_count = state.counter, message = state.message}
    end
}

-- BDD Specifications
Specification([[
Feature: Simple State Management
  Test basic state functionality without agents

  Scenario: State updates correctly
    Given the procedure has started
    When the procedure runs
    Then the state counter should be 5
    And the state message should be complete
    And the procedure should complete successfully

  Scenario: Outputs are returned
    Given the procedure has started
    When the procedure runs
    Then the output should exist
    And the output final_count should be 5
    And the output message should be complete

  Scenario: Iterations are tracked
    Given the procedure has started
    When the procedure runs
    Then the total iterations should be less than 10
]])

-- Custom steps can be added here if needed
-- step("custom assertion", function(input)
--   assert(state.counter > 0)
-- end)
```

## Quick Start

Run the example:

```bash
tactus run 01-getting-started/02-simple-logic.tac
```

Test with mocks:

```bash
tactus test 01-getting-started/02-simple-logic.tac --mock
```

[View source on GitHub →](https://github.com/AnthusAI/Tactus-examples/blob/main/01-getting-started/02-simple-logic.tac)

::band{columns="neighbors"}

- [*← Previous Example* **Hello World**](/examples/getting-started/hello-world/)
- [*Next Example →* **Parameters**](/examples/getting-started/parameters/)

::band{columns="cta"}

## Explore more examples

Learn Tactus through practical, runnable examples organized by topic.

::button{href="/examples/" label="View All Examples" size="lg"}
