negative matching conditions?

10 views
Skip to first unread message

Ross Duncan

unread,
Nov 28, 2017, 11:53:56 AM11/28/17
to quant...@googlegroups.com
Dear all,

Is there a way to specify a that a match shouldn’t happen? I’m specifically interested in the case where a rule can match a vertex with any label EXCEPT zero.

I guess there is no way to do this in the matcher, but if you a work around using a sim_proc that will also be fine. Any ideas?

-r

Aleks Kissinger

unread,
Nov 28, 2017, 2:39:11 PM11/28/17
to quant...@googlegroups.com
If there is a particular vertex that should match any node with a
non-zero angle, you can use REWRITE_TARGETED for this. Supposing its
v0 in your pattern that should match, you can use something like this:

def first_nonzero_green(g):
for v in verts(g):
if not vertex_angle_is(g, v, '0') and g.typeOf(v) == 'Z': return v
return None

simproc = REPEAT(REWRITE_TARGETED(rule, 'v0', nonzero) >> REDUCE(simps))


The only issue is this won't try to do the match for any nonzero green
node, but just the first one. If that's something you need, I can
probably extend REWRITE_TARGETED.
> --
> You received this message because you are subscribed to the Google Groups "Quantomatic" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to quantomatic...@googlegroups.com.
> To post to this group, send email to quant...@googlegroups.com.
> Visit this group at https://groups.google.com/group/quantomatic.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages