Add reverse-mode constraint-propagation functions#756
Open
dpsanders wants to merge 4 commits into
Open
Conversation
Move reverse-mode elementary functions, previously in IntervalContractors.jl,
into the core package as `src/intervals/interval_operations/reverse.jl`:
- §10.5.4 reverses: `sqr_rev`, `abs_rev`, `pown_rev`, `sin_rev`, `cos_rev`,
`tan_rev`, `cosh_rev`, `mul_rev`
- Additional reverses: `add_rev`, `sub_rev{1,2}`, `div_rev{1,2}`,
`sqrt_rev`, `cbrt_rev`, `exp{,2,10}_rev`, `expm1_rev`,
`log{,2,10}_rev`, `log1p_rev`, `sinh_rev`, `tanh_rev`,
`asin_rev`, `acos_rev`, `atan_rev`, `asinh_rev`, `acosh_rev`, `atanh_rev`
Decorated `Interval` outputs are forced to `trv` per §11.7.1; NaI inputs
propagate to NaI.
Includes the libieeep1788 ITF1788 reverse test corpus and a `reverse.jl`
unit-test file. Test generator extended with reverse-function dispatch
entries and a `_mul_rev_to_pair` helper for the `mulRevToPair` cases.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Port the additional reverse-mode functions previously living in
IntervalContractors.jl that are not collisions with existing IA APIs:
- `mul_rev_to_pair` — IEEE 1788-2015 §10.5.5 two-output reverse
multiplication, returning the disjoint half-rays when `0 ∈ b`.
Decoration follows §11.7.1: `trv` on a true split, otherwise the
standard division decoration on the first output.
- `inv_rev` — reverse of `inv`; inv is its own inverse.
- `sign_rev` — reverse of `sign`; preimage assembled from which of
`{-1, 0, 1}` lies in the constraint.
- `pow_rev1(b, c)` — reverse of `^` in the base, `c^(1/b) ∩ x`.
- `pow_rev2(a, c)` — reverse of `^` in the exponent,
`(log(c) / log(a)) ∩ x`.
All five functions follow the existing `BareInterval` impl + `Interval`
dispatch via `_rev_dispatch` pattern, with §11.7.1 `trv` decoration on
single-output Interval results. New unit tests in
`test/interval_tests/reverse.jl` cover NaI propagation, decoration,
empty/entire edge cases, and the §10.5.5 split behaviour for
`mul_rev_to_pair`.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…, power_rev, max_rev, min_rev) Port the constraint-propagation-style tuple-rewriting reverses from IntervalContractors.jl. Given a binary forward `a = f(b, c)`, each function returns the triplet `(a, b', c')` where `b' ⊆ b`, `c' ⊆ c` are the tightenings induced by the constraint and `a` is unchanged. Names and arities preserved from IntervalContractors except `mul_rev`, which is renamed `times_rev` because IA already exports a same-arity `mul_rev(b, c, x)` with the IEEE 1788 §10.5.4 single-output semantics. Methods added: - `plus_rev(a, b, c)` — `a = b + c` - `minus_rev(a, b, c)` — `a = b - c` - `minus_rev(a, b)` — `a = -b` - `times_rev(a, b, c)` — `a = b * c` (was `mul_rev` in IC) - `div_rev(a, b, c)` — `a = b / c` - `power_rev(a, b, n::Integer)` — `a = b^n`, integer exponent - `power_rev(a, n::Integer)` — defaults `b = entireinterval()` - `power_rev(a, b, c)` — `a = b^c`, interval exponent - `max_rev(a, b, c)`, `min_rev` — `a = max(b, c)` / `min(b, c)` Implementation notes: - Adds a `_rev_dispatch_tuple` helper bridging `BareInterval` impls to the `Interval` API: NaI propagation across the whole tuple, `trv` decoration on derived outputs (per §11.7.1) while passing through unchanged inputs with their original decorations. - `power_rev` uses IA's existing `rootn`, which already handles negative exponents (`inv(rootn(·, |n|))`) and even-`n` clipping to `[0, ∞)`. - `times_rev` uses `extended_div` + hull when `0 ∈ b` or `0 ∈ c` to deliver a single-interval enclosure of each output. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
Benchmark Results (Julia v1)Time benchmarks
Memory benchmarks
|
4 tasks
Reflects the new reverse-mode constraint-propagation API added in this branch. `IntervalContractors.jl`'s deprecation PR pins `IntervalArithmetic = "1.1"` to ensure callers see the new exports. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds reverse-mode elementary functions for interval constraint propagation, previously living in
IntervalContractors.jl, into the core package. This is the IA half of the planned move; a companionIntervalContractors.jldeprecation PR will follow.Three commits, building cleanly on top of master:
sqr_rev,abs_rev,pown_rev,sin_rev,cos_rev,tan_rev,cosh_rev,mul_rev) plus the standard additional reverses from the constraint-propagation literature (add_rev,sub_rev1/2,div_rev1/2,sqrt_rev,cbrt_rev, theexp{,2,10}/expm1family, thelog{,2,10}/log1pfamily,sinh/tanh/asinh/atanh, andasin/acos/atan). Includes thelibieeep1788_rev.itlandlibieeep1788_mul_rev.itlITF1788 test corpora.mul_rev_to_pair,inv_rev,sign_rev,pow_rev1,pow_rev2.mul_rev_to_pairfollows §11.7.1 decoration (trvon a true split, propagated standard-division decoration otherwise).plus_rev(a, b, c),minus_rev(3-arg + unary),times_rev,div_rev,power_rev(Integer + Interval forms),max_rev,min_rev. These return(a, b', c')withapassed through andb'/c'decoratedtrvper §11.7.1. Note: the IntervalContractors namemul_revis renamed totimes_revhere to avoid colliding with the IEEE 1788 single-outputmul_rev(b, c, x)already added in commit (1).API design:
Intervalmethods accept an optionaldec = :defaultkwarg and forcetrvper §11.7.1.Intervalmethods use a_rev_dispatch_tuplehelper that propagates NaI across the whole tuple and decorates only the derived outputs astrv(input passthroughs keep their original decoration).power_revreuses IA's existingrootn(which already handles even-nclipping and negativenviainv(rootn(·, |n|))).Test plan
test/interval_tests/reverse.jl: 127/127 unit tests covering NaI propagation, decoration, empty/entire edge cases, and the §10.5.5 split behaviour formul_rev_to_pair.test/ITF1788_tests/libieeep1788_rev.jl+libieeep1788_mul_rev.jl: 1123/1127 (4 known-loose@test_broken).ReversePropagation.jlandIntervalConstraintProgramming.jlalready call IA's IEEE 1788 reverses; this PR is what unblocks them.🤖 Generated with Claude Code