syntax = "proto3";

package logic.v1beta3;

import "gogoproto/gogo.proto";

option go_package = "github.com/axone-protocol/axoned/x/logic/types";

// Substitution represents a substitution made to the variables in the query to obtain the answer.
message Substitution {
  option (gogoproto.goproto_stringer) = true;

  // variable is the name of the variable.
  string variable = 1 [(gogoproto.moretags) = "yaml:\"variable\",omitempty"];
  // expression is the value substituted for the variable, represented directly as a Prolog term (e.g., atom, number, compound).
  string expression = 2 [(gogoproto.moretags) = "yaml:\"expression\",omitempty"];
}

// Result represents the result of a query.
message Result {
  option (gogoproto.goproto_stringer) = true;

  // error specifies the error message if the query caused an error.
  string error = 5 [
    (gogoproto.nullable) = true,
    (gogoproto.moretags) = "yaml:\"error\",omitempty"
  ];

  // substitutions represent all the substitutions made to the variables in the query to obtain the answer.
  repeated Substitution substitutions = 2 [
    (gogoproto.nullable) = false,
    (gogoproto.moretags) = "yaml:\"substitutions\",omitempty"
  ];
}

// Answer represents the answer to a logic query.
message Answer {
  option (gogoproto.goproto_stringer) = true;

  // has_more specifies if there are more solutions than the ones returned.
  bool has_more = 2 [(gogoproto.moretags) = "yaml:\"has_more\",omitempty"];
  // variables represent all the variables in the query.
  repeated string variables = 3 [(gogoproto.moretags) = "yaml:\"variables\",omitempty"];
  // results represent all the results of the query.
  repeated Result results = 4 [
    (gogoproto.nullable) = false,
    (gogoproto.moretags) = "yaml:\"results\",omitempty"
  ];
}
