1

Question

I would like to know what notation can be used to represent the intersection of two strings.

First things first

When I say string I refer to a sequence of characters in computer science ("EXAMPLE") for instance.

When I say substring I mean a consecutive piece of the initial string ("AMPLE") for instance would be a substring of the first example string. I say this to clarify that I'm not talking about subsequences which would mean that "XMLE" would be valid subsequence but not a substring.

What I'm trying to write

If I have two strings $N$ and $M$. I want to find if the substring $N_{15}$ (this is how I denoted from character position 1 to 5) is in $M$. If yes, take the length of the substring $|N_{15}|$ (I used the notation for set cardinality here) else the length is $0$.

What I wrote

For given $i, j$ I wrote $|N_{ij} \cap M|$ trying to say that if $N_{i, j} \in M$ the intersection would be of cardinality $|N_{i, j}|$ and zero otherwise.

My worries

I am worried that if somebody looks at $N$ and $M$ as sets (or even general sequences) this won't make much sense and it might not be clear. I can write the equation and clarify within a few sentences just like here as of what I've meant but at this point I'd like to consult with somebody mathematically more literate than me.

Another worry is that if somebody looks at $N$ and $M$ as sets $N_{ij}$ would be viewed as the element in a cartesian product which would further confuse the reader.

Ilhan
  • 331
  • 2
    Use $N[i]$ to denote the $i$-th position in the string $N$ and $N[i:i+h]$ for a substring of $N$ of lenght $h$. Then $N[i:h]$ is a substring of $M$ iff exists $k$ such that $N[i+j]=M[k+j]$ for $j=0,\ldots, h$. – Mauro ALLEGRANZA Apr 07 '17 at 20:20
  • 1
    You're already confusing people by writing $S\in M$ when you want to say that $S$ is a substring of $M,$ unless you have somehow defined a string to be the set of all of its substrings. – David K Apr 07 '17 at 20:22

0 Answers0