rodrigodesalvobraz / neuralpp Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
Evaluates and simplifies the function
Eliminates the quantifier expression
Rename GeneralNormalizer
and QuantifierFreeNormalizer
GeneralNormalizer
currently pushes the integral down into the leaves of a piecewise function. This does it lazily (and we also have another normalizer called LazyNormalizer
. It also does not push down the add.
QuantifierFreeNormalizer
does it eagerly. It pushes down the add and the integral, and you have to renormalize after you normalize the leaf/ subsection of the tree
Delete LazyNormalizer
[max(lower_bounds), min(upper_bound)] => Also need to normalize the interval => min and max is technically also a piecewise
MagicInterval
into the normal Interval
classSome docstrings are outdated
EquivalenceClass
and OrderedZ3Expression
in z3_expression
_updated_type_dict_by_context
which can be demonstrated by this example:
>>> _updated_type_dict_by_context({x:int, y:int, z:int, x*y: int->int->int, (x*y)*z: int->int->int}, True)
{x:int, y:int, z:int, x*y: int->int->int, x*y*z: int->int->int}
But it should return with the entry x*y*z: int->int->int->int
, it's because we don't re-compute the type of the simplified keys.
If we do want to re-compute the type of the simplified keys, then type_dict
is not a very useful design. By having type_dict
, we assume the types of all subexpressions can be found in it. But that's not always true when we introduce simplification. For example, when we simplify (x+1)*(x+1)
(its type_dict
would be {x:int, x+1:int->int->int, (x+1)*(x+1): int->int->int}
), we get x**2+2*x+1
. Here x**2
and 2*x
are subexpressions not in type_dict
, and we need to compute their type from the variable types.
So we should just redesign type_dict
to not contain types of built-in functions, but only types of variables (including uninterpreted functions). And always compute the function types based on pre-defined rules (e.g., "int
+ float
returns float
") and the variable types.
I was searching for a name for the class of operation of quantifier expression, which should not only be a Context
/Expression
, but also contain a property identity
(as in identity element), so that when the constrain of a quantifier expression is unsatisfiable, it can be automatically evaluated to the identity
of its operation
.
When searching for the name, I found the usage of “quantifier” a bit hard to understand for anyone not familiar with Probabilistic Inference Modulo Theories (PIMT), which uses the word “quantifier” in an unusually generalized way. Since “quantifier” is mostly understood to mean either the universal quantifier (“forall”) or the existential quantifier (“exists”) (there are more edgy ones, not including summation or product). What PIMT calls “quantifier” is usually referred to as iterated binary operation, which is also a bit long and uncommon.
I found a mathematicians’ discussion on the topic of wording of iterated binary operation, where no good replacement was concluded on (they proposed “summation”, “magmatic operation”).
Further, our “quantifier” operation is supposed to be commutative and associative (as defined in the PIMT paper). So technically the set we operate on is a commutative monoid, or even an abelian group (given inversion).
To conclude, I think we have two names to decide:
a. The class name of “quantifier” operation
b. The class name of what’s currently “QuantifierExpression”
Some choices of “a” are:
QuantifierOperation
should be commutative and associative and contains an identity element.inverse()
method.Some choices of “b” are:
Issue:
Currently, we have a wrapping around SymPy Expression. We currently have a type dictionary for a whole expression. Inferring the type in SymPy is actually a bottleneck. This is where Xiang is finding a lot of the runtime at.
Our higher order inference typing is also already an issue (E.g.: Our typing for add is Callable[[float, float], float]
.) This is because SymPy and Z3 can both do (add, 1, 2, 3), which does NOT follow the structure of our callable. It may be easier to just discard this.
Solution:
SymPy has something called domain
(like real number R, etc.). It might be more useful to use the domain. If it's a real number, just return float. => https://docs.sympy.org/latest/modules/polys/domainsintro.html
Xiang also hacked in another version of the typing for the operator. He changed the Callable[[float, float], float]
to Callable[[], float]
.
Issue:
SymPy does not know anything about the thing it is trying to integrate. Thus, it is trying all of the heuristics it knows to integrate it.
Solution:
We are already only using polynomials, so we should use the built-in polynomial that SymPy has to offer. =>https://docs.sympy.org/latest/modules/polys/reference.html
Can also convert the SymPy Poly object into a binary
Can also simplify the object => not need to convert it into a binary
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.