Skip to content

rewrite Expression.__nonzero__() #19040

@rwst

Description

@rwst

Symbolic expressions may be part of type-neutral computations, e.g. matrices, polynomials. Developers do not expect proof machinery to crank up when writing if x!=0, but this is just what happens. So bool(x1!=x2) should be changed to mean not (x1-x2).is_trivial_zero() for symbolic x. The ticket should provide a different interface for cases requiring simplification/proof:

  • bool(rel) equivalent to (not)(LHS-RHS).is_trivial_zero() for ==,!= ; and for <, >, <=, >= the result follows alpha order of lhs and rhs
  • satisfiable(rel) attempting simplification/proof, returning (Yes,example)/False/Undefined
  • solve(rel) in case of satisfiable=Yes returning the full solution set
  • holds(rel), quick alias of satisfiable (later without giving an example)
  • ex.is_zero(simplify=False) (default) calling the fast bool(ex==0)
  • ex.is_zero(simplify=True) attempting simplification/proof by calling ex==0.holds()
  • prove(rel) showing more or less steps of simplification (which is out of reach for the moment)

This ticket will implement the new behaviour of bool(rel) and put all other functionality of ex.__nonzero__() into holds() and ex.is_zero(simplify=True).

See also #19162.

CC: @nexttime @behackl @kcrisman @eviatarbach

Component: symbolics

Issue created by migration from https://trac.sagemath.org/ticket/19040

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions