instruction
stringlengths
0
29.8k
⌀
Questions regarding solver programs for the boolean satisfiability problem.
null
null
In thinking about how to approach this problem I think several things will be required, some tivial: 1. An expression tree where non-leaf node is an operation (not sure if that part is redundant), but not every node has just two children. 2. All nodes for operations have a defined number of children that they must ...
Constructing a data structure for a computer algebra system
|data-structures|computer-algebra|
In thinking about how to approach this problem I think several things will be required, some tivial: 1. An expression tree where non-leaf node is an operation (not sure if that part is redundant), but not every node has just two children. 2. All nodes for operations have a defined number of children that they must ...
This looks like a classical application for [Object-Oriented Programming][1] (OOP), or more explicitly, [Polymorphism][2]. You could create a basic object, e.g. `treeObj` with a method `evaluate`, and then generate sub-types for every object in your language, e.g. a `plusOp` object for the $+$ expression, the constr...
|data-structures|computer-algebra|mathematical-software|
Is "party attendance" type of problems solvable in Prolog? For example: > Burdock Muldoon and Carlotta Pinkstone both said they would come if Albus Dumbledore came. Albus Dumbledore and Daisy Dodderidge both said they would come if Carlotta Pinkstone came. Albus Dumbledore, Burdock Muldoon, and Carlotta Pinkstone al...
null
null
Yep, this generates a regular language. We can show this fairly easily by constructing an equivalent regular grammar. We start with $$E \rightarrow aO | bO | bbE | bb$$ $$O \rightarrow aE | bE | abaE | aba$$ Introduce new nonterminal symbols as follows: $$V \rightarrow bE | b$$ $$W \rightarrow bX$$ $$X \rig...
From the comments the OP wrote, I understand OP wants to start small. However, we need to think more generally so that the to-be developped CAS can be of real use. Otherwise it is nothing but another calculator. My suggestion: Numbers, elements, sets, operations, etc. are fundermental in algebra. The data structu...
From the comments the OP wrote, I understand OP wants to start small. However, we need to think more generally so that the to-be developped CAS can be of real use. Otherwise it is nothing but another calculator. My suggestion: Numbers, elements, sets, operations, etc. are fundermental in algebra. The data structu...
From the comments OP wrote, I understand he wants to start small. However, we need to think more generally so that the to-be developped CAS can be of real use. Otherwise it is nothing but another calculator. My suggestion: Numbers, elements, sets, operations, etc. are fundermental in algebra. The data structures ...
To solve a problem with Prolog, as with any programming language, be it declarative or imperative, you have to think about the representation of the solution and the input. Since this is a programming question, it would've been popular on StackOverflow.com where programmers solve programming problems. Here I would a...
To solve a problem with Prolog, as with any programming language, be it declarative or imperative, you have to think about the representation of the solution and the input. Since this is a programming question, it would've been popular on StackOverflow.com where programmers solve programming problems. Here I would a...
I found the following paper on SAT solving using prolog: * [A Pearl on SAT Solving in Prolog][1] by Jacob M. Howe and Andy King An implementation of the solver can be found [here][3]. See [this stackoverflow answer][2] for details on the code and how to use it. [1]: http://www.soi.city.ac.uk/~ja...
null
Take a look at Chapter 8 of [Paradigms of Artificial Intelligence Programming][1] - where the author [Peter Norvig][2] [solves this problem in Common Lisp][3]. [1]: http://norvig.com/paip.html [2]: http://norvig.com/ [3]: http://norvig.com/paip/macsyma.lisp
[Alexia Massalin's Dissertation on Synthesis][1] was a Phd thesis on Operating Systems that contained a concept called 'Quajects'. Best I can work out - a Quaject is construct that generates Assembler customised for the function being used at the time. (Perhaps like a [JIT][2]). The project that I've seen that ...
Massalin's Synthesis Quajects equivalent to ASM generating macros used in Game Oriented Assembly LISP?
|operating-systems|
null
Is ["party attendance"][1] type of problems solvable in Prolog? For example: > Burdock Muldoon and Carlotta Pinkstone both said they would come if Albus Dumbledore came. Albus Dumbledore and Daisy Dodderidge both said they would come if Carlotta Pinkstone came. Albus Dumbledore, Burdock Muldoon, and Carlotta Pinksto...
null
null
[Alexia Massalin's Dissertation on Synthesis][1] was a Phd thesis on Operating Systems that contained a concept called 'Quajects' (see [Chapter 4][2]). Best I can work out - a Quaject is construct that generates Assembler customised for the function being used at the time. (Perhaps like a [JIT][3]). The project...
As I see it, a Quaject is a kind of [_software component_][1] in the sense that it has a **provided** interface (the _callentry_ functions), which contains the functions it offers, and a **required** interface (the _callout_ functions), which contains the functions it needs to operate. The _callback_ part of the inter...
To solve a problem with Prolog, as with any programming language, be it declarative or imperative, you have to think about the representation of the solution and the input. Since this is a programming question, it would've been popular on StackOverflow.com where programmers solve programming problems. Here I would a...
As spotted by svick, the first issue with the code in the OP is that names beginning with upper-case letters are variables in Prolog. So `admit(CP) :- admit(AD)` is equivalent to `attend(X) :- attend(Y)`, which results in Prolog immediately entering an infinite loop trying to demonstrate that `attend` holds for some te...
Hello i have a directed acyclic graph where edge (A,B) means that vertex A depends on vertex B. **The depency relation is as follows**: - When vertex B is removed, all dependent vertexes should also be removed. - When vertex A is removed and vertex A was the only vertex that depends on B, vertex B should al...
Dependency Graph - Acyclyc graph
|algorithms|graphs|
I have a directed acyclic graph where edge (A,B) means that vertex A depends on vertex B. Vertex deletions have the following restrictions: 1. When vertex B is removed, all dependent vertexes should also be removed. 2. When vertex A is removed and vertex A was the only vertex that depends on B, vertex B sho...
Dependency Graph - Acyclic graph
[Alexia Massalin's Dissertation on Synthesis][1] was a Phd thesis on Operating Systems that contained a concept called 'Quajects' (see [Chapter 4][2]). This is some [additional commentary on the Phd Thesis][3]. Best I can work out - a Quaject is construct that generates Assembler customised for the function bei...
null
First, let us make two maybe obvious, but important assumptions: 1. `_.random_item` can choose the last position. 2. `_.random_item` chooses every position with probability $\frac{1}{n+1}$. In order to prove correctness of your algorithm, you need an inductive argument similar to the one used [here](http://cs...
From the comments OP wrote, I understand he wants to start small. However, we need to think more generally so that the to-be developped CAS can be of real use. Otherwise it is nothing but another calculator. Please see [Definition of Computer Algebra System](http://www.math.wpi.edu/IQP/BVCalcHist/calc5.html). My sug...
The deletion process has two phases, one for each condition. 1. Delete the specified node and all nodes that have a directed path to it. 2. Delete all nodes that have no incoming edges anymore and are no sources (iterate). There are two imporant observations that make this correct: * During phase two, we c...
null
You are given n integers a_1, ..., a_n all between 0 and m. Under each integer a_i you should write an integer b_i between 0 and m with the requirement that the b_i's form a non-decreasing sequence. Define the deviation of such a sequence to be max(|a_1-b_1|, ..., |a_m-b_m|). Design an algorithm that finds the b_i's wi...
How to use greedy algorithm to solve this?
|optimization|greedy-algorithms|
For a given undirected graph $G$, a [Gomory-Hu tree][1] is a graph which has the same nodes as $G$, but its edges represent the minimal cut between each pair of nodes in $G$. The Gomory-Hu algorithm finds such a tree for a graph. A representant pair of nodes is defined as follows: if $R$ and $S$ are two components of t...
What is the proof for the lemma "For every iteration of the Gomory-Hu algorithm, there is a representant pair for each edge"?
|graphs|algorithm-analysis|
You are given n integers $a_1, \ldots, a_n$ all between $0$ and $m$. Under each integer $a_i$ you should write an integer $b_i$ between $0$ and $m$ with the requirement that the $b_i$'s form a non-decreasing sequence. Define the deviation of such a sequence to be $\max(|a_1-b_1|, \ldots, |a_m-b_m|)$. Design an algorith...
You are given n integers $a_1, \ldots, a_n$ all between $0$ and $l$. Under each integer $a_i$ you should write an integer $b_i$ between $0$ and $l$ with the requirement that the $b_i$'s form a non-decreasing sequence. Define the deviation of such a sequence to be $\max(|a_1-b_1|, \ldots, |a_l-b_l|)$. Design an algorith...
You are given n integers $a_1, \ldots, a_n$ all between $0$ and $l$. Under each integer $a_i$ you should write an integer $b_i$ between $0$ and $l$ with the requirement that the $b_i$'s form a non-decreasing sequence. Define the deviation of such a sequence to be $\max(|a_1-b_1|, \ldots, |a_n-b_n|)$. Design an algorith...
I'm going to think out loud here just working through the hints you've given. Let's go to the original hint of saying that $O(nl)$ is what you should try first. I can think of a greedy algorithm that has that time. The $l$ part of the time complexity means you can keep a list of the count of each occurence of each v...
To solve a problem with Prolog, as with any programming language, be it declarative or imperative, you have to think about the representation of the solution and the input. Since this is a programming question, it would've been popular on StackOverflow.com where programmers solve programming problems. Here I would a...
I'm going to think out loud here just working through the hints you've given. Let's go to the original hint of saying that $O(nl)$ is what you should try first. I can think of a greedy algorithm that has that time. The $l$ part of the time complexity means you can keep a list of the count of each occurence of each v...
null
The deletion process has two phases, one for each condition. 1. Delete the specified node and all nodes that have a directed path to it. 2. Delete all nodes that have no incoming edges anymore and are no sources (iterate). There are two imporant observations that make this correct: * During phase two, we c...
Suppose I have a recurrence like $T(n)=2T(n/4)+\log(n)$ with $a=2, b=4$ and $f(n)=\log(n)$. That should be [case 1 of the Master theorem](http://en.wikipedia.org/wiki/Master_theorem#Case_1) because $n^{1/2}>\log(n)$. There is also a lambda in case 1: $f(n)=O(n^{(1/2)-\lambda})$. Is this correct? And how can I find t...
Finding lambda of Master Theorem
|time-complexity|
Given a complete binary tree with n nodes. I'm trying to proof that a complete binary tree has exactly $\lceil n/2 \rceil$ leaves. I think I can do this by induction. For $h(t)=0$, the tree is empty. So there are no leaves and the claim holds for an empty tree. For $h(t)=1$, the tree has 1 node, that also is a l...
How can I proof that a complete binary tree has $\lceil n/2 \rceil$ leaves?
|graphs|data-structures|
Given a complete binary tree with n nodes. I'm trying to prove that a complete binary tree has exactly $\lceil n/2 \rceil$ leaves. I think I can do this by induction. For $h(t)=0$, the tree is empty. So there are no leaves and the claim holds for an empty tree. For $h(t)=1$, the tree has 1 node, that also is a l...
How can I prove that a complete binary tree has $\lceil n/2 \rceil$ leaves?
null
null
|proof-techniques|asymptotics|recurrence-relation|
First, it might help to be a little more specific with your terminilogy. I'll assume you mean "complete" in the way that [CLRS01] defines it: > All leaves have the same depth and all internal nodes have degree 2. Second, is this homework? You can prove this using structural induction. Show your claim holds f...
As you correctly noted, the case 1 of the Master theorem applies here. In other words, the case 1 applies if $f(n) = O(\log_b a - \lambda)$ for some constant $\lambda > 0$. Indeed, we will have to see if we can find *some* $\lambda > 0$ so that in this case, $\log n = O(n^{\log_4 2 - \lambda}) = O(n^{1/2-\lambda})$...
This a homework question from Udi Manber's book. Any hint would be nice :) I must show that: >$n(\log_3(n))^5 = O(n^{1.2})$ I tried using Theorem 3.1 of book: >$f(n)^c = O(a^{f(n)})$ (for $c > 0$, $a > 1$) Substituing: $(\log_3(n))^5 = O(3^{\log_3(n)}) = O(n) $ but $n(\log_3(n))^5 = O(n\cdot n) = O...
First, it might help to be a little more specific with your terminology. I'll assume you mean "complete" in the way that [CLRS01] defines it: > All leaves have the same depth and all internal nodes have degree 2. Second, is this homework? You can prove this using structural induction. Show your claim holds f...
Given a complete binary tree with $n$ nodes. I'm trying to prove that a complete binary tree has exactly $\lceil n/2 \rceil$ leaves. I think I can do this by induction. For $h(t)=0$, the tree is empty. So there are no leaves and the claim holds for an empty tree. For $h(t)=1$, the tree has 1 node, that also is a...
|data-structures|graphs|proof-techniques|combinatorics|binary-trees|
null
|algorithms|optimization|greedy-algorithms|
|algorithms|graphs|algorithm-analysis|
As you correctly noted, the case 1 of the Master theorem applies here. In other words, the case 1 applies if $f(n) = O(n^{\log_b a - \lambda})$ for some constant $\lambda > 0$. Indeed, we will have to see if we can find *some* $\lambda > 0$ so that in this case, $\log n = O(n^{\log_4 2 - \lambda}) = O(n^{1/2-\lambd...
If the statement you're trying to prove by induction is > For all positive integers $n$, a complete binary tree with $n$ nodes has $\lceil{n/2}\rceil$ leaves. then the induction hypothesis must be > For all positive integers $k<n$, a complete binary tree with $k$ nodes has $\lceil{k/2}\rceil$ leaves. Simila...
>**Definition**: monotone polygon - a polygon $P$ in the plane is called monotone with respect to a straight line $L$, if every line orthogonal to $L$ intersects $P$ at most twice. I am just wondering if this possible to test a polygon $P$ or monotonicity with respect to any arbitrary line $L$. If $P$ is monotone in...
Testing Polygon for Monotonicity with respect to any arbitrary line
|algorithms|computational-geometry|
null
>**Definition**: monotone polygon - a polygon $P$ in the plane is called monotone with respect to a straight line $L$, if every line orthogonal to $L$ intersects $P$ at most twice. I am wondering if and how it is possible to test whether there is a line $L$ for a given polygon $P$ so that $P$ is monotone with respec...
Languaged like Java, C#, Eiffel, and C++ have subtype hierarchies base on directed acyclic graphs, due it implementing interfaces in the first two and multiple inheritance in the second two. An obvious way to check whether one type is a subtype of another is to traverse the graph of the subtype hierarchy to see whether...
Efficient subtype testing
|programming-languages|compilers|
Languaged like Java, C#, Eiffel, and C++ have subtype hierarchies base on directed acyclic graphs, due it implementing interfaces in the first two and multiple inheritance in the second two. An obvious way to check whether one type is a subtype of another is to traverse the graph of the subtype hierarchy to see whether...
null
Languaged like Java, C#, Eiffel, and C++ have subtype hierarchies which are directed acyclic graphs, due to interfaces in Java and C# and multiple inheritance in Eiffel and C++. An obvious way to check whether type $A$ is a subtype of type $B$ is to traverse the graph of the subtype hierarchy starting at $A$ to see whe...
Languages like Java, C#, Eiffel, and C++ have subtype hierarchies which are directed acyclic graphs, due to interfaces in Java and C# and multiple inheritance in Eiffel and C++. An obvious way to check whether type $A$ is a subtype of type $B$ is to traverse the graph of the subtype hierarchy starting at $A$ to see whe...
|programming-languages|compilers|typing|
Consider an array $X$ of $n$ cells, each containing a number of $\{1,..., n\}$. There is at least one duplicate number, i.e., a number that appears at least twice. I want output _some_ duplicate number. When streaming we may pass over $X$ more than once. The inspection of a cell generates cost $1$. The cost of a run o...
Streaming algorithm and random access
|algorithms|randomized-algorithms|randomness|
Languages like Java, C#, Eiffel, and C++ have subtype hierarchies which are directed acyclic graphs, due to interfaces in Java and C# and multiple inheritance in Eiffel and C++. An obvious way to check whether type $A$ is a subtype of type $B$ is to traverse the graph of the subtype hierarchy starting at $A$ to see whe...
Given a sequence $\{ a_1, a_2, \ldots, a_n \}$ and an integer $k<n$ the [problem][1] is to find a subset $A\subset [n]$ such that 1. $|A|=k$ 2. The value $$ \sum_{i\in A} i \cdot a_i$$ is maximized. ---------- For instance, if the given sequence is $50; 100; 20; 40; 30$ and $k = 2$, the best weighted s...
Weighted subset sum problem