Skip to content

Assuming ​

Evaluate exprexpr with condcond assumed for the duration of the call, then forget it. Provided by @enumeratio/analytic.

✓ checked against that system · ! checked, with disagreements (hover a chip)Wolfram LanguageAssuming!
Assuming(cond, expr)evaluate exprexpr under a single assumed condition, a List of them (an implicit conjunction), or an And of them.
Typed signatures
TypePackageApplies
(expression, expression) -> expressionanalyticalways

Domain: Analytic

Details
  • Built on compute-engine's own assumption store: the condition is pushed in a fresh scope (ce.pushScope/ce.assume), exprexpr is evaluated, and the scope is popped — compute-engine documents assumptions as scoped, so popping restores exactly what was in force before, even nested and even mid-evaluation (unlike ce.checkpoint, which refuses there).
  • No leakage: an assumption made here is gone once the call returns, whatever exprexpr does — verified by asking about the assumed symbol immediately after.
  • What resolves under the assumption is whatever compute-engine's own evaluate() already consults assumptions for — Abs, Sign, and ln⁡∘exp⁡\ln \circ \exp among them. This is more eager than bare Wolfram evaluation for those heads (Wolfram leaves Abs(x) alone until Refine/Simplify names it explicitly); it is not a general Simplify.

Examples

Basic #

∣x∣=x|x| = x once x>0x > 0 is assumed

live ↗
InAssuming(x>0,∣x∣)\mathrm{Assuming}(x\gt0, \vert x\vert)Outxx

a List of conditions is an implicit conjunction: sign⁡(x)+sign⁡(y)=0\operatorname{sign}(x) + \operatorname{sign}(y) = 0 under x>0∧y<0x>0 \wedge y<0

live ↗
InAssuming({x>0y<0,sgn(x)+sgn(y))\mathrm{Assuming}(\begin{cases}x\gt0\\y\lt0\end{cases}, \mathrm{sgn}(x)+\mathrm{sgn}(y))Out00
live ↗
InAssuming(a>0,[Refine(a2),∫01 ⁣xa dx])\mathrm{Assuming}(a\gt0, \bigl\lbrack\mathrm{Refine}(\sqrt{a^2}), \int_{0}^{1}\!x^{a}\, \mathrm{d}x\bigr\rbrack)Out[a,1a+1]\bigl\lbrack a, \frac{1}{a+1}\bigr\rbrack
live ↗
InAssuming(x≥0∧y<0,if IsTrue(Refine(x−y>0)) then Refine(x2y2) else 0)\mathrm{Assuming}(x≥0∧y\lt0, \text{if }\mathrm{IsTrue}(\mathrm{Refine}(x-y\gt0))\text{ then }\mathrm{Refine}(\sqrt{x^2y^2})\text{ else }0)Out−(xy)-(xy)
Scope #

Wraps an expression in assumptions and leaves the body as is

live ↗
InAssuming(n∈Z∧p∈P∧n>0,operations)\mathrm{Assuming}(n∈ℤ∧p∈\mathbb{P}∧n\gt0, \mathrm{operations})Outoperations\mathrm{operations}
live ↗
InAssuming(a>0,[∫01 ⁣1x+a dx,FourierTransform(1x2+a,x,w)])\mathrm{Assuming}(a\gt0, \bigl\lbrack\int_{0}^{1}\!\frac{1}{x+a}\, \mathrm{d}x, \mathrm{FourierTransform}(\frac{1}{x^2+a}, x, w)\bigr\rbrack)Out[ln⁡(a+1)−ln⁡(a),FourierTransform(1x2+a,x,w)]\bigl\lbrack\ln(a+1)-\ln(a), \mathrm{FourierTransform}(\frac{1}{x^2+a}, x, w)\bigr\rbrack
Properties #

the assumption on zz is gone as soon as Assuming returns — the second sign⁡(z)\operatorname{sign}(z) stays symbolic

live ↗
In[Assuming(z>0,sgn(z)),sgn(z)]\bigl\lbrack\mathrm{Assuming}(z\gt0, \mathrm{sgn}(z)), \mathrm{sgn}(z)\bigr\rbrackOut[1,sgn(z)]\bigl\lbrack1, \mathrm{sgn}(z)\bigr\rbrack

Nested assumptions let the square root simplify, giving −xy-xy

live ↗
InAssuming(x≥0,Assuming(y<0,Refine(x2y2)))\mathrm{Assuming}(x≥0, \mathrm{Assuming}(y\lt0, \mathrm{Refine}(\sqrt{x^2y^2})))Out−(xy)-(xy)
live ↗
InAssuming(m mod 2=0,Simplify(cos⁡(kπ)m,k∈Z))\mathrm{Assuming}(m\bmod2=0, \mathrm{Simplify}(\cos(kπ)^{m}, k∈ℤ))Out((−1)k)m((-1)^{k})^{m}
About
Examples9
Checked againstWolfram Language 7 agree1 differ1 unevaluated
CrosswalkWolfram Language

Implementation

mappedwolframpackages/oracle/src/mappings.ts

Wolfram's own Assuming only affects functions that consult $Assumptions (Simplify, FullSimplify, Refine) — a bare Abs(x) inside it stays symbolic, unlike compute-engine's own eager assumption-aware evaluate(). Wrapping the body in FullSimplify is what makes the oracle check the same claim we do.