-
Notifications
You must be signed in to change notification settings - Fork 660
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
[Feature] Primitive Type Circuits #975
Comments
Can someone clarify for me if we're writing everything into an R1CS circuit at the moment? |
@howardwu Do you mean, are we compiling with R1CS circuit as a target? Yes. Not sure if I understood the question. |
@howardwu I think the idea is to parse as a circuit for semantic reasons and make it easier and more maintainable to implement methods and static variables on types. However, we could still target the basic underlying type as far as R1CS. |
I believe that the main reason for this is to have the following associated to built-in types like
I'm mainly talking about the user's view here, not necessarily the implementation. In other words, how the Leo documentation should describe and categorize things. Now we have scalar types (consisting of atomic values) and aggregate types (consisting of compound values); circuit types are aggregate types while An important point is that For comparison, Rust has methods for struct types, for enum types, and for built-in types. So the notion of Rust method is orthogonal to the kind of type it refers to. Similarly, Leo could have a notion of method for different kinds of types (circuit, built-ins), without necessarily viewing all the types with methods as circuit types. Same for constants, such as Regarding the AST question, as also discussed (and perhaps agreed?) in a recent meeting, I vote for keeping (essentially) the same representation as we have now for scalar values, i.e. not introducing a "circuit layer", which is isomorphic anyways, and it has to be special because the internal member variable could not have a user-accessible type. On a semi-related note, I've been wondering about the best way to standardize the nomenclature for 'method' vs. 'member function', and 'field' vs. 'member variable' or 'member constant' (we don't have the latter though). We have been avoiding 'field' to avoid confusion with the field type, but it is a fairly standard term. Just bringing all of this up for further thought. |
@acoglio, essentially that's what I have in mind, but it's a bit more complex at a deeper look. The logic would be to still treat them as a circuit in AST and ASG. Otherwise, the code complexity is up a lot. However, we can still write them to theorems and the ir/compiler as their base types. Another complexity would be, though, is how we represent those instance/static methods and constants in the theorems as well. Does that make sense? |
@gluax I agree that it should be implemented in the way that makes things most simple and uniform, as you say; you know best what makes sense for the Leo compiler. I'm mainly thinking of the user-level story and nomenclature. For instance, we could introduce a notion of 'named type' as a type that has a "name", which may be a circuit type or a scalar type, and then say that named types have methods (built-in/predefined for scalar types, user-defined for circuit types). The new ABNF grammar could look like this:
Regarding how to extend the ACL2 formalization of Leo for this (I think this is what you meant by "represent in the theorems"), I would probably introduce this notion of named type in the ACL2 abstract syntax of Leo as well, and use that as the unifying notion for types that have methods (and constants). In other words, the treatment of circuit types and scalar types would be unified by the common notion of being named types. I think that this will work for the ACL2 formalization (we'll find out soon enough if that's not the case), and it might also work for the Leo compiler's Rust implementation, but there may be other considerations for the latter that I ignore. Anyways, something you might at least consider; happy to discuss it more, if of interest. Maybe that was your plan all along, and we are just discussing nomenclature here. Weakly related to the above, is the lexical status of the scalar types. Currently they are keywords, while non- |
This PR is to have a list of requirements and objects for Primitive Type Circuits and goals.
In addition, it will allow people to retroactively review.
Objectives
Parse Primitives Into CircuitInit Expressions
should be roughly parsed as something like initially:
Defining Primitive Circuits
We should discuss how these should work here so to keep it all in line.
The text was updated successfully, but these errors were encountered: