instruction
stringlengths
0
29.8k
⌀
I have some questions regarding acceptance of a language by DFA 1. Whether more that one dfa accept a language 2. Whether a dfa can accept more than one language
Language acceptance by DFA
|automata|regular-languages|finite-automata|
1. Yes, there can be many DFAs for a language (many will be silly though, one way to get another is to add unreachable states to any DFA for the langauge). 2. No a DFA accepts *exactly* one language.
null
1. Yes, there can be many DFAs for a language. Many will be silly though, one way to get another is to add unreachable states to any DFA for the language). It is also possible to have more than one sensible DFA: ![Two equivalent DFAs both accepting (a|b)*; the obvious single state DFA with a self loop, and a two sta...
$\newcommand{\maxsnp}{\mathsf{Max}\text{-}\mathsf{SNP}}$The definition of $\maxsnp$ gives us the ability to define: 1. Universal ($\forall$) and existential ($\exists$) quantifiers over variables 2. Existential quantifiers over relations With this definition we can define $\mathsf{Max}$-$\mathsf{SAT}$: $$\exi...
Just to be absolutely clear, Integer Factorization is not known to be NP-intermediate, just suspected to be based on the lack of either NP-completeness proof or polynomial-time algorithm (despite lots of work put into both). I don't know of any natural problem (i.e. not constructed by Ladner for the proof) that is defi...
To expand Luke's answer for your second question: If you fix a DFA (call it $D$), then there are strings that it accepts, let call the set of those strings $ACC_D$, and strings which it rejects (which we can call $REJ_D$). Each input string is either accepted or rejected, then it is either in $ACC_D$ or otherwise, i...
1. Yes, there can be many DFAs for a language. Many will be silly though, one way to get another is to add unreachable states to any DFA for the language). It is also possible to have more than one sensible DFA: ![Two equivalent DFAs both accepting (a|b)*; the obvious single state DFA with a self loop, and a two st...
To expand Luke's answer for your second question: If you fix a DFA (call it $D$), then there are strings that it accepts, let call the set of those strings $ACC_D$, and strings which it rejects (which we can call $REJ_D$). Each input string is either accepted or rejected, then it is either in $ACC_D$ or otherwise, i...
To expand Luke's answer for your second question: If you fix a DFA (call it $D$), then there are strings that it accepts, let's call the set of those strings $ACC_D$, and strings which it rejects (which we can call $REJ_D$). Each input string is either accepted or rejected, then it is either in $ACC_D$ or otherwise,...
From CLRS: >When the loop is a for loop, the moment at which we check the loop invariant just prior to the first iteration is immediately after the initial assignment to the loop-counter variable and just before the first test in the loop header. Why is the checking moment specifically chosen to be after the init...
Invariant Proof for For Loops?
|proof-techniques|correctness-proof|
Invariant Proof of For Loops?
We will show by induction that the permutation $\rho_n = (2,3,4,\ldots, n,1)$ is an example with $C(\rho_n) = 2^{n-1}$. If this is the worst case, as it is for the first few $n$ (see the notes for [OEIS sequence A192053](http://oeis.org/A192053)), then $m(n) \approx (2/e)^{n}$. So the normalized min, like the normalize...
We will show by induction that the permutation $\rho_n = (2,3,4,\ldots, n,1)$ is an example with $C(\rho_n) = 2^{n-1}$. If this is the worst case, as it is for the first few $n$ (see the notes for [OEIS sequence A192053](http://oeis.org/A192053)), then $m(n) \approx (2/e)^{n}$. So the normalized min, like the normalize...
>Consider the searching problem: >Input: A sequence of n numbers A(a1, a2, ...an) and a value v. >Output: An index i such that v = A[i] or the special value NIL if v does not appear in A >Write pseudocode for linear search, which scans through the sequence, looking for v. Using a loop invariant, prove that you...
Proof of linear search?
|proof-techniques|correctness-proof|loop-invariants|
null
What about using a "goal" variable initialized to $NIL$ and taking as invariant "After iteration i, the goal variable contains an index $0 \leq j < i$ such that A[j] = v if there exists one (in the range $\{0, \dots, i - 1\}$), or NIL otherwise" ?
It's impossible to prove unless you state the algorithm. But, let's say your algorithm maintain a candidate index $j$ for loop iteration, which is update to $j \leftarrow j+1$, if $v_j \neq v$, and if the loop termination depends on $j$ not updating of reaching $n$ and the output is $j$, then you could say that a vali...
Consider the searching problem: >Input: A sequence of $n$ numbers $A=(a_1, a_2, \ldots , a_n)$ and a value $v$. >Output: An index $i$ such that $v = a_i$ or the special value NIL if $v$ does not appear in $A$ Write pseudocode for linear search, which scans through the sequence, looking for $v$. Using a loop in...
null
null
What about using a "goal" variable initialized to NIL and taking as invariant "After iteration i, the goal variable contains an index $0 \leq j < i$ such that $A[j] = v$ if there exists one (in the range $\{0, \cdots, i - 1\}$), or NIL otherwise" ?
The loop invariant probably involves the loop control variable. If so, it only makes sense to ask if the invariant is true, when the loop-counter variable is initialized. When the loop control variable is uninitialized, expressions that involve it are undefined. Consider a simple example, a loop whose purpose is to...
I have difficulties understanding the definition of the class [Max-SNP](http://en.wikipedia.org/wiki/SNP_%28complexity%29) (optimization variant of **strict NP**), thus I have to following basic question: If a problem is known to be Max-SNP hard, does this imply NP-hardness of the problem?
|complexity-theory|np-hard|
1. Express this problem as an integer linear program in which the variables take on values on $[2,3]$ . 2. Show that there must in fact be an optimal solution. I am lost on both parts for this problem.
Integer LP formulation and the existence of a solution
null
From [CLRS][1] (third edition, page 19), there is a footnote: >When the loop is a for loop, the moment at which we check the loop invariant just prior to the first iteration is immediately after the initial assignment to the loop-counter variable and just before the first test in the loop header. Why is the check...
null
|proof-techniques|correctness-proof|loop-invariants|
null
|search-algorithms|data-mining|searching|
Is there any algorithm that tells us how to modify semantic actions associated with a left-recursive grammar? For example, we have the following grammar, and its associated semantic actions: $ S \rightarrow id = expr $ { S.s = expr.size } S $\rightarrow$ if expr then $S_1$ else $S_2$ { $S_1.t = S.t + 2; $ $S_2....
How to specify semantic actions when removing left-recursion from a grammer
|compilers|semantics|
How to modify semantic actions when removing left-recursion from a grammer
null
for example there is a neat/classic reduction of factoring to SAT which is also a source of presumed "hard" SAT instances. basically one uses EE ideas for binary multiplication encoded into the SAT circuit. think of binary multiplication as an addition of a series of left shifted multiplicands, each "masked" (ANDed) by...
> Express this problem as an integer linear program in which the variables take on values on [0,1] $$\begin{align} \text{max: } &\sum_i^m y_i \cdot p_i - \sum_j^n x_j \cdot s_j &\\ \text{subject to: } &x_i \geq y_j &\forall i \in L_j \\ &0 \leq x_i \leq 1 &\forall i \\ &0 \leq y_j \leq 1 &\forall j \end{alig...
It's impossible to prove unless you state the algorithm. But, let's say your algorithm maintain a candidate index $j$ for loop iteration, which is update to $j \leftarrow j+1$, if $v_j \neq v$, and if the loop termination depends on $j$ not updating or reaching $n$ and the output is $j$, then you could say that a vali...
From my Googling, it appears that call by value-result is similar to call by reference in that it changes values in the caller, but it's different in that the changes don't take place until the callee exits, and that if the same variable is passed as more than one argument, it'll be treated as separate values in the ca...
I have a container with a certain dimension. A number of small boxes that may be different in size is to be packed into the container. How to arrange the small boxes such that the container contains as many as possible?
Algorithm to pack any small boxes into a big box
|efficiency|
null
I have a container with a certain dimension. A number of small boxes that may be different in size is to be packed into the container. How to arrange the small boxes such that the container contains as many as possible? Edit: - No rotation is allowed. - The heavier boxes must not be on the top of the lighter o...
|algorithms|combinatorics|efficiency|approximation|knapsack-problems|
null
null
I'm unclear about the use of the phrases "infinite" language or "finite" language in computer theory. I think the root of the trouble is that a language like L={ab}* is **infinite** in the sense that it can generate an infinite (but countable) number of strings. Yet, it can still be recognized by a **finite** state ...
Infinite Language vs. finite language
|formal-languages|regular-languages|
The loop invariant probably involves the loop control variable. If so, it only makes sense to ask if the invariant is true, when the loop-counter variable is initialized. When the loop control variable is uninitialized, expressions that involve it are undefined. Consider a simple example, a loop whose purpose is to...
Oh my. This seems like a confusion caused by the (old school) terminology of "finite-state language" as a synonym for what is known today as "regular language". Anyways, the standard definitions for finite/infinite accepted these days regard only the size of the language: 1. a **finite** language is any set $L$ o...
I'm unclear about the use of the phrases "infinite" language or "finite" language in computer theory. I think the root of the trouble is that a language like $L=\{ab\}^*$ is **infinite** in the sense that it can generate an infinite (but countable) number of strings. Yet, it can still be recognized by a **finite** s...
|formal-languages|terminology|regular-languages|
I recently took a practice exam for the Computer Science GRE and this was one of the questions: > assume that set A has 5 elements and set B has 4 elements, how many > functions exist from set A to set B? I had no idea what this means, I don't recall ever studying functions between sets, could someone shed some...
Functions between sets?
|sets|
I recently took a practice exam for the Computer Science GRE and this was one of the questions: > Assume that set $A$ has 5 elements and set $B$ has 4 elements, how many functions exist from set $A$ to set $B$? I had no idea what this means, I don't recall ever studying functions between sets, could someone shed...
|combinatorics|sets|
$\newcommand{\stirling}[2]{\genfrac{\{}{\}}{0pt}{}{#1}{#2}}$Your comment is correct in that there are $4^5=1024$ functions from $A$ to $B$. Letting $|A| =n, |B| = m$ this can be seen by the identity: $$\sum_{k=0}^n \stirling{n}{k} m(m - 1) \dotsb (m - k + 1) = m^n$$ This describes all the ordered partitions o...
$\newcommand{\stirling}[2]{\genfrac{\{}{\}}{0pt}{}{#1}{#2}}$Your comment is correct in that there are $4^5=1024$ functions from $A$ to $B$. Letting $|A| =n, |B| = m$ this can be seen by the identity: $$\sum_{k=0}^n \stirling{n}{k} m(m - 1) \dotsb (m - k + 1) = m^n$$ This describes all the ordered partitions o...
null
null
Your problem is called **3D Bin Packing** and is indeed an NP problem. Looking those key words on Google will yield many articles about more or less complex approximation algorithms that can help you solve this problem.
Your problem is called [(multiple constraints) knapsack problem][1] and is indeed an NP problem. Looking those key words on Google will yield many articles about more or less complex approximation algorithms that can help you solve this problem :) [1]: http://en.wikipedia.org/wiki/List_of_knapsack_problems#Mu...
The loop invariant probably involves the loop control variable. If so, it only makes sense to ask if the invariant is true, when the loop control variable is initialized. When the loop control variable is uninitialized, expressions that involve it are undefined. Consider a simple example, a loop whose purpose is to...
I have asked this exact question on [StackOverflow][3]. I did not get the answer that I was looking for. Please read this question fully before answering. Thank You.<br><br> For static pattern database(5-5-5), see [this][1](page 290 and 283) For [What is 15-puzzle?][2]<br> I am creating a static patter database(5-5-5...
Need a practical solution for creating pattern database(5-5-5) for 15-Puzzle
|algorithms|artificial-intelligence|recursion|java|
null
It was brought to my attention that the cost of type inference in a functional language like OCaml can be very high. The claim is that there is a sequence of expressions such that for each expression the length of the corresponding type is exponential on the length of the expression. I devised the sequence below. My...
A more concise example that illustrates that type inference can be very costly?
|functional-programming|
Concise example of exponential cost of ML type inference
|lambda-calculus|type-theory|functional-programming|type-inference|type-checking|
Is there a clear reference, with pseudo-code, on how to go about implementing a Prolog interpreter in a purely functional language? That which I have found so far seems to deal only with imperative languages, is merely a demonstration of Prolog implemented in itself, or offers no concrete algorithm to use for interpret...
How to implement a prolog interpreter in a purely functional language?
|functional-programming|prolog|logic-programming|
In this answer, I'll stick to a core ML fragment of the language, with just lambda-calculus and polymorphic `let` following [Hindley-Milner](http://en.wikipedia.org/wiki/Hindley%E2%80%93Milner). The full OCaml language has additional features such as row polymorphism (which if I recall correctly doesn't change the theo...
I think the simplest way to think of Convolution is as a method of changing a pixel's value to a new value based on the weight of nearby pixels. It's easy to see why Box Blur: _____________ |1/9|1/9|1/9| |1/9|1/9|1/9| |1/9|1/9|1/9| ------------- works. Convolving this kernel is the same...
Since [Prolog][1] = [Syntactic Unification][2] + [Backward chaining][3] + [REPL][4] All three parts can be found in [Artificial intelligence: structures and strategies for complex problem solving][5] by George F. Luger. In the fourth edition of the book all three parts are implemented in [LISP][6] in Section 15.8, L...
Since [Prolog][1] = [Syntactic Unification][2] + [Backward chaining][3] + [REPL][4] All three parts can be found in [Artificial intelligence: structures and strategies for complex problem solving][5] by George F. Luger. In the fourth edition of the book all three parts are implemented in [LISP][6] in Section 15.8, L...
Since [Prolog][1] = [Syntactic Unification][2] + [Backward chaining][3] + [REPL][4] All three parts can be found in [Artificial intelligence: structures and strategies for complex problem solving][5] by George F. Luger. In the fourth edition of the book all three parts are implemented in [LISP][6] in Section 15.8, L...
Since [Prolog][1] = [Syntactic Unification][2] + [Backward chaining][3] + [REPL][4] All three parts can be found in [Artificial intelligence: structures and strategies for complex problem solving][5] by George F. Luger. In the fourth edition of the book all three parts are implemented in [LISP][6] in Section 15.8, L...
null
Since [Prolog][1] = [Syntactic Unification][2] + [Backward chaining][3] + [REPL][4] All three parts can be found in [Artificial intelligence: structures and strategies for complex problem solving][5] by George F. Luger. In the fourth edition of the book all three parts are implemented in [LISP][6] in Section 15.8, L...
I know that if you try and make the theory $\lambda\beta+\{s = t\ |\text{ s, t are terms without }\lambda\beta\text{ normal forms}\}$ then that theory becomes inconsistent. Are terms without $\lambda\beta$ normal forms also unconvertible in $\lambda\beta$? If so are these linked in some way?
Are terms without $\lambda\beta$ normal forms unconvertible in $\lambda\beta$?
|lambda-calculus|
I know that if you try and make the theory $$\lambda\beta+\{s = t\ |\text{ s, t are terms without }\lambda\beta\text{ normal forms}\}$$ then that theory becomes inconsistent. Are two terms where one is without a $\lambda\beta$ normal form also unconvertible in $\lambda\beta$, ie can it ever be true that $\lambda\...