Without loss of generality, I think we can craft a virtual namespace where we understand *keys* as predicates over *values*, where a particular value can be checked against a key simply by checking the predicate. Lookups then return sets of values, and we relax slightly referential transparency to simply guarantee that if a particular set `s`

is returned at local time `t`

, the set returned at `t + n`

for any non-negative `n`

will include all elements of `s`

.

Examples of keys-as-predicates:

- the simple content-addressed predicate
`\v -> hash v == h`

for some fixed`h`

- an example unspent resource lookup
`\v -> let r = asResource v in unspentInController c t r`

for a fixed controller`c`

and controller-time`t`

, where`unspentInController`

checks the controller signature, proper format, etc. attesting to the created-but-not-consumed resources at`t`

- a more complex unspent resource lookup which also checks that the resource label is equal to some constant
- a lookup of some particular piece of oracle data, e.g.
`\v -> isOracleFormat v t && checkSignature o v`

for some fixed oracle`o`

and time`t`

A few questions arise here:

- How do we actually encode functions? This one isn’t too difficult; see here. We can also hash the encoded functions for constant-sized keys.
- How do we actually fetch the right data? Obviously not all functions will be easily computable, and in the limit case, we would have to iterate over
*all data*and test the predicate in order to return, which is infeasible. In practice, only a subset of known predicates will be supported - but the relaxed referential transparency guarantee also always allows us to return`{}`

before appropriate indexes for a particular predicate are created. In some cases (e.g. resources at some time), it would be helpful to have affirmative proof that a response is complete.

cc also @mariari @Moonchild