> Okay, well if you want this to be included in sympy I suggest to begin.
> by making some specific proposals either here or in github issues. We
> should agree the basic ideas before too much work is done. Of course
> you don't have to implement all the proposals but we should agree what
> makes sense as part of sympy even if your project is only a part of
> what we would want.

> Where possible it is best to improve the implementation of existing
> API functions rather than introduce new ones but there certainly are
> reasons for wanting some new functions for working with inequalities:
> exactly what those new functions would be is the part that needs to be
> agreed if this is to be included in sympy.

> I would say that eliminating one or more variables from a system of
> inequalities is very useful and there is e.g. Fourier-Motzkin
> elimination
> https://en.wikipedia.org/wiki/Fourier%E2%80%93Motzkin_elimination
> as well as linear programming:
> https://en.wikipedia.org/wiki/Linear_programming

> Actually one of the most useful things at least for internal use in
> sympy would be being able to ask whether an inequality is implied by a
> collection of inequalities. A simple example is that x > 0 implies
> that x > 1 

I think you meant that x > 1 implies that x > 0, but I get the point. 

> but we would like to pose more complicated questions like:

> Given that x > y, y > 0, x + y > z is it the case that 2*x > 0 

> The possible answers to a problem like this are "yes", "no" or "maybe".

I see. Well I believe I can implement this function using the Linear 
Programing technique. 

if that is okay with you, I would like to start working on it right after 
my semester exams (in 3 weeks). 

Is there anything more I need to know/do before I start coding?   

> The reason that we want to be able to answer this sort of question is
> because handling inequalities like this is a key feature that is
> wanted in the new assumptions system. A function that can take a
> system of inequalities and determine their satisfiability is
> sufficient to implement this because if (A and not B) is not
> satisfiable then we must have (B or not A) which is the same as (A
> implies B).

Oscar
On Tuesday, 29 December 2020 at 22:35:59 UTC+2 Oscar wrote:

> Okay, well if you want this to be included in sympy I suggest to begin
> by making some specific proposals either here or in github issues. We
> should agree the basic ideas before too much work is done. Of course
> you don't have to implement all the proposals but we should agree what
> makes sense as part of sympy even if your project is only a part of
> what we would want.
>
> Where possible it is best to improve the implementation of existing
> API functions rather than introduce new ones but there certainly are
> reasons for wanting some new functions for working with inequalities:
> exactly what those new functions would be is the part that needs to be
> agreed if this is to be included in sympy.
>
> I would say that eliminating one or more variables from a system of
> inequalities is very useful and there is e.g. Fourier-Motzkin
> elimination
> https://en.wikipedia.org/wiki/Fourier%E2%80%93Motzkin_elimination
> as well as linear programming:
> https://en.wikipedia.org/wiki/Linear_programming
>
> Actually one of the most useful things at least for internal use in
> sympy would be being able to ask whether an inequality is implied by a
> collection of inequalities. A simple example is that x > 0 implies
> that x > 1 but we would like to pose more complicated questions like:
>
> Given that x > y, y > 0, x + y > z is it the case that 2*x > 0
>
> The possible answers to a problem like this are "yes", "no" or "maybe".
>
> The reason that we want to be able to answer this sort of question is
> because handling inequalities like this is a key feature that is
> wanted in the new assumptions system. A function that can take a
> system of inequalities and determine their satisfiability is
> sufficient to implement this because if (A and not B) is not
> satisfiable then we must have (B or not A) which is the same as (A
> implies B).
>
> Oscar
>
> ‪On Mon, 28 Dec 2020 at 18:41, ‫אוריאל מליחי‬‎ <[email protected]> 
> wrote:‬
> >
> > Thank you all for your advices.
> > and Oscar, for your question- yes, i do intend
> > for this to be incorporated as part of sympy if it is possible.
> >
> > On Sunday, 27 December 2020 at 23:57:20 UTC+2 Oscar wrote:
> >>
> >> ‪On Sun, 27 Dec 2020 at 10:46, ‫אוריאל מליחי‬‎ <[email protected]> 
> wrote:‬
> >> >
> >> > Hello everyone!
> >>
> >> Hi,
> >>
> >> > As part of my final project in my computer science degree I would 
> like to develop a class for linear inequalities simplifying.
> >>
> >> That sounds like an excellent project. To be clear, are you intending
> >> for this to be incorporated as part of sympy?
> >>
> >> Handling systems of inequalities is a feature that is currently
> >> missing from sympy but the most useful way to add it would really be
> >> as a function or several functions rather than a class (although the
> >> function could use a class internally).
> >>
> >> > The class's main algorithm is that for given a set of linear 
> inequalities in m variables, it returns a simplified set. "Simplified" may 
> mean an equivalent set with a smallest number of inequalities. As an 
> example, given the inequalities:
> >> >
> >> > x+y≥1
> >> >
> >> > x+y≤0
> >> >
> >> > the algorithm should return the empty set. Given the inequalities:
> >> >
> >> > x+y≥1
> >> >
> >> > 2x+2y≥3
> >> >
> >> > the algorithm should return e.g.
> >> >
> >> > 2x+2y≥3
> >>
> >> Or perhaps:
> >>
> >> x+y >= 3/2
> >>
> >> It would be useful to have a function for making a subset of the
> >> symbols in an inequality become the subject. There already is a
> >> function for this but it doesn't work for systems of inequalities with
> >> multiple unknowns:
> >>
> >> In [1]: from sympy.solvers.inequalities import reduce_inequalities
> >>
> >> In [2]: ineq = x + y > 2
> >>
> >> In [3]: reduce_inequalities(ineq, [x])
> >> Out[3]: x > 2 - y
> >>
> >> In [4]: reduce_inequalities(ineq, [y])
> >> Out[4]: y > 2 - x
> >>
> >> In [5]: reduce_inequalities([x+y > 2, x < 1], [x, y])
> >> 
> ---------------------------------------------------------------------------
> >> NotImplementedError
> >> inequality has more than one symbol of interest.
> >>
> >> > The class will also implement operator overloading for + (adding one 
> set to another) and – (removing a subset from original set) and more.
> >>
> >> This is already handled by Python's built in set class so it isn't
> >> really necessary to make a class for this. We can just put the
> >> inequalities in a set.
> >>
> >> > For this project to work I need to fully understand the implemented 
> inequality classes in SymPy which are in sympy.core.relational, so I would 
> know how to manipulate SymPy's inequalities.
> >> >
> >> > The problem is that when I am trying to go through the code of those 
> classes I get lost. There are so many subclasses there and every subclass 
> is inheriting from some other base class.
> >> >
> >> > Is there a way to see a class diagram of those classes so it would be 
> more clear what the purpose of each class is? Does anyone have another idea 
> for understanding those classes?
> >>
> >> The codebase for sympy is large which means it takes time to
> >> understand. You can see the inheritance scheme for these classes with
> >> mro:
> >>
> >> In [6]: LessThan.mro()
> >> Out[6]:
> >> [sympy.core.relational.LessThan,
> >> sympy.core.relational._Less,
> >> sympy.core.relational._Inequality,
> >> sympy.core.relational.Relational,
> >> sympy.logic.boolalg.Boolean,
> >> sympy.core.basic.Basic,
> >> sympy.printing.defaults.Printable,
> >> sympy.core.evalf.EvalfMixin,
> >> object]
> >>
> >> Here Printable and EvalfMixin are mixins that provide printing support
> >> and make it possible to use .evalf() e.g.:
> >>
> >> In [7]: x < pi
> >> Out[7]: x < π
> >>
> >> In [8]: _.evalf()
> >> Out[8]: x < 3.14159265358979
> >>
> >> Basic is a fundamental class in sympy. Most sympy objects are
> >> instances of Basic. Basic is used to represent mathematical objects as
> >> trees and to implement operations like subs working over those trees.
> >> You can see an explanation of that here:
> >> https://docs.sympy.org/latest/tutorial/manipulation.html
> >> (Surprisingly that page doesn't actually mention Basic!)
> >>
> >> Boolean is a subclass of Basic for objects representing boolean
> >> True/False. The Boolean class provides operations like `&` and `|`
> >> representing "and" and "or" (as well as many other operations):
> >>
> >> In [9]: (x < pi) & (y < 3)
> >> Out[9]: x < π ∧ y < 3
> >>
> >> Relational is a subclass of Boolean and is the common superclass for
> >> LessThan, StrictLessThan, Equality, Unequality, GreaterThan and
> >> StrictGreaterThan representing the 6 types of relation in sympy (`<=,
> >> <, ==, !=, >=, >`).
> >>
> >> The classes `_Inequality` and `_Less` are used for sharing/dividing
> >> code between the different inequality classes.
> >>
> >> --
> >> Oscar
> >
> > --
> > You received this message because you are subscribed to the Google 
> Groups "sympy" group.
> > To unsubscribe from this group and stop receiving emails from it, send 
> an email to [email protected].
> > To view this discussion on the web visit 
> https://groups.google.com/d/msgid/sympy/c00aa378-2b27-4b79-a94b-d6c540f76fb9n%40googlegroups.com
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/13846f03-4277-4898-ae38-20f86e65ba11n%40googlegroups.com.

Reply via email to