How to resolve "Quantifier hierarchy ended with a universal quantifier"? - boolean

I was trying to compile a QBF solver tool called CADET. CADET can only solve the format type of QDIMACS.
After the cloning of repository and installing the tool a simple command ie. ./cadet <filename>.qdimacs is required to execute the file. The photos of the error and the QDIMACS file is given.
This is the .qdimacs file code
c This QDIMACS file encodes the formula
c forall x1, x2 exists y. y <-> x1 & x2.
c x1 is represented by number 1
c x2 is represented by number 2
c y is represented by number 3
p cnf 3 3
a 1 2 0
e 3 0
1 -3 0
2 -3 0
-1 -2 3 0
This is warning I am getting during execution:
harish#harish-Lenovo-ideapad-510-15IKB:~/cadet$ ./cadet harish.qdimacs
CADET v2.5
Processing file "harish.qdimacs".
Warning: Quantifier hierarchy ended with a universal quantifier.
Warning: Removing last quantifier. Will obtain a propositional problem. This is a bit hacky, so beware.
Aborted (core dumped)

This was due to a trailing space in the file due to which the tool could not execute properly.

Related

Principle of duality

The following is given in my textbook-
When we start with a boolean relation, another boolean relation can be derived by:
changing OR to AND
changing AND to OR
replacing 0 to 1 and 1 to 0
This derived expression is known as the dual of the initial expression.
So dual of 1 AND 0 is 0 OR 1. Isn't?
What about the dual of X OR X' ? Is it X' AND X? (Note that ' stands for complement.)
PS -
One change we did not need to make as part of this interchange was to
complement. We say that complement is a self-dual operation. The
identity or do-nothing operation x (copy the input to the output) is
also self-dual.
What does the above line mean?
Source : Duality principle in wikipedia

Error when running G= graph(s,t) in matlab

I want to calculate L = laplacian(G) from a graph dataset. I imported the dataset which contains two columns: FromNodeId and ToNodeId:
# Nodes: 3997962 Edges: 34681189
# FromNodeId ToNodeId
0 1
0 2
0 31
0 73
0 80
0 113619
0 2468556
0 2823829
0 2823833
0 2846857
0 2947898
0 3011654
0 3701688
0 3849377
0 4036524
0 4036525
0 4036527
0 4036529
0 4036531
0 4036533
0 4036534
0 4036536
0 4036537
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
To do so, I need to find G first so I use G = graph(FromNodeId, FromNodeId). When I did that, I got this error:
>> G = graph(fromNodeId,toNodeId)
Error using matlab.internal.graph.MLGraph
Source must be a dense double array of node indices.
Error in matlab.internal.graph.constructFromEdgeList (line 125)
G = underlyingCtor(double(s), double(t), totalNodes);
Error in graph (line 264)
matlab.internal.graph.constructFromEdgeList(...
I don't know why! Can I get a solution of that? Thank you.
Turns out the problem lies in the fact that no zeros are allowed when using the Graph function in this manner. (See: Target must be a dense double array of node indices. How to Solve?)
I downloaded the dataset and ran it successfully with the following code. Note that this code uses a system command and is not compatible with all operating systems, but it should be simple enough to rewrite to whatever operating system you use. It also assumes the .txt file to be in the working directory.
% Removes first lines with comments in them; this system command was tested on Linux Ubuntu 14.04 and is probably not portable to Windows.
% If this system command doesn't work, manually remove the first four lines from the text file.
system('tail -n +5 com-lj.ungraph.txt > delimitedFile.txt');
% Read the newly created delimited file and add 1 to all nodes.
edges=dlmread('delimitedFile.txt')+1;
% Build the graph
G=graph(edges(:,1),edges(:,2));
Assuming you've build your arrays similarly to how I did it, adding 1 to FromNodeIdFull and ToNodeIdFull should resolve your problem. In other words, the following code snippet should solve your problem; if it doesn't I advise you to rewrite based on the code presented above.
G=graph(FromNodeIdFull+1,ToNodeIdFull+1);
Leaving my old answer here, as deleting it may cause confusion for others reading both this answer and the comments to it. Note that the answer below did NOT resolve the issue.
Just putting the comments by myself and NKN into an answer:
The problem lies in the fact that the arrays are sparse but graph() seems to expect full arrays. The following should work:
FromNodeIdFull=full(double(FromNodeId));
ToNodeIdFull=full(double(ToNodeId));
G=graph(FromNodeIdFull,ToNodeIdFull);
Depending on whether your input arrays are already doubles or not you may be able to remove the double() from the first two lines.

Unicode BIDI (UBA): R RLI R; Why should RLI stay on level 0

implementing isolater logic for the BIDI got me stuck again. Given the following test case.
#Levels: 1 0 1
#Reorder: 0 1 2
R RLI R ; 2 # LTR flag
\____/ \_/ (my run sequences)
Here is my current understanding:
After processing rules X1-X8 you end up with levels 0 0 1 which will convert to two isolated run sequences.
As far as I can tell, rules W1-W7 should not apply to any characters.
Rule N1 however will raise the level of the RLI to 1 as it is an NI between two strong types, the R and the eos of the first sequence.
Rule I1/2 will then push the first R to level 1.
Rule L1 could lower the level of an RLI but does not apply here.
How is that, that the RLI should end up on level 0.
Same problem with similar tests, just invthe opposite direction.
#Levels: 2 1 2
#Reorder: 2 1 0
L LRI L; 4
Sadly http://unicode.org/cldr/utility/bidi.jsp does not implement the latest algorithm including the RLI/LRI.
Any advice welcome :) thank you.
Okay the issue was that Rule N1 should not have been applied since the eos is of type L and not R.
I have missed the Note at X10 stating that: ...and if there is none or the last character of the sequence is an isolate initiator (lacking a matching PDI), with the paragraph embedding level."

Input format explanation for TOH

Today i came across this Tower of Hanoi problem from Facebook and here is the question and solution for this - Facebook sample puzzle: Towers of Hanoi
But the problem i am facing is i am not able to understand the inputs given here . i know the basics of tower of Hanoi. i am not able to understand this part
Constraints:
1<= N<=8
3<= K<=5
Input Format:
N K
2nd line contains N integers.
Each integer in the second line is in the range 1 to K where the i-th integer denotes the peg to which disc of radius i is present in the initial configuration.
3rd line denotes the final configuration in a format similar to the initial configuration.
N and K are inputs where N is the number of disks and K is the number of pegs. But what is the initial configuration and final configuration here is an example.
Sample Input #00:
2 3
1 1
2 2
where 2 is the Number of disks and 3 is the number of pegs what the next line 1 1 and 2 2. can anyone please help me in understanding this problem and correct me if my understanding is wrong.
This sample input denotes: Both disks are on the first peg, and you should move them to the second peg.
Another sample input:
6 4
4 2 4 3 1 1
1 1 1 1 1 1
describes this placement:
5 1
6 2 4 3
_ _ _ _

Why does ToMatlab[] randomly yield invalid matrices in Matlab (vertcat error)? (bugfix included)

I've been using ToMatlab[], available at http://library.wolfram.com/infocenter/MathSource/577/, to convert Mathematica expressions to Matlab in order to numerically simulate a model.
I recently ran into a bug: I try to have Matlab evaluate a function produced by ToMatlab[], but it gives me the following error:
??? Error using ==> vertcat
CAT arguments dimensions are not consistent.
which means I have a non-square matrix (i.e., not a matrix).
Searched around and found (one) mention of the bug, but no solution is mentioned: http://groups.google.com/forum/#!searchin/comp.soft-sys.math.mathematica/tomatlab/comp.soft-sys.math.mathematica/cxNZC9IYgfQ/2Q6jP4U4hzkJ
Dug into it a little more, and discovered what the problem was:
Converting a symbolic matrix using the original ToMatlab[] routine can introduce an error if the foldlines[] routine folds a line with the "..." literal right before an operator that is both binary and unary (such as + and -) and is not separated from its right operand by whitespace (e.g., "+5" instead of "+ 5").
Reason being is that the Dot-Dot-Dot symbol "..." are interpreted as spaces in matrices, according to the Matlab documentation. This causes the extra element to be introduced. See the appended examples for an illustration.
I was able to fix this bug by padding the "+" operator by replacing "+" with " + " in the Plus conversion pattern "ToMatlabaux[e_ /; Head[e] === Plus]". I made this and similar (but otherwise insignificant) style modifications to the original ToMatlab[] routine and uploaded it to pastebin here:
http://pastebin.com/TcjErHVT - ToMatlab Bugfix
I attempted to contact Dr. Ojanen about this, but I received an error from his old mail server saying that his username no longer existed there.
I informed Wolfram about this too, but they said that it is up to the contributor to update their code in the Library Archive.
[Appended examples]
EDU>> [3 + 5]
ans =
8
EDU>> [3 + ...
5]
ans =
8
EDU>> [3 +...
5]
ans =
3 5
EDU>> [3 (+ 5)]
ans =
3 5
EDU>> [3 ...
+5]
ans =
3 5