Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
GSoC 2015 Application Aaditya M Nair : Improve the assumptions system.
Clone this wiki locally
Name: Aaditya M Nair
I am a 2nd Year undergraduate pursuing Bachelor of Technology and MS (By Research) in Computer Science at International Institute of Information Technology, Hyderabad. During this time I have taken courses like
1. Mathematics-I (Set Theory, Combinatorics, Introductory Graph Theory) 2. Mathematics-II (Basic Matrices and Determinants, Jacobians, Gaussian Elimination) 3. Mathematics-III (Probability Theory, Complex Algebra)
as well as other computer oriented courses like
1. Data Structures 2. Algorithms 3. Structured Software Analysis and Design
I work on a Fedora 21 machine. I prefer using VIM as my primary text-editor due to availability of Keyboard based commands for almost everything and its general customizability and speed.
I have been programming for three years now. I began with C++/C and then moved on to NodeJS and Python. I switched to Python as my primary language due to its general ease of Programming and understandability. It also has a highly evolved documentation system that was very useful to me during the learning phase.
List / Dictionaries are my most favorite Python features. In SymPy, one of favorite features is transforms especially Fourier Transforms. As a student of Signal Analysis this semester, this feature helped me in a lot of analysis.
Contributions to SymPy
I started tinkering with SymPy around January, 2015 and I made my first contribution at the end of that month. Since then I have been consistently contributing to and learning from the awesome community that is Sympy.
- (Merged) Fixed incompatiblity with latest version of pyglet (1.2alpha1)
- (Merged) reduce -> functools.reduce / for loops
- (Under Review) Function unicode compatiblity
(Under Review) Implement
This project aims to completely replace SymPy's old assumptions system and replace it with a completely new one. Aaron Meurer had already started some work on this direction. This project hopes to extend and probably complete this work.
In essence, the new assumptions system will separate the symbols from the assumptions associated with it.
>>> x=Symbols('x', positive=True) >>> x.is_positive True
New Assumptions (Partially Implemented):
>>> x = Symbol('x') >>> y = Symbol('y') >>> facts = Q.positive(x) & Q.positive(y) >>> ask(Q.positive(x), facts) True
The present assumptions system creates a lot of bugs like #8873 which are fixed through non-desirable hacks. The new system will provide a better and elegant solutions to them
Plan of Execution
Develop helper functions to facilitate further development.
Add functions that convert a fact_name to corresponding property.
>>> as_property('real') Q.real >>> as_not_property('positive') ~Q.positive
Qto facilitate the above.
ManagedPropertiesclass to use the new style assumptions.
This involves changing parts of code that used the old-style assumptions to new-style assumptions.
for k, v in cls.default_assumptions.items(): setattr(cls, as_property(k), v)
for k, v in cls.default_assumptions.items(): if v == True: global_assumptions &= as_property(k)(self) else: global_assumptions &= as_not_property(k)(self)
ask()to read the old-style assumptions. Change the
Symbolclass to use new-assumptions.
>>> ask(Q.real(Symbol('x', real=True))) None
After the project:
>>> ask(Q.real(Symbol('x', real=True))) True
This involves directly updating the
global_assumptions. when new
i.e. when the following symbol is created:
>>> x = Symbol('x', real=True)
the following call is made internally:
global_assumptions &= Q.real(x)
All calls to
x.is_<attribute>will be equivalent to
Make a few core components (
Mul, etc ) use the new assumptions system and test them.
Presently these classes use old assumptions:
def _eval_is_imaginary(self): rv = _fuzzy_group(a.is_imaginary for a in self.args) if rv is False: return rv iargs = [a*S.ImaginaryUnit for a in self.args] r = _fuzzy_group(a.is_real for a in iargs) if r: s = self.func(*iargs, evaluate=False) return fuzzy_not(s.is_zero)
These will be more like:
def _eval_is_imaginary(self): rv = _fuzzy_group(ask(Q.imaginary(a)) for a in self.args) if rv is False: return rv iargs = [a*S.ImaginaryUnit for a in self.args] r = _fuzzy_group(ask(Q.real(a)) for a in iargs) if r: s = self.func(*iargs, evaluate=False) return fuzzy_not(ask(Q.zero(s)))
Once those functions are tested. Update to new assumptions on other core operations (
The assumptions system has, in many places, missing or incomplete documentation. Mostly, I believe that not enough examples are provided in the doc-strings. These examples could be added to make the code more easily understandable.
- Develop helper functions.
ManagedPropertiesfor new-style assumptions
Week-2 -- Week-3
ask()so that it reads the old-style assumptions from a
symbolclass to accept new assumptions. Test them.
Week-4 -- Week-5
- Port some core functions (
Pow, etc ) to use the new assumptions system.
- Port some core functions (
ask()to accept expressions containing the above core functions.
- Catch-Up week.
Week-8 -- Week-9
- Extend new assumptions to all core functions.
- Solve issues like #8873 caused due to old assumptions.
Week-11 -- On-wards
- Documentation and various bug-fixes.
Other Commitments (During GSoC)
I will have my semester finals till 7th of May. After that I am to start a research project for my course. This research is only intended as an introduction to the field and will only last at-most 8 weeks. Hence, during the research, I will be able to devote around 35 hours per week, after which I can contribute much more.