Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse handle_query prover functions. #2503

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

chriseth
Copy link
Member

@chriseth chriseth commented Feb 19, 2025

Parses query / prover functions of the form

 query |<i>| std::prover::handle_query(<Y>, <i>, match std::prover::eval(<pc>) {
   <value1> => std::prelude::Query::Output(std::convert::int::<fe>(std::prover::eval(<arg1>)), std::prover::eval(<arg2>)),
   <value2> => std::prelude::Query::Input(std::convert::int::<fe>(std::prover::eval(<arg1>)), std::convert::int::<fe>(std::prover::eval(<arg2>))),
   ...
   _ => std::prelude::Query::None,

i.e. the ones used for "free input" columns.

@chriseth chriseth force-pushed the handle_query_prover_functions branch from e58288a to 1e27b18 Compare February 20, 2025 11:06
@chriseth chriseth force-pushed the handle_query_prover_functions branch from 1e27b18 to 7ccd1b4 Compare February 20, 2025 11:16
@chriseth chriseth marked this pull request as ready for review February 20, 2025 12:28
@chriseth chriseth changed the title Support handle_query prover functions. Parset handle_query prover functions. Feb 20, 2025
@chriseth chriseth changed the title Parset handle_query prover functions. Parse handle_query prover functions. Feb 20, 2025
@@ -36,12 +38,23 @@ pub enum ProverFunctionComputation<'a> {
/// The expression `f` in `query |i| std::prover::compute_from(Y, i, [X, ...], f)`,
/// where f: (fe[] -> fe)
ComputeFrom(&'a Expression),
/// Represents a call to `handle_query` (see `try_decode_handle_query`), where the
/// keys are the pc values (the first input column). The two two arguments to both input
Copy link
Collaborator

Choose a reason for hiding this comment

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

"two two arguments"

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this comment is missing some context here (not sure what "two arguments" or "input columns" are referring to)... maybe it should be elsewhere or have a bit more context?

{
Ok(provide_if_unknown)
let results = [
try_decode_provide_if_unknown(index, function, try_symbol_by_name),
Copy link
Collaborator

Choose a reason for hiding this comment

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

very minor, but this way its always evaluating all three, instead of stopping on the first success... if the functions have the same signature, maybe its possible to do something like [try_func1, try_func2, try_func3].iter().map(|f| f(...))?

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.

2 participants