MCPcopy Create free account
hub / github.com/cortex-js/compute-engine / assumeElement

Function assumeElement

src/compute-engine/assume.ts:751–801  ·  view source on GitHub ↗
(proposition: Expression)

Source from the content-addressed store, hash-verified

749 // We already know symbol > lowerVal (or >=)
750 if (isStrict) {
751 // Assuming symbol > k: tautology if existing lower bound implies this
752 // If lowerVal > k, then symbol > lowerVal > k, so symbol > k (tautology)
753 // If lowerVal == k and bound is strict, then symbol > lowerVal = k (tautology)
754 if (lowerVal > k) return 'tautology';
755 if (bounds.lowerStrict && lowerVal >= k) return 'tautology';
756 } else {
757 // Assuming symbol >= k: tautology if lowerVal >= k (with strict bound) or lowerVal > k
758 if (lowerVal > k) return 'tautology';
759 if (bounds.lowerStrict && lowerVal >= k) return 'tautology';
760 if (!bounds.lowerStrict && lowerVal >= k) return 'tautology';
761 }
762 }
763 }
764
765 if (bounds.upper !== undefined) {
766 const upperVal = isNumber(bounds.upper)
767 ? bounds.upper.numericValue
768 : undefined;
769 if (typeof upperVal === 'number' && isFinite(upperVal)) {
770 // We know symbol < upperVal (or <=), now checking symbol > k
771 if (isStrict) {
772 // Contradiction if upperVal <= k
773 if (upperVal < k) return 'contradiction';
774 if (bounds.upperStrict && upperVal <= k) return 'contradiction';
775 if (!bounds.upperStrict && upperVal <= k)
776 return 'contradiction';
777 } else {
778 // symbol >= k: contradiction if upperVal < k
779 if (upperVal < k) return 'contradiction';
780 if (bounds.upperStrict && upperVal <= k) return 'contradiction';
781 }
782 }
783 }
784 } else {
785 // effectiveOp is 'less' or 'lessEqual'
786 // We're asserting symbol < k or symbol <= k
787 const isStrict = effectiveOp === 'less';
788
789 if (bounds.upper !== undefined) {
790 const upperVal = isNumber(bounds.upper)
791 ? bounds.upper.numericValue
792 : undefined;
793 if (typeof upperVal === 'number' && isFinite(upperVal)) {
794 // We already know symbol < upperVal (or <=)
795 if (isStrict) {
796 // Assuming symbol < k: tautology if existing upper bound implies this
797 if (upperVal < k) return 'tautology';
798 if (bounds.upperStrict && upperVal <= k) return 'tautology';
799 } else {
800 // symbol <= k: tautology if upperVal <= k
801 if (upperVal < k) return 'tautology';
802 if (upperVal <= k) return 'tautology';
803 }
804 }

Callers 1

assumeFunction · 0.85

Calls 9

isFunctionFunction · 0.90
isSymbolFunction · 0.90
domainToTypeFunction · 0.90
assumeElementOfSetFunction · 0.85
undefinedIdentifiersFunction · 0.85
assertMethod · 0.80
evaluateMethod · 0.65
declareMethod · 0.65
setMethod · 0.65

Tested by

no test coverage detected