0

Apologies for any incorrect usage of maths notation in my explanation. Assume I have two sequences $A$ and $B$, I want to obtain a new sequence that contains all the elements from both $A$ and $B$ up to the first occurrence where they differ (appearing only once), and then it should include all the elements from both $A$ and $B$ that come after this first difference.

For example, given sequence $A = (a, b, c, d)$ and sequence $B = (a, b, d, c)$, the expected result for sequence $C$ is $(a, b, c, d, d, c)$.

I have an idea, but I'm not sure if it is appropriate. For sequence $A$,$B$ with length $n$,$m$ respectively, let $k$ be the smallest index of $A_i\neq B_i$, i.e. $k=\min\{i|A_i\neq B_i \}$, then the new sequence should be $C=A_{1:k-1}\cup A_{k:n}\cup B_{k:m}$.

My uncertainty lies in whether the symbol "$\cup$" can be used for combining sequences. I would greatly appreciate it if someone could provide a more concise and rigorous representation or confirm the correctness of my idea.

Prem
  • 14,696
iggy
  • 13
  • Why would the combined sequence not be $(a,b,c,d,c)$? You might be after the shortest sequence that contains $A$ and $B$ as subsequences. – Chris Lewis Jul 22 '23 at 14:59
  • If you're looking for concatenation symbol, there are suggestions here. If you're looking for how to denote a sub-interval in a sequence, your notation looks fine. – Chad K Jul 22 '23 at 15:46

1 Answers1

1

We have 2 Sequences $A$ & $B$ , which we want to combine , to get new Sequence $C$.

Let $A=(a_1,a_2,a_3,a_4,\cdots,a_n)$
Let $B=(b_1,b_2,b_3,b_4,\cdots,b_m)$

Let $k$ be the Index such that $a_k \ne b_k \land [ (i<k) \implies (a_i=b_i) ]$ (Basically , this is the Index where the earliest mismatch occurs)

We want $C=(\color{red}{a_1,\cdots,a_{k-1}},\color{blue}{a_k,\cdots,a_n},\color{green}{b_k,\cdots,b_{m}})$ (where red is the Common Part , blue is rest of A & green is rest of B)

Of course , it is Exactly Same as this :
$C=(\color{red}{b_1,\cdots,b_{k-1}},\color{blue}{a_k,\cdots,a_n},\color{green}{b_k,\cdots,b_{m}})$

We want the Catenation or Concatenation of Sequences (not $\cup$ , Union of Sets)

The various Catenation Operations (symbols) used commonly are :
$\color{orange}{X{\Vert}Y}$ , $X^{\frown}Y$ , $X +\!\!\!\!+ Y$

Common Sub-Sequence Notations used are :
$\color{orange}{(a_i)_{i=1}^{k-1}}$ , $B[k:n]$ , $A_{1:(k-1)}$ , $(b_i)_{k}^m$

We then get ( choosing the Orange Choices ) the following Sequence :

$$C=(a_i)_{i=1}^{k-1}{\Vert}(a_i)_{i=k}^{n}{\Vert}(b_i)_{i=k}^{m}$$
where $k$ is the Index such that $a_k \ne b_k \land [ (i<k) \implies (a_i=b_i) ]$

We might use other notations & then "simplify" a little , to get the Equivalent Sequence :

$$C=A+\!\!\!\!+B[k:m]$$
where $k$ is the Index such that $a_k \ne b_k \land ( A[1:k-1] \equiv B[1:k-1] )$

Prem
  • 14,696