Can you help me mathematically describe this pattern?

  • Thread starter farkuldi
  • Start date
In summary, the conversation discusses the syntax for describing a pattern of numbers generated by a computer program. The program only generates 1s and 0s, with specific rules for string length and the placement of four consecutive 1s. The participants consider using mathematical language, such as set notation or regular expressions, to describe the set of possible strings.
  • #1
farkuldi
4
0
Hello,

This is a simple question, but I don't remember how to do it. I am working with a computer program someone else wrote to generate some strings of numbers, and I need to know the syntax for describing the pattern of these numbers. I have determined the characteristics of all the possible numbers the program could generate (it's not complicated), but I need help translating it into mathematical language. So here goes.

The program only generates 1s and 0s, and concatenates them into one large string.

A string of length two can be generated, but it must be "11."

Strings of length one, three, four, or five are impossible.

Strings of length six must have a sequence of four consecutive 1s in the second through fifth positions, i.e., ?1111? (the question marks can be either zero or one).

Strings can be greater than length six, but there must always be this same ?1111? placed somewhere in the string, so ?1111? is allowed, ?1111?? is allowed, ?1111?? is allowed, and so on. As long as ?1111? appears somewhere in the string, it is legal.

Can someone please explain how I can describe this mathematically?

Thanks in advance for any help.
 
Last edited:
Mathematics news on Phys.org
  • #2
Sounds like s is a valid string if and only if either s=11 or there exist (non-null) strings t,u such that s=t1111u. Am I interpreting correctly?
 
  • #3
economicsnerd said:
Sounds like s is a valid string if and only if either s=11 or there exist (non-null) strings t,u such that s=t1111u. Am I interpreting correctly?

Well yes, but the substrings s and t would have to be composed of only ones and zeroes. I think the important thing is that, other than the special case of the two character string 11, a string must contain at least four consecutive ones, and those four consecutive ones must have at least one character on either side of them.

So basically we could have 11010111110, 0111111, 0101011110, 011110010101, etc.

I was hoping for a more numerical way of describing the set of possible strings, i.e. set notation (?) or similar.

Thanks for your reply!
 
  • #4
Sounds like a job for a regular expression (regex).

^11$|^[01]+1111[01]+$

Vertical bar means alteration -- choose one or the other. It binds loosely.
^ means beginning of string.
$ means end of string.
[] surrounding a list of characters matches any character in the list
+ means that the preceding element may be repeated one or more times

You could also do it with Bachus-Naur form (BNF)
 
  • #5
Hehe, I'm quite familiar with regular expressions and was going to fall back to using one if I couldn't find anything else, so I guess we think alike! However, I just thought I could do it in something less computer science-y and more along the lines of formal mathematical notation. For some reason, set notation kept sticking in my mind.

I do have a grammar which I could easily put into Bachus-Naur form, but that is what I am trying to get away from.

Thank you. :)
 
  • #6
The set of such strings is [tex] \{(1,1)\}\cup\left[\left(\bigcup_{k=1}^\infty\{0,1\}^k\right)\times \{(1,1,1,1)\}\times \left(\bigcup_{k=1}^\infty\{0,1\}^k\right) \right],[/tex] but writing it in this "more precise" way doesn't add any clarity.
 
  • Like
Likes 1 person
  • #7
economicsnerd said:
The set of such strings is [tex] \{(1,1)\}\cup\left[\left(\bigcup_{k=1}^\infty\{0,1\}^k\right)\times \{(1,1,1,1)\}\times \left(\bigcup_{k=1}^\infty\{0,1\}^k\right) \right],[/tex] but writing it in this "more precise" way doesn't add any clarity.

Thank you, that is what I was hoping for. I wasn't looking for precision of clarity; I just wanted to know the formal way to describe it. Now I see. I'd better go brush up on my set notation now so that I can remember how to read it.

Thanks again.
 

Related to Can you help me mathematically describe this pattern?

1. What is the process for mathematically describing a pattern?

The process for mathematically describing a pattern involves first identifying the pattern and its characteristics, such as the type of pattern (geometric, arithmetic, etc.), the elements or variables involved, and any repeating elements or sequences. From there, you can use mathematical equations, formulas, and patterns to describe the pattern and its behavior.

2. How do you determine the equation for a pattern?

To determine the equation for a pattern, you need to analyze the pattern and look for any consistent relationships or rules between the elements or variables. These relationships can then be translated into mathematical equations or formulas that accurately describe the pattern and can be used to predict future elements in the pattern.

3. Can you use any type of mathematical equation to describe a pattern?

Yes, you can use a variety of mathematical equations to describe a pattern, including linear equations, quadratic equations, geometric sequences, and more. The type of equation needed will depend on the type of pattern and its characteristics.

4. How do you know if your mathematical description accurately describes the pattern?

To ensure that your mathematical description accurately describes the pattern, you can test it by plugging in different values for the variables and seeing if the resulting elements match the pattern. You can also check for any errors or inconsistencies in your equations or formulas.

5. Can you use mathematical description to predict future elements in a pattern?

Yes, by using mathematical equations and formulas to accurately describe a pattern, you can make predictions about future elements in the pattern. This can be helpful in understanding the behavior and trends of the pattern and can also be used for practical applications, such as in forecasting stock market trends or predicting population growth.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
3
Views
1K
  • General Math
Replies
12
Views
1K
Replies
66
Views
4K
Replies
13
Views
1K
  • General Math
Replies
1
Views
1K
Replies
13
Views
2K
Replies
1
Views
850
  • General Math
Replies
8
Views
1K
  • Programming and Computer Science
Replies
10
Views
2K
Back
Top