NAME

Logic::Relational::Variable - Represents a logical variable in the logic engine.

SYNOPSIS

use Logic::Relational::Variable;
my $var = Logic::Relational::Variable->new(name => 'X');
say $var->id;   # unique integer ID
say $var->name; # X

DESCRIPTION

Logic::Relational::Variable represents a logical variable. Each variable has a unique internal ID to distinguish it from other variables, even if they share the same display name.

METHODS

new

Constructor. Takes name (optional) and id (optional). If id is omitted, a unique integer ID is allocated from a global counter.

id

Returns the unique integer ID.

name

Returns the display name of the variable.

as_string

Returns a string representation of the variable, formatting it with its name and ID.

freshen

Takes a variable mapping hash reference. If this variable's ID is not present in the mapping, a new variable with the same name and a fresh ID is created and stored in the mapping. Returns the mapped variable.