README.md
Domain Specific Language for the Abstraction and Reasoning Corpus (ARC-DSL)
The DSL was created with the aim of being expressive enough to allow programs solving arbitrary ARC tasks, and generic, i.e. consisting of only few primitives, each useful for many tasks (see dsl.py). As a proof of concept, solver programs for the training tasks were written (see solvers.py). See arc_dsl_writeup.pdf for a more detailed description of the work.
Example solver program for task 00d62c1b written in the DSL

def solve_00d62c1b(I):
objs = objects(grid=I, univalued=T, diagonal=F, without_bg=F)
black_objs = colorfilter(objs=objs, value=ZERO)
borders = rbind(function=bordering, fixed=I)
does_not_border = compose(outer=flip, inner=borders)
enclosed = mfilter(container=black_objs, function=does_not_border)
O = fill(grid=I, value=FOUR, patch=enclosed)
return O
The function solve_00d62c1b takes an input grid I and returns the correct output grid O. An explanation of what the variables store and how their values were computed:
objs: the set of objects extracted from the input gridIthat are single-color only, where individual objects may only have cells that are connected directly, and cells may be of the background color (black); the result of calling theobjectsprimitive onIwithunivalued=True,diagonal=Falseandwithout_background=Trueblack_objs: the subset of the objectsobjswhich are black; the result of filtering objects by their color, i.e. callingcolorfilterwithobjects=objsandcolor=ZERO(black)borders: a function taking an object and returningTrueiff that object is at the border of the grid; the result of fixing the right argument of theborderingprimitive toIby calling the functionrbindonfunction=borderingandfixed=Idoes_not_border: a function that returns the inverse of the previous function, i.e. a function that returnsTrueiff an object does not touch the grid border; the result of composing theflipprimitive (which simply negates a boolean) andbordersenclosed: a single object defined as the union of objectsblack_objsfor which functiondoes_not_borderreturnsTrue, i.e. the black objects which do not touch the grid border (corresponding to the “holes” in the green objects); the result of callingmfilter(which combinesmergeandfilter) withcontainer=black_objsandcondition=does_not_borderO: the output grid, created by coloring all pixels of the objectenclosedyellow; the result of calling thefillprimitive onIwithcolor=FOUR(yellow) andpatch=enclosed
Another solver example: 5521c0d9

def solve_5521c0d9(I):
objs = objects(grid=I, univalued=T, diagonal=F, without_bgT)
foreground = merge(containers=objs)
empty_grid = cover(grid=I, patch=foreground)
offset_getter = chain(h=toivec, g=invert, f=height)
shifter = fork(outer=shift, a=identity, b=offset_getter)
shifted = mapply(function=shifter, container=objs)
O = paint(grid=empty_grid, obj=shifted)
return O
objs: the set of objects extracted from the input gridIthat are single-color only, ignoring the background color; the result of calling theobjectsprimitive onIwithunivalued=True,diagonal=Falseandwithout_background=Trueforeground: all the objects treated as a single object, the result of calling themergeprimitive on the objectsobjsempty_grid: a new grid, whereforegroundis removed (covered), i.e. replaced with the background color (black); the result of calling thecoverprimitive withgrid=Iandpatch=foregroundoffset_getter: a function that takes an object and returns a vector pointing up by as much as that object is high; the result of composing the three functionstoivec,invertandheight; the result of calling thechainprimitive withh=toivec,g=invertandf=heightshifter: a function that takes an object and shifts it as much upwards as it is high; the result of calling theforkprimitive withouter=shift,a=identityandb=offset_gettershifted: all the objects shifted up by their heights, as a single object, obtained by appling the constructed function on the set of objects and merging the results; the result of calling themapplyprimitive onfunction=shifterandcontainer=objsOthe desired output grid, obtained by painting the resulting object onto the gridempty_gridwhere the original objects were removed from; the result of calling thepaintprimitive ongrid=empty_gridandobj=shifted