aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarcos Magueta <maguetamarcos@gmail.com>2026-02-06 20:18:17 -0300
committerGitHub <noreply@github.com>2026-02-06 20:18:17 -0300
commitbaca3a79cded23329ba8555afefb5590b679c955 (patch)
tree7d3566cf3ad4fc76621fee784a915f1a7b60b18a /src
parenta138f1c57ef376a3f2521ce1f8877ed97bc3e654 (diff)
downloadSakura-baca3a79cded23329ba8555afefb5590b679c955.tar.gz
Sakura-baca3a79cded23329ba8555afefb5590b679c955.zip
Fix comparison relation order, rebranding & roadmap (#50)
Diffstat (limited to '')
-rw-r--r--src/constraint.erl75
-rw-r--r--src/operations.erl2
-rw-r--r--src/repl.erl10
-rw-r--r--src/xml_server_app.erl6
4 files changed, 46 insertions, 47 deletions
diff --git a/src/constraint.erl b/src/constraint.erl
index 24b5fa7..0562f49 100644
--- a/src/constraint.erl
+++ b/src/constraint.erl
@@ -23,12 +23,12 @@
validate_tuple/3,
validate_tuple_against_schema/3,
build_membership_criteria/2,
- lt/1, % value < X
- lte/1, % value <= X
- gt/1, % value > X
- gte/1, % value >= X
- eq/1, % value = X
- neq/1, % value != X
+ lt/2, % value < X
+ lte/2, % value <= X
+ gt/2, % value > X
+ gte/2, % value >= X
+ eq/2, % value = X
+ neq/2, % value != X
between/2, % Min <= value < Max
%% Constraint Propagation
empty_constraints/0, % Create empty #relation_constraints{}
@@ -132,9 +132,9 @@ equal(DomainName, Cardinality) ->
constraints = #{},
%% The diagonal has the same cardinality as the domain itself
cardinality = Cardinality,
- generator = {comparison, '==', DomainName},
+ generator = {comparison, '=:=', DomainName},
membership_criteria = #{
- intension => fun(#{left := L, right := R}) -> L == R end
+ intension => fun(#{left := L, right := R}) -> L =:= R end
},
provenance = undefined,
lineage = {base, equal}
@@ -551,44 +551,44 @@ build_membership_criteria(Database, Schema) ->
%% @doc Create a "less than" constraint: value &lt; X
%%
%% Expressed relationally as: (value, X) ∈ less_than
--spec lt(term()) -> relational_constraint().
-lt(Value) ->
- {member_of, less_than, #{left => {var, value}, right => Value}}.
+-spec lt(term(), term()) -> relational_constraint().
+lt(Left, Right) ->
+ {member_of, less_than, #{left => Left, right => Right}}.
%% @doc Create a "less than or equal" constraint: value &lt;= X
--spec lte(term()) -> relational_constraint().
-lte(Value) ->
- {member_of, less_than_or_equal, #{left => {var, value}, right => Value}}.
+-spec lte(term(), term()) -> relational_constraint().
+lte(Left, Right) ->
+ {member_of, less_than_or_equal, #{left => Left, right => Right}}.
%% @doc Create a "greater than" constraint: value &gt; X
%%
-%% Expressed relationally as: (X, value) ∈ less_than
--spec gt(term()) -> relational_constraint().
-gt(Value) ->
- {member_of, less_than, #{left => Value, right => {var, value}}}.
+%% Expressed relationally as: (X, value) ∈ greater_than
+-spec gt(term(), term()) -> relational_constraint().
+gt(Left, Right) ->
+ {member_of, greater_than, #{left => Left, right => Right}}.
%% @doc Create a "greater than or equal" constraint: value &gt;= X
--spec gte(term()) -> relational_constraint().
-gte(Value) ->
- {member_of, less_than_or_equal, #{left => Value, right => {var, value}}}.
+-spec gte(term(), term()) -> relational_constraint().
+gte(Left, Right) ->
+ {member_of, greater_than_or_equal, #{left => Left, right => Right}}.
%% @doc Create an "equal" constraint: value = X
--spec eq(term()) -> relational_constraint().
-eq(Value) ->
- {member_of, equal, #{left => {var, value}, right => Value}}.
+-spec eq(term(), term()) -> relational_constraint().
+eq(Left, Right) ->
+ {member_of, equal, #{left => Left, right => Right}}.
%% @doc Create a "not equal" constraint: value != X
--spec neq(term()) -> relational_constraint().
-neq(Value) ->
- {member_of, not_equal, #{left => {var, value}, right => Value}}.
+-spec neq(term(), term()) -> relational_constraint().
+neq(Left, Right) ->
+ {member_of, not_equal, #{left => Left, right => Right}}.
%% @doc Create a range constraint: Min &lt;= value &lt; Max
%%
%% This is a conjunction of two relational constraints:
-%% (Min, value) ∈ less_than_or_equal AND (value, Max) ∈ less_than
+%% (Min, value) ∈ greater_than_or_equal AND (value, Max) ∈ less_than
-spec between(term(), term()) -> relational_constraint().
between(Min, Max) ->
- {'and', [gte(Min), lt(Max)]}.
+ {'and', [gte({var,value}, Min), lt({var, value}, Max)]}.
%%% Constraint Propagation
%%%
@@ -788,13 +788,12 @@ rename_vars_in_constraint({'not', Constraint, Universe}, Mappings) ->
rename_vars_in_constraint(Other, _Mappings) ->
Other.
-%% Helper: convert declarative operator to relational constraint
-op_to_constraint(lt, Value) -> lt(Value);
-op_to_constraint(lte, Value) -> lte(Value);
-op_to_constraint(gt, Value) -> gt(Value);
-op_to_constraint(gte, Value) -> gte(Value);
-op_to_constraint(eq, Value) -> eq(Value);
-op_to_constraint(neq, Value) -> neq(Value);
+op_to_constraint(lt, Value) -> lt({var, value}, Value);
+op_to_constraint(lte, Value) -> lte({var, value}, Value);
+op_to_constraint(gt, Value) -> gt({var, value}, Value);
+op_to_constraint(gte, Value) -> gte({var, value}, Value);
+op_to_constraint(eq, Value) -> eq({var, value}, Value);
+op_to_constraint(neq, Value) -> neq({var, value}, Value);
op_to_constraint(between, {Min, Max}) -> between(Min, Max);
op_to_constraint(_, _Value) -> {'and', []}. % No-op constraint
@@ -987,8 +986,8 @@ example() ->
DB = operations:create_database(test_db),
maps:keys(DB#database_state.relations),
{DB1, _} = operations:create_relation(DB, employees, #{id => integer, name => string, age => integer, salary => integer}),
- IdConstraint = constraint:create_1op(id, integer, [constraint:gt(0)]),
- AgeConstraint = constraint:create_1op(age, integer, [constraint:gte(18), constraint:lt(70)]),
+ IdConstraint = constraint:create_1op(id, integer, [constraint:gt({var, value}, 0)]),
+ AgeConstraint = constraint:create_1op(age, integer, [constraint:gte({var, value}, 18), constraint:lt({var,value}, 70)]),
SalaryConstraint = constraint:create_1op(salary, integer, [constraint:between(30000, 200000)]),
C1 = constraint:add_attribute_constraint(undefined, id, IdConstraint),
C2 = constraint:add_attribute_constraint(C1, age, AgeConstraint),
diff --git a/src/operations.erl b/src/operations.erl
index f4143c8..0462034 100644
--- a/src/operations.erl
+++ b/src/operations.erl
@@ -1,6 +1,6 @@
%%% @doc Extended Relational Database Operations (RM/T)
%%%
-%%% This module implements core database operations for Domino, an extended
+%%% This module implements core database operations for Sakura, an extended
%%% relational database engine based on E. F. Codd's RM/T (1979).
%%%
%%% == Architecture ==
diff --git a/src/repl.erl b/src/repl.erl
index 599d721..b26a418 100644
--- a/src/repl.erl
+++ b/src/repl.erl
@@ -1,4 +1,4 @@
-%%% @doc Interactive REPL Helper for Domino Query Planner
+%%% @doc Interactive REPL Helper for Sakura Query Planner
%%%
%%% Provides convenience functions for working with the query planner
%%% in the Erlang shell (REPL). Includes utilities for pretty-printing
@@ -69,7 +69,7 @@
%%% Public API
-%% @doc Start the Domino system and initialize Mnesia.
+%% @doc Start the Sakura system and initialize Mnesia.
%%
%% Call this first when starting a new REPL session.
%%
@@ -78,7 +78,7 @@
start() ->
main:setup(),
io:format("~n~s~n", [banner()]),
- io:format("Domino REPL started. Type repl:help() for usage.~n~n"),
+ io:format("Sakura REPL started. Type repl:help() for usage.~n~n"),
ok.
%% @doc Create an example database with sample data.
@@ -243,7 +243,7 @@ pretty(Results) ->
-spec help() -> ok.
help() ->
io:format("~n~s~n~n", [banner()]),
- io:format("Domino Query REPL - Lisp-inspired tuple-based query language~n~n"),
+ io:format("Sakura Query REPL - Lisp-inspired tuple-based query language~n~n"),
io:format("Quick Start:~n"),
io:format(" repl:start(). %% Initialize system~n"),
io:format(" DB = repl:example_db(). %% Create example database~n"),
@@ -321,6 +321,6 @@ help() ->
banner() ->
"========================================\n"
- " Domino - Extended Relational DB\n"
+ " Sakura - Extended Relational DB\n"
" Tasmania / RM/T Implementation\n"
"========================================".
diff --git a/src/xml_server_app.erl b/src/xml_server_app.erl
index b7b9faa..51a9565 100644
--- a/src/xml_server_app.erl
+++ b/src/xml_server_app.erl
@@ -11,9 +11,9 @@ start() ->
%% @doc Start XML server on specified port.
start(Port) ->
- % Initialize Domino
+ % Initialize Sakura
main:setup(),
- io:format("~nDomino initialized~n"),
+ io:format("~nSakura initialized~n"),
% Create example database
DB = repl:example_db(),
@@ -23,6 +23,6 @@ start(Port) ->
io:format("~nXML Server ready!~n"),
io:format("Connect with: nc localhost ~p~n", [Port]),
- io:format("Or run Emacs client: M-x domino-run-examples~n~n"),
+ io:format("Or run Emacs client: M-x sakura-run-examples~n~n"),
ok.