Matrix / tensor transformation DSL (BLAZE/SYNGAR, Wang, Dillig & Singh,
POPL'18, Fig.17) for the AFTA example-driven (PBE) backend.
A matrix is encoded as a MATLAB-style string -- rows separated by ";",
elements within a row by "," -- which is exactly the notation the paper uses
(e.g. the vector [1,2,3,4,5,6] reshaped row-wise to 2x3 is "1,2,3;4,5,6").
Encoding matrices as strings lets the AFTA PBE engine and the @example
input/output specification work unchanged: a benchmark is
open Matrix
@example(f "1,2,3,4,5,6" = "1,2,3;4,5,6")
def f (m: String) : String := (?hole : String);
solved with: uv run python -m aeon --no-main -s afta <file>.ae
The operators below mirror Fig.17: Reshape(t, v), Permute(t)/transpose,
Fliplr(t), Flipud(t). All are total: a shape-incompatible reshape returns its
input unchanged.
Reshape the matrix's elements (row-major) into a `rows` x `cols` matrix
(Reshape with size vector [rows, cols]); identity if the element count does
not match rows*cols.
Reshape the matrix's elements (row-major) into a `rows` x `cols` matrix
(Reshape with size vector [rows, cols]); identity if the element count does
not match rows*cols.