Public Model Checking API v1¶
This HTTP API is for developers who want to run model checking from their own code, without the web UI. The user guide covers the same checks in the browser.
Base URL:
https://vitamin.r2.enst.fr/api/v1/model-checking
Only paths under /api/v1/model-checking form the public contract. UI routes such as
/api/ai, /api/examples and /api/admin may change without a new API version. The
short paths below (/execute and the rest) are relative to the base URL, so /execute is
/api/v1/model-checking/execute.
Contract files¶
Table 1: Contract files.
| Artifact | Where |
|---|---|
| OpenAPI for v1 | frontend/openapi/openapi-model-checking-v1.json in the repository |
| Full live OpenAPI | /openapi.json on the server |
| Swagger UI, ReDoc | /docs, /redoc on the server |
Use the OpenAPI file for client generation: it documents the v1 contract.
Authentication¶
Some deployments require a shared integrator key. When enabled, send
Authorization: Bearer YOUR_SECRET. A missing or malformed header gets 401 and a wrong
secret gets 403. If the deployment does not use a key, omit the header.
Discovery¶
The paths /, /health, /openapi.json, /docs and /redoc are relative to the server
root, for example https://vitamin.r2.enst.fr/health. On a server that also serves the UI,
GET / returns the UI page to any client that does not send Accept: application/json,
curl included; send that header for the API status.
Table 2: Discovery endpoints.
| Method | Path | Purpose |
|---|---|---|
| GET | / |
API status and public API metadata |
| GET | /health |
Health check and feature flags |
| GET | /api/v1/model-checking/logics |
Available logics |
| GET | /api/v1/model-checking/trace-capabilities |
Trace support by logic |
| GET | /api/v1/model-checking/graph/limits |
Graph size limits |
Endpoints¶
Table 3: Model checking endpoints.
| Method | Path | Purpose |
|---|---|---|
| POST | /execute |
Check one formula against one model |
| POST | /execute-batch |
Check several formulas against one model |
| POST | /validate-formula |
Check formula syntax for a logic |
| POST | /validate-model |
Check model file structure for a logic |
| POST | /parse-model |
Parse a model from a JSON body |
| POST | /parse-model-upload |
Parse an uploaded model file |
| POST | /graph |
Return the graph structure of a valid model |
| POST | /graph/serialize |
Serialize graph data back to model text |
| POST | /model-syntax |
Model syntax reference for a model type (CGS, costCGS, ...). The JSON body gives parser_type, or logic, or model_content for the server to detect the type |
| POST | /formula-syntax |
Formula syntax reference for a logic |
| POST | /synthesize-strategy |
Synthesize a winning ATL* strategy for one formula |
| POST | /export/pdf |
Export result data to PDF; a result may carry strategyExport (strategy or reason, see ExportPdfStrategy in the OpenAPI file) |
Execute¶
/execute and /execute-batch take multipart/form-data. They differ in the formula field,
formula against formulas, and in the response: /execute takes one formula and returns one
result (if you send several statements it runs only the first), while /execute-batch takes
statements and returns a list.
Table 4: Execute fields.
| Field | Required | Meaning |
|---|---|---|
file |
yes | Model file to check |
logic |
yes | Logic name, as listed by GET /logics |
formula or formulas |
yes | One formula, or one or more statements for a batch |
generate_trace |
no, default false |
Return a witness or counterexample trace where the logic supports it |
schedule |
no | NatSL evaluation schedule, space (default) or time; ignored for other logics |
A trace is a run of the model: a witness shows how the formula holds, a counterexample how
it fails. GET /trace-capabilities lists which logics return one. Example:
curl -sS -X POST "http://localhost:8001/api/v1/model-checking/execute" \
-F "file=@model.txt" \
-F "logic=CTL" \
-F "formula=EF p" \
-F "generate_trace=true"
Add the bearer header when the server has the key enabled. /execute returns one
ModelCheckResult; read success first. Its main fields:
success:truewhen the check finished,falsewhen it did not.verification: details of a finished check.verification.is_satisfiedis the verdict, whether the initial state satisfies the formula;verification.satisfying_stateslists the states where it holds. When the checker returns a value per state, as ATLF does,verification.state_valuesmaps each state to the formula's value in [0,1] andverification.initial_state_valuegives the initial state's value; any value above 0 counts as holding inis_satisfiedandsatisfying_states. Both fields are absent for other logics. Send an ATLF model as an ordinary CGS file with labels in [0,1].result: the checker's result text. Its layout depends on the request, for example a tuple of states without a trace and a set with a trace, so readverificationinstead.error_details: present whensuccessisfalse, with acode, amessageand acategory.trace: the witness or counterexample, when requested and supported.execution_time,formulaandlabel(the batch label, if any).
Batch formulas¶
/execute-batch returns a list of ModelCheckResult, one per formula. The list is not in the
order you wrote: results for formulas that use undefined propositions come first. Match
results to formulas by label or formula. A text with only comments gives an empty list.
Write the formulas field as statements:
- End each statement with
;. The last statement may omit it. - At most one
;per line, and nothing after it. A second statement on the same line fails with "Line N: Text found after formula terminator (';'). Only one formula allowed per line."; two;on one line fail with "Multiple formulas (terminators) found on the same line." - A statement may span several lines.
- An optional label goes before the formula:
label: formula;. Labels and formula bodies must be unique in the batch. - Comments start with
#or//and may also follow a statement on its line.
A statement-format error comes back as HTTP 200 with a one-item list whose
error_details.code is formula_split_error. Example, with the statements in
formulas.txt (reach: EF p; and safe: AG !q;, one per line):
curl -sS -X POST "http://localhost:8001/api/v1/model-checking/execute-batch" \
-F "file=@model.txt" \
-F "logic=CTL" \
-F "formulas=<formulas.txt"
Synthesize a strategy¶
ATL_STAR is the id that GET /logics lists for ATL, an alternating-time temporal logic. In
ATL a coalition takes any path formula, so temporal operators and coalitions can be nested
under it. For this logic /execute says whether a
formula holds. /synthesize-strategy also returns the strategy behind a yes: the rule that tells
the coalition (the agents named in <<...>>) which action to play so the formula holds whatever
the other agents do. The route has no logic field, because ATL_STAR is the only logic that
supports it. It takes multipart/form-data:
file(required): the model file, a concurrent game structure (CGS).formula(required): one ATL* formula whose outermost operator is a single coalition, with no coalition nested inside it, such as<<1>> F goal. With several statements only the first is used, as in/execute.state(optional): the name of the state to synthesize at, as in the model'sName_Statesection (for examples1). The default is the model's initial state.
Example, with the bundled model for this logic:
curl -sS -X POST "http://localhost:8001/api/v1/model-checking/synthesize-strategy" \
-F "file=@vitamin_api/examples/CGS/ATL_STAR/atl_star_nested_coalition_2agents_2states.txt" \
-F "formula=<<1>> X goal"
The response is a StrategySynthesisResult; read success first. Its main fields:
success:truewhen the check finished,falsewhen it did not.satisfied: whether the formula holds at the state.strategy: present only whensatisfiedistrue, with the three fields below.error_details: present whensuccessisfalse, as in/execute.result,initial_state,execution_timeandformula: the checker's result text, the verdict text for the state (for exampleState s0: True), the seconds taken and the checked formula.
A position is a model state plus the strategy's memory. The memory identifies a state of the
automaton that the checker builds from the formula to track the path so far. A strategy can play
differently at one model state depending on that automaton state, so the state alone does not
identify a position. Memory values are labels, so compare them only for equality; 0 does not
mean the start of the path. The strategy object holds only the positions reachable from
start:
start: the starting position,{"state", "memory"}.moves: for each reachable position, the action each coalition agent plays (state,memory,agent,action).transitions: every real successor of a position. The coalition fixes only its own actions, so a position has one transition per response of the agents outside the coalition. Each has asourceposition, ajoint_action(a list of{"agent", "action"}for every agent) and atargetposition.
To play the strategy, start at start and play the actions that moves lists for the current
position. After the other agents respond, find the transition from this position whose
joint_action matches what was played, and continue from its target.
For <<1>> X goal on the model above, the response starts like this. The moves and
transitions for state s1 are omitted, and IDLE and O are the names the checker gives
to agent 2's actions:
{
"success": true,
"satisfied": true,
"strategy": {
"start": {"state": "s0", "memory": 1},
"moves": [{"state": "s0", "memory": 1, "agent": 1, "action": "a"}],
"transitions": [
{
"source": {"state": "s0", "memory": 1},
"joint_action": [{"agent": 1, "action": "a"}, {"agent": 2, "action": "IDLE"}],
"target": {"state": "s1", "memory": 0}
},
{
"source": {"state": "s0", "memory": 1},
"joint_action": [{"agent": 1, "action": "a"}, {"agent": 2, "action": "O"}],
"target": {"state": "s1", "memory": 0}
}
]
}
}
A formula that does not hold gives success=true, satisfied=false and no strategy. A
formula the synthesis does not support and a state that is not in the model give HTTP 200 with
success=false and the code SEMANTIC_ERROR; read error_details.message to tell the two
apart. A formula is unsupported when its outermost operator is not a single coalition, or when
it nests a coalition inside another, such as <<1>> F (<<2>> G goal). The route also returns
SYNTAX_ERROR for a formula that does not parse, and model_logic_incompatible,
formula_split_error, undefined_atomic_propositions, empty_input and TIMEOUT as
described in the next section.
Errors and limits¶
Table 5: HTTP status codes.
| Status | Meaning |
|---|---|
| 200 | The request completed. Read success, verification.is_satisfied (satisfied for /synthesize-strategy) and error_details in the body |
| 400 | A value was rejected: for example schedule other than space or time for NatSL, any other invalid value, or a form text field larger than 1024 KB |
| 401 | Missing bearer token when auth is enabled |
| 403 | Invalid bearer token |
| 422 | Request validation failed: a missing or wrongly typed field, or an unknown logic |
| 429 | Rate limit exceeded |
| 500 | Server error |
Problems with the check itself return 200 with success=false and an error_details.code.
The execute routes and /synthesize-strategy set these codes:
model_logic_incompatible: the logic needs another model type.formula_split_error: the formula text could not be split into formulas, for example a duplicate label, an empty formula or text after;on the same line;error_details.details.linegives the line when the message names one.undefined_atomic_propositions: the formula names a proposition the model does not declare.empty_input:/executegot a formula that is only whitespace or comments (a missing field is a 422).TIMEOUT: the check ran out of time.
Checker failures add their own codes.
For undefined_atomic_propositions, error_details.details lists the undefined and
available names. A name that is a temporal operator glued to declared names, such as
Fgoal or pUq when the model declares goal, p and q, also gets a suggestions
object that maps it to the spaced form ({"Fgoal": "F goal", "pUq": "p U q"}), because an
operator is a word of its own and Fgoal is read as one name. The message repeats the
suggestion.
Limits depend on the server configuration. With the settings templates in the repository:
- Rate limit per client IP, then 429: 10 requests per minute for
/execute,/execute-batchand/synthesize-strategy, and 30 per minute for/export/pdfand/parse-model-upload. The other model-checking routes are not rate limited. - Time limit:
MODEL_CHECKER_TIMEOUTper check, orMODEL_CHECKER_TRACE_TIMEOUTwithgenerate_trace=true; 1800 s for both when the server sets none (the env templates set 280 s)./synthesize-strategyhas nogenerate_tracefield and always usesMODEL_CHECKER_TIMEOUT. A formula that runs out of time givesTIMEOUTfor that formula. A batch also has the same limit as a whole: if it takes longer, the response is a list with a singleTIMEOUTresult.
Use GET /graph/limits for the graph size bounds on a given deployment.