Skip to content

Finite Field API extension#605

Merged
disteph merged 10 commits intomasterfrom
ff-api-extension
Mar 10, 2026
Merged

Finite Field API extension#605
disteph merged 10 commits intomasterfrom
ff-api-extension

Conversation

@disteph
Copy link
Copy Markdown
Collaborator

@disteph disteph commented Mar 2, 2026

This PR extends the C API with finite-field (ff) term construction/deconstruction/model operations, aligns constructor naming, updates Sphinx docs, and adds API test coverage.

What’s Added

  1. FF type + term constructors
    Added yices_ff_type(mpz_t order) with prime-order validation (INVALID_FFSIZE on non-prime).
    Added FF term constructors:
    yices_ff_const
    yices_ff_add, yices_ff_sub, yices_ff_neg
    yices_ff_mul, yices_ff_square, yices_ff_power
    yices_ff_sum, yices_ff_product
    Added FF atoms:
    yices_ff_eq_atom, yices_ff_neq_atom
    yices_ff_eq0_atom, yices_ff_neq0_atom
  2. FF deconstruction APIs
    Added yices_ff_const_value(term_t t, mpz_t z).
    Split sum deconstruction by theory:
    yices_sum_component(..., mpq_t coeff, ...) is now arithmetic-only.
    Added yices_ffsum_component(..., mpz_t coeff, ...) for FF sums.
  3. Model extension + value extraction
    Added model assignment API:
    yices_model_set_ff_mpz(model_t *model, term_t var, mpz_t val)
    Added model value extraction APIs:
    yices_get_ff_value(model_t *mdl, term_t t, mpz_t val, mpz_t mod)
    yices_val_get_ff(model_t *mdl, const yval_t *v, mpz_t val, mpz_t mod)
  4. Constructor naming cleanup
    Simplified public term-constructor names:
    YICES_FF_CONSTANT (canonical)
    YICES_FF_SUM (canonical)
    Kept compatibility aliases in yices_types.h:
    YICES_ARITH_FF_CONSTANT = YICES_FF_CONSTANT
    YICES_ARITH_FF_SUM = YICES_FF_SUM
  5. Internal/public declarations and docs
    Added matching lock-free o declarations for all new APIs.
    Updated API docs/comments in headers and Sphinx:
    new FF functions
    constructor/tag docs for YICES_FF_CONSTANT, YICES_FF_SUM
    model DAG docs include YVAL_FINITEFIELD
    Removed stale TODO note for YVAL_FINITEFIELD.
  6. Tests
    Added API test: tests/api/test_ff_api.c
    Covers all newly added FF API entry points, including:
    constructors/atoms
    FF const/sum deconstruction
    model assignment and value extraction
    Adjusted to pass both release and debug API test runs.
    Validation
    make check-api (release): PASS
    make YICES_MODE=debug check-api: PASS

@coveralls
Copy link
Copy Markdown

coveralls commented Mar 2, 2026

Coverage Status

coverage: 66.539% (+0.05%) from 66.485%
when pulling 2d69a07 on ff-api-extension
into d2afb85 on master.

@disteph disteph requested a review from ahmed-irfan March 2, 2026 08:04
@disteph
Copy link
Copy Markdown
Collaborator Author

disteph commented Mar 2, 2026

Added a bug fix in src/model/concrete_values.c‎

- v_ff = (value_ff_t *) safe_malloc(sizeof(value_bv_t));
+ v_ff = (value_ff_t *) safe_malloc(sizeof(value_ff_t));

@disteph disteph added this to the Yices 2.8 milestone Mar 2, 2026
==================================== ===========================
:c:enum:`YICES_BOOL_CONSTANT` Boolean constant
:c:enum:`YICES_ARITH_CONSTANT` Arithmetic constant
:c:enum:`YICES_FF_CONSTANT` Finite-field constant
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some spaces missing

Constructor Term
================================ ===========================
:c:enum:`YICES_ARITH_SUM` Arithmetic sum
:c:enum:`YICES_FF_SUM` Finite-field sum
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spaces missing

*
* YICES_BOOL_CONSTANT boolean constant
* YICES_ARITH_CONSTANT rational constant
* YICES_FF_CONSTANT finite-field constant
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spaces missing

*
* YICES_BV_SUM sum of pairs a * t where a is a bitvector constant (and t is a bitvector term)
* YICES_ARITH_SUM sum of pairs a * t where a is a rational (and t is an arithmetic term)
* YICES_FF_SUM sum of pairs a * t where a is a finite-field constant (and t is a finite-field term)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spaces missing

YICES_SCALAR_CONSTANT, // CONSTANT_TERM
YICES_ARITH_CONSTANT, // ARITH_CONSTANT
YICES_ARITH_FF_CONSTANT, // ARITH_FF_CONSTANT
YICES_FF_CONSTANT, // ARITH_FF_CONSTANT
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spaces missing

YICES_POWER_PRODUCT, // POWER_PRODUCT
YICES_ARITH_SUM, // ARITH_POLY
YICES_ARITH_FF_SUM, // ARITH_FF_POLY
YICES_FF_SUM, // ARITH_FF_POLY
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spaces missing

@disteph disteph merged commit 016a624 into master Mar 10, 2026
34 checks passed
daniel-raffler added a commit to daniel-raffler/yices2_java_bindings that referenced this pull request Mar 15, 2026
We're not adding the entire ff API, but just the new constructors. This was necessary as the new constructors changed the values of existing constructors

Adding the rest of the API will have to be done in a separate commit
See SRI-CSL/yices2#605
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants