Vadalog supports built-in operations over values of data types. These operations allow to compare values, perform arithmetics, manipulate strings and datetime values. Operations are supported through symbolic operators, which can be prefix, infix or functional-style. Vadalog supports single-fact operators (simply called operators) and multi-facts operators (called aggregation operators).

Single-fact operators

Comparison operators

The comparison operators are ==,>,<,>=,<=,<> (alternate syntax !=). They can be used to compare literals of any data type and return a Boolean, depending whether the comparison is satisfied or not. Only values of the same type can be compared.
  • == : equals to
  • > : greater than
  • < : less than
  • >= : greater or equal
  • <= : less or equal
  • <> : not equal
  • != : not equal
Marked nulls can be compared only with marked nulls, since they are the only ones having unknown data type. Marked nulls are equal when they have the same identifier (i.e. they are the same marked null).

Arithmetic operators

The arithmetic operators are * (multiplication), / (division), + (addition), - (subtraction). Infix *, /, +, - can be applied to all numeric (integer and double) operands, with an implicit upcast to double if any double is involved. The operator + (plus) also performs string concatenation with an implicit upcast to string if any string is involved. The operator - (minus) also exists in its monadic version, which simply inverts the sign of a numeric value. Division by 0 always fails, causing the program to abort. Operations associate to the left, except that multiplication and division operators have higher precedence than addition and subtraction operators. Precedence can be altered with parentheses.

Boolean operators

The Boolean operators are and (&&), or (||) or not. They can be used to combine Boolean data types.

Logical operators

Vadalog supports explicit logical operators as functions in addition to implicit logical operations through rule structure. These explicit operators (and(), or(), not(), etc.) allow for combining and manipulating Boolean expressions within a single rule. The operators can evaluate complex logical conditions and can be assigned to variables for further processing. Key distinction:
  • Implicit AND/OR: Multiple conditions in a rule body are implicitly AND-ed. Multiple rules with the same head represent OR.
  • Explicit operators: Functions like and(), or(), not(), xor(), if() allow complex boolean logic within expressions and can be assigned to variables.
Available explicit logical operators:
  • and(args) - Logical AND of multiple conditions
  • or(args) - Logical OR of multiple conditions
  • not(expression) - Logical NOT/negation
  • xor(expression1, expression2) - Exclusive OR
  • nand(expression1, expression2) - NOT AND
  • nor(expression1, expression2) - NOT OR
  • xnor(expression1, expression2) - Exclusive NOR
  • implies(expression1, expression2) - Logical implication
  • iff(expression1, expression2) - If and only if
  • if(condition, true_value, false_value) - Conditional expression

and(args)

The and(args) operator evaluates to true if all the conditions in args are true. You can assign the result to a variable and use ==#T to enforce that all conditions must be true. Example 1: Basic and(args) usage This example shows the use of the and(args) operator to evaluate multiple conditions on the variable X. The rule b(X, IsIn) checks if X is greater than 2, less than 5, and equal to 3. The result of this conjunction is stored in IsIn.
Expected output:

or(args)

The or(args) operator evaluates to true if any of the conditions in args are true. You can assign the result to a variable and use ==#T to enforce that at least one condition must be true. Example 2: Basic or(args) usage This example illustrates the use of the or(args) operator to evaluate multiple conditions on the variable X. The rule b(X, IsIn) checks if X is less than 2, equal to 4, or equal to 6. The result of this disjunction is stored in IsIn.
Expected output:

not(expression)

The not(expression) operator negates the Boolean value of the expression. It returns #T if the expression is #F, and #F if the expression is #T. Example 3: Basic not(expression) usage This example demonstrates the use of the not operator to negate a condition.
Expected output:

xor(expression1, expression2)

The xor(expression1, expression2) operator (exclusive or) evaluates to true if exactly one of the two expressions is true, but not both. Example 4: Basic xor(expression1, expression2) usage This example shows the exclusive or operation between two conditions.
Expected output:

nand(expression1, expression2)

The nand(expression1, expression2) operator (not and) evaluates to true if at least one of the expressions is false. Example 5: Basic nand(expression1, expression2) usage This example demonstrates the NAND operation.
Expected output:

nor(expression1, expression2)

The nor(expression1, expression2) operator (not or) evaluates to true only if both expressions are false. Example 6: Basic nor(expression1, expression2) usage This example demonstrates the NOR operation.
Expected output:

xnor(expression1, expression2)

The xnor(expression1, expression2) operator (exclusive nor) evaluates to true if both expressions have the same Boolean value. Example 7: Basic xnor(expression1, expression2) usage This example demonstrates the XNOR operation.
Expected output:

implies(expression1, expression2)

The implies(expression1, expression2) operator (implication) evaluates to false only if the first expression is true and the second is false. Example 8: Basic implies(expression1, expression2) usage This example demonstrates logical implication.
Expected output:

iff(expression1, expression2)

The iff(expression1, expression2) operator (if and only if) evaluates to true if both expressions have the same Boolean value. Example 9: Basic iff(expression1, expression2) usage This example demonstrates the if and only if operation.
Expected output:

if(condition, true_value, false_value)

The if(condition, true_value, false_value) operator provides conditional logic. It returns true_value if the condition is true, otherwise it returns false_value. Example 10: Basic if(condition, true_value, false_value) usage This example demonstrates conditional logic using the if operator to classify numbers as positive or non-positive.
Expected output:
Example 11: String condition with if operator This example uses the if operator to check if a string is empty and return appropriate labels.
Expected output:
Example 12: Null check with if operator This example uses the if operator to check if a string is not null and return appropriate labels.
Expected output:
Example 13: Nested if statements for credit rating This example demonstrates complex nested if statements to implement a credit rating system based on credit scores. Each nested if evaluates a range of credit scores and assigns a corresponding rating value.
Expected output:
Example 14: Using and(args) with condition enforcement In this example, the and(args) operator is used to evaluate conditions on X, and the result is compared to #T to enforce that all conditions must be true. The rule b(X) only succeeds if X is greater than 2, less than 5, and equal to 3.
Expected output:

String operators

The String operators are substring, contains, contains_any, rlike, starts_with, ends_with, concat, concat_ws, +, index_of, string_length, to_lower, to_upper, split, replace, join, is_empty, and strip. These operators allow manipulation and comparison of String values.

substring

A rule using substring returns a substring from the specified start to end index, using zero-based indexing:
Example:
showLineNumbers
Expected output:

contains

A rule with contains returns true if the string contains substring:
Example:
showLineNumbers
Expected output:
contains can also be used directly as a boolean condition in the rule body (see Implicit Boolean Conditions).

starts_with

A rule with starts_with returns true if the string starts with start_string:
Example:
showLineNumbers
Expected output:

ends_with

A rule with ends_with returns true if the string ends with end_string:
Example:
showLineNumbers
Expected output:

contains_any

A rule with contains_any returns true if the string contains any of the keywords in the keywords_array:
Example:
showLineNumbers
Expected output:

rlike

A rule with rlike returns true if the string matches the given regular expression pattern:
Example:
showLineNumbers
Expected output:

concat

A rule with concat returns the concatenation of string and concat_string:
Example:
showLineNumbers
Expected output:

string_length

A rule with string_length returns an integer representing the length of the string. strlen is an accepted alias:
Example:
showLineNumbers
Expected output:

to_lower

A rule with to_lower converts string to lowercase:
Example:
showLineNumbers
Expected output:

to_upper

A rule with to_upper converts string to uppercase:
Example:
showLineNumbers
Expected output:

split

A rule with split divides string by a specified delimiter, producing a list of substrings:
Example:
showLineNumbers
Expected output:

index_of

A rule with index_of finds the index of substring within string, returning -1 if not found:
Example:
showLineNumbers
Expected output:

substring (single parameter)

You can also use substring with a single parameter to get the substring from a starting position to the end:
Example:
showLineNumbers
Expected output:

concat_ws

A rule with concat_ws concatenates strings with a specified separator:
Example:
showLineNumbers
Expected output:

replace

A rule with replace replaces occurrences of a substring with another string:
Example:
showLineNumbers
Expected output:

join

A rule with join joins array elements into a string with a specified delimiter:
Example:
showLineNumbers
Expected output:

is_empty

A rule with is_empty checks if a string is empty or contains only whitespace:
Example:
showLineNumbers
Expected output:

strip

A rule with strip removes leading and trailing whitespace from a string:
Example:
showLineNumbers
Expected output:

Similarity operators

The similarity operators measure how close two strings are, which is useful for fuzzy matching, deduplication, and entity resolution. They live in the similarity: namespace. For the string operators _sim/jaro_winkler/jaccard, 1.0 means identical and 0.0 means completely different. The cosine_sim operators instead operate on numeric vectors (array<double>), typically embeddings produced by embeddings:vectorize — see AI functions.

similarity:levenshtein

A rule with similarity:levenshtein returns the edit distance between two strings: the minimum number of single-character insertions, deletions, or substitutions needed to turn one into the other (0 means identical).
Example:
showLineNumbers
Expected output:

similarity:levenshtein_sim

A rule with similarity:levenshtein_sim returns the normalized edit similarity, computed as 1 - distance / max(length). Two empty strings are defined as fully similar (1.0).
Example:
showLineNumbers
Expected output:

similarity:jaro_winkler

A rule with similarity:jaro_winkler returns the Jaro-Winkler similarity, which boosts the score of strings sharing a common prefix. This makes it well suited to matching short strings such as person or company names.
Example:
showLineNumbers
Expected output:

similarity:jaccard

A rule with similarity:jaccard treats each string as the set of its whitespace-delimited tokens and returns the size of their intersection divided by the size of their union. Two empty token sets are defined as fully similar (1.0).
Example:
showLineNumbers
Expected output:

similarity:cosine_sim

A rule with similarity:cosine_sim returns the cosine similarity between two numeric vectors (arrays of doubles), such as embeddings. similarity:cosine_sim_udf computes the same value via a UDF. See AI functions for generating embeddings with embeddings:vectorize.
Example:
showLineNumbers

Set operators

Vadalog supports set operations on arrays using the union (|) and intersection (&) operators.

Union (|)

The union operator combines two arrays, removing duplicates:
showLineNumbers
Expected output:

Intersection (&)

The intersection operator finds common elements between two arrays:
showLineNumbers
Expected output:

Implicit Boolean Conditions

Boolean-returning functions can be used directly as conditions in rule bodies without explicit comparison to #T. This provides a more natural syntax for filtering.

Direct Boolean Functions as Conditions

showLineNumbers
Expected output:

Negated Boolean Conditions with !

Use ! to negate boolean expressions directly in conditions:
showLineNumbers
Expected output:

Distinction: not vs !

  • not: Used for negating atoms (checking if a predicate doesn’t exist)
  • !: Used for negating boolean expressions
showLineNumbers
Expected output:
Note: Bob is blocked, so doesn’t appear in either output.