PhantomTrace — a mathematical framework where numbers exist in present or absent states with custom operations to include addition, subtraction, multiplication, division, and erasure.
Project description
PhantomTrace
A Python library implementing an experimental mathematical framework where numbers can exist in two states: present or absent. It defines five operations that interact with these states in consistent, rule-based ways.
Zero is redefined: 0 is not emptiness — it's one absence (1(0)). This means every operation has a defined result, including division by zero.
Read the paper: Absence Theory
Installation
pip install phantomtrace
Quick Start
from absence_calculator import AbsentNumber, add, subtract, multiply, divide, erase, format_result
# Create numbers — present (default) or absent
five = AbsentNumber(5) # 5 (present)
three_absent = AbsentNumber(3, 1) # 3(0) (absent)
# Addition — same state combines, mixed state is unresolved
result = add(AbsentNumber(5), AbsentNumber(3))
print(result) # 8
# Subtraction — equal values cancel to void
result = subtract(AbsentNumber(7), AbsentNumber(7))
print(result) # void
# Multiplication — states combine (like XOR)
result = multiply(AbsentNumber(5, 1), AbsentNumber(3))
print(result) # 15(0)
# Erasure — flips the state of the erased portion
result = erase(AbsentNumber(5), AbsentNumber(3))
print(result) # 2 + 3(0)
# Over-erasure — excess becomes erased debt
result = erase(AbsentNumber(7), AbsentNumber(10))
print(result) # 7(0) + erased 3
# Resolve erased excess by adding
from absence_calculator import ErasedExcess
resolved = add(result, AbsentNumber(3))
print(resolved) # 10(0)
# Division by zero — defined! (0 is one absence)
result = divide(AbsentNumber(10), AbsentNumber(1, 1))
print(result) # 10(0)
Using the Expression Solver
from absence_calculator import solve, format_result
# Parse and solve string expressions
print(format_result(solve("5 + 3"))) # 8
print(format_result(solve("5(0) + 3(0)"))) # 8(0)
print(format_result(solve("7 - 7"))) # void
print(format_result(solve("5(0) * 3"))) # 15(0)
print(format_result(solve("5 erased 3"))) # 2 + 3(0)
print(format_result(solve("7 erased 10"))) # 7(0) + erased 3 (over-erasure)
print(format_result(solve("5(0)(0)"))) # 5 (double absence = present)
# Parenthesized expressions (operations on unresolved inputs)
print(format_result(solve("(1 + 5(0)) erased 1"))) # 6(0)
# Zero operations
print(format_result(solve("0 + 0"))) # 2(0) (two absences)
print(format_result(solve("0 * 0"))) # 1 (absence of absence = presence)
print(format_result(solve("10 * 0"))) # 10(0)
print(format_result(solve("10 / 0"))) # 10(0)
Interactive Calculator
After installing, you can run the interactive calculator from the command line:
phantomtrace
Or as a Python module:
python -m absence_calculator
This gives you a calc >> prompt where you can type expressions and see results.
Core Concepts
Objects and States
An object is a number that has both a value and a state:
- Present (default): Written normally, e.g.
5. Present quantities reflect the presence of a given unit of interest. (e.g. if the unit is a cat, then 5 represents 5 cats that are there or in a present state) - Absent: Written with
(0), e.g.5(0)— think of it as5 * 0. Absent quantities reflect the absence of a given unit of interest. (e.g. if the unit is a phone, then 5(0) represents 5 phones that are not currently there but are still considered for computation)
Absence
- Zero:
0is not emptiness, it's one absence (1(0) = 1 * 0 = 0) - Absence of absence returns to present:
5(0)(0) = 5, and0(0) = 1
Operations
| Operation | Symbol | Rule |
|---|---|---|
| Addition | + |
Expands the amount of objects under consideration. Same state: magnitudes combine. Mixed: unresolved |
| Subtraction | - |
Contracts the amount of objects under consideration. (If the domain of consideration is constricted to nothing then the result is void. Void is not an object, nor the new zero, it simply means we are not considering anything on which to act.) Same state: magnitudes reduce. Mixed: unresolved |
| Multiplication | * |
Magnitudes multiply. States combine (presentpresent=present, absentpresent=absent, absent*absent=present) |
| Division | / |
Magnitudes divide. States combine same as multiplication. Division by 0 is defined! |
| Erasure | erased |
Same state required. Remainder keeps state, erased portion flips state. Over-erasure creates erased excess |
Over-Erasure (v0.2.0)
When you erase more than the total, the result carries an erased excess (erasure debt):
7 erased 10=7(0) + erased 3— all 7 flip state, 3 excess erasure persists- Adding resolves excess:
(7(0) + erased 3) + 3=10(0) - Erasing erased:
(erased 3) erased (erased 3)=erased 3(0)(absence of erased)
Compound Expressions (v0.2.0)
Operations can now accept unresolved expressions as inputs:
(1 + 5(0)) erased 1=6(0)— erases the present part, combining with the absent part
Result Types
- AbsentNumber: A number with a state (present or absent)
- Void: Complete cancellation — not zero, but the absence of any quantity under consideration
- ErasureResult: Two parts — remainder (keeps state) and erased portion (flipped state)
- ErasedExcess: Excess erasure debt that persists until resolved
- Unresolved: An expression that cannot be simplified (e.g., adding present + absent)
Toggle Module (v0.2.0)
The toggle module applies erasure logic to vectors using pattern-based index selection.
from absence_calculator import toggle
vector = [4, 7, 19, 22, 26]
# toggle.ys(pattern, range, vector)
# Pattern determines which indices to toggle
# Range is (start, end) inclusive — inputs to the pattern function
result = toggle.ys("x^2", (1, 4), vector)
# i=1: 1^2=1, toggle index 1 (7 -> 7(0))
# i=2: 2^2=4, toggle index 4 (26 -> 26(0))
# i=3: 3^2=9, out of bounds, skip
# i=4: 4^2=16, out of bounds, skip
print(result) # [4, 7(0), 19, 22, 26(0)]
# Also accepts lambda functions as patterns
result = toggle.ys(lambda x: x * 2, (0, 2), [10, 20, 30, 40, 50])
print(result) # [10(0), 20, 30(0), 40, 50(0)]
# toggle.nt — flips everything EXCEPT the targeted indices (inverse of ys)
result = toggle.nt(lambda x: x * 2, (0, 2), [10, 20, 30, 40, 50])
print(result) # [10, 20(0), 30, 40(0), 50]
API Reference
Types
AbsentNumber(value, absence_level=0)— A number with a state.absence_level0 = present, 1 = absentVoid/VOID— Represents complete cancellationErasureResult(remainder, erased)— Result of an erasure operationErasedExcess(value, absence_level=0)— Excess erasure debt from over-erasureUnresolved(left, op, right)— An expression that can't be simplified
Functions
add(x, y)— Add two values (supports compound inputs with excess resolution)subtract(x, y)— Subtract two AbsentNumbersmultiply(x, y)— Multiply two AbsentNumbersdivide(x, y)— Divide two AbsentNumberserase(x, y)— Erase y from x (supports over-erasure and compound inputs)solve(expr_string)— Parse and evaluate a string expression (supports parentheses)format_result(result)— Convert any result to a readable stringparse_number(s)— Parse a string like"5(0)"into an AbsentNumber
Toggle
toggle.ys(pattern, range, vector)— Toggle vector elements at pattern-computed indicestoggle.nt(pattern, range, vector)— Toggle all elements NOT at pattern-computed indices (inverse of ys)
Constants
ALL_OPERATIONS— Dictionary describing all operations with rules and examples
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file phantomtrace-0.2.0.tar.gz.
File metadata
- Download URL: phantomtrace-0.2.0.tar.gz
- Upload date:
- Size: 10.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
28d5e2f58f5e3eb8baa9ccba9dbd8f23a9bbcda053bc5b18afadd14577359bb5
|
|
| MD5 |
2ce8719368a443801446449f6f01332f
|
|
| BLAKE2b-256 |
c256a4436671a6f74fe039c440c1d4415146ce09cb1007647af5e2e790dd9fc9
|
File details
Details for the file phantomtrace-0.2.0-py3-none-any.whl.
File metadata
- Download URL: phantomtrace-0.2.0-py3-none-any.whl
- Upload date:
- Size: 11.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5b8493ee0c752c1c8465131070b3a1cef3ed5199dc26651bd5024f70d6917685
|
|
| MD5 |
c6151f40ac7a0bc65341d3668d51081c
|
|
| BLAKE2b-256 |
a334f5999bee6d2ead68e6bc3d5bad9a2a68bb239361876b17b6c1182b184292
|