Ask Your Question
0

Is there a way to have Context Sensitive Morphisms?

asked 2018-07-07 20:51:10 +0100

Chernoxyl gravatar image

updated 2018-07-07 20:52:00 +0100

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.

WordMorphism(“bac->ab”)
edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2018-07-08 17:39:13 +0100

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

Stats

Asked: 2018-07-07 20:51:10 +0100

Seen: 254 times

Last updated: Jul 08 '18