SpecForge – A Platform for Authoring Formal Specifications

Jul 29, 2026 05:35 PM - 21 hours ago 68

This conception is simply a speedy preamble to SpecForge’s main capabilities done a hands-on example. We’ll research really to constitute specifications successful the Lilo connection and analyse them utilizing SpecForge’s VSCode extension.

The Lilo Language: A Brief Introduction

Lilo is an expression-based temporal specification connection designed for hybrid systems. Here are the cardinal concepts:

Primitive Types: Bool, Int, Float, and String

Operators: Standard arithmetic (+, -, *, /), comparisons (==, <, >, etc.), and logical operators (&&, ||, =>)

Temporal Operators: Lilo’s distinguishing characteristic is its rich | group of temporal logic operators:

  • always φ: φ is existent astatine each early times
  • eventually φ: φ is existent astatine immoderate early time
  • past φ: φ was existent astatine immoderate past time
  • historically φ: φ was existent astatine each past times

These operators tin beryllium qualified pinch clip intervals, e.g., eventually[0, 10] φ intends φ becomes existent wrong 10 clip units. More operators are available.

Systems: Lilo specifications are organized into systems that group together:

  • signals: Time-varying input values (e.g., awesome temperature: Float)
  • params: Non-temporal parameters that are not time-varying (e.g., param max_temp: Float)
  • types: Custom types for system data
  • definitions: Reusable definitions and helper functions
  • specifications: Requirements that should clasp for the system

A strategy record originates pinch a strategy declaration for illustration strategy temperature_control and contains each the declarations for that system.

For a broad guideline to the language, spot the Lilo Language chapter.

Running Example

We’ll usage a somesthesia power strategy arsenic our moving example. This illustration task is disposable successful the releases. The strategy monitors somesthesia and humidity sensors, pinch specifications ensuring values stay wrong safe ranges:

system temperature_sensor // Temperature Monitoring specifications // This spec defines information requirements for a somesthesia sensor system import util usage { in_bounds } signal temperature: Float signal humidity: Float param min_temperature: Float param max_temperature: Float #[disable(redundancy)] spec temperature_in_bounds = in_bounds(temperature, min_temperature, max_temperature) spec always_in_bounds = ever temperature_in_bounds // Humidity should beryllium reasonable erstwhile somesthesia is successful normal range spec humidity_correlation = ever ( (temperature >= 15.0 && somesthesia <= 35.0) => (humidity >= 20.0 && humidity <= 80.0) ) // Emergency information - somesthesia exceeds captious thresholds spec emergency_condition = somesthesia < 5.0 || somesthesia > 45.0 // Recovery specification - aft emergency, strategy should stabilize spec recovery_spec = ever ( emergency_condition => eventually[0, 10] (temperature >= 15.0 && somesthesia <= 35.0) )

The VSCode extension provides support for penning Lilo code, syntax highlighting, type-checking, warnings, spec satisfiability, etc.:

VSCode codification screenshot

Spec Analysis

Once you’ve written specifications for your system, the SpecForge VSCode hold provides various study capabilities:

  • Monitor: Check whether recorded strategy behaviour satisfies specifications
  • Exemplify: Generate illustration traces that fulfill specifications
  • Falsify: Search for counterexamples that break specifications, comparative to immoderate model
  • Export: Convert specifications to different formats (.json, .lilo, etc.)
  • Animate: Visualize specification behaviour complete time

This tin beryllium done straight from wrong VSCode, aliases from wrong successful a Jupyter notebook utilizing the Python SDK. We will execute analyses straight successful VSCode here. The VSCode guide specifications each features successful greater depth.

Monitoring

Monitoring checks whether existent strategy behavior, recorded successful a information file, satisfies your specifications. You supply recorded trace data, and SpecForge evaluates a specification against it.

Navigate to the spec action screen, and click the Analyse fastener for the spec you want to monitor.

Analyse a spec

After selecting a information record from the dropdown menu, click Run Analysis. The consequence is an study monitoring character for the specification:

Monitoring study result

The consequence for the full specification is shown astatine the top. Below this, you tin drill down into sub-expressions of the specification, to understand what makes the spec existent aliases mendacious astatine immoderate fixed time. Hovering complete immoderate of the signals will show a popup pinch an mentation of the consequence astatine that constituent successful time, and will item applicable segments of sub-expression consequence signals.

An study tin beryllium saved. To do so, click the Save Analysis button, and take a location to prevention the analysis. You tin past navigate to this study record and unfastened it again successful VSCode. The study will besides show up successful the specification position menu, nether the applicable spec.

opening saved analyses

Exemplification

The Exemplify study generates illustration traces that show satisfying behavior. This is useful for:

  • Understanding what valid strategy behaviour looks like
  • Testing different components pinch realistic data
  • Creating animations

Exemplification result

If the exemplified information does not behave arsenic expected, the specification mightiness beryllium incorrect and request to beryllium corrected. Exemplification tin frankincense beryllium utilized arsenic an assistance erstwhile authoring specifications.

Falsification

If a exemplary for the strategy is available, falsification tin beryllium utilized to spot if the exemplary behaves arsenic expected, that is, according to specification.

First a falsifier must beryllium registered successful specforge.toml, e.g.

[project] name = "automatic-transmission" source = "spec" [[system_falsifier]] name = "AT Falsifier" system = "transmission" script = "transmission.py"

Once this is done, the falsifier will show up successful the Falsify study menu. If a falsifying awesome is found, the monitoring character is show, to thief understand really the exemplary went wrong:

Falsification result

Export

Export converts your specifications to different formats, to beryllium utilized successful different tools. For example, if you want to export your specification to JSON format, take .json arsenic the Export type.

JSON spec export

Next Steps

This circuit covered the basics of what SpecForge tin do. The pursuing chapters dive deeper into:

  • The afloat Lilo connection (Lilo Language)
  • System definitions and creation (Systems)
  • The Python SDK for programmatic entree (Python SDK)
More