Skip Menu |

This queue is for tickets about the FLAT CPAN distribution.

Report information
The Basics
Id: 120672
Status: open
Priority: 0/
Queue: FLAT

People
Owner: Nobody in particular
Requestors: user42_kevin [...] yahoo.com.au
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: suggest prefix of lang
Date: Tue, 21 Mar 2017 18:07:25 +1100
To: bug-FLAT [...] rt.cpan.org
From: Kevin Ryde <user42_kevin [...] yahoo.com.au>
As an idea for a feature, it could be good to have something for getting the "prefix" of an lang, accepting strings which are prefixes of strings in FA. I struck this when fiddling with bit strings representing fractions written in binary. If a certain bit string is acceptable, up to that many digits so far, then its prefixes are to be acceptable too. I had a go at some code, finding all predecessors of accepting states, or for Regex some slightly subtle mangling. I wrote some docs of what I thought below. Does this sound likely? There'd be more or different possible. Maybe a generic ancestors() could find prefix states. An equivalent descendants() on starting states would be what prune() retains. Maybe even queries about prefix-ness, like whether a lang contains any prefix, all prefixes, or is prefix-free (or what jargon). I had one place wanting to verify I accepted all prefixes, but test ->equals(->prefix), or prefix states == accepting states, would be enough for now. Of course all of the above could be similar for suffix too. =item C<$new_lang = $lang-E<gt>prefix> =item C<$new_lang = $lang-E<gt>prefix ($proper)> Return a new regular language object for prefixes of C<$lang>. This means all strings S for which there exists some T with S.T in C<$lang>. If optional parameter C<$proper> is true, then T must be non-empty so that only proper prefixes S are accepted. The default or C<$proper> false is to accept the full strings of C<$lang> too. In both cases S can be the empty string provided suitable T exists. For C<$proper> false this means if C<$lang> accepts anything at all (C<! $lang-E<gt>is_empty>). For C<$proper> true it means if C<$lang> accepts some non-empty string.
On Tue Mar 21 03:08:44 2017, user42_kevin@yahoo.com.au wrote: Show quoted text
> As an idea for a feature, it could be good to have something for getting > the "prefix" of an lang, accepting strings which are prefixes of strings > in FA. > > I struck this when fiddling with bit strings representing fractions > written in binary. If a certain bit string is acceptable, up to that > many digits so far, then its prefixes are to be acceptable too. > > I had a go at some code, finding all predecessors of accepting states, > or for Regex some slightly subtle mangling. I wrote some docs of what I > thought below. Does this sound likely? > > There'd be more or different possible. Maybe a generic ancestors() > could find prefix states. An equivalent descendants() on starting > states would be what prune() retains. Maybe even queries about > prefix-ness, like whether a lang contains any prefix, all prefixes, or > is prefix-free (or what jargon). I had one place wanting to verify I > accepted all prefixes, but test ->equals(->prefix), or prefix states == > accepting states, would be enough for now. Of course all of the above > could be similar for suffix too. > > > > =item C<$new_lang = $lang-E<gt>prefix> > > =item C<$new_lang = $lang-E<gt>prefix ($proper)> > > Return a new regular language object for prefixes of C<$lang>. This means > all strings S for which there exists some T with S.T in C<$lang>. > > If optional parameter C<$proper> is true, then T must be non-empty so that > only proper prefixes S are accepted. The default or C<$proper> false is to > accept the full strings of C<$lang> too. > > In both cases S can be the empty string provided suitable T exists. For > C<$proper> false this means if C<$lang> accepts anything at all (C<! > $lang-E<gt>is_empty>). For C<$proper> true it means if C<$lang> accepts > some non-empty string.
will take a look!
Subject: Re: [rt.cpan.org #120672] suggest prefix of lang
Date: Sun, 03 Jun 2018 12:27:40 +1000
To: "B. D. Estrade via RT" <bug-FLAT [...] rt.cpan.org>
From: Kevin Ryde <user42_kevin [...] yahoo.com.au>
"B. D. Estrade via RT" <bug-FLAT@rt.cpan.org> writes: Show quoted text
> > will take a look!
I didn't post code I tried. I've used it on DFAs but for NFA I'm not sure if it might want an epsilon_closure or two. The regex bit is bigger than I had meant to do, but still I learnt something :). The distinction between proper prefix and any prefix comes into its own for making the regex pieces.

Message body is not shown because sender requested not to inline it.

Message body is not shown because sender requested not to inline it.