kdrag.solvers.tla

Automatically downloads tla2tools.jar

Module Attributes

consts

But really this should be module defined = ( { "$IfThenElse", "$BoundedForall", "$BoundedExists", "$SetOfRcds", "$FcnConstructor", "$FcnApply", "$SetEnumerate", "$RcdConstructor", }.union(consts.keys()) .union(binops.keys()) .union(unops.keys()) .union(comp.keys()) ) def is_defined(f: App) -> bool: if

Functions

apalache_check(filename[, init, next_, inv])

Run the model checker on a tla file.

assoc_list(pairs)

Convert a list of pairs to a dictionary.

check(filename[, check_deadlock, continue_, ...])

Run the model checker on a tla file.

domain(e)

install_apalache()

pluscal_translate(filename)

Run the pluscal translator on a tla file.

prime(e)

run_apalache(args)

Run apalache with the given arguments.

run_tools(args)

Run tla2tools.jar with the given arguments.

tla_to_xml(filename)

Convert tla file to xml output

Classes

App(f, args)

Untyped Ast for expressions

Module(name, variables, definitions, ...)

A TLA+ Module.

StringLit(value)

Exceptions

SortInference

class kdrag.solvers.tla.App(f: object, args: list[App])

Bases: object

Untyped Ast for expressions

Parameters:
  • f (object)

  • args (list[App])

all_decls() → set[str]
Return type:

set[str]

args: list[App]
f: object
infer_lite() → SortRef | None
Return type:

SortRef | None

is_binder()
is_const()
is_value()
class kdrag.solvers.tla.Module(name: str, variables: list[str], definitions: dict[str, ~kdrag.solvers.tla.App], def_params: dict[str, list[str]], theorems: list[~kdrag.solvers.tla.App], decls: dict[str, ~z3.z3.FuncDeclRef] = <factory>)

Bases: object

A TLA+ Module. Build it from a file using Module.of_file(filename) or from a string using Module.of_string(string).

mod.infer_sorts() will automatically try to infer the sorts of all variables. It may be preferable to manually declare them as these sorts are part of the spec.

Parameters:
  • name (str)

  • variables (list[str])

  • definitions (dict[str, App])

  • def_params (dict[str, list[str]])

  • theorems (list[App])

  • decls (dict[str, FuncDeclRef])

Var(name: str, sort: SortRef) → ExprRef
Parameters:
  • name (str)

  • sort (SortRef)

Return type:

ExprRef

action(actname: str, decls: dict[str, FuncDeclRef | ExprRef] = {}) → ExprRef

Return the action of the module as an smt expression. These are expressions that may involve primed variables, but do not involve other temporal operators.

Parameters:
  • actname (str)

  • decls (dict[str, FuncDeclRef | ExprRef])

Return type:

ExprRef

apply(name, *args: ExprRef) → ExprRef
Parameters:

args (ExprRef)

Return type:

ExprRef

behavior(name: str, decls: dict[str, FuncDeclRef | ExprRef]) → ExprRef

Return a useful smt form of statements that involve non trivial temporal operators

Parameters:
  • name (str)

  • decls (dict[str, FuncDeclRef | ExprRef])

Return type:

ExprRef

declare_operator(name: str, *sorts: SortRef)
Parameters:
  • name (str)

  • sorts (SortRef)

declare_var(v: ExprRef)
Parameters:

v (ExprRef)

declare_vars(vs: list[ExprRef])
Parameters:

vs (list[ExprRef])

decls: dict[str, FuncDeclRef]
def_params: dict[str, list[str]]
definitions: dict[str, App]
infer_sorts()
invariant(inv=None, init=None, step=None)
name: str
static of_file(filename, pcal=False) → Module
Return type:

Module

operator(name: str, decls: dict[str, FuncDeclRef | ExprRef] = {}, sort=None) → ExprRef
Parameters:
  • name (str)

  • decls (dict[str, FuncDeclRef | ExprRef])

Return type:

ExprRef

theorems: list[App]
to_smt(e: App, decls: Mapping[str, FuncDeclRef | ExprRef], sort=None) → ExprRef
Parameters:
  • e (App)

  • decls (Mapping[str, FuncDeclRef | ExprRef])

Return type:

ExprRef

variables: list[str]
vars() → list[ExprRef]
Return type:

list[ExprRef]

vars1() → list[ExprRef]
Return type:

list[ExprRef]

exception kdrag.solvers.tla.SortInference

Bases: Exception

add_note(object, /)

Exception.add_note(note) – add a note to the exception

args
with_traceback(object, /)

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

class kdrag.solvers.tla.StringLit(value: str)

Bases: object

Parameters:

value (str)

value: str
kdrag.solvers.tla.apalache_check(filename: str, init=None, next_=None, inv=None)

Run the model checker on a tla file. Returns the stdout of the model checker.

Parameters:

filename (str)

kdrag.solvers.tla.assoc_list(pairs: list[App]) → dict[str, App]

Convert a list of pairs to a dictionary. Each pair is an App with two arguments.

Parameters:

pairs (list[App])

Return type:

dict[str, App]

kdrag.solvers.tla.check(filename: str, check_deadlock=True, continue_=False, inv=None, config=None)

Run the model checker on a tla file. Returns the stdout of the model checker.

Parameters:

filename (str)

kdrag.solvers.tla.consts: dict[object, ExprRef] = {'BOOLEAN': K(Bool, True), 'FALSE': False, 'TRUE': True}

But really this should be module defined = (

{

“$IfThenElse”, “$BoundedForall”, “$BoundedExists”, “$SetOfRcds”, “$FcnConstructor”, “$FcnApply”, “$SetEnumerate”, “$RcdConstructor”,

}.union(consts.keys()) .union(binops.keys()) .union(unops.keys()) .union(comp.keys())

) def is_defined(f: App) -> bool:

if

kdrag.solvers.tla.domain(e: ExprRef) → SortRef
Parameters:

e (ExprRef)

Return type:

SortRef

kdrag.solvers.tla.install_apalache()
kdrag.solvers.tla.pluscal_translate(filename: str) → bytes

Run the pluscal translator on a tla file. Returns the stdout of the translator.

Parameters:

filename (str)

Return type:

bytes

kdrag.solvers.tla.prime(e: ExprRef) → ExprRef
Parameters:

e (ExprRef)

Return type:

ExprRef

kdrag.solvers.tla.run_apalache(args: list[str])

Run apalache with the given arguments. Returns the stdout of the process.

Parameters:

args (list[str])

kdrag.solvers.tla.run_tools(args: list[str])

Run tla2tools.jar with the given arguments. Returns the stdout of the process.

Parameters:

args (list[str])

kdrag.solvers.tla.tla_to_xml(filename)

Convert tla file to xml output