CFG that generates $1^*$ is decidable

I read somewhere that the problem which asks whether or not a $ CFG$ $ G$ generates $ 1^*$ is decidable. The proof goes like this:

$ 1^* \cap G$ is context free since it is the intersection of a regular language and a $ CFG$ , therefore we can test if $ 1^* \cap G$ is empty since it is decidable to check if a $ CFG$ is empty. If $ 1^* \cap G$ is empty, reject, otherwise, accept

I have doubts however with this proof since it only shows that some string in $ 1^*$ is generated by $ G$ , but not whether $ G$ generates all strings in $ 1^*$ .

Moreover, if this proof is correct, we can use the same proof outline under the alphabet $ \Sigma=\{0,1\}$ to show that $ G$ generates $ \Sigma^*$ , or that $ \Sigma^* \subseteq G$ . However, it is known that it is undecidable whether $ R \subseteq G$ , where $ R$ is a regular language, and $ G$ is a $ CFG$ (by setting $ R=\Sigma^*$ , and $ \Sigma=\{0,1\}$ .

But to show that a $ CFG$ generates $ 1^*$ is decidable, the only way I can think of is to use something similar to the proof that it is decidable for a $ PCP$ instance to generate some string in $ 1^*$ (i.e., $ w=v$ , where $ w,v \in 1^*$ ), i.e. we can check if the $ CFG$ has rule $ S \rightarrow S1$ , then accept. O.w. if it has rules of the form $ S \rightarrow 1^aS1^b$ such that $ a > b$ , and rules of the form $ S \rightarrow 1^cS1^d$ such that $ c < d$ , then accept… But is there a simpler way to solve this problem ?

An algorithm which efficiently generates random samples without replacement, from a large range [0-N], N ~ 10^12?

I want an algorithm which generates random integers, without replacement, from a large range [0-N], N~10^12.

However, the whole range should not be stored in memory. The memory footprint should be O(1) relative to N. The algorithm can (probably must) retain state after every sample request.

The randomness should be “strong” in the cryptographic sense.

Is this correct : whether or not a type 3 grammar generates $\Sigma^*$ is not c.e

An example from Sipser’s book, Introduction to the Theory of Computation, shows that it is not decidable for a $ TM$ to recognize whether a $ CFG$ (or a type 2 grammar) generates $ \Sigma^*$ , where $ \Sigma$ is the alphabet. Call this language $ CFG_{all}$

But the above language is also not computably enumerable. There can be a reduction from $ CFG_{all}$ to $ \bar{A_{TM}}$ , where $ \bar{A_{TM}}$ is the language s.t. the input $ TM$ does not accept any input. $ \bar{A_{TM}}$ is not computably enumerable.

But could we say that whether or not a type 3 grammar generates $ \Sigma^*$ is also not c.e. ? (since type 3 grammars are a subset of context-free grammars). While it is true that a finite automaton can recognize $ \Sigma^*$ , this language is different right from whether a type 3 grammar generates $ \Sigma^*$ ?

Just to clarify the source of my confusion, in summary, it is decidable for a $ TM$ to decide whether a pushdown automaton recognizes $ \Sigma^*$ or accepts any input, but it is not decidable or even computably enumerable for a $ TM$ to recognize that a CFG generates $ \Sigma^*$ . Similarly, it is decidable for a $ TM$ to check if a finite automaton accepts $ \Sigma^*$ , but it may not be decidable for a $ TM$ to check if a type 3 grammar generates $ \Sigma^*$ . It’s somehow the difference between recognizing and generating.

get_template_directory_uri() generates wrong path

I’ve uploaded a wordpress site but it’s missing javascript and css. The links on the head still have the local path (src='https://localhost...') and not the new ones. So I guess it has to do with get_template_direcory_uri() that I use in fucntions.php to apply my javascript/jquery,bootstrap,css etc.

How yo fix that?

I’ve tried adding to config.php:

define( 'WP_SITEURL', 'http://' . $  _SERVER['HTTP_HOST'] ); define( 'WP_HOME',    'http://' . $  _SERVER['HTTP_HOST'] ); 

and

define( 'WP_HOME', 'https://...' ); define( 'WP_SITEURL', 'https://...' ); 

but they didn’t help…

Proving the decidability of whether a CFG generates a particular string or not

Let $ G$ be a context-free grammar and $ w$ be a string of length $ |w| = n$ .

Consider the language $ A_{CFG}$ = { <$ G$ , $ w$ > | $ G$ is CFG that generates $ w$ }, where <$ G$ , $ w$ > is a string encoding of $ G$ and $ w$ .

Now we have to show that $ A_{CFG}$ is decidable, or in other words, there exists an algorithm that determines whether $ w$ is generated by $ G$ or not.

Now, the proof given in my book converts $ G$ into an equivalent CFG $ G’$ in Chomsky Normal Form and one-by-one checks all derivations in $ G’$ that take $ 2n – 1$ steps, since a grammar in CNF takes exactly $ 2n – 1$ steps to generate a string of length $ n$ .

Now, I have an alternate algorithm in mind. I want you guys to tell me if there is something wrong with it or not because this one seems to be much simpler than the one given in my book.

So, since every CFG has a pushdown automaton which recognizes the same language, we convert the CFG into an equivalent PDA. Now we simulate the PDA on our Turing machine on the string $ w$ . This process must end in a finite number of steps since our string is finite in length.

Is this an alternate algorithm that illustrates the decidability of $ A_{CFG}$ or is there something wrong with it?

Magento 2 generates thousands of temp table queries on product update

I have a Magento 2.2.5 store with ~20k products and ~250 categories arranged in a tree of maximum 2 sub categories.

One of the top categories has 5k products and when I try to remove a product from the category, or remove the category for a specific product the server takes more than 2 minutes and times out.

After reading the general_log, I saw thousands of queries like this:

SELECT `e`.* FROM `tmp_select_e5e424ef98e4a8a4026e18df9d8088e0` AS `e` WHERE (hash_key = '1_44083') 

peaking the database server to 100%: enter image description here

I think this has something to do with url_rewrites, but I can’t seem to understand how is this a problem with only 5k products.

Are there any configurations I can set maybe loosing functionalities, to be able to do something as simple as removing a product from a category?

Thanks a lot.