instruction stringlengths 0 29.8k ⌀ |
|---|
I'm developing a functional programming language that offers Rank-n polymorphism. Like Haskell I don't want types to appear at the term level, but I have no idea to insert type abstraction and type application in a term afterward.
For example, identity function is defined like below in Haskell.
id :: forall a... |
null |
Consider the search 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 inva... |
null |
There are two types of sets $\mathcal{X} = \{X_{1}, X_{2}, \ldots, X_{n_{1}} \}$ and $\mathcal{Y} = \{Y_{1}, Y_{2}, \ldots, Y_{n_{2}}\}$ such that $n = n_{1} + n_{2}$.
Given an sequnce $\alpha$ over $\mathcal{X} \cup \mathcal{Y}$.
The goal is to find the longest increasing sub-sequence $\beta$ such that
1. the ... |
Is this varient of longest nested sets problem NP-hard? |
|dynamic-programming|np-hard| |
This problem is [strongly](https://en.wikipedia.org/wiki/Strong_NP-completeness) NP-hard.
A set of transactions can be regarded as a directed graph. Let $A$ be the set of vertices corresponding to players with positive losses and let $B$ be the set of vertices corresponding to players with positive wins.
The number... |
There are two types of sets $\mathcal{X} = \{X_{1}, X_{2}, \ldots, X_{n_{1}} \}$ and $\mathcal{Y} = \{Y_{1}, Y_{2}, \ldots, Y_{n_{2}}\}$ such that $n = n_{1} + n_{2}$.
Given a sequnce $\alpha$ over $\mathcal{X} \cup \mathcal{Y}$,the goal is to find the longest increasing sub-sequence $\beta$ such that
1. the sub-s... |
Is this varient of longest increasing nested sets problem NP-hard? |
null |
There are two types of sets $\mathcal{X} = \{X_{1}, X_{2}, \ldots, X_{n_{1}} \}$ and $\mathcal{Y} = \{Y_{1}, Y_{2}, \ldots, Y_{n_{2}}\}$ such that $X_i, Y_j \subseteq [m]=[\mathrm{poly}(n)]$ and $n = n_{1} + n_{2}$.
Given a sequnce $\alpha$ over $\mathcal{X} \cup \mathcal{Y}$,the goal is to find the longest increasing... |
Interesting perspectives presented by (Lance Fortnow, The Golden Ticket: P, NP, and the Search for the Impossible, 2013, Chapter 7), has shown analogies to the Liar-paradox, Circuits and more, relating to the P, NP problem.
This tackles directly the hypothetical perspective, in sense of being a paradox, which brings... |
In a hypothetical scenario, where a precise and formal definition does not exist here, and thus expressed with analogies and verbal reasoning for the sake of simplifying the P, NP problem.
A(lan) Turing Machine arrives to the "Universal-Algorithm-Island", and meets Christopher, an oracle with a True or False respons... |
null |
This problem is polynomial-time solvable.
Suppose we know the last selected $X_\ell$. Then, remove all $Y$s that have a non-empty intersection to $X_\ell$. Now, we don't have to check for the second condition anymore because we have $X_i \cap Y_j \neq \emptyset \implies X_\ell \cap Y_j \neq \emptyset$ by the first c... |
I am new to Linear Programming and Approximation algorithms. and I am trying to do this exercise for writing an IP and relax it to LP. What I am given: <br />
- A digraph `G = (V,E)` with w<sub>v</sub> being the weight on vertex `v` for every `v ∈ V`.<br />
- A multi-set S is a set such that it contains elements mo... |
To write an IP and relax it to LP for finding a multi-set in a graph |
|graphs|approximation|linear-programming|integer-programming| |
(I haven't read any literature on this paradox nor am I good at formal proofs, so this is just my intuitive thoughts on the paradox.)
I have a question about the relation between functions and truth, such as that discussed in the Church-Turing thesis.
If we assume the statement "This statement is false" as a func... |
|propositional-logic|check-my-answer|philosophy| |
null |
I solved the problem:
[![enter image description here][1]][1]
It did seem impossible to make a deterministic function with the described properties (since only integer numbers are allowed). The trick of this exercise is using infinite domains.
[1]: https://i.stack.imgur.com/gmOfK.png |
null |
If you can access the bits as an array of W bit words: Let k = nW + k'. If k' > 0 then shift the last word by (W - k') bit positions and use the result instead of the last word, so n is increased by 1.
If there is a fast "popcount" instruction then you use that.
Otherwise, you can split a word w into (w & 0x333... |
null |
I have read that 1NF, 2NF and 3NF decompositions are lossless and dependency-preserving.
Consider this example on a relation $R(A,B,C,D)$ with functional dependencies set as $FD =${ $AB \rightarrow CD, A \rightarrow C, BC \rightarrow D$ }
Here when we do 2NF decomposition we get $R_{1}(A,C)$ with $FD =${$A \right... |
2NF decompositions are dependency preserving? |
|database-theory| |
So i'm defining the embarassingly parallel complexity class as the set of decision problems which can be solved in time $O(T(n))$ on a single computer and in time $O(T(n)/g(n))+O(\log(g(n))$ if you have access to $O(g(n))$ machines where $g(n)$ can be of a total size up to $T(n)$.
So these are the types of problem... |
Is there a standard name for the complexity class "embarassingly parallel" |
|complexity-theory|complexity-classes| |
Let $\Sigma$ be an alphabet, and denote by $\mathrm{ind}(\varphi_M^{(k)})$ the index set (w.r.t some numbering) of the $k$-ary partial computable function $\varphi_M^{(k)} : (\Sigma^*)^k \rightarrow \Sigma^*$, which represents the $k$-ary proper function of the Turing machine $M$. Is it the case that $\mathrm{ind}(\var... |
I am self-learning [proof assistants][1] and decided to start on some basic proofs and work my way up. Since proofs are based on other proofs and so form a hierarchy, is there a repository of the hierarchy of proofs?
I know I can pick a particular proof-assistant and analyze its library to extract its hierarchy, how... |
null |
// Let's look at the number 11201 in base 3
// which we will represent as (11201),3
//
// (11201),3 = ( ),7
//
// 3^4 3^3 3^2 3^1 3^0
// 1 1 2 0 1
//
// The "amount" of number we have in any given base
// can be computed... |
{"Voters":[{"Id":91753,"DisplayName":"John L."}]} |
In my OS course, the instructor mentioned the following: In UNIX if a parent process creates a new child ("fork") then the child is an exact duplicate of the parent. This means its memory space is a copy of the parent's.
Now if the child process immediately calls "exec", it replaces its own memory space with that of... |
How does caching, paging, virtual memory, and OS all tie together for UNIX copy-on-write? |
|computer-architecture|process-scheduling|paging|os-kernel|cache| |
I am currently reading reading Chapter 11 of Operating Systems: Principles & Practice by Anderson and Dahlin, which speaks about file systems as abstractions for non-volatile storage.
The distinction between files and directories is first made. Afterwards, in examining what files are, a distinction between file data... |
Meaning of "untyped bytes" in file systems |
|operating-systems|filesystems| |
They mean that the data is an array of bytes, nothing more. It does not come with any type information to indicate how the data should be interpreted. It is up to applications to figure out how to interpret the data. |
Donald Knuth's *The Art of Computer Programming, Volume 1 Fascicle 1* contains the following exercise:
> If $\alpha$ is any string of 0s and 1s, let $\operatorname{s}(\alpha)$ and $\operatorname{u}(\alpha)$ be the integers that it represents when regarded as a signed or unsinged binary number. Prove that, if $x$ is ... |
Within the set of signed integers representable by a bit string of length n, are any two elements equivalent to each other mod 2^n? |
|computer-architecture|binary|modular-arithmetic| |
There are two types of sets $\mathcal{X} = \{X_{1}, X_{2}, \ldots, X_{n_{1}} \}$ and $\mathcal{Y} = \{Y_{1}, Y_{2}, \ldots, Y_{n_{2}}\}$ such that $X_i, Y_j \subseteq [m]=[\mathrm{poly}(n)]$ and $n = n_{1} + n_{2}$.
Given a sequence $\alpha$ over $\mathcal{X} \cup \mathcal{Y}$, the goal is to find the longest increasi... |
I think there is a problem in the definition of your IP and LP systems.
If $x_u$ represents the number of times you can select a vertex $u$ in the multiset $S$, then you want to verify the following conditions:
- For an edge $(u, v)\in E$, either $x_u \geqslant 1$ or $x_v \geqslant 2$. That means that $x_u + \frac... |
I think there is a problem in the definition of your IP and LP systems.
If $x_u$ represents the number of times you can select a vertex $u$ in the multiset $S$, then you want to verify the following conditions:
- For an edge $(u, v)\in E$, either $x_u \geqslant 1$ or $x_v \geqslant 2$. That means that $x_u + \frac... |
I think there is a problem in the definition of your IP and LP systems.
If $x_u$ represents the number of times you can select a vertex $u$ in the multiset $S$, then you want to verify the following conditions:
- For an edge $(u, v)\in E$, either $x_u \geqslant 1$ or $x_v \geqslant 2$. That means that $x_u + \frac... |
I think there is a problem in the definition of your IP and LP systems.
If $x_u$ represents the number of times you can select a vertex $u$ in the multiset $S$, then you want to verify the following conditions:
- For an edge $(u, v)\in E$, either $x_u \geqslant 1$ or $x_v \geqslant 2$. That means that $x_u + \frac... |
I understand that pumping lemma can only be used to prove that a certain language is "non-regular", it cannot be used for proving regularity
But since, it's a property of regular language, we should be able to pick up a language that is regular, literally, and then see if this property exists in that language, which... |
Is it possible to divide a string, according to pumping lemma, from a language in a way that pumping a section would render the language -non regular |
|finite-automata|pumping-lemma| |
The pumping lemma states that **THERE EXISTS** a decomposition $s = xyz$ verifying the 3 conditions. Not that the 3 conditions holds for all decompositions $s = xyz$.
That means that you cannot choose the decomposition yourself, you just know that there exists one. |
Although you decomposed the table using the dependency that violates 2NF $(A\rightarrow C)$, the new tables are in BCNF, and decomposition to BCNF is not always dependency preserving. |
One popular algorithm to find the Voronoi diagram out of a collection of points (*sites*) in the plane is [Fortune's algorithm](https://en.wikipedia.org/wiki/Fortune%27s_algorithm). It is usually described in terms of a *sweep line*, whose interaction with *sites* give raise to *parabolas*, whose intersections eventual... |
Is Fortune's algorithms for Voronoi diagrams described anywhere by Prof. Fortune? |
|voronoi-diagrams| |
It seems like your understanding of the matter is pretty good. You are just missing one tiny trick: *Make the pages read-only*.
When the OS `fork`s the process, it maps the parent's pages also into the child, *AND sets the pages to read-only*. Before doing that, it also has to remember what the pages were set to bef... |
It seems like your understanding of the matter is pretty good. You are just missing one tiny trick: *Make the pages read-only*.
When the OS `fork`s the process, it maps the parent's pages also into the child, *AND sets the pages to read-only*. Before doing that, it also has to remember what the pages were set to bef... |
null |
null |
Bytes can be signed or unsigned, be considered numbers or characters, that's about the only typing information you can attach to them. The text means that the bytes are just eight bits, regardless any interpretation.
|
There are two things that I think is wrong with your example, hence your argument. First the string $s = (01)^{p-1}1$ *may not* always produce a string from $L = \{ s | \text{ such that } s \text{ ends in 11} \}$ since in the statement for the pumping lemma, $p \ge 1$. So in your case if $p = 1$ then $s$ is just $1$.
... |
The "popular description" of Fortune's algorithm in terms of parabolas does not appear to be due to Fortune, but due to Guibas and Stolfi [1]. They start by analyzing the geometrical interpretation of Fortune's algorithm in section 5 of the original paper, and then deviate from the original paper by keeping track of th... |
There are two things that I think is wrong with your example, hence your argument. First the string $s = (01)^{p-1}1$ *may not* always produce a string from $L = \{ s | \text{ such that } s \text{ ends in 11} \}$ since in the statement for the pumping lemma, $p \ge 1$. So in your case if $p = 1$ then $s$ is just $1$.
... |
In a project of mine, I want to represent states as efficiently as possible. Initially, I went ahead with a BitBoard representation and some clever tricks to speed up the evaluation of the game tree. That works fine. Though when looking up any given state in the Look-Up table, I need to do some heavy calculations.
A... |
How to properly save Zobrist Keys? |
|hash|hash-tables|hashing| |
null |
One popular algorithm to find the Voronoi diagram out of a collection of points (*sites*) in the plane is [Fortune's algorithm](https://en.wikipedia.org/wiki/Fortune%27s_algorithm). It is usually described in terms of a *sweep line*, whose interaction with *sites* give raise to *parabolas*, whose intersections eventual... |
null |
Is P vs NP, a paradox in a hypothetical perspective? |
null |
Interesting perspectives presented by (Lance Fortnow, The Golden Ticket: P, NP, and the Search for the Impossible, 2013, Chapter 7), has shown analogies to the Liar-paradox, Circuits and more, relating to the P, NP problem.
This tackles directly the hypothetical perspective, in sense of being a paradox, which brings... |
Prove or disprove: f(n-1) is omega(f(n)).
I actually need a more specific example of this but I thought this claim was interesting.
I want to know if (n-1)log(n-1) is omega(nlogn)
|
Prove or disprove: f(n-1) is omega(f(n)) |
|complexity-theory| |
Hint: show $(n-1)! \neq \Omega(n!)$ |
null |
I'm learning how to write my own theorem prover. After skimming Decision Procedures (Kroening & Strichman, 2016), I didn't find any SMT algorithms for solving quantified n-ary predicate formulas. I realize that some quantified predicate formulas with an arity above 2 are undecidable. But I'm not sure if all of them are... |
Is there an SMT/SAT algorithm for General Predicate Logic (FOL)? |
|satisfiability|automated-theorem-proving|smt-solvers| |
null |
null |
null |
You can define a machine implementing the computable function $(\Sigma^*)^k \rightarrow (\Sigma^*)^{k+1}$ for adding the blank to the set of inputs, then compose the machine implementing this function with your machine taking $k+1$ inputs to produce the required machine with $k$ inputs. |
You can define a machine implementing the computable function $(\Sigma^*)^k \rightarrow (\Sigma^*)^{k+1}$ for adding the blank to the set of inputs, then compose the machine implementing this function with your machine taking $k+1$ inputs to produce the required machine with $k$ inputs.
The $S^m_n$ theorem can be us... |
You can define a machine implementing the computable function $(\Sigma^*)^k \rightarrow (\Sigma^*)^{k+1}$ for adding the blank to the set of inputs, then compose the machine implementing this function with your machine taking $k+1$ inputs to produce the required machine with $k$ inputs.
The $S^m_n$ theorem can be us... |
null |
Look at how the pumping lemma is proven.
If L is regular then it has a state machine with k states for some k. If you process a string with k or more symbols, then after processing k symbols, you have visited the start state and k further states, k+1 in total. Since there are only k states, two of these must be th... |
null |
You ask two questions. I start by answering your first question.
Undecidability is a worst-case property, which says there is no single algorithm that can work for all problem instances. But some problem instances are, intuitively, "easier". There are problem instances that can be solved. For instance, if you on... |
null |
I have this grammar:
E -> E + T
E -> T
T -> T * F
T -> F
F -> ( E )
F -> id
And this is the state diagram for it:
[![enter image description here][1]][1]
I tried to construct a parse table and I am getting shift/reduce conflict. More specifically in state 2 I can shift `*`. Also... |
SLR parse table construction for left recursive grammar |
|parsers| |
No, you're not right.
State 4 contains the item $E\to\cdot T$. After a GOTO on T, that should produce a state with item $E\to T\cdot$. But the destination state (S2) contains the item $T\to T\cdot$. That's a simple transcription error.
Now, `*` is in FOLLOW(T), but it's not in FOLLOW(E), which is what the item sh... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.