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 @@ -839,6 +839,21 @@ written
| `"forall n in ZZ+ : n! >= 2^(n - 1)".ToEntity().Evaled` | `UnhandledParseException` | `True` |
| `"forall n in ZZ+ /\\ [4; +oo) : n^2 - 2 n - 1 > 0".ToEntity().Evaled` | `UnhandledParseException` | `True` — decided about `4 + t` over `ZZ*` |

### An implication needs its conclusion's condition only where its assumption holds

`a implies (b provided c)` was `(a implies b) provided c`, the condition lifted over the whole
implication as it is over other nodes. But where `a` fails the implication holds whatever the
conclusion is, so the condition is needed only where `a` holds: it is
`(a implies b) provided (a implies c)`, and a condition among `a`'s conjuncts is no condition at
all. `not x = 0 implies x/x = 1` was left undefined at `0`, where it holds
([#1409](https://github.com/asc-community/AngouriMath/issues/1409), Sullivan and Mackey's Prob 1.5.6).

| Input | Was (2.5.0) | Now |
|---|---|---|
| `"not x = 0 implies x / x = 1".ToEntity().Simplify()` | `True provided not x = 0` | `True` |
| `"not x = 0 implies (y / y = 1)".ToEntity().Simplify()` | `True provided not y = 0` | `True provided not x = 0 implies not y = 0` |
| `forall x in RR : not x = 0 implies x / x = 1` | `UnhandledParseException` (left as written when quantifiers arrived) | `True` |

### `acsch(c x)` and `asech(c x)` are integrated with a symbolic `c`, and `|c|` differentiates to `0` in `x`

Three defects behind one symptom: `x acsch(2 x)` was answered and `x acsch(c x)` declined. The
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,24 @@ partial record Impliesf
private protected override Entity IntrinsicCondition => True;
/// <inheritdoc/>
protected override Entity InnerSimplify(bool isExact)
=> ExpandOnTwoArguments(Assumption, Conclusion,
{
// A conclusion defined only under a condition needs it only where the assumption
// holds, since where the assumption fails the implication holds whatever the
// conclusion is: a implies (b provided c) is (a implies b) provided (a implies c),
// and a condition among the assumption's conjuncts is no condition. Lifted over the
// whole implication, as other nodes lift one, `not x = 0 implies x/x = 1` was
// `True provided not x = 0`, undefined at 0 where the implication holds.
// https://github.com/asc-community/AngouriMath/issues/1409
if (Conclusion.InnerSimplified(isExact) is Providedf(var claim, var condition))
{
var assumption = Assumption.InnerSimplified(isExact);
var established = Andf.LinearChildren(assumption);
var needed = Andf.LinearChildren(condition).Where(conjunct => !established.Contains(conjunct)).ToList();
var implication = new Impliesf(assumption, claim).InnerSimplified(isExact);
return needed.Count == 0 ? implication
: implication.Provided(assumption.Implies(needed.Aggregate((left, right) => left & right))).InnerSimplified(isExact);
}
return ExpandOnTwoArguments(Assumption, Conclusion,
(left, right) => MixesANumberWithATruthValue(left, right) ? null
: (left.Evaled, right.Evaled) switch
{
Expand All @@ -225,6 +242,7 @@ protected override Entity InnerSimplify(bool isExact)
_ => null
},
(@this, a, b) => ((Impliesf)@this).New(a, b), isExact, settlesNaN: true);
}
}

partial record Equalsf
Expand Down
13 changes: 13 additions & 0 deletions Sources/Tests/UnitTests/Core/ProvidedImpliedByTheExpressionTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,19 @@ public sealed class ProvidedImpliedByTheExpressionTest
public void TheConditionTheExpressionStatesIsDropped(string input, string expected)
=> Assert.Equal(expected.ToEntity().Simplify(), input.ToEntity().Simplify());

/// <summary>
/// An implication needs its conclusion's condition only where its assumption holds, and
/// not at all where the assumption states it: <c>not x = 0 implies x/x = 1</c> holds at
/// every <c>x</c>, 0 among them, where it was <c>True provided not x = 0</c>.
/// https://github.com/asc-community/AngouriMath/issues/1409
/// </summary>
[Theory]
[InlineData("not x = 0 implies x / x = 1", "True")]
[InlineData("x > 0 and not x = 0 implies x / x = 1", "True")]
[InlineData("not x = 0 implies (y / y = 1)", "(not x = 0 implies True) provided (not x = 0 implies not y = 0)")]
public void AnAssumptionDischargesTheConditionItStates(string input, string expected)
=> Assert.Equal(expected.ToEntity().Simplify(), input.ToEntity().Simplify());

/// <summary>
/// The derivatives the comparison page shows, which carried the condition twice.
/// </summary>
Expand Down
2 changes: 2 additions & 0 deletions Sources/Tests/UnitTests/Core/QuantifierTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ public void DecidedOverAFiniteSet(string statement, string expected)
[InlineData("exists x in QQ : 2 x = 3", "True")]
[InlineData("forall x in ZZ : 2 divides x", "False")]
[InlineData("exists x in ZZ : 2 divides x", "True")]
// A condition the hypothesis states is no condition on the claim.
[InlineData("forall x in RR : not x = 0 implies x / x = 1", "True")]
// Uniqueness: two real roots, one positive whole one.
[InlineData("exists! x in RR : x^2 = 4", "False")]
[InlineData("exists! x in ZZ+ : x^2 = 4", "True")]
Expand Down
Loading