-
Notifications
You must be signed in to change notification settings - Fork 77
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
Traits for Lookup Tables #131
Comments
Here's an idea for a trait Lookup<Q> {
/// Completion Type
///
/// This type is the corresponding completion for the query type `Q`.
type Completion;
/// Inserts a lookup query into the `compiler` returning the relevant completion for the query.
fn lookup(&self, query: &Q, compiler: &mut StandardComposer) -> Option<Self::Completion>;
} Here's a schematic example: impl Lookup<Summands> for AddTable<3> {
type Completion = Sum;
fn lookup(&self, query: &Summands, compiler: &mut StandardComposer) -> Option<Self::Completion> {
let row = self.find_row(query[0], query[1])?;
compiler.assert_lookup(&self.table, row);
Some(row[2])
}
} In this example, you have an arity-3 table called the This can be made quite general I imagine for lots of kinds of queries. Since However this trait is defined, we should think about how to handle the case of unknown (compile-time) vs known (proving-time) variables. |
I'm working on this now because I want to get better with Rust and traits and I think this is a fairly manageable project to learn with. (But it's no problem if somebody beats me to the punch with a nice Lookup trait that resolves this issue) |
Please go ahead! I don't think this is super urgent and it's good to take careful time designing APIs and definitely a good learning example. |
Currently we have a long and complicated
src/lookup/lookup_table.rs
with a lot of repeated code which generates lookup tables foradd
,mul
, andxor
. As suggested here by @CPerezz we should make a trait for lookup tables and haveadd
,mul
etc implement the trait. This can also address this comment from @bhgomes, as each lookup table can implement its ownlookup
function that knows which columns are to be considered "outputs", if any.The text was updated successfully, but these errors were encountered: