Feat/fst order pred part1 & part2 (#454)

Implement support for first order predicates in the backend.
Now a statement template can have a predicate hash or a wildcard.

## predicate <-> predicate hash constraints

To build the custom predicate table we need to calculate the custom predicate batch id, which uses the serialization of the statement templates before normalization.  This serialization uses the predicate hash when the template uses a predicate (instead of a wildcard).  Then in normalization we recalculate the predicate hash if it was a Batch Self.

This means that the relation between hash and predicate must be checked before and after normalization when the template is not using a wildcard.  How this is achieved:
- Before normalization: the constructor of StatementTmplTarget forces that if we keep a predicate, it's hash must be equal to the pred_hash when the template has a predicate (and not a wildcard)
- After normalization: the predicate hash is calculated in the normalization and replaced in the case of the template using a predicate and it being a BatchSelf.  If it was a predicate but not batch self, the old value was used which was constrained via the constructor.

See `CircuitBuilder::add_virtual_statement_tmpl` and `normalize_st_tmpl_circuit`

## Wildcard predicate resolution

It is done via `make_predicate_from_template_circuit` and is fairly simple as it's contains similar logic to `make_statement_arg_from_template_circuit` but simpler.
This commit is contained in:
Eduard S. 2026-01-20 13:14:22 +01:00 committed by GitHub
parent 1724e7b146
commit 9c9a2c454c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 569 additions and 240 deletions

View file

@ -820,8 +820,12 @@ impl Params {
HASH_SIZE + STATEMENT_ARG_F_LEN * self.max_statement_args
}
pub const fn pred_hash_or_wc_size() -> usize {
1 + HASH_SIZE
}
pub const fn statement_tmpl_size(&self) -> usize {
HASH_SIZE + self.max_statement_args * Self::statement_tmpl_arg_size()
Self::pred_hash_or_wc_size() + self.max_statement_args * Self::statement_tmpl_arg_size()
}
pub fn custom_predicate_size(&self) -> usize {