Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions BREAKING-CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -1667,6 +1667,21 @@ has no zeros, so `x! = 0` is still `{ }`, and so is `arcsin(x) = 5`.
| `"phi(x) = 4".Solve("x")` | `{ }` | `{ x : phi(x) = 4 }` |
| `"binomial(x, 2) = 3".Solve("x")` | `UnhandledParseException` | `{ x : binomial(x, 2) = 3 }` |

### An equation in a set, a cardinality or a power set of the unknown is left unsolved, and threw

`Solve` threw `NotSufficientlySupportedException` for an equation whose unknown sits under a set
operation or a cardinality, where the inverter's contract is to decline and leave the equation
unsolved, as the equations in the entry on inverses no node writes are. A power set of the unknown
was answered, and wrongly: the answer held `x`
([#1544](https://github.com/asc-community/AngouriMath/issues/1544)).

| Input | Was (2.5.0) | Now |
|---|---|---|
| `"card(x) = 3".ToEntity().Solve("x")` | throws `NotSufficientlySupportedException` | `{ x : #x = 3 }` |
| `"(x /\\ {1, 2}) = {1}".ToEntity().Solve("x")` | throws `NotSufficientlySupportedException` | `{ x : x /\ { 1, 2 } = { 1 } }` |
| `"(x \\ {1}) = {2}".ToEntity().Solve("x")` | throws `NotSufficientlySupportedException` | `{ x : x \ { 1 } = { 2 } }` |
| `"powerset(x) = {{}, {1}}".ToEntity().Solve("x")` | `{ { { }, { 1 / x } } }` | `{ x : powerset(x) = { { }, { 1 } } }` |

### `erf`, `erfc` and `erfi` are functions

**Addition, and two silent misreadings fixed.** The error function `erf(z) = 2/sqrt(pi) int_0^z
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -598,37 +598,42 @@ partial record Impliesf

partial record Equalsf
{
// A statement equal to a value has a set for its preimage, which the inverter cannot
// write, so it declines, and the solver leaves the equation unsolved.
private protected override IEnumerable<Entity>? InvertNode(Entity value, Entity x)
=> throw new NotSufficientlySupportedException(
"Inverting this node would need a set-valued answer, which the inverter cannot give");
=> null;
}

partial record Greaterf
{
// A statement equal to a value has a set for its preimage, which the inverter cannot
// write, so it declines, and the solver leaves the equation unsolved.
private protected override IEnumerable<Entity>? InvertNode(Entity value, Entity x)
=> throw new NotSufficientlySupportedException(
"Inverting this node would need a set-valued answer, which the inverter cannot give");
=> null;
}

partial record GreaterOrEqualf
{
// A statement equal to a value has a set for its preimage, which the inverter cannot
// write, so it declines, and the solver leaves the equation unsolved.
private protected override IEnumerable<Entity>? InvertNode(Entity value, Entity x)
=> throw new NotSufficientlySupportedException(
"Inverting this node would need a set-valued answer, which the inverter cannot give");
=> null;
}

partial record Lessf
{
// A statement equal to a value has a set for its preimage, which the inverter cannot
// write, so it declines, and the solver leaves the equation unsolved.
private protected override IEnumerable<Entity>? InvertNode(Entity value, Entity x)
=> throw new NotSufficientlySupportedException(
"Inverting this node would need a set-valued answer, which the inverter cannot give");
=> null;
}

partial record LessOrEqualf
{
// A statement equal to a value has a set for its preimage, which the inverter cannot
// write, so it declines, and the solver leaves the equation unsolved.
private protected override IEnumerable<Entity>? InvertNode(Entity value, Entity x)
=> throw new NotSufficientlySupportedException(
"Inverting this node would need a set-valued answer, which the inverter cannot give");
=> null;
}

partial record Set
Expand Down Expand Up @@ -701,34 +706,34 @@ partial record Unionf
partial record Intersectionf
{
// f(x) /\ A = value
// Deciding the membership would need a piecewise condition, which is not written
// here; declined.
private protected override IEnumerable<Entity>? InvertNode(Entity value, Entity x)
=> throw new NotSufficientlySupportedException(
"Deciding this membership would need a piecewise condition, which is not supported here");
=> null;
}

partial record SetMinusf
{
// f(x) \ A = value
// Deciding the membership would need a piecewise condition, which is not written
// here; declined.
private protected override IEnumerable<Entity>? InvertNode(Entity value, Entity x)
=> throw new NotSufficientlySupportedException(
"Deciding this membership would need a piecewise condition, which is not supported here");
=> null;
}

partial record Inf
{
// TODO: CSet is needed here => InvertNode to return a Set, not an IEnumerable
// f(x) in A = value
private protected override IEnumerable<Entity>? InvertNode(Entity value, Entity x)
=> throw new NotSufficientlySupportedException(
"Inverting this node would need a set-valued answer, which the inverter cannot give");
=> null;
}

partial record Subsetf
{
// A subset B = value asks for a set of sets, which the inverter cannot return.
private protected override IEnumerable<Entity>? InvertNode(Entity value, Entity x)
=> throw new NotSufficientlySupportedException(
"Inverting this node would need a set-valued answer, which the inverter cannot give");
=> null;
}

partial record IndexedSetOperation
Expand All @@ -742,8 +747,7 @@ partial record Powersetf
{
// powerset(f(x)) = value has no inverse the inverter can write.
private protected override IEnumerable<Entity>? InvertNode(Entity value, Entity x)
=> throw new NotSufficientlySupportedException(
"Inverting this node would need a set-valued answer, which the inverter cannot give");
=> null;
}
}

Expand Down Expand Up @@ -777,26 +781,23 @@ partial record Cardf
// card(S) = n has every set of n elements for its solutions, which is not something
// the inverter can hand back.
private protected override IEnumerable<Entity>? InvertNode(Entity value, Entity x)
=> throw new NotSufficientlySupportedException(
"Inverting this node would need a set-valued answer, which the inverter cannot give");
=> null;
}

partial record Dividesf
{
// (a divides x) = value has the multiples of a for its solutions -- a set, which the
// inverter cannot return, the same as membership.
private protected override IEnumerable<Entity>? InvertNode(Entity value, Entity x)
=> throw new NotSufficientlySupportedException(
"Inverting this node would need a set-valued answer, which the inverter cannot give");
=> null;
}

partial record Congruentf
{
// (x = b (mod n)) = value has a residue class for its solutions -- a set, which the
// inverter cannot return, the same as divisibility and membership.
private protected override IEnumerable<Entity>? InvertNode(Entity value, Entity x)
=> throw new NotSufficientlySupportedException(
"Inverting this node would need a set-valued answer, which the inverter cannot give");
=> null;
}

partial record Quantifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,20 @@ public void ARootIsInTheAnswerAndANonRootIsNot(string equation, string root, str
Assert.Equal(Entity.Boolean.False, IsIn(other, solved));
}

/// <summary>
/// A set, a cardinality or a power set of the unknown has a set of sets for its preimage,
/// which the inverter cannot write, and it threw <c>NotSufficientlySupportedException</c>
/// out of <c>Solve</c> where its contract is to decline and leave the equation unsolved.
/// https://github.com/asc-community/AngouriMath/issues/1544
/// </summary>
[Theory]
[InlineData("card(x) = 3", "{1, 2, 3}", "{1}")]
[InlineData("(x /\\ {1, 2}) = {1}", "{1}", "{2}")]
[InlineData("(x \\ {1}) = {2}", "{2}", "{1, 2, 3}")]
[InlineData("powerset(x) = {{}, {1}}", "{1}", "{2}")]
public void ASetOfSetsIsLeftUnsolved(string equation, string root, string other)
=> ARootIsInTheAnswerAndANonRootIsNot(equation, root, other);

/// <summary>
/// The factorial is the gamma function one along, which has no zeros, so a factorial
/// equal to zero does have none, and the roots found beside one are the whole answer.
Expand Down
Loading