Can I Compare Symbol to String

52 Views Asked by At

I'm a student majoring in computer science.

I'm not sure if I can use the equality sign (=) for a string value. (I can definitely do that in computer code...)

So please check the mathematical representation bellow.

enter image description here

I want to firmly define pattern matching between $P'$ and $P$.

For P' to be matched by $P$, for all elements of $P'$,

$P'_i$ (it is string value) should be equal to $P_i$ or $P_i$ is equal to underscore (_).

Is there any problem to use the representation above?

Thank you!


enter image description here

I edited the representation based on some feedback!

Are there still things to improve?

1

There are 1 best solutions below

1
On

I would write:

$$ \operatorname{matched}(P,P')= \begin{cases} \text{false} & |P|\ne|P'|\\ \bigwedge_\limits{i=1}^{|P|} \left(P_i=P'_i \lor \_\right) & \text{otherwise} \end{cases} $$

Now we know what parameter 'matched' takes. Also it is customary to use $P$ instead of $P'$ where possible. The stop value for the global AND should be on the top. And the logic for case $2$ can be contracted.