RSS Amplifier

Steven Kalt · Apr 24, 2016

you can take the derivative of a regular expression?!

0
Sign in to vote or save

This page cannot be shown here. You can still read it on the original site — the toolbar below keeps your place in the directory.

But we can describe some of the ideas in words. Let’s say we have a regular expression which is supposed to match the strings (‘a’, ‘abab’, ‘aaaabb’, ‘bbc’). The derivative of those strings with respect to 'a' is (’’, ‘bab’, ‘aaabb’) – you strip off the a from every string. It turns out (which is not totally…

But we can describe some of the ideas in words. Let’s say we have a regular expression which is supposed to match the strings (‘a’, ‘abab’, ‘aaaabb’, ‘bbc’).

The derivative of those strings with respect to 'a' is (’’, ‘bab’, ‘aaabb’) – you strip off the a from every string.

It turns out (which is not totally obvious to me, but I think if you go through all the cases it’s not too bad) that you can take the derivative of any regular expression in a pretty straightforward way – like if you have (a+)|(b+), the derivative with respect to a is (a+). These derivatives turn out to combine in nice ways which is I guess why they are called derivatives.

Read on /notes/techniques/brzozowski_derivatives/

Comments

Nothing yet. Say the first thing.

    Sign in to join the conversation.