How to determine the finite or infinite number of words in a formal language

In order to decide whether a context-free grammar generates the empty language or not, you can compute the set of productive nonterminals. A nonterminal $A$ is productive if there is a rule $A to alpha$ where all nonterminals in $alpha$ are already known to be productive. The set of productive nonterminals can be computed iteratively using the definition. The grammar generates the empty language iff the start symbol is not productive.

In order to determine whether the language generated by a context-free grammar is infinite or not, you can use the pumping lemma. First you need to convert the grammar into Chomsky normal form. Then, there are thresholds $n_1,n_2$, depending on the number of nonterminals, such that the language generated by the grammar is infinite iff it contains a word whose length is between $n_1$ and $n_2$ (in the case of regular grammars, you can take $n_1 = n$ and $n_2 = 2n-1$, where $n$ is the number of nonterminals, but for general context-free grammars, $n_1,n_2$ are exponential in $n$); this is a consequence of the pumping lemma. This is not a very efficient algorithm, unfortunately, but it shows that the problem is decidable.

Infinite horizontal scroll | Web Hosting Talk


Hi and thank you for making such a awesome template-

after updating template i faced an issues there is a lot of unuseful scroll space on the screen i tired to fix it width overflow-x:hidden but it did not solved in tablets and smartphones.

everyday i am receiving lots of error in search console and as you can see google says the page is not mobile friendly-

Mobile Friendly Test

can anyone help me to fix this issues?

my website url is: seofox.ir

turing machines – How is it possible that for infinite L in R exists subset L’ which is not in Re?

Subsets of recursive languages aren’t always recursive or recursively enumerable. The simplest example is the language of all strings: it is clearly recursive (even regular), and all languages are its subsets including those not in $RE$.

To solve this question, consider this: how many subsets does an infinite language $L$ have? What does that imply regarding their membership in $RE$?

sqlite – How to design & implement folders and subfolders (infinite) in my database?

So I am building a desktop application using Qt, C++, and SQLite.

I want the user to be able to create as many folders as he likes, and those folders can have “notes” (its a note-taking app) and/or as many subfolders as one wishes there to be.

My question is how to implement something like this in database design?

So for example, each folder record in the database can have a “parent_folder” field with those that don’t have parent folders have a specific id, and the others would have the rowid of the folder record that is their parent.

I will have to somehow iterate over this table, add dynamically to my gui (my tree widget) folders and subfolders. Not to mention if I also have a table for notes, each note will have to have an id corresponding to the rowid of its parent folder.

This is a half-baked solution that I haven’t really developed well, but it was the first thing that I can come up with. (this is my first question here, please be merciful)

co.combinatorics – Sequence defined by recurrence relation as infinite product

Let $f(n)$ be A007814, the exponent of the highest power of $2$ dividing $n$, a.k.a. the binary carry sequence, the ruler sequence, or the $2$-adic valuation of $n$.

Then we have an integer sequence given by
begin{align}
a(0)=a(1)&=1\
a(2n)& = pa(n)+qa(2n-2^{f(n)})\
a(2n+1) &= a(n-2^{f(n)})
end{align}

Let $g(n, 0)$ be a degree of $p + q$ in $a(n)$, then I conjecture that
$$a(n) = prodlimits_{k=0}^{infty} (q^{k+1} + psumlimits_{j=0}^{k} q^j)^{g(n, k)}$$
where

  • $g(n, k) = g(h(n, k), 0)$ for $n geqslant 0, k > 0$
  • $h(n, k) = h(h(n, 1), k – 1)$ for $n geqslant 0, k > 1$
  • $h(n, 1) = s(s(n))$ for $n geqslant 0$
  • $s(n) = n – leftlfloorlog_2{n}rightrfloor$ for $n > 0$ with $s(0) = 0$

Is there a way to prove it? Is there any patterns for $g(n,0)$?

microservices – Make infinite loop handleable via delay?

I have a Node.js micro-service architecture-based back-end. Services communicate with each other via PubSub. E.g. upon a request to service A, service A messages either service B or service C via PubSub. B and C can message other services and so on.
What exactly is to happen is for the user to decide. The problem is: In rare, but unavoidable edge-cases, the set-up could result in an endless loop of PubSub messages, like e.g. A->B->C->A and so on.
Infinite loops are, of course, bad, bloat the system, and could make it eventually crash.

Now, one way to prevent that would be passing a counter in the PubSub payload, increasing it by one each time a service messages to another service, and then aborting any further processing as soon as a certain threshold would be reached.
However, that would mean that the user would not get the result they expect.

So, I was thinking about just adding delays based on the counter value: The more often a certain request is passed around between services, the longer the delay before proceeding, till a certain quite long max delay value of e.g. 5 minutes would be reached.

However, I’m not really sure if that would be a good solution.

  • What would be the risks of that approach?
  • How would I measure if the delay is long enough and how many infinite messages could be passed around without the system breaking down?

python – Why is this loop sometimes working fine and sometimes printing infinite results?

I have been searching but can’t find anything that helps me.
I have a code which requires me to create a code 00.00.00 to use them for separate them, so I have create a list that I join at the end (“0”, “0”, “.”…)

The matter is that for some values, I need ONE to match certain conditions, so I’m using a function that returns int if is correct (I need the number), or False if it does not.

I have created a function for that loop but sometimes it runs nice, and some times it keeps running deleting the number

def code_validator(code, list_acc, q_dict, pos_dict, rareza, q):
    code2 = code.copy()
    while code2.count('0') > 4:
            a = random.choice(list_acc)
            a_q = q_dict(a)
            a_p = int(pos_dict(a))
            if q == 1:
                if type(acc_dict(a, rareza)) == int:
                    code2(a_p) = acc_dict(a, rareza)
                    q = q+1
                while acc_dict(a, rareza) == False:
                    code_validator(code2, list_acc, q_dict, pos_dict, rareza, q)
            elif code2(a_p) == '0':
                    code2(a_p) = str(random.randint(1,a_q))
            print(code2)
            breakpoint
            if code2.count('0') == 4:
                break
    return code2

Output when it runs fine:

('0', '0', '.', '0', '0', '.', 3, '0')
('0', '0', '.', '2', '0', '.', 3, '0') 

Output when it fails:

('0', '0', '.', '0', '0', '.', 3, '0')
('5', '0', '.', '0', '0', '.', 3, '0')
('0', '0', '.', '0', '0', '.', 3, '0')
('1', '0', '.', '0', '0', '.', 3, '0')
('0', '0', '.', '0', '0', '.', 3, '0')
('0', '0', '.', '3', '0', '.', 3, '0')
('0', '0', '.', '0', '0', '.', 3, '0')
('0', '0', '.', '0', '0', '.', 3, '0')
('0', '0', '.', '1', '0', '.', 3, '0')
('0', '0', '.', '0', '0', '.', 3, '0')
('0', '0', '.', '1', '0', '.', 3, '0') #For example.

Hope someone can help me. I will be glad to add more code if it’s necessary.

Pagination vs. Infinite Scrolling for page displaying Folders and Files

We have pages which display the contents of a Folder. A Folder can contain zero to many Folders and zero to many Files.

Implementing pagination in this scenario seems awkward — what if my page has 35 Folders and 75 Files, say, and my page size is 25? Page one will be filled with Folders. Page two will have 10 Folders and 15 Files…just seems awkward.

So is infinite scrolling a better option here? Seems like it.

Thank you