-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FindInstance and boolean minimization #28
Comments
Hi @anandijain , thanks for your kind words. For the second question, I am not familiar with Quine–McCluskey algorithm, but I think Groebner.jl can help. As I understand, one can quite easily (at least) find all prime implicants with Gröbner bases. Take, for instance, the function from example on wiki: For any two terms, say Going to the code using Groebner, AbstractAlgebra
_, (a, b, c, d) = PolynomialRing(QQ, [:a,:b,:c,:d])
# all minterms in f, x' maps to (1 + x)
F = [
(1 + a)*b*(1 + c)*(1 + d),
a*(1 + b)*(1 + c)*(1 + d),
a*(1 + b)*(1 + c)*d,
a*(1 + b)*c*(1 + d),
a*(1 + b)*c*d,
a*b*(1 + c)*(1 + d),
a*b*c*(1 + d),
a*b*c*d
]
groebner(F) 4-element Vector{AbstractAlgebra.Generic.MPoly{Rational{BigInt}}}:
b*c*d + b*c + b*d + b
a*d + a
a*c
a*b + a Switching back So, as I far as I see, Groebner can do the first step from the QMC algorithm. Probably we can figure how to fully minimize the function using only Groebner bases after a closer look. |
About your first question, I am actually very interested in CRNs myself. I have little knowledge about your particular application, but I believe a lot of work has been done in this direction. I kindly ask @pogudingleb for some insight here |
For the first question. It looks like you can get only linear equations from your balancing conditions (correct me if I am wrong). |
Thanks both! @sumiya11 I am fairly close to implementing what you wrote for boolean minimization in code. This amount of simplification is still really good. The issue I've run into though is I have everything in Symbolics, (I'm using a version-updated copy of your Symbolics fork). I'm wondering if you have any codes to translate to AA. If not I can hack it together relatively easily I think. edit: |
That's great! I am not completely sure what you mean by ring vs. field, could you elaborate? I probably have no functions for AA <--> DP conversions.. Btw, Groebner.jl can work with DynamicPolynomials.jl directly: using Groebner, DynamicPolynomials
@polyvar a b c d
F = [
(1 + a)*b*(1 + c)*(1 + d),
a*(1 + b)*(1 + c)*(1 + d),
.....
]
groebner(F)
> 4-element Vector{Polynomial{true, Int64}}:
ad + a
ac
ab + a
bcd + bc + bd + b |
For factoring using AbstractAlgebra: divides
R, (a, b, c, d) = PolynomialRing(QQ, ["a","b","c","d"])
f = b*c*d + b*c + b*d + b
divides(f, b) # f / b
> (true, c*d + c + d + 1) # implying b
f = c*d + c + d + 1
divides(f, c) # f / c
> (false, 0) # implying 1+c
divides(f, 1 + c) # f / (1 + c)
> (true, d + 1)
f = d + 1
# and so on.. |
Ahh, I was looking for a https://github.com/anandijain/Boolin.jl/blob/aj/simplify/test/simplify.jl#L178 is the code that I've been messing around with. I think what I meant is that it's easiest to convert back to boolean if I only allowed the ring operations (+, *) in the resulting expressions from I think I might have been staring at this for too long, there could be just dumb bugs of mine in the rules or the factoring. Thanks for walking me through this, shouldn't be too much more to get it relatively robust |
Aah, I see, good luck with that! Let me know if you'd need help with Groebner stuff |
A thought on ^ |
Hello, I've been using this package a lot recently and I love it.
I know fairly little about this subject, but I have a couple of applications that are really benefiting from the Symbolic polynomial improvements and I'm looking to help out.
The first application is balancing chemical reactions and the second is minimizing boolean expressions.
Lots of chemical reactions have an infinite number of possible stoichiometric coefficients that satisfy being balanced.
For example, the following equations represent the reaction
OH- + H+ <-> H2O
in mathematica. To the human eye, it's clear that the coefficients [1, 1, 1] are the "best". I'd like to try to write my ownFindInstance
, but having trouble finding resources on how this function is implemented. I'm wondering if you know.My second question is more concrete. I stumbled on https://en.wikipedia.org/wiki/Quine%E2%80%93McCluskey_algorithm, which mentions that it is an analogous algorithm to Buchberger's for boolean expressions. I'm curious if your F4 implementation might be general enough that I don't have to reimplement Quine McCluskey, or what I'd need to do to make it work.
Thanks and feel free to close since this issue is pretty off topic to the core purpose of this package
The text was updated successfully, but these errors were encountered: