FM FBK
About Contact Download Documentation Publications Applications Links

Kratos2 Python API Reference

API for Kratos2.

Basic Types

Type Objects

class Type(object)

Base class for Kratos Type objects

write

def write(out, bindings=None)

printer in K2 format

__str__

def __str__()

Get a string representation of this type in K2 format.

VoidType Objects

class VoidType(Type)

void type

LabelType Objects

class LabelType(Type)

label type

BoolType Objects

class BoolType(Type)

boolean type

IntType Objects

class IntType(Type)

integer type

RealType Objects

class RealType(Type)

real type

SymbolType Objects

class SymbolType(Type)

symbolic type

BVType Objects

class BVType(Type)

fixed-size bit-vector type.

Attributes:

FPType Objects

class FPType(Type)

IEEE floating-point type.

Attributes:

MapType Objects

class MapType(Type)

map type.

Attributes:

FunctionType Objects

class FunctionType(Type)

function type.

Attributes:

EnumType Objects

class EnumType(Type)

symbolic enum type.

Attributes:

Expr Objects

class Expr(object)

Base class for Kratos expressions.

Attributes:

write

def write(out, indent=None, bindings=None)

Generate a K2 representation of this expression.

Arguments:

__str__

def __str__()

Get a string representation of this type in K2 format.

children

def children()

Return the list of children of this expression.

VarExpr Objects

class VarExpr(Expr)

A var expression.

Attributes:

ConstExpr Objects

class ConstExpr(Expr)

A const expression.

Attributes:

OpExpr Objects

class OpExpr(Expr)

An op expression.

Attributes:

CallExpr Objects

class CallExpr(Expr)

A call expression.

Attributes:

AssignExpr Objects

class AssignExpr(Expr)

An assign expression.

Attributes:

AssumeExpr Objects

class AssumeExpr(Expr)

An assume expression.

Attributes:

TypeCastExpr Objects

class TypeCastExpr(Expr)

A typecast expression.

Attributes:

SeqExpr Objects

class SeqExpr(Expr)

A seq expression.

Attributes:

JumpExpr Objects

class JumpExpr(Expr)

A jump expression.

Attributes:

LabelExpr Objects

class LabelExpr(Expr)

A label expression.

Attributes:

HavocExpr Objects

class HavocExpr(Expr)

A havoc expression.

Attributes:

CondJumpExpr Objects

class CondJumpExpr(Expr)

A condjump expression.

Attributes:

ExprVisitor Objects

class ExprVisitor(object)

A generic visitor for expressions. The visitor works by calling a method visit_ClassName for visiting expression of type ClassName. If no such method exists, generic_visit is called. The methods must accept a single argument, the expression to visit. Each method should call self.visit(c) recursively on each child c that needs to be visited.

visit

def visit(expr)

visitor entry point.

Arguments:

generic_visit

def generic_visit(expr)

generic visitor function, which simply visits all the children of the input expression.

Arguments:

IdentityVisitor Objects

class IdentityVisitor(ExprVisitor)

A subclass of ExprVisitor that builds a copy of the input expression

InplaceIdentityVisitor Objects

class InplaceIdentityVisitor(IdentityVisitor)

A subclass of IdentityVisitor that modifies the input expression in-place.

Function Objects

class Function(object)

A Kratos function.

Attributes:

__str__

def __str__()

Get a string representation of this function in K2 format.

write

def write(out, bindings=None)

Write a K2 representation of the function to the file-like out.

Arguments:

get_const

def get_const()

Get the const expression for this function.

get_type

def get_type()

Get the type of this function.

is_param

def is_param(name)

Return true if name is a name of one of the function parameters.

is_return_var

def is_return_var(name)

Return true if name is a name of one of the function return vars.

is_local

def is_local(name)

Return true if name is a name of one of the function local vars.

is_own

def is_own(name)

Return true if name is a parameter, return var or local var.

get_param

def get_param(name)

Get the parameter with the given name. Raise KeyError if not found.

get_local

def get_local(name)

Get the local var with the given name. Raise KeyError if not found.

get_return_var

def get_return_var(name)

Get the return var with the given name. Raise KeyError if not found.

get_own

def get_own(name)

Get the parameter, local var or return var with the given name. Raise KeyError if not found.

copy

def copy()

Return a copy of this function.

Program Objects

class Program(object)

A Kratos program.

Attributes:

__str__

def __str__()

Get a string representation of this program in K2 format.

write

def write(out)

Write a K2 representation of the program to the file-like out.

Arguments:

is_global

def is_global(name)

Returns true if name is the name of a global var of this program.

get_global

def get_global(name)

Get the global var with the given name. Raise KeyError if not found.

get_function

def get_function(name)

Get the function with the given name. Raise KeyError if not found.

copy

def copy()

Return a copy of this program.

ExecutionStep Objects

class ExecutionStep(object)

A step of a Kratos execution trace.

Arguments:

write

def write(out, indent=0)

Write a K2 representation of the execution step to the file-like out.

Arguments:

copy

def copy()

Return a copy of this execution step.

__str__

def __str__()

Get a string representation of this execution step in K2 format.

ExecutionPath Objects

class ExecutionPath(list)

A subpath of a Kratos execution trace.

write

def write(out, indent=0)

Write a K2 representation of the execution path to the file-like out.

Arguments:

copy

def copy()

Return a copy of this execution path.

__str__

def __str__()

Get a string representation of this execution path in K2 format.

Parsing

parse_program

def parse_program(src)

Parse a Program from the given file-like object.

Arguments:

parse_expr

def parse_expr(src)

Parse an Expr from the given file-like object.

Arguments:

parse_execution_path

def parse_execution_path(src)

Parse an ExecutionPath from the given file-like object.

Arguments:

Verification

RESULT_ERROR

error verification result

RESULT_UNKNOWN

unknown verification result

RESULT_SAFE

safe verification result

RESULT_UNSAFE

unsafe verification result

VERIFICATION_MODEL_CHECKING

model checking verification method

VERIFICATION_SYMBOLIC_EXECUTION

symbolic execution verification method

VERIFICATION_SIMULATION

simulation verification method

VerificationResult Objects

class VerificationResult(object)

A Kratos verification result.

Attributes:

encode

def encode(config, program)

Encode a Program into a symbolic transition system.

Arguments:

Returns:

verify

def verify(method, config, program)

Perform verification of the given Kratos program.

Arguments:

Returns:

Utility Functions

get_version

def get_version()

Get the Kratos version information as a string.

VarProvider Objects

class VarProvider(object)

A provider of fresh variables and names.

Attributes:

__init__

def __init__(*scopes)

Constructor.

Arguments:

mkvar

def mkvar(tp, name='$tmp')

Generate a unique var of the given type.

Arguments:

auxvar

def auxvar(tp)

Generate an auxiliary var of the given type. If an aux var of the requested type was already created, it will be reused.

Arguments:

mkname

def mkname(name='$tmp')

Generate a unique name with the given prefix.

Arguments:

get_kratos_executable

def get_kratos_executable()

Returns the full path to the kratos executable. Raises an Exception if the path cannot be determined.