Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^2: Perl 6 rules and complexity

by fergal (Chaplain)
on Feb 17, 2006 at 02:46 UTC ( [id://530846]=note: print w/replies, xml ) Need Help??


in reply to Re: Perl 6 rules and complexity
in thread Perl 6 rules and complexity

Yeah, it depends on the grammar but worst case is exponential (according to this guy anyway). If it's memoizable it's guaranteed to be linear in the length of the string being parsed (worst case is @rules * length($string) ). This only includes a very limited type of backtracking, once you allow more powerful regex-like backtracking on quantified rules it becomes very easy to lose linearity even with memoization.

It would be unfortunate if people could write programs that didn't either compile or fail in a reasonable time or if people took 2 pieces of code that independently compiled quickly but when appended compiled much more slowly.

The ability to cause arbitrary side-effects in rule actions makes that far easier to do or possibly even guarantees it for anything but the simplest grammars (for example any grammar that is an extension of Perl6's).

Replies are listed 'Best First'.
Re^3: Perl 6 rules and complexity
by zby (Vicar) on Feb 18, 2006 at 09:42 UTC
    To put that in context - it is known that type inference in languages like ML is DEXP Time complete (http://portal.acm.org/citation.cfm?coll=GUIDE&dl=GUIDE&id=96748, my Masters Thesis was a modified proof of that :))

      That might be in context but it's not a context that I'm the least bit familiar with!

      DTIME and DEXPTIME don't seem to have a lot of material about them on the web or at least they don't seem to have many introductions to the terminology. wikipedia and some lecture notes are the closest I could find.

      Apart from being a performance guarantee for a specific model of computation, rather than an asymptotic guarantee, how is DEXPTIME different from O(2^n)? Is it any worse or better. Is it just more precise or am I wrong to interpret DEXPTIME as DTIME(some exponential function)?

        DEXPTIME is Deterministic Expotential Time ie it is the same as O(2^n) for time (time is the most frequently used measure of complexity but there are others and among them is space). So I really should have written that ML grammar is expotential in the worst case too.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://530846]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2024-04-19 11:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found