Lookup argument

halo2 uses the following lookup technique, which allows for lookups in arbitrary sets, and is arguably simpler than Plookup.

Note on Language

In addition to the general notes on language:

  • We call the polynomial (the grand product argument polynomial for the permutation argument) the "permutation product" column.

Technique Description

We express lookups in terms of a "subset argument" over a table with rows (numbered from 0), and columns and .

The goal of the subset argument is to enforce that every cell in is equal to some cell in . This means that more than one cell in can be equal to the same cell in , and some cells in don't need to be equal to any of the cells in .

  • might be fixed, but it doesn't need to be. That is, we can support looking up values in either fixed or variable tables (where the latter includes advice columns).
  • and can contain duplicates. If the sets represented by and/or are not naturally of size , we extend with duplicates and with dummy values known to be in .
    • Alternatively we could add a "lookup selector" that controls which elements of the column participate in lookups. This would modify the occurrence of in the permutation rule below to replace with, say, if a lookup is not selected.

Let be the Lagrange basis polynomial that evaluates to at row , and otherwise.

We start by allowing the prover to supply permutation columns of and . Let's call these and , respectively. We can enforce that they are permutations using a permutation argument with product column with the rules:

This is a version of the permutation argument which allows and to be permutations of and , respectively, but doesn't specify the exact permutations. and are separate challenges so that we can combine these two permutation arguments into one without worrying that they might interfere with each other.

The goal of these permutations is to allow and to be arranged by the prover in a particular way:

  1. All the cells of column are arranged so that like-valued cells are vertically adjacent to each other. This could be done by some kind of sorting algorithm, but all that matters is that like-valued cells are on consecutive rows in column , and that is a permutation of .
  2. The first row in a sequence of like values in is the row that has the corresponding value in Apart from this constraint, is any arbitrary permutation of .

Now, we'll enforce that either or that , using the rule

In addition, we enforce using the rule

Together these constraints effectively force every element in (and thus ) to equal at least one element in (and thus ). Proof: by induction on prefixes of the rows.

Cost

  • There is the original column and the fixed column .
  • There is a permutation product column .
  • There are the two permutations and .
  • The gates are all of low degree.

Generalizations

halo2's lookup argument implementation generalizes the above technique in the following ways:

  • and can be extended to multiple columns, combined using a random challenge. and stay as single columns.
    • The commitments to the columns of can be precomputed, then combined cheaply once the challenge is known by taking advantage of the homomorphic property of Pedersen commitments.
  • Then, a lookup argument for an arbitrary-width relation can be implemented in terms of a subset argument, i.e. to constrain in each row, consider as a set of tuples (using the method of the previous point), and check that .
    • In the case where represents a function, this implicitly also checks that the inputs are in the domain. This is typically what we want, and often saves an additional range check.
  • We can support multiple tables in the same circuit, by combining them into a single table that includes a tag column to identify the original table.
    • The tag column could be merged with the "lookup selector" mentioned earlier, if this were implemented.

These generalizations are similar to those in sections 4 and 5 of the Plookup paper That is, the differences from Plookup are in the subset argument. This argument can then be used in all the same ways; for instance, the optimized range check technique in section 5 of the Plookup paper can also be used with this subset argument.