Ask Your Question

Is there a way to have Context Sensitive Morphisms?

asked 2018-07-07 13:51:10 -0500

Chernoxyl gravatar image

updated 2018-07-07 13:52:00 -0500

I be been using WordMorphism and I was wondering if there is a way to have context sensitive substitutions?

An example would be b”a”c -> ab so a is replaced iff bac appears.

edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted

answered 2018-07-08 10:39:13 -0500

vdelecroix gravatar image

Yes and no. You can always recode your word on a larger alphabet and apply a substitution on this larger alphabet. For your example

sage: W = Words('abc')
sage: w = W('abbabacacabcabcaacabcbac')
sage: WW = Words('abcA')
sage: ww = WW(['A' if w[i] == 'a' and i > 0 and w[i-1] == 'b' and i < len(w)-1 and w[i+1] == 'c' else w[i] for i in range(len(w))])
sage: ww
word: abbabAcacabcabcaacabcbAc
sage: f = WordMorphism('a->a,b->b,c->c,A->ab', domain=WW, codomain=W)
sage: f(ww)
word: abbababcacabcabcaacabcbabc
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2018-07-07 13:51:10 -0500

Seen: 47 times

Last updated: Jul 08 '18