Earlier, I asked a question on here asking for help with the conversion of a transition-graph of a finite automaton into a regular expression:
Understanding (and forming) the regular expression of this finite automaton
Thanks to the user Patrick87, I was able to find the help I was looking for. I also read the following link that he mentioned in his answer :
http://krchowdhary.com/toc/dfa-to-reg-exp.pdf
which explains three algorithmic methods to find regular expressions. Intuitively, I was attracted towards the Brzozowski Algebraic Method and tried to solve the FA that I had asked for help on in the previous post which is mentioned at the top.
The following are the characteristic equations that I have made for the FA. Please tell me and correct me if I am wrong and point me in the right direction!
R1 = bR2 + aR3
R2 = aR2 + bR4
R3 = aR3 + bR2 + λ
R4 = aR4 + bR3
Are these correct? If yes, then how how do I go about with the substitutions as every Ri will be in terms of Rj where i≠j.
Please help :D
I'll take a stab at this... We first reduce each equation so that we don't have any Ri's equal to expressions containing themselves...
R1 = bR2 + aR3
R2 = a*bR4
R3 = a*bR2 + a*
R4 = a*bR3
Now for the substitutions... first eliminate R4
R2 = a*ba*bR3
Now we get rid of R2
R1 = ba*ba*bR3 + aR3
R3 = a*ba*ba*bR3 + a*
We don't want R3 on its own RHS...
R3 = (a*ba*ba*b)*a*
Now eliminate R3
R1 = ba*ba*b(a*ba*ba*b)*a* + a(a*ba*ba*b)*a*
This looks right, and as such we can transform it to yours. You should try this exercise.
Related
The task is something like this. Alice must send Bob the money, but so that the amount remains hidden.
How can this be done if only "hiding" balances are stored in the blockchain? How can I prove to someone that my balance is positive after the transfer?
In other words, how can I prove to someone that the number x >0, if the person only knows the "hiding" of this number, say, g^x, where g is the generator of some elliptic curve. Prove without revealing x.
I know how snarks are constructed: R1 CS-> AP -> weil pairing, I know how this problem would be solved if x were known and not hidden.
For example, we represent x = sum(u_i*2^i) write in R1 CS another u_i u_i = u_i and thus prove that all u_i = 0 or 1
what's next? some very simple dumb guy. if x was known, we would have written it just in r1 cs as a public input and would have quietly checked something like
v2 = u11+u22
v3 = v2+u32^2
...
vn = u_(n-1) + u_n2^(n-1)
and would add public input vn = x
and so what to do?
I'm confused about what the big-O notation of 8^(log2(n)) would be.
Would you just be able to change it to O(8^n) since the log2 would somewhat act as constant that just reduces the value of n? or would it be something else?
In a somewhat similar case what would be the big-O for log2(n^n). would this just be O(log2(n))?
We'll need the following properties of logs and exponents to understand this one:
bLogb(x) = x
k . Logb(x) = Logb(xk)
(xa)b = xa.b
For the first problem:
8Log2(n)
= (23)Log2(n) (because 8 = 23)
= 23 . Log2(n) (using Prop#3)
= 2Log2(n3) (using Prop#2)
= n3 (using Prop#1)
= O(n3)
For the second problem:
Log2(nn)
= n . Log2(n) (using Prop#2)
= O(n Log(n))
Big-O of 8^(log(n)) will be O(2^log(n)) as 8 = 2^3.
Also log(n^n) = n*log(n). So big-O for log2(n^n) would be O(n*log2(n))
I wrote the following function to perform SVD according to page 45 of 'the deep learning book' by Ian Goodfellow and co.
def SVD(A):
#A^T
AT = np.transpose(A)
#AA^T
AAT = A.dot(AT)
#A^TA
ATA = AT.dot(A)
#Left single values
LSV = np.linalg.eig(AAT)[1]
U = LSV #some values of U have the wrong sign
#Right single values
RSV = np.linalg.eig(ATA)[1]
V = RSV
V[:,0] = V[:,0] #V isnt arranged properly
values = np.sqrt(np.linalg.eig(ata)[0])
#descending order
values = np.sort(values)[::-1]
rows = A.shape[0]
columns = A.shape[1]
D = np.zeros((rows,columns))
np.fill_diagonal(D,values)
return U, D, V
However for any given matrix the results are not the same as using
np.linalg.svd(A)
and I have no idea why.
I tested my algorithm by saying
abs(UDV^T - A) < 0.0001
to check if it decomposed properly and it hasn't. The problem seems to lie with the V and U components but I can't see what's going wrong. D seems to be correct.
If anyone can see the problem it would be much appreciated.
I think you have a problem with the order of the eigenpairs that eig(ATA) and eig(AAT) return. The documentation of np.linalg.eig tells that no order is guaranteed. Replacing eig by eigh, which returns the eigenpairs in ascending order, should help. Also don't rearrange the values.
By the way, eigh is specific for symmetric matrices, such as the ones that you are passing, and will not return complex numbers if the original matrix is real.
I need to make an optional match on relationship properties of r1 and r2.
r1 is n layers deep so I'm getting the error:
"Type mismatch: expected Map, Node or Relationship but was
Collection"
MATCH (a:node{x:”foo”} )-[r1:sub*]->(b)-[r2:inst]->(c)
USING INDEX a:node(x)
WHERE r1.value = v2.value
RETURN b,r2,c
How can I compare r1.value to r2.value when I don't know the value upfront?
Thanks!
MATCH (a:node{x:"foo"})-[r1:sub*]->(b)-[r2:inst]->(c)
USING INDEX a:node(x)
UNWIND r1 as r
WITH b, r2, c, r
WHERE r.value = r2.value
RETURN b,r2,c
I guess this is what you are looking for:
MATCH (a:node{x:”foo”} )-[r1:sub*]->(b)-[r2:inst]->(c)
USING INDEX a:node(x)
WHERE last(r1).value = v2.value
RETURN b,r2,c
Explanation: r1 is collection. It's totally logical because you are specifying an arbitrary length.
So, if you need to compare last relationship in this chain with some specific relationship, you can use last function.
i have two bezier curves placed at a distance apart in space.
curve 1 has control points A0, A1,A2, A3. A0 and A3 lie on curve and are its end points
Curve 2 has control points C0,C1, C2, C3 . C0 and C3 lie on curve.and are its end points
i want to join the two curves A and C with an intermediate bezier curve B. the intermediate Curve B has control points A3 and C0 which lie on the curve and are its end points. the intermediate control points B1 and B2 are unknown to me. also the joining should be smooth enough. please help as to how to proceed. have read alot about beziers but dont know how to do this.
thanks and regards,
Gauri
B1 will be: B1x = 2 * A3x - A2x; B1y = 2 * A3y - A2y;
B2 will be: B2x = 2 * C0x - C1x; B2y = 2 * C0y - C1y;
This should give you perfectly smooth join.
#Arty
You are correct but this will only assure a "smooth enough" join.
To achieve a better looking join of those 2 curves you must also have 2nd derivative equals at the junction points. I place this here for those that might need this piece of information.