Skip to content

Solve answers every negation with the empty set, because the statement solver has no arm for not #1127

Description

@Rafael-SOWNet

Found while answering #996, and deliberately left out of #1126 because it is a solver change
rather than a domain-versus-set one. Measured on master at b30a4923, .NET 10, default settings.

not has no arm in the statement solver, so every negation answers "no solutions"

"not (x = 1)".ToEntity().Solve("x")     ->   {  }
"not (x > 1)".ToEntity().Solve("x")     ->   {  }
"not (x in RR)".ToEntity().Solve("x")   ->   {  }

The empty set is a positive claim — no x satisfies this — and each of these has solutions.
not (x = 1) holds at every value but 1.

Cause

StatementSolver.Solve (SolveStatement.cs) has arms for Equalsf, Andf, Orf, Impliesf,
the four comparisons, Inf, Providedf and Piecewise. There is no Notf arm, so a negation
falls to _ => Set.Empty.

This is the defect #1036 fixed for equations — an equation nothing settled was answered with the
empty set rather than with itself — left unfixed for negation.

What the answer should be

The same shape #1126 gives an implication: { x : not a } names the set without naming a universe,
and a complement written that way is right whatever x ranges over.

Notf(var operand) => new ConditionalSet(x, expr),

with the rewrites that can do better than that — not (x = a) where the equation is solvable,
not (x > a) as x <= a — going in front of it if they are wanted. The point of the issue is that
the fallback must not be Empty.

Worth checking at the same time whether Solve of a bare Boolean should be Empty either:
"A implies true".ToEntity().Solve("A") is { A : not A } because Solve(True, A) is Empty,
where every A satisfies it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions