instruction stringlengths 0 29.8k ⌀ |
|---|
|strings|suffix-array| |
Using the Pumping-Lemma for $ \{L = a^nb^n | n \in \mathbb{N}\} $.
We define $p \in \mathbb{N}$ \
It exists a word $w = a^pb^p$ \
For every $|w| \ge p$: $w=xyz$, $y > 0$, $|xy| \le p$ \
Because of $|xy| \le p$, we can say that y only consists of a\'s or b\'s. \
For the language to be regular $|xy^iz| \in L$ \... |
Using the Pumping-Lemma for $ \{L = a^nb^n | n \in \mathbb{N}\} $.
We define $p \in \mathbb{N}$ \
It exists a word $w = a^pb^p$ \
For every $|w| \ge p$: $w=xyz$, $y > 0$, $|xy| \le p$ \
Because of $|xy| \le p$, we can say that y only consists of a\'s or b\'s. \
For the language to be regular $|xy^iz| \in L$ \... |
What you suggested does not work. As a sanity check, consider pumping down with $i = 0$ -- this should result in a word with a fewer number of a's.
If you consider the word $w = a^p b^p$, where $p > 0$ is a pumping constant, then since $w\in L$ and $|w| \geq p$, we can parition $w = xyz$ where:
1- $|xy| \leq p$
... |
Iterative minimization algorithm to find a target among a set of points |
null |
I can see many possible approaches. I don't think there's enough information to tell which will be best, so you might have to try them out and see.
Notation: Let $d(A)$ denote the true distance from $A$ to $T$ (which is not observable), and $\tilde{d}(A)$ for the measured distance from $A$ to $T$.
Method 1: One ... |
Let $G = (V, E)$ be a directed weighted graph such that all the weights on the edges are positive.
In $G$, we have two nodes, $v$ and $u$, that have a path from $v$ to $u$.
The question asks find a set of edges $ E' \subseteq E $ with the minimum weight such that
$G' = (V, E') $, has no path from $v$ to $u$.
... |
Disconnection of a directed and weighted graph |
|algorithms|graphs|correctness-proof|dijkstras-algorithm| |
Let $G = (V, E)$ be a directed weighted graph such that all the weights on the edges are positive.
In $G$, we have two nodes, $v$ and $u$, that have a path from $v$ to $u$.
The question asks to find a set of edges $ E' \subseteq E $ with the minimum weight such that
$G' = (V, E') $ has no path from $v$ to $u$.
... |
The algorithm is not correct. Imagine the following graph:
```
2 1 2
v --- o --- o --- u
| |
2| |2
| 1 |
o --- o
| |
2| |2
| 1 |
o --- o
| |
2| |2
| 1 |
o --- o
```
Your algorithm will... |
I'm taking an automata class and one of the examples is showing this is regular. My initial thought was to make a DFA to show it is but i'm a bit confused on what a DFA with a standard 5 tuple would look like for this. I know my alphabet is all the combinations of 0,1,2 for the columns and that my final state would be ... |
Trouble proving this is regular |
|finite-automata|formal-grammars| |
Note that for two ternary numbers $x = x_1x_2...x_n$ and $y = y_1y_2...y_n$ with digits $x_i$ and $y_i$ holds that
$$x < y \iff x_1x_2...x_n \prec y_1y_2...y_n$$
where $\prec$ is supposed to be [lexicographic order](https://en.wikipedia.org/wiki/Lexicographic_order) (dictionary order) of the strings.
So in general
... |
Note that for two ternary numbers $x = x_1x_2...x_n$ and $y = y_1y_2...y_n$ with digits $x_i$ and $y_i$ holds that
$$x < y \iff x_1x_2...x_n \prec y_1y_2...y_n$$
where $\prec$ is supposed to be the [lexicographic order](https://en.wikipedia.org/wiki/Lexicographic_order) (dictionary order) of strings.
In general
-... |
Something I was asked to solve and tried to come up with a formula or some method to solve it after I did and couldn't.
- Given is a graph G=(V,E) that is undirected and weighted. Say we want
to find the lightest paths tree (assume using Dijkstra's algorithm),
we will call it K, and the Minimal Spanning Tre... |
Lightest Paths Tree that is 10 times heavier than an MST of the same graph |
|graphs|dijkstras-algorithm|prims-algorithm| |
null |
The enemy puts a few dozen highly trained snipers around the generals camp. Anyone leaving looking like a messenger or entering looking like a messenger will be instantly shot.
Sorry, your general will be in the dark. |
I'm kinda confused on how to construct this DFA. I'm trying but keep running into the problem of reading an a after the b's or what to do if starting with a b. |
Provide a 2-state DFA for L={a}∗{b}∗ , the set of words of the form aa⋯abb⋯b |
|finite-automata| |
I'm kinda confused on how to construct this DFA. I'm trying but keep running into the problem of reading an a after the b's or what to do if starting with a 'b'. |
null |
For anyone whose first reaction to Andrej Bauer's response was to wonder, like me, whether this is caused by inductive types or also present in the baseline calculus of constructions without inductive types, here is another example that doesn't make use of inductive types at all:
```coq
Definition T := forall P : P... |
I was referring to the textbook Artificial Intelligence: A modern approach 3rd by Stuart Russell and Peter Norvig.
what to prove about the general "graph search": (Here I assume "within a factor of b" means multiplier $b$ instead of [addition $\pm b$][1] based on the complexity context. So if time complexity is $O(b... |
null |
null |
I'd like to count the number of left to right maxima in a permutation in Sage/Python, i.e. the number of times a number appears in the permutation that is greater than all of the previous numbers. The first number will always count as a maxima. I'm struggling with how to formulate the 'if' statement to include all prev... |
Counting left to right maxima in permutations in Sage |
|permutations| |
The problem statement is the following: given a non-empty set P of (x, y) points with an associated reward, find the path through P that gives the maximum earning. The earning of a path is the sum of the rewards minus the total cost of visiting each point, measured as the distance between any pair points. I have to des... |
Given two paths, how can I merge them in a Divide-and-Conquer algorithm to find the optimum earning route given a set of points with rewards? |
|algorithms|optimization|divide-and-conquer| |
null |
just just a visual idea:
Get all the segments possible, and remove all the crossing ones.
Their number should be greatly reduced. Then apply brute-force algorithm, or more smart ones. |
Just a visual idea:
Get all the segments possible, and remove all the crossing ones.
Their number should be greatly reduced. Then apply brute-force algorithm, or smarter ones. |
Let $\Phi$ be a k-CNF and $\Phi_{min}$ be a minimal CNF (one that contains smallest amount of literal occurences) that is equal to $\Phi$.
Can $\Phi_{min}$ contain a clause of size $m > k$?
What I have tried:
Let's define the concept of partial assignment: asingnment that has free variables. Example: $x_1 = 0,... |
Let $G = (V, E)$ be a directed weighted graph such that all the weights on the edges are positive.
In $G$, we have two nodes, $v$ and $u$, that have a path from $v$ to $u$.
The question asks to find a set of edges $ E' \subseteq E $ with the minimum weight such that
$G' = (V, E') $ has no path from $v$ to $u$.
... |
|algorithms|graphs|correctness-proof|network-flow|dijkstras-algorithm| |
null |
Let $G = (V, E)$ be a directed weighted graph such that all the weights on the edges are positive.
In $G$, we have two nodes, $v$ and $u$, that have a path from $v$ to $u$.
The question asks to find a set of edges $ E' \subseteq E $ with the minimum weight such that
$G' = (V, E') $ has no path from $v$ to $u$.
... |
I am reading about Datalog+- (e,g, https://ieeexplore.ieee.org/abstract/document/5571709), and I have a doubt about its semantics, and about the complexity of query answering.
In Datalog+-, you write sets of TGDs whose chase is not guaranteed to terminate. However, Datalog+- guarantees that, for the problem of query... |
Datalog+- doubt about semantics and complexity |
|database-theory|first-order-logic|datalog| |
null |
null |
Lets take the Language $$L = \{ (ab)^na^k | n \ge k \}$$
Does it dictate, that the $(ab)^n$ comes before the $a^k$ ? Or is the order irrelevant as long as it matches the $n \ge k$ criterium?
In simple terms: is the word $aaaababab \in L$ ?
And if so, does this apply for every language?
|
Does a language dictate the order of the word? |
|formal-languages|regular-languages| |
Example $L = {(ab)^na^k|n\ge k}$
When searching for a word $w$, using $p \in \mathbb{N}$, for instance $(ab)^pa^p$, but wanting to pump $a$ (which is not possible because $|xy| \le p$ holds), how do I deal with that? I would need a variable $j \lt p$ for $(ab)^ja^j$ to have the possibility that $a \in y$, so I ca... |
How to handle multiple exponents (Pumping-Lemma) |
|formal-languages|regular-languages|pumping-lemma| |
In complexity theory, what we call a "problem" is never *one* question, but instead *an infinite family of questions that depend on an input*. For each input, there is a question.
An algorithm is said to solve the problem if for any input, the algorithm is able to find the answer to the question. Upper bounds and lo... |
This can be summed up in one sentence that you should memorise:
> In complexity theory, what we call a "problem" is never *one* question, but instead *an infinite family of questions that depend on an input*.
For each input, there is a question.
An algorithm is said to solve the problem if for any input, the a... |
This can be summed up in one sentence that you should memorise:
> In complexity theory, what we call a "problem" is never *one* question, but instead *an infinite family of questions that depend on an input*.
For each input, there is a question.
An algorithm is said to solve the problem if for any input, the a... |
null |
There is actually a more generalized version of the pumping lemma, where you can pump a substring anywhere in the word. The proof is almost the same: in a computation of a word $w$ in a DFA, if there is a substring long enough, it contains a cycle.
The lemma can be stated as such:
> Let $L$ be a regular language ... |
This can be summed up in one sentence that you should memorise:
> In complexity theory, what we call a "problem" is never *one* question, but instead *an infinite family of questions that depend on an input*.
For each input, there is a question.
An algorithm is said to solve the problem if for any input, the a... |
Yes, order matters. The fundamental operation is "string concatenation", for which order is important.
One question: if you were happy about transposing $(ab)^n$ and $a^k$, why wouldn't you also be happy about transposing the $a$ and $b$ inside $(ab)^n$ to get a string like $aaabbabb$?
Of course it's possible to ... |
Given the language $L = \{ a^n | \text{n is odd} \}$
I'm looking for a word $w$ using $p \in \mathbb(N)$. For example, if it would be even, instead of odd I'd choose $w = a^{2p}$.
But with odd, I'm really struggling to find a word. What do I do? Define a variable $j$ and say $\text{j is odd}$ so $a^j \in L$
... |
How to handle odd word |
|formal-languages|regular-languages|pumping-lemma| |
I have no idea what exactly you're asking, but if you consider $w = a^{2p}$ to be a valid answer for even-sized words, I assume $w = a^{2p+1}$ would be fine for odd words. |
Yes, order matters. The fundamental operation used in the definition of language $L$ is "string concatenation", for which order is important.
One question: if you were happy about transposing $(ab)^n$ and $a^k$, why wouldn't you also be happy about transposing the $a$ and $b$ inside $(ab)^n$ to get a string like $aa... |
I cannot help but wonder: how to compute an inverse of a suffix array, preferably in linear time?
For $ISA$, it holds that $ISA[SA[i]] = i$. |
Some people in the literature (very few actually) do not consider missing transitions as *nondeterminism*, and given a DFA, they allow themselves to remove all transitions that lead to states from which we cannot reach an accepting state. The reason for that is technical, as sometimes it may simplify proofs a bit. Or i... |
There are two types of people, those who allow missing transitions when they define a DFA, and those who do not. It does not make a notable difference, see my answer [here][1]. Stick to the definition you have seen in class/book/whatever.
[1]: https://cs.stackexchange.com/questions/133701/why-is-this-automaton-c... |
There are two types of people, those who allow missing transitions when defining a DFA, and those who do not. It does not make a notable difference, see my answer [here][1]. Stick to the definition you've seen in class/book/whatever.
[1]: https://cs.stackexchange.com/questions/133701/why-is-this-automaton-consid... |
This can be summed up in one sentence that you should memorise:
> In complexity theory, what we call a "problem" is never *one* question, but instead *an infinite family of questions that depend on an input*.
For each input, there is a question.
An algorithm is said to solve the problem if for any input, the a... |
This can be summed up in one sentence that you should memorise:
> In complexity theory, what we call a "problem" is never *one* question, but instead *an infinite family of questions that depend on an input*.
For each input, there is a question.
An algorithm is said to solve the problem if for any input, the a... |
On page 77 there is the following quote regarding naming contexts and de Bruijn indices:
> Γ = x ↦ 4, y ↦ 3, z ↦ 2, a ↦ 1, b ↦ 0
>
> Then x (y z) would be represented as 4 (3 2), while λw. y w would be
> represented as λ. 4 0 and λw.λa.x as λ.λ.6.
In the second example how do we distinguish between the... |
How are conflicts between free and bound de Bruijn indices resolved? |
|programming-languages|types-and-programming-languages|types| |
null |
Each query can be implemented to run in $O(\log n)$ time by lazily propagating appropriate operators on the binary search tree.
The lazy propagation technique \*1, is that it is possible to perform *range update* on a BST as long as such update operations can be composed in $O(1)$ time (forms a monoid).
Let $x_i$ a... |
On page 77 of Types and Programming Languages, there is the following quote regarding naming contexts and de Bruijn indices:
> Γ = x ↦ 4, y ↦ 3, z ↦ 2, a ↦ 1, b ↦ 0
>
> Then x (y z) would be represented as 4 (3 2), while λw. y w would be
> represented as λ. 4 0 and λw.λa.x as λ.λ.6.
In the second examp... |
There is a solution to your pumping problem using the classical formulation of the Pumping Lemma, writing $w=xyz$ and considering $|xy| \le p$ and $xy^iz$ for $i\ge 0$. The trick is *pumping down*...
For clarity, instead consider $L = \{b^na^k \mid n\ge k\}$. Assume pumping length $p$. Consider the string $w = b^pa^... |
Let
- $I$ be a set of items;
- $C \subseteq \mathcal{P}(I)$ be a set of subsets of $I$, where $\mathcal{P}(I)$ stands for the power set of $I$; And
- $C(i) = \{ c \in C \mid i \in c \}$ be the set of sets, in $C$, containing item $i \in I$.
We state the following definitions.
**Definition 1**: We say that $\... |
null |
null |
null |
null |
I want to find set cover of this problem.
I have sets, each of cardinality 3. I want to find set cover.
This is what I am doing.
Treat each set as an edge, which is incident on each of its element.
I am considering each element as a vertex.
Now I will find minimum edge cover of this (hyper)graph.
Is this the rig... |
Set cover to Edge cover |
null |
First, apply the standard reduction: to solve a ratio maximization problem (sometimes called "fractional programming"), binary search on the solution $t$:
$$
\max_x \frac{f(x)}{g(x)} \geq t \iff \max_x f(x) - t g(x) \geq 0 \\
\text{assuming } g(x) > 0 \; \forall x.
$$
Applying that to this problem,
$$
\beg... |
Can someone please explain me how to solve this?
In this [post][1] here was one user sketching the solution but I still don't understand how to construct a context-free language $L$ in such a way that the words in $L$ of the form $ww$ are $a^mb^mc^ma^mb^mc^m(m≥0)$. How does the grammar for L looks like? What equalit... |
How to construct context-free language $L$ to prove $L′=\{x|xx∈L\}$ is not context-free? |
|formal-languages|context-free|formal-grammars| |
null |
Context-free languages are not closed under intersection. We start there.
The relevant example is here that
$\{ a^p b^p c^q \mid p,q\ge 0 \} \cap \{ a^p b^q c^q \mid p,q\ge 0 \} = K$, where $K = \{ a^m b^m c^m \mid m\ge 0 \}$ is not context-free.
The two languages each force a pair of letters to have the same num... |
Take a look at
$$L = \{a^nb^nc^ma^mb^kc^l : n, m, k, l \geq 0\}.$$
Now take some $x \in L$ with $x = ww$, then $x = a^nb^nc^ma^mb^kc^l$ for some $n, m, k, l \geq 0$.
There's only *one* possible way to split $x$ into two equal parts $w$:
$$w = a^nb^nc^m = a^mb^kc^l.$$
Note that for pairwise distinct symbols $... |
Take a look at
$$L = \{a^nb^nc^ma^mb^kc^l : n, m, k, l \geq 0\}.$$
Now take some $x \in L$ with $x = ww$, then $x = a^nb^nc^ma^mb^kc^l$ for some $n, m, k, l \geq 0$.
There's only *one* possible way to split $x$ into two equal parts $w$:
$$w = a^nb^nc^m = a^mb^kc^l.$$
Note that for distinct symbols $c_i$, $c_... |
The problem statement is:
>Given a search algorithm that finds and returns a k-colored graph for $k \ge 4$ if one exists, and otherwise returns false, show that there exists a search algorithm for 3-coloring.
My idea is to connect each vertex $v \in V$ to another colored vertex(all new vertices are colored in the ... |
Algorithm for 3-coloring a graph, given a search algorithm that finds a k-colored graph for $k \ge 4$ if one exists, and otherwise returns false |
|reductions|colorings| |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.