The datalog_ast module

AST for Datalog

class octant.datalog_ast.AST

Base ast (abstract syntax tree) type for octant Datalog

class octant.datalog_ast.Atom(table, args, negated=False, labels=None)

Represents an atom either in the head or body

  • table: a string, the name of the predicate
  • args: ast.Expr list, the arguments of the atom
  • negated: boolean, whether the predicate is negated or not
  • labels: string list, arguments are initially labelled for primitive
    tables
  • types: string list, the types of the arguments (used by typechecker only)
pin_variables(rule_id)

Make variables distinct by adding the rule_id

variables()

Variables of the atom

class octant.datalog_ast.BoolConstant(val)

A boolean constant

Parameters:val – the boolean value (as a bool)
class octant.datalog_ast.Constant(name)

A constant to be substituted

class octant.datalog_ast.Expr(dtype=None)

An abstract expression with an optional

pin_variables(rule_id)

Variable pining

Pinning a variable associates it to a single rule. Default operation on expr is nothing.

variables()

Free variables (default is none)

class octant.datalog_ast.IpConstant(val)

An ip address constant

Parameters:val – ip address represented as a string
class octant.datalog_ast.NumConstant(val, dtype='int')

A numeric constant

class octant.datalog_ast.Operation(oper, args, dtype=None)

An n-ary operation

Parameters:
  • oper – the name of the operation
  • args – the AST of the arguments of the operation
  • type – an optional type constaint.
pin_variables(rule_id)

Variable pining

Pinning a variable associates it to a single rule. Default operation on expr is nothing.

variables()

Free variables (default is none)

class octant.datalog_ast.Rule(head, body)

Represents a rule

body_tables()

All tables used by the rule

body_variables()

Body variables of a rule as a set.

head_table()

Table introduced by the rule

head_variables()

Head variables of a rule

class octant.datalog_ast.StringConstant(val, dtype='string')

A string constant

Parameters:
  • val – the value of the string
  • typ – The type used
class octant.datalog_ast.Variable(ident, dtype=None)

A variable (scope rule)

Parameters:
  • ident – the name of the variable
  • dtype – an optional type constraint
full_id()

Unique name of the variable valid in program scope.

pin_variables(rule_id)

Variable pining

Pinning a variable associates it to a single rule. Default operation on expr is nothing.

variables()

Free variables (default is none)