Calculated Column Index in SWI-Prolog

In SQL I can add a calculated column to my table:

ALTER TABLE MyTable
Add Column CodeHead As LEFT(Code,Len(Code)-4)

Then create an index on it:

CREATE INDEX CodeHeadIdx ON MyTable.CodeHead

Can I do the same in SWI-Prolog? But with a twist, I don’t
want to see the computed column in the data, it should
be a kind of hidden column. Some problem is a call goal

might not be enough instantiated to even compute the
hidden column. So I even don’t know how a customization
should work. But I think some Prolog systems offered

a mechanism in library(record) or something? For example
used for inverse indexes.

This is called “index on expression”, as documented for example for PostgreSQL and SQLite.