Protobuf Documentation
📝 Description
This module implements a Prolog logic interpreter (go-native) and its unification algorithm to evaluate logical expressions against the current state of the blockchain.
This distinctive module allows for the creation of advanced, goal-oriented queries and logical systems that can be applied to a wide range of use cases, while still maintaining the determinism and predictability of blockchain technology. It also features a collection of predefined, blockchain-specific predicates that can be used to access information about the state of the blockchain.
Concepts
Program
A program is a text that is parsed and compiled by the interpreter. A program is composed of a set of predicates, which are defined by the user and can be used to express the desired query logic.
Predicate
A predicate is a statement that describes a relationship between one or more variables or constants. A predicate consists of a name followed by zero or more arguments.
Rule & Fact
A rule is a statement that describes a relationship between one or more variables or constants, similar to a predicate. However, unlike a predicate, a rule also specifies one or more conditions that must be true in order for the relationship described by the rule to hold.
A rule has the following format:
head :- body.
The symbol :-
is called the "if-then" operator, and it means that the relationship described in the head of the rule
holds only if the conditions in the body are true.
For example:
grandfather(X,Y) :- father(X,Z), father(Z,Y). # X is the grandfather of Y if X is the father of Z and Z is the father of Y.
A fact is a special type of rule that has no body (with no :-
and no conditions). A fact has the following format:
head.
For instance:
father(john, mary). # john is the father of mary.
Variable
A variable is a predicate argument that is used as a placeholder for a value. It can represent any type of data, such as numbers, strings, or lists.
Variables are denoted by a name that starts with an uppercase letter, for example X
or Foo
.
For instance:
father(X, mary). # ask for all X that are the father of mary.
Query
A query is a statement used to retrieve information from the blockchain. It can be sent against a program, but this
is optional. The interpreter evaluates the query and returns the result to the caller. Queries can be submitted to a
module using the Ask
message.