-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
copilot-language
: Support modifying values in arrays
#36
Comments
Currently there is no way to construct an array from stream carrying scalars. Having a feature like this (and a similar one for structs) would indeed help a lot, and is worth looking into. |
I wouldn't know how to go about it. I'm thinking about kinds and arities, but I'm not sure we could make it work. |
Update: Someone is working on a feature atm that would allow us to implement this. |
Update: @InnovativeInventor has implemented 'set' or 'update' for arrays, which allows us to implement this. We'll be discussing integrating this into Copilot in the upcoming future. |
Update: similar requests have come up recently related to structs. We are looking into porting the solution that @InnovativeInventor prepared to work for structs and adding both to Copilot. Stay tuned. |
For awareness, we have an open issue #520 that we intend to merge today on updating fields of structs. |
Description Copilot currently supports reading values from streams of arrays, but not changing them. We'd like to be able to modify an array by adjusting the value at a specific position. Type
Additional context None. Requester
Method to check presence of bug Not applicable (not a bug). Expected result Copilot provides a mechanism to update specific values in arrays in an stream of arrays. Desired result Copilot provides a mechanism to update specific values in arrays in an stream of arrays. Proposed solution Extend Extend Further notes None. |
copilot-language
: Support modifying values in arrays
Change Manager: Confirmed that the issue exists. |
Technical Lead: Confirmed that the issue should be addressed. |
Technical Lead: Issue scheduled for Copilot 4. Fix assigned to: @ivanperez-keera. |
… !. Refs Copilot-Language#36. A prior commit has introduced a new symbol (!) as the preferred way to project an element of an array for the purposes of reading it. This commit modifies the pretty printer so that it uses the same notation when printing an expression that projects a value of an array.
…e#36. A prior commit has introduced a new symbol (!) as the preferred way to project an element of an array for the purposes of reading it. This commit modifies all examples involving arrays to use the new notation.
…Language#36. We want to add support to be able to modify values of elements in arrays. In order to provide a uniform interface for arrays and structs, we have decided to unify the syntax for array and struct accessors, so that one operator symbol indicates read access, and doubling the same operator symbol indicates modification access. For example, (!) would indicate accessing an element of an array to consult it, and (!!) would indicate the same but to update it or modify it. The analogous operators for structs would be (#) and (##). At present, the symbol (!!) is being used for an auxiliary function that indexes a list of streams by a stream of indexes. That function is expensive, and rarely used in real specifications. This commit renames such rarely used function, (!!), to avoid a name clash with our desired name for the function to access elements of arrays in streams for the purposes of modifying them.
Copilot-Language#36. Copilot currently supports reading values from arrays, but not changing them. This commit adds a new Op3 that allows array elements to be modified. Co-authored-by: Max Fan <maxwell.y.fan@nasa.gov>
…guage#36. Copilot defines a types for fixed-length arrays, but no way to update them. In order to implement array updates for values in streams, we need to have a mechanism to update values in individual arrays. This commit adds a function to arrays to update a value while preserving the length. Co-authored-by: Max Fan <maxwell.y.fan@nasa.gov>
…n. Refs Copilot-Language#36. Copilot currently supports reading values from arrays, but not changing them. This commit adds a new operation to the high-level Copilot language that allows updating array elements. It relies on a low-level Op3 that captures the correspnding operation in Copilot Core expressions. In order to provide a uniform interface for arrays and structs, we have decided to unify the syntax for array and struct accessors, so that the operator symbol (=:) is used to set the value of individual elements, and (=$) is used to apply a function to values of elements (at each time). To support using the same syntax for both structs and arrays, this commit moves those operators into a new class, defined in a module Copilot.Language.Operators.Projection. The module Copilot.Language.Operators.Struct now uses that module instead of defining the operators locally, and so does the new module Copilot.Language.Operators.Array. Co-authored-by: Max Fan <maxwell.y.fan@nasa.gov>
Copilot currently supports reading values from arrays, but not changing them. This commit adds the translation to C of expressions that update an element of an array. Co-authored-by: Max Fan <maxwell.y.fan@nasa.gov>
…-Language#36. Copilot currently supports reading values from arrays, but not changing them. This commit adds the interpretation in Haskell of expressions that update an element of an array in a stream of arrays. Co-authored-by: Max Fan <maxwell.y.fan@nasa.gov>
…pilot-Language#36. Copilot currently supports reading values from arrays, but not changing them. This commit add support to pretty-print expressions that update elements of an array. Co-authored-by: Max Fan <maxwell.y.fan@nasa.gov>
…age#36. Copilot currently supports reading values from arrays, but not changing them. This commit adds symbolic reasoning support for array update expressions by translating them to What4. The implementation is largely inspired by the existing translation for array index expressions. Because the index in an array update expression can be symbolic, we must build a chain of symbolic if-then-else expressions that check the value of the possibly-symbolic index against all possible concrete index values from `0` to `n - 1` (where `n` is the size of the array).
…lot-Language#36. Previous commits have introduced support to modify individual elements of arrays, either by giving a new stream of values for a position in an array, or by applying a stream function to an element. This commit updates an existing example in the examples/ directory to demonstrate array updates.
…t-Language#36. Previous commits have introduced support to modify individual elements of arrays, either by giving a new stream of values for a position in an array, or by applying a stream function to an element. This commit introduces a new example in the examples/ directory to demonstrate using copilot-theorem to reason about arrays where individual elements are being updated.
Implementor: Solution implemetned, review requested. |
Change Manager: Verified that:
|
Change Manager: Implementation ready to be merged. |
If I have 2 streams carrying doubles, such as:
Is it possible to define, with some function (or maybe an
Op2
):The text was updated successfully, but these errors were encountered: