Regularity of Language L Over Decimal Divisibility by 7

In summary: That means that $w$ is supposed to be interpreted as a number consisting of digits between $0$ and $9$ (decimal means base-10), even though the symbols in the alphabet are only 1,2,4,5,7,9.
  • #1
evinda
Gold Member
MHB
3,836
0
Hello! :)
I have a question.Given $\Sigma=\{1,2,4,5,7,9\}$ and $L=\{w:w \in \Sigma^{*},\text{ and w as a decimal gets divided completely by } 7\}$,is the language L regular?
 
Technology news on Phys.org
  • #2
evinda said:
Hello! :)
I have a question.Given $\Sigma=\{1,2,4,5,7,9\}$ and $L=\{w:w \in \Sigma^{*},\text{ and w as a decimal gets divided completely by } 7\}$,is the language L regular?

Hi! ;)

Did you try anything?
Which methods could be applied?
Does any method lead to anything?
 
  • #3
I like Serena said:
Hi! ;)

Did you try anything?
Which methods could be applied?
Does any method lead to anything?

I thought that I could show that the language is regular,drawing a DFA,which states are all the possible remainders..Is this right?
Could I also do this,without the use of a DFA? :confused:
 
  • #4
evinda said:
I thought that I could show that the language is regular,drawing a DFA,which states are all the possible remainders..Is this right?
Could I also do this,without the use of a DFA? :confused:

That was also my first idea. :cool:
I guess you could also create a regular expression, but I think that would be more complicated.
 
  • #5
I like Serena said:
That was also my first idea. :cool:
I guess you could also create a regular expression, but I think that would be more complicated.

I just can imagine that the final state of the DFA should be the one with $\text{remainder}=0$,but I don't really know which other transitions there could be.. :confused:
Also,could you help me to construct the regular expression?
 
  • #6
evinda said:
I just can imagine that the final state of the DFA should be the one with $\text{remainder}=0$,but I don't really know which other transitions there could be.. :confused:
Also,could you help me to construct the regular expression?

Each transition would correspond to the next digit on the input.
Each state would correspond to a remainder...

Best regular expression I can come up with at this time is:
77* | 14 | 21 | 4(2|9) | 91 | 11(2|9) | ...
But this is not a finite regular expression.
Hmm, perhaps if we continue a couple more steps we'll see a pattern emerge that we can make more concise.
 
  • #7
We can start at the state with remainder 0, corresponding to the empty symbol.
This state would also be the final state, since we would have a number that is divisible by 7.

Then, after an 1, we can go to the state with remainder 1.
From state 1, a 2 would bring us for instance to the number 12, which has remainder 5.
So a 2 would bring us from state 1 to state 5.

Perhaps you can draw something? :eek:
 
  • #8
I like Serena said:
We can start at the state with remainder 0, corresponding to the empty symbol.
This state would also be the final state, since we would have a number that is divisible by 7.

Then, after an 1, we can go to the state with remainder 1.
From state 1, a 2 would bring us for instance to the number 12, which has remainder 5.
So a 2 would bring us from state 1 to state 5.

Perhaps you can draw something? :eek:

I have tried to draw the DFA.I hope you can distinguish what I have written :eek:
View attachment 1866

Is it right?
 

Attachments

  • pda.jpg
    pda.jpg
    68.4 KB · Views: 47
  • #9
evinda said:
I have tried to draw the DFA.I hope you can distinguish what I have written :eek:
View attachment 1866

Is it right?

Aha!
I like the colors! (Cool)

Looks good... except for that arrow from 4 to 1 that has a 3 attached to it.
I believe 3 is not part of the alphabet. :eek:
 
  • #10
I like Serena said:
Aha!
I like the colors! (Cool)

Looks good... except for that arrow from 4 to 1 that has a 3 attached to it.
I believe 3 is not part of the alphabet. :eek:

I understand... thank you very much! :)

- - - Updated - - -

I like Serena said:
Best regular expression I can come up with at this time is:
77* | 14 | 21 | 4(2|9) | 91 | 11(2|9) | ...
But this is not a finite regular expression.
Hmm, perhaps if we continue a couple more steps we'll see a pattern emerge that we can make more concise.

Could you also explain me how I can find the regular expression?? :confused:
 
  • #11
evinda said:
I understand... thank you very much! :)

- - - Updated - - -
Could you also explain me how I can find the regular expression?? :confused:

I am looking again at the exercise..and I have also an other question...What is meant with the fact that $w$ is a decimal? :confused:
 
  • #12
evinda said:
Could you also explain me how I can find the regular expression?? :confused:

I don't see how we can find a finite regular expression.
evinda said:
I am looking again at the exercise..and I have also an other question...What is meant with the fact that $w$ is a decimal? :confused:

That means that $w$ is supposed to be interpreted as a number consisting of digits between $0$ and $9$ (decimal means base-10), even though the symbols in the alphabet are only 1,2,4,5,7,9.
So it's not for instance an octal (base-8) or hexadecimal number (base-16).
 
  • #13
I like Serena said:
I don't see how we can find a finite regular expression.
Never mind! :)

I like Serena said:
That means that $w$ is supposed to be interpreted as a number consisting of digits between $0$ and $9$ (decimal means base-10), even though the symbols in the alphabet are only 1,2,4,5,7,9.
So it's not for instance an octal (base-8) or hexadecimal number (base-16).

I understand..Thank you very much for your help! :rolleyes:
 
  • #14
I like Serena said:
I guess you could also create a regular expression, but I think that would be more complicated.

I am trying to find also a regular expression..but which identity should have a number so that is gets divided completely by 7?
 
  • #15
evinda said:
I am trying to find also a regular expression..but which identity should have a number so that is gets divided completely by 7?

I thought that it could be $(1|2|4|5|7|9)^{*}7$ but then I found a counterexample.. $419$ is not divisible by 7! Is it maybe similar to this one?Do I just have to change something or is it completely wrong? :confused:
 
  • #16
evinda said:
I am trying to find also a regular expression..but which identity should have a number so that is gets divided completely by 7?

evinda said:
I thought that it could be $(1|2|4|5|7|9)^{*}7$ but then I found a counterexample.. $419$ is not divisible by 7! Is it maybe similar to this one?Do I just have to change something or is it completely wrong? :confused:

I am pretty sure that it cannot be done.
If only it was about divisibility by 5 for instance. That's easy. It needs to end in either 0 or 5.
But with 7 any sequence of digits is fine with basically no clear cue what the last digit should be.
Ah well, to be fair, there is a pattern (google it), but I don't think it can be caught in a regular expression.
 
  • #17
I like Serena said:
I am pretty sure that it cannot be done.
If only it was about divisibility by 5 for instance. That's easy. It needs to end in either 0 or 5.
But with 7 any sequence of digits is fine with basically no clear cue what the last digit should be.
Ah well, to be fair, there is a pattern (google it), but I don't think it can be caught in a regular expression.

Ok,I understand.. :) And something else..Could I just write the function of the PDA, instead of drawing it? :confused:
 
  • #18
I like Serena said:
I don't see how we can find a finite regular expression.
How can this be if there is a supposedly correct finite automaton in post #8?

This page on Stack Overflow explains the idea behind the automaton. The transition function is the following (the first argument is a state, the second one is a new symbol read).
\[
\delta(q,s)=(10q+s)\text{ mod }7
\]
I have not checked everything, but the transitions from 2 seem correct except for symbol 1, which should lead to state 0.

The standard algorithm for converting a DFA into a regular expression may return expressions that are exponential in size compared to the size of the automaton. Here you can find an explicit regular expression whose length is 12 or 13 thousand, as well as the automaton.
 
  • #19
Evgeny.Makarov said:
How can this be if there is a supposedly correct finite automaton in post #8?

This page on Stack Overflow explains the idea behind the automaton. The transition function is the following (the first argument is a state, the second one is a new symbol read).
\[
\delta(q,s)=(10q+s)\text{ mod }7
\]
I have not checked everything, but the transitions from 2 seem correct except for symbol 1, which should lead to state 0.

The standard algorithm for converting a DFA into a regular expression may return expressions that are exponential in size compared to the size of the automaton. Here you can find an explicit regular expression whose length is 12 or 13 thousand, as well as the automaton.

Could I find maybe a simpler grammar or isn't it possible? :eek: :confused:
 
  • #20
Evgeny.Makarov said:
The transition function is the following (the first argument is a state, the second one is a new symbol read).
\[
\delta(q,s)=(10q+s)\text{ mod }7
\]

evinda said:
Could I find maybe a simpler grammar or isn't it possible? :eek: :confused:

That is the simpler grammar in the form of a deterministic finite state machine. The $\delta$ function describes the set of transitions.
Augment it with a definition of the input symbols, the set of states, the initial state, the set of final states, and there you go! (Cool)
 
  • #21
I like Serena said:
That is the simpler grammar in the form of a deterministic finite state machine. The $\delta$ function describes the set of transitions.
Augment it with a definition of the input symbols, the set of states, the initial state, the set of final states, and there you go! (Cool)

I tried this:
-input-symbols: $\Sigma=\{1,2,4,5,7,9\}$
-set of states: $\Sigma_{k}=\{0,1,2,3,4,5,6\}$
-initial state: $I=\{0\}$
-set of final states: $F=\{0\}$
-transition: $\delta(q,s)=(10q+s)mod7$

But...isn't it the description of the DFA ?What do you mean that it is a grammar? :confused:
 
  • #22
evinda said:
I tried this:
-input-symbols: $\Sigma=\{1,2,4,5,7,9\}$
-set of states: $\Sigma_{k}=\{0,1,2,3,4,5,6\}$
-initial state: $I=\{0\}$
-set of final states: $F=\{0\}$
-transition: $\delta(q,s)=(10q+s)mod7$

But...isn't it the description of the DFA ?What do you mean that it is a grammar? :confused:

I tend to mix them up, although I guess formally a DFA is not a grammar.
Anyway, it is straight forward to convert the DFA to a set of production rules.
$$S_0 \to 1\ S_1\ |\ 2\ S_2\ |\ ...$$
$$S_1 \to ...$$

In other words, the grammar $G = (N, \Sigma, P, S)$ with
$$N = \{S_0,S_1,S_2,S_3,S_4,S_5,S_6\}$$
$$\Sigma = \{1,2,4,5,7,9\}$$
$$P = \{ S_q \to s S_{(10q+s)\text{mod}7} : s \in \Sigma, S_q \in N \} \cup \{ S_0 \to \varnothing \}$$
$$S = S_0$$
 
Last edited:
  • #23
I like Serena said:
I tend to mix them up, although I guess formally a DFA is not a grammar.
Anyway, it is straight forward to convert the DFA to a set of production rules.
$$S_0 \to 1\ S_1\ |\ 2\ S_2\ |\ ...$$
$$S_1 \to ...$$

In other words, the grammar $G = (N, \Sigma, P, S)$ with
$$N = \{S_0,S_1,S_2,S_3,S_4,S_5,S_6\}$$
$$\Sigma = \{1,2,4,5,7,9\}$$
$$P = \{ S_q \to s S_{(10q+s)\text{mod}7} : s \in \Sigma, S_q \in N \}$$
$$S = S_0$$

I understand..Thanks a lot! :)
 
  • #24
evinda said:
I understand..Thanks a lot! :)

Oops. Forgot the terminal state. :eek:
Just added it in my previous post.
 
  • #25
I like Serena said:
Oops. Forgot the terminal state. :eek:
Just added it in my previous post.

Oh yes,right! Thank you very much! :rolleyes:
 

Related to Regularity of Language L Over Decimal Divisibility by 7

1. What is L Regular?

L Regular, also known as the regular language, is a type of formal language that can be recognized and generated by a regular grammar or automaton.

2. How is L Regular different from other types of formal languages?

L Regular is unique in that it can be recognized and generated by a regular grammar or automaton, while other types of formal languages such as context-free languages or context-sensitive languages require more complex grammars or automata.

3. What are the applications of L Regular in computer science?

L Regular plays a crucial role in the theory of formal languages and automata, and has practical applications in computer science such as in the design of programming languages, compilers, and regular expressions.

4. Can regular expressions be used to represent L Regular?

Yes, regular expressions are a powerful tool for representing L Regular languages, as they allow for concise and efficient pattern matching and string manipulation.

5. Is L Regular equivalent to regular expressions?

While regular expressions can represent L Regular languages, they are not equivalent. Regular expressions can also represent some languages that are not regular, such as context-free languages. However, regular expressions are a useful tool for working with L Regular languages.

Similar threads

  • Programming and Computer Science
Replies
1
Views
2K
  • Programming and Computer Science
Replies
2
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
2K
  • Programming and Computer Science
Replies
8
Views
2K
  • Programming and Computer Science
Replies
11
Views
3K
  • Programming and Computer Science
Replies
9
Views
7K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
2K
  • Set Theory, Logic, Probability, Statistics
Replies
24
Views
4K
  • Programming and Computer Science
Replies
8
Views
2K
  • Classical Physics
Replies
0
Views
201
Back
Top