ajcr / transfinite Goto Github PK
View Code? Open in Web Editor NEWTransfinite ordinal arithmetic and factorisation up to epsilon-zero
License: MIT License
Transfinite ordinal arithmetic and factorisation up to epsilon-zero
License: MIT License
There are numerous test cases in this repo, but it is possible that some edge cases have been missed for ordinal comparison and ordinal arithmetic/factorisation.
Using hypothesis could be a way to generate better test-cases and find any missing cases.
a**(x + y + z) == a**x * a**y * a**z
.b * a
should be w**w**w*3+w**w+w**9*2
(new code is correct)
The __{eq,lt,add,mul,pow}__
, methods are short but not necessarily easy to read: https://github.com/ajcr/transfinite/blob/master/transfinite/ordinal.py#L127-L216
It would be nice to get rid of try
/except
blocks and add comments to make the logic clearer.
3*(w2+4) = w6+16 by the distributive law for ordinals, but output is \omega\cdot2 + 4
For example:
>>> a = w1**2 * w
>>> b = w1**2
>>> a < b
AttributeError: 'int' object has no attribute 'terms'
>>> 2**(w**2 + w)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-50-c210e4a385bb> in <module>
----> 1 2**(w**2 + w)
~/projects/transfinite/transfinite/ordinal.py in __rpow__(self, other)
210 if is_finite_ordinal(self.exponent):
211 return Ordinal(
--> 212 Ordinal((self.exponent - 1) * self.coefficient, other ** self.addend)
213 )
214 # n**w**a == w**w**a for all 1 < n < w and a >= w
~/projects/transfinite/transfinite/ordinal.py in __init__(self, exponent, coefficient, addend)
31
32 if not isinstance(coefficient, int):
---> 33 raise TypeError("coefficient must be an integer greater than 0")
34
35 if coefficient < 1:
TypeError: coefficient must be an integer greater than 0
Should return w**(w + 1)
.
Also 2**(w**2 + 3)
gives w**(w*8)
but should give w**w * 8
.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.