@@ -2057,12 +2057,15 @@ is var (divided, remainder)
20572057 // larger the angle is.
20582058 growth : RewriteRuleGrowth . Collects ) ,
20592059
2060+ // The four rules below are the definitions arccsc(z) = arcsin(1 / z) and its siblings,
2061+ // read through n / d = 1 / (d / n), which holds for a nonzero n. At n = 0 the left
2062+ // side is arcsin(0) = 0 and the right arccsc(d / 0), which has no value.
20602063 new MatchedRule (
20612064 "an-arcsine-of-a-numeric-reciprocal-is-an-arccosecant" ,
20622065 MatchPattern . Node < Arcsinf > ( MatchPattern . Node < Divf > ( MatchPattern . Any ( "n" ) , MatchPattern . Any ( "d" ) ) ) ,
20632066 bound => new Arccosecantf ( bound [ "d" ] / bound [ "n" ] ) ,
20642067 Soundness . SoundUnderAssumptions ,
2065- when : bound => bound [ "n" ] is Number && bound [ "d" ] is not Number ,
2068+ when : bound => bound [ "n" ] is Number && bound [ "n" ] != Integer . Zero && bound [ " d"] is not Number ,
20662069 description : "arcsin(1 / c) = arccosec(c), for a numeric c" ,
20672070 // One inverse function becomes another and the quotient stays a quotient with its
20682071 // operands the other way round, so the two are the same size whatever they are.
@@ -2073,7 +2076,7 @@ is var (divided, remainder)
20732076 MatchPattern . Node < Arccosf > ( MatchPattern . Node < Divf > ( MatchPattern . Any ( "n" ) , MatchPattern . Any ( "d" ) ) ) ,
20742077 bound => new Arcsecantf ( bound [ "d" ] / bound [ "n" ] ) ,
20752078 Soundness . SoundUnderAssumptions ,
2076- when : bound => bound [ "n" ] is Number && bound [ "d" ] is not Number ,
2079+ when : bound => bound [ "n" ] is Number && bound [ "n" ] != Integer . Zero && bound [ " d"] is not Number ,
20772080 description : "arccos(1 / c) = arcsec(c), for a numeric c" ,
20782081 // One inverse function becomes another and the quotient stays a quotient with its
20792082 // operands the other way round, so the two are the same size whatever they are.
@@ -2084,7 +2087,7 @@ is var (divided, remainder)
20842087 MatchPattern . Node < Arccosecantf > ( MatchPattern . Node < Divf > ( MatchPattern . Any ( "n" ) , MatchPattern . Any ( "d" ) ) ) ,
20852088 bound => new Arcsinf ( bound [ "d" ] / bound [ "n" ] ) ,
20862089 Soundness . SoundUnderAssumptions ,
2087- when : bound => bound [ "n" ] is Number && bound [ "d" ] is not Number ,
2090+ when : bound => bound [ "n" ] is Number && bound [ "n" ] != Integer . Zero && bound [ " d"] is not Number ,
20882091 description : "arccosec(1 / c) = arcsin(c), for a numeric c" ,
20892092 // One inverse function becomes another and the quotient stays a quotient with its
20902093 // operands the other way round, so the two are the same size whatever they are.
@@ -2095,7 +2098,7 @@ is var (divided, remainder)
20952098 MatchPattern . Node < Arcsecantf > ( MatchPattern . Node < Divf > ( MatchPattern . Any ( "n" ) , MatchPattern . Any ( "d" ) ) ) ,
20962099 bound => new Arccosf ( bound [ "d" ] / bound [ "n" ] ) ,
20972100 Soundness . SoundUnderAssumptions ,
2098- when : bound => bound [ "n" ] is Number && bound [ "d" ] is not Number ,
2101+ when : bound => bound [ "n" ] is Number && bound [ "n" ] != Integer . Zero && bound [ " d"] is not Number ,
20992102 description : "arcsec(1 / c) = arccos(c), for a numeric c" ,
21002103 // One inverse function becomes another and the quotient stays a quotient with its
21012104 // operands the other way round, so the two are the same size whatever they are.
@@ -2546,17 +2549,26 @@ is var (divided, remainder)
25462549 bound => Functions . Patterns . PushNotInside ( Orf . LinearChildren ( ( Orf ) bound [ "chain" ] ) , disjoin : false ) ,
25472550 Soundness . Sound ,
25482551 description : "not (a or b or ...) = (not a) and (not b) and ..." ) ,
2552+ // Transitivity is a fact about an order, so the pair below fires only where the
2553+ // three operands are known to be ordered. Elsewhere the implication need not have a
2554+ // truth value -- at a = i, b = 1, c = 0 it is NaN -- and the ordered condition cannot
2555+ // be attached instead, as its siblings attach it: a comparison with no truth value
2556+ // inside a conjunction that is already false leaves the implication true, so at
2557+ // a = i, b = 0, c = 1 the chain of greaters is True and `True provided a in RR` is
2558+ // not. https://github.com/asc-community/AngouriMath/issues/876
25492559 new MatchedRule (
25502560 "a-chain-of-greaters-implies-its-own-ends" ,
25512561 MatchPattern . Node < Impliesf > ( MatchPattern . Node < Andf > ( MatchPattern . Node < Greaterf > ( MatchPattern . Any ( "a" ) , MatchPattern . Any ( "b" ) ) , MatchPattern . Node < Greaterf > ( MatchPattern . Any ( "b" ) , MatchPattern . Any ( "c" ) ) ) , MatchPattern . Node < Greaterf > ( MatchPattern . Any ( "a" ) , MatchPattern . Any ( "c" ) ) ) ,
25522562 bound => Entity . Boolean . True . Provided ( bound [ "a" ] . DomainCondition ) . Provided ( bound [ "b" ] . DomainCondition ) . Provided ( bound [ "c" ] . DomainCondition ) ,
25532563 Soundness . SoundUnderAssumptions ,
2564+ when : bound => Functions . Patterns . AreOrdered ( bound [ "a" ] , bound [ "b" ] , bound [ "c" ] ) ,
25542565 description : "(((a > b) and (b > c)) implies (a > c)) = True" ) ,
25552566 new MatchedRule (
25562567 "a-chain-of-lesss-implies-its-own-ends" ,
25572568 MatchPattern . Node < Impliesf > ( MatchPattern . Node < Andf > ( MatchPattern . Node < Lessf > ( MatchPattern . Any ( "a" ) , MatchPattern . Any ( "b" ) ) , MatchPattern . Node < Lessf > ( MatchPattern . Any ( "b" ) , MatchPattern . Any ( "c" ) ) ) , MatchPattern . Node < Lessf > ( MatchPattern . Any ( "a" ) , MatchPattern . Any ( "c" ) ) ) ,
25582569 bound => Entity . Boolean . True . Provided ( bound [ "a" ] . DomainCondition ) . Provided ( bound [ "b" ] . DomainCondition ) . Provided ( bound [ "c" ] . DomainCondition ) ,
25592570 Soundness . SoundUnderAssumptions ,
2571+ when : bound => Functions . Patterns . AreOrdered ( bound [ "a" ] , bound [ "b" ] , bound [ "c" ] ) ,
25602572 description : "(((a < b) and (b < c)) implies (a < c)) = True" ) ,
25612573 new MatchedRule (
25622574 "a-equals-with-zero-on-the-left-turns-round" ,
@@ -3084,6 +3096,13 @@ is var (divided, remainder)
30843096 MatchPattern . Any ( "n" ) ) ) ) ,
30853097 bound => new Powf ( bound [ "a" ] / new Powf ( bound [ "b" ] , bound [ "c" ] ) , bound [ "n" ] ) ,
30863098 Soundness . SoundUnderAssumptions ,
3099+ // The guard of the quotient rule above, for the same reason: b ^ (c * n) is
3100+ // (b ^ c) ^ n, and a ^ n / (b ^ c) ^ n is (a / b ^ c) ^ n, only for a whole n or
3101+ // positive real bases. At a = 1, b = -1, n = 1/2 the quotient is
3102+ // 1 / (-1) ^ 1 = -1 and the gathered power (1 / 1) ^ (1/2) = 1.
3103+ when : bound => bound [ "n" ] is Integer
3104+ || ( bound [ "a" ] . Evaled is Real { IsPositive : true }
3105+ && bound [ "b" ] . Evaled is Real { IsPositive : true } ) ,
30873106 description : "a ^ n / b ^ (c * n) = (a / b ^ c) ^ n, for a positive whole c" ,
30883107 // The exponent is matched twice and written once, and one power node goes: the delta
30893108 // is -(1 + |n|), at most -2 and further the larger the exponent is.
@@ -3100,6 +3119,11 @@ is var (divided, remainder)
31003119 MatchPattern . Node < Powf > ( MatchPattern . Any ( "b" ) , MatchPattern . Any ( "n" ) ) ) ,
31013120 bound => new Powf ( new Powf ( bound [ "a" ] , bound [ "c" ] ) / bound [ "b" ] , bound [ "n" ] ) ,
31023121 Soundness . SoundUnderAssumptions ,
3122+ // Guarded as its mirror is: at a = -1, b = 1, n = 1/2 the quotient is -1 and the
3123+ // gathered power ((-1) ^ 2 / 1) ^ (1/2) is 1.
3124+ when : bound => bound [ "n" ] is Integer
3125+ || ( bound [ "a" ] . Evaled is Real { IsPositive : true }
3126+ && bound [ "b" ] . Evaled is Real { IsPositive : true } ) ,
31033127 description : "a ^ (c * n) / b ^ n = (a ^ c / b) ^ n, for a positive whole c" ,
31043128 // The exponent is matched twice and written once, and one power node goes with it:
31053129 // the delta is -(1 + |n|), the mirror of the rule that takes it into the divisor.
@@ -4015,7 +4039,12 @@ is var (divided, remainder)
40154039 MatchPattern . Node < Divf > ( MatchPattern . Node < Mulf > ( MatchPattern . Node < Signumf > ( MatchPattern . Any ( "a" ) ) , MatchPattern . Node < Mulf > ( MatchPattern . Any ( "b" ) , MatchPattern . Any ( "a" ) ) ) , MatchPattern . Node < Absf > ( MatchPattern . Any ( "a" ) ) ) ,
40164040 bound => bound [ "b" ] . Provided ( ! bound [ "a" ] . EqualTo ( Integer . Zero ) ) ,
40174041 Soundness . SoundUnderAssumptions ,
4018- description : "(sgn(a) * (b * a)) / abs(a) = b, provided a is not zero" ,
4042+ // sgn(a) is a / abs(a), so sgn(a) * a / abs(a) is a^2 / abs(a)^2: 1 for a real a and
4043+ // not otherwise -- at a = i it is -1. Realness is a reading, not a condition on
4044+ // where either side is defined, so it is decided here, as the comparison rules
4045+ // decide it, and the rule does not fire on an operand not known to be real.
4046+ when : bound => Functions . Patterns . OrderedConditionFor ( bound [ "a" ] ) == Entity . Boolean . True ,
4047+ description : "(sgn(a) * (b * a)) / abs(a) = b, for a real a, provided a is not zero" ,
40194048 // Three copies of a go and one comes back inside the condition; the sign, the
40204049 // absolute value, the quotient and two products go against the three nodes the
40214050 // condition and its attachment add: the delta is -1 - 2|a|, at most -3.
0 commit comments