instruction
stringlengths
0
29.8k
⌀
I have the following language $\qquad \{0^i 1^j 2^k \mid 0 \leq i \leq j \leq k\}$ I am trying to determine which chomsky language class it fits into. I can see how it could be made using a context-sensitive grammar so I know it is atleast context-sensitive. It seems like it wouldn't be possible to make with a co...
A directed graph is said to be *unipathic* if for any two vertices $u$ and $v$ in the graph $G=(V,E)$, there is at most one simple path from $u$ to $v$. Suppose I am given a unipathic graph $G$ such that each edge has a positive or negative weight, but contains no negative weight cycles. From this I want to fin...
I was given the question > Where does the following language fit in the Chomsky hierarchy? > > Nonnegative solutions $(x,y)$ to the Diophantine equation $3x-y=1$. I understand languages like $L = \{ 0^n1^n \mid n \ge 1\}$, but this language confuses me. What do the words in the language look like? How could I...
How can solutions of a Diophantine equation be expressed as a language?
Find shortest paths in a weighed unipathic graph
In the script I am currently reading on the lambda calculus, beta equivalence is defined as this: > The $\beta$-equivalence $\equiv_\beta$ is the smallest equivalence that contains $\rightarrow_\beta$. I have no idea what that means. Can someone explain it in simpler terms? Maybe with an example? I need it for...
What is beta equivalence?
|lambda-calculus|
$\to_\beta$ is the one-step relation between terms in the $\lambda$-calculus. This relation is neither reflexive, symmetric, or transitive. The equivalence relation $\equiv_\beta$ is the reflexive, symmetric, transitive closure of $\to_\beta$. This means 1. If $M\to_\beta M'$ then $M\equiv_\beta M'$. 2. For all...
OK, so here is a question from a past test in my Theory of Computation class: >A useless state in a TM is one that is never entered on any input string. Let $USLESS_{TM}$ = {$<$$M$, $q$$>$ | $M$ is a TM that contains useless state $q$}. Prove that $USELESS_{TM}$ is undecidable. I think I have an answer, but I'...
A Question Relating to A Useless Turing Machine
|undecidability|turing-machines|
This is clearly reducible from the Halting Problem. If the machine doesn't stop (for some $x$) than any final state is "useless". Given an input $M,x$ it is easy to construct $M_x$ that either halts on every input (thus it's final state is not useless), or doesn't halt for any input (thus it's final state is useless).
OK, so here is a question from a past test in my Theory of Computation class: >A useless state in a TM is one that is never entered on any input string. Let $USLESS_{TM} = \{\langle M\rangle, q \mid q \text{ is a useless state in }M\}$. Prove that $USELESS_{TM}$ is undecidable. I think I have an answer, but I...
It is elementary set theory really. You know what is a reflexive relation, what is a symmetric relation, and what is a transitive relation, right? An equivalence relation is one that satisfies all three of those properties. Have you heard of the "transitive closure" of a relation $R$? Well, it is nothing but th...
Another way to decide $FINITE_{CFG}$ is via the pumping lemma. The pumping lemma says that each CFL $L$ has a number $N$ (which can be computed from the grammar, or at least an upper bound of it can easily be computed), such that any $x\in L$ which is longer than $N$ can be "pumped". This means that if $L$ is fin...
null
|formal-languages|homework|
|formal-languages|
OK, so here is a question from a past test in my Theory of Computation class: >A useless state in a TM is one that is never entered on any input string. Let $$USELESS_{TM} = \{\langle M\rangle, q \mid q \text{ is a useless state in }M\}.$$ Prove that $USELESS_{TM}$ is undecidable. I think I have an answer, bu...
|undecidability|turing-machines|
Write $\bar n$ for the decimal expansion of $n$ (with no leading `0`). Let $a$ and $b$ be integers, with $a > 0$. Consider the language of multiples of $a$ plus a constant: $$M = \{ \overline{a\,x+b} \mid x\in\mathbb{N} \}$$ Is $M$ regular? context-free? (Contrast with [Language of the graph of an affine funct...
Language of the multiples of an integer
|formal-languages|context-free|integers|
Write $\bar n$ for the decimal expansion of $n$ (with no leading `0`). Let `:` be a symbol distinct from any digit. Let $a$ and $b$ be integers, with $a > 0$. Consider the language of solutions of the Diophantine equation $y=ax+b$: $$L = \{ \bar{x} \mathtt: \bar{y} \mid y = a\,x + b \}$$ Is $L$ regular? context-f...
Language of the graph of an affine function
|formal-languages|regular-languages|integers|
**Hint #1**: first solve the more popular problem "write a automaton that recognizes the decimal/binary representations of numbers divisible by 3" **when the least signigicant bit** appears first. Intermediate question: prove that $\{ \overline{a\,x+b}\mid x\in\mathbb{Z}\}$ is regular. **Hint #2**: The graph of t...
It is regular. Let's work in binary, which will clearly generalize to any base > 1. Let $M_{a,b}$ be the language in question. For a = 1, b = 0 we get $M_{1,0} = \{1, 10, 11, 100, 101, ...\}$ which is all strings over $\{0,1\}$ without leading zeroes, which is clearly regular (regular expression $(0+1)^*-0^+(0...
It is regular. Let's work in binary, which will clearly generalize to any base > 1. Let $M_{a,b}$ be the language in question. For a = 1, b = 0 we get $M_{1,0} = \{1, 10, 11, 100, 101, ...\}$ which is all strings over $\{0,1\}$ without leading zeroes, which is regular (construct a regular expression for it). ...
It is regular. Let's work in binary, which will clearly generalize to any base > 1. Let $M_{a,b}$ be the language in question. For a = 1, b = 0 we get $M_{1,0} = \{1, 10, 11, 100, 101, ...\}$ which is all strings over $\{0,1\}$ without leading zeroes, which is regular (construct a regular expression for it). ...
I have used the technique of dynamic programming multiple times however today a friend asked me how I go about defining my sub-problems, I realized I had no way of providing an objective formal answer. How do you formally define a sub-problem for a problem that you would solve using dynamic programming?
Deciding on Sub-Problems for Dynamic Programming
|dynamic-programming|
**Hint 1**: What happens when $a=1$ and $b=0$? **Hint 2**: Can a different value of $a,b$ change the classification of the language? **Hint 2.1**: Well, if $a=10$ it's not a problem, right? **Hint 2.2**: Closure properties? Now deal with the $b$. Does the $b$ really matters for **most** of the $x$'s (that is,...
It is regular. Let's first work in binary, which will generalize to any base > 1. Let $M_{a,b}$ be the language in question. For a = 1, b = 0 we get $M_{1,0} = \{1, 10, 11, 100, 101, ...\}$ which is all strings over $\{0,1\}$ without leading zeroes, which is regular (construct a regular expression for it). ...
It is regular. Let's first work in binary, which will generalize to any base > 1. Let $M_{a,b}$ be the language in question. For a = 1, b = 0 we get $M_{1,0} = \{1, 10, 11, 100, 101, ...\}$ which is all strings over $\{0,1\}$ without leading zeroes, which is regular (construct a regular expression for it). ...
The "best" data structure probably depends on what particular problem you're trying to solve with it. Here's one approach that I've seen (and have used myself), which simply stores all the information and leaves it up to the algorithm what to do with it. 1. First you index the nodes by unique integers, 0 through n-...
It is regular. Let's first work in binary, which will generalize to any base > 1. Let $M_{a,b}$ be the language in question. For a = 1, b = 0 we get $M_{1,0} = \{1, 10, 11, 100, 101, ...\}$ which is all strings over $\{0,1\}$ without leading zeroes, which is regular (construct a regular expression for it). ...
The principle of dynamic programming is to think top-down (i.e recursively) but solve bottom up. So a good strategy for designing a DP is to formulate the problem recursively and generate sub-problems that way.
It is regular. Let's first work in binary, which will generalize to any base > 1. Let $M_{a,b}$ be the language in question. For a = 1, b = 0 we get $M_{1,0} = \{1, 10, 11, 100, 101, ...\}$ which is all strings over $\{0,1\}$ without leading zeroes, which is regular (construct a regular expression for it). ...
It is regular. Let's first work in binary, which will generalize to any base > 1. Let $M_{a,b}$ be the language in question. For a = 1, b = 0 we get $M_{1,0} = \{1, 10, 11, 100, 101, ...\}$ which is all strings over $\{0,1\}$ without leading zeroes, which is regular (construct a regular expression for it). ...
A Question relating to a Turing Machine with a useless state
null
OK, so here is a question from a past test in my Theory of Computation class: >A useless state in a TM is one that is never entered on any input string. Let $$\mathrm{USELESS}_{\mathrm{TM}} = \{\langle M\rangle, q \mid q \text{ is a useless state in }M\}.$$ Prove that $\mathrm{USELESS}_{\mathrm{TM}}$ is undecidab...
null
This is clearly reducible from the Halting Problem. If a machine $M$ does not stop on input $x$ then any final state is "useless". Given an input $M,x$ for the Halting problem, it is easy to construct $M_x$ that halts on every input (thus its final state is not useless) if and only if $M$ halts on $x$. That way you can...
Write $\bar n$ for the decimal expansion of $n$ (with no leading `0`). Let `:` be a symbol distinct from any digit. Let $a$ and $b$ be integers, with $a > 0$. Consider the language of solutions of the Diophantine equation $y=ax+b$: $$L = \{ \bar{x} \mathtt: \bar{y} \mid y = a\,x + b \}$$ Is $L$ regular? context-f...
|formal-languages|regular-languages|context-free|integers|
Regarding "Is $L$ regular?": You should reflexively check the [Pumping condition](https://en.wikipedia.org/wiki/Pumping_lemma_for_regular_languages); can a long solution $\bar{x}:\bar{y}$ be pumped? >! No, it can not. Assume a pumping constant $p$. Because $y = ax + b$ has arbitrarily large solutions ($a>0$ !), we c...
In a standard algorithms course we are taught that **quicksort** is $\mathcal{O}(n \log n)$ on average and $\mathcal{O}(n^2)$ in the worst case. At the same time, other sorting algorithms are studied which are $\mathcal{O}(n \log n)$ in the worst case (like **mergesort** and **heapsort**), and even linear time in the b...
Language of the values of an affine function
As @Suresh pointed out, once you know that your problem can be solved by DP (i.e., it exhibits optimal substructure and overlapping subproblems), you may think of a divide and conquer recursive solution. Of course, divide and conquer will be highly ineffective because every subproblem encountered in the associated ...
Write $\bar n$ for the decimal expansion of $n$ (with no leading `0`). Let $a$ and $b$ be integers, with $a > 0$. Consider the language of multiples of $a$ plus a constant: $$M = \{ \overline{a\,x+b} \mid x\in\mathbb{N} \}$$ Is $M$ regular? context-free? (Contrast with [Language of the graph of an affine funct...
Write $\bar n$ for the decimal expansion of $n$ (with no leading `0`). Let `:` be a symbol distinct from any digit. Let $a$ and $b$ be integers, with $a > 0$. Consider the language of solutions of the Diophantine equation $y=ax+b$: $$L = \{ \bar{x} \mathtt: \bar{y} \mid y = a\,x + b \}$$ Is $L$ regular? context-f...
|formal-languages|context-free|regular-languages|integers|
My experience is finding out a way to "cut down redundant enumerating with help of storing useful value already enumerated". By the way, Dynamic Programming is really popular in ICPC(International Collegiate Programming Contest. Anyone can have his own feeling about DP after practice several ICPC problems.
null
If you want to prove the identities by hand, I do not know if there are absolutely general techniques. You can start with the axioms and well known identities for CTL and work from there. If you want the answer and worry about having a human readable proof separately, you can use a CTL satisfiability checker like [M...
**Hint #1**: first solve the more popular problem "write a automaton that recognizes the decimal/binary representations of numbers divisible by 3" **when the least signigicant bit** appears first. Intermediate question: prove that $\{ \overline{a\,x+b}\mid a\,x+b≥0 \quad x\in\mathbb{Z}\}$ is regular. **Hint #2**:...
As @Suresh pointed out, once you know that your problem can be solved by DP (i.e. it exhibits optimal substructure and overlapping subproblems), you may think of a divide and conquer recursive solution. Of course, divide and conquer will be highly ineffecient because every subproblem encountered in the associated r...
|logic|lambda-calculus|type-theory|
null
For the purposes of this proof we will assume that $USELESS_{TM}$ is decidable to display a contradiction. Create TM $R$ that does the following: - Converts TM $M$ to a pushdown automata $P$ with a relaxed stack (ie. no LIFO requirement). This is equivalent to a directed graph detailing the transition between ...
Access control models are typically very coarse-grained, allowing one access to a resource (possibly with some combination of read/write/execute permission) or exclude such access. Some models of database security allow access to be granted on a per row basis (though I don't have a reference handy). Have fine-graine...
I am currently learning the lambda calculus and was wondering about the following two different kinds of writing a lambda term. 1. $\lambda xy.xy$ 2. $\lambda x.\lambda y.xy$ Is there any difference in meaning or the way you apply beta reduction, or are those just two ways to express the same thing? Especi...
Is there a difference between $\lambda xy.xy$ and $\lambda x.\lambda y.xy$?
|lambda-calculus|
In real world applications is there a concrete benefit when using O(log(log(n)) instead of O(log(n)) algorithms ? This is the case when one use for instance van Emde Boas trees instead of more conventional binary search tree implementations. But for example, if we take n < 10^6 then in the best case the double log...
Logarithmic vs double logarithmic time complexity
|algorithms|complexity-theory|binary-trees|algorithm-analysis|
The first is an abbreviation for the second. It's a common syntactic convention to shorten expressions. On the other hand, if you have tuples in the language, then there is a difference between 1. $\lambda x.\lambda y.xy$ and 2. $\lambda (x,y).xy$. In the former case I can provide a single argument to the fu...
Transforming a function that takes multiple arguments to a chain of functions with single arguments is called **currying**. The two functions are essentially the same. [Wikipedia article about currying][1] [1]: http://en.wikipedia.org/wiki/Currying
These are just differences of notations. $λxyz.t$ is short for $λx.λy.λz.t$. No magic here. Indeed, $\mbox{pair}=λxyp.pxy$ but you tend to emphasize that $\mbox{pair}\,t\,u$ is a function $λp.ptu$ by changing the way you write the definition. But it is really the same.
The first is an abbreviation for the second. It's a common syntactic convention to shorten expressions. On the other hand, if you have tuples in the language, then there is a difference between 1. $\lambda x.\lambda y.xy$ and 2. $\lambda (x,y).xy$. In the former case I can provide a single argument to the fu...
In real world applications is there a concrete benefit when using $\mathcal{O}(\log(\log(n))$ instead of $\mathcal{O}(\log(n))$ algorithms ? This is the case when one use for instance van Emde Boas trees instead of more conventional binary search tree implementations. But for example, if we take $n < 10^6$ then in...
One could imagine that the difference in complexity really does not matter so much, and that the actual run-time is more important. But if the algorithm is at the core of another algorithm, then this difference may be important. From a purely theoretical purpose, the difference of course does matter, especially if t...
I've actually benchmarked the van Emde-Boas tree myself once. I compared it with an AA Tree, a hashmap and a bit array. The tests perform `size` inserts with random numbers in the interval `[0, bound]`, then `size` searches, then `size` deletes and then again `size` searches. Deletes are done on random numbers as we...
Do not forget that $\log n$ still grows exponentially (in $\log(n)$) faster than $\log(\log n)$! Indeed, if you look at the quotient of $\log(n)$ and $\log(\log(n))$, there is not much impressive to see: ![log(n)/log(log(n))][1] But still, you get a factor five to six for sizes up to $100000$. Note that larger...
Regarding "Is $L$ regular?": You should reflexively check the [Pumping condition](https://en.wikipedia.org/wiki/Pumping_lemma_for_regular_languages); can a long solution $\bar{x}:\bar{y}$ be pumped? >! No, it can not. Assume a pumping constant $p$. Because $y = ax + b$ has arbitrarily large solutions ($a>0$ !), we c...
Write $\bar n$ for the decimal expansion of $n$ (with no leading `0`). Let `:` be a symbol distinct from any digit. Let $a$ and $b$ be integers, with $a > 0$. Consider the language of solutions of the Diophantine equation $y=ax+b$: $$L = \{ \bar{x} \mathtt: \bar{y} \mid y = a\,x + b \}$$ Is $L$ regular? context-f...
null
null
See Sutter, [The Free Lunch is Over][1] (2005): it has graphs, discusses how various processor characteristics relate to performance of actual programs, and makes some predictions that turned out true, as far as I can tell. [1]: http://www.gotw.ca/publications/concurrency-ddj.htm
We all know that Markov Chains can be used for generating real-looking text (or real-sounding music). I've also heard that Markov Chains has some applications in the image processing, is that true? What are some other uses of MCs in CS?
What are the uses of Markov Chains in CS?
|soft-question|probability-theory|
> Markov chains appear everywhere. Why? Because the model is so general: You are interested in a large set of objects, and you can handle local manipulations on these objects, eg. modifying an object slightly to get a new one. You want to study global properties of this set of objects, such as its approximate size. Thi...
I've actually benchmarked the van Emde-Boas tree myself once. I compared it with an AA Tree, a hashmap and a bit array. The tests perform `size` inserts with random numbers in the interval `[0, bound]`, then `size` searches, then `size` deletes and then again `size` searches. Deletes are done on random numbers as we...
**Hint 1**: What happens when $a=1$ and $b=0$? OK, we nailed it for a specific pair $a,b$. Now, does it will become any different for other $a,b$? **Hint 2**: Go on with $b=0$ and arbitrary $a$ **Hint 3**: Try to think what happens if $a=0$ and $b$ is not. This can't happen in this question, but it should give...
An important application are [Hidden Markov Models](https://en.wikipedia.org/wiki/Hidden_Markov_model) which essentially assume the underlying random distribution follows a Markov chain. One exiting application of HMMs is [gene prediction](https://en.wikipedia.org/wiki/Gene_prediction) in bioinformatics. The task is to...
I'm looking for a data structure that stores a set of strings over a character set $\Sigma$, capable of performing the following operations. We denote $\mathcal{D}(S)$ as the data structure storing the set of strings $S$. * `Add-Prefix-Set` on $\mathcal{D}(S)$: given some set $T$ of (possibly empty) strings, whose s...
Is there a 'string stack' data structure that supports these string operations?
|time-complexity|data-structures|strings|
I'm looking for a data structure that stores a set of strings over a character set $\Sigma$, capable of performing the following operations. We denote $\mathcal{D}(S)$ as the data structure storing the set of strings $S$. * `Add-Prefix-Set` on $\mathcal{D}(S)$: given some set $T$ of (possibly empty) strings, whose s...
I'm looking for a data structure that stores a set of strings over a character set $\Sigma$, capable of performing the following operations. We denote $\mathcal{D}(S)$ as the data structure storing the set of strings $S$. * `Add-Prefix-Set` on $\mathcal{D}(S)$: given some set $T$ of (possibly empty) strings, whose s...
Assume I have two formulae $\Phi$ and $\Psi$ (over the same set of atomic propositions $AP$) in [CTL][1]. We have that $\Phi \equiv \Psi$ iff $Sat_{TS}(\Phi) = Sat_{TS}(\Psi)$ for all transition systems $TS$ over $AP$. Given that there are infinitely many transition systems, it's impossible to check them all. I thou...
How can I decide manually whether two CTL formulae are equivalent?
I'm looking for a data structure that stores a set of strings over a character set $\Sigma$, capable of performing the following operations. We denote $\mathcal{D}(S)$ as the data structure storing the set of strings $S$. * `Add-Prefix-Set` on $\mathcal{D}(S)$: given some set $T$ of (possibly empty) strings, whose s...