Ok, how about SymPy's old `patternify` method?  A function that takes a clean Theano expression (or apply node), a set of terms that should be made into logic variables, and then uses `raw_init` *a lot* to create the relevant pattern.

```Python
jj = 238908925034 # -- a number that cannot occur in the graph
x = lptensor('x', 'float32', [False])
y = lptensor('y', 'float32', [False])

theano_pattern = tensor.set_subtensor(x[0:jj], y) # Legitimate by Theano standards
variables = 'x', 'y', 'float32', jj
logpy_pattern = patternify(theano_pattern, variables) # uses raw_init to replace all instances of `v` with `var(v)` for v in `variables`

goals = (
        (eq, node.outputs[0], logpy_pattern),
        (shape_dimo, (x, 0), jj),
     )
```