Lazy Eval and Parallel Processing in Python!

You can’t count till infinity, but you can see every number at once! (With proper focus)

I’m trying to make an infinite set to evaluate its contents all at once, selectively adhere to values, and reference the last index at infinity

I also want to index some of these values with others, so I can work with context


Q = set()
N = []
while True:
 Q = set(Q)
 N.append(Q)
v = i = k = n = any(N)
N_inf = N[-1]
v.append(i)
k.append(n)

I need this entire thing re-written to make use of parallel processing as it is a lazy evaluator.

Remember the patterns can still be there, even with time and space removed

“I’m trying to make an infinite set to evaluate its contents all at once, selectively adhere to values, and reference the last index at infinity”

Good luck with that.

You can’t evaluate an infinite set all at once, because it’s infinite and the universe is only finite.

There are definitely mathematics you can perform on “infinite sets”
though you’re not going to use a Python stdlib set to accomplish
those. Likely you’ll need to work out which properties of your
“infinite set” are relevant to the operations you’ll be performing,
and model a custom Python data structure (perhaps an object Class)
to have variables (e.g. class attributes) which represent those
properties.

I need to focus on N all at once, no trying to count to it, no trying to focus on every individual part of it.

I think you need to clarify your objective. What do you need to do with this set? What do you mean by “focusing” on this set?

Other things I don’t understand, could you explain what you mean more precisely with:

  • “adhere to values”?
  • “the patterns can still be there, even with time and space removed”?

Personally, I feel we luck enough context about what you’re trying to do in order to offer a proper alternative.
I don’t know what you mean by “evaluating it’s contents at once”. I might not have a PhD in Mathematics as yet, but I certainly feel it’s highly impossible. What’s possible however is to evaluate the properties of an infinite set based on its elements, but not each individual element of that set. I don’t know if I’m making sense.
Also, I think you’ll have to redefine your definition of infinite. Like @steven.daprano said, the universe is finite, and so is the memory on your PC. It just might be really really really huge, but not endless.
Lastly, if you consider your task computation intensive, I suggest you look into Python libraries targeted towards scientific calculations and computations, or you code use some C code for this.

You seem to be making some of the same mistakes as your previous post

Namely, the line Q = set(Q) doesn’t do anything. Python sets can’t be put into each other because they are mutable and therefore non-hashable. Perhaps you mean to use frozensets.

>>> ZERO = frozenset()
>>> Q = ZERO
>>> L = [ZERO]
>>> for i in range(5):
...     Q = frozenset({Q})
...     L.append(Q)
... 
...     
>>> L
[frozenset(), frozenset({frozenset()}), frozenset({frozenset({frozenset()})}), frozenset({frozenset({frozenset({frozenset()})})}), frozenset({frozenset({frozenset({frozenset({frozenset()})})})}), frozenset({frozenset({frozenset({frozenset({frozenset({frozenset()})})})})})]

I meant I need to have the program act “as if” it contained infinity

I feel like people are having a hard time reading my OP, as I have already explained why latter posts are invalid m

“I meant I need to have the program act “as if” it contained infinity”

What does that mean?

If you can’t explain what you are trying to do, we can’t help you.

I suggest you watch this video:

and then explain precisely what you are trying to do.

3 Likes

I want to retrieve the parameter of a function directly and in full

That, and a peanut butter and jelly sandwich

import inspect

def directly_and_in_full(the):
    ...

inspect.signature(directly_and_in_full).parameters["the"]
2 Likes

Is there any way to do this without importing other libraries?

Importing other libraries is the right way to do it. The inspect module is part of the std lib, it is guaranteed to be available.

The inspect module is the right tool for the job. If you asked a carpenter how to cut a piece of wood, and they said “use a saw”, would you say “I don’t want to use a saw. Can I use a screwdriver or a hammer instead?”

Just use the damn saw wink

But if you prefer, you can open the inspect.py file in your text editor, Select All, then Copy, then go into your file, and Paste. Then repeat for any imports which the inspect module uses.

Now you have duplicated all the code in inspect, so you can use it without an import. Your script is now 200 times bigger than it needs be, all to save a one line import. Yay!!!

2 Likes

I think people get confused because infinity is not a number. We’ll it’s not so stop trying to treat it like one. You don’t need to iterate up to infinity. Infinity is good on its own.
(Not saying regular numbers don’t need iteration, just saying that infinity has its own algorithm that makes it accessible; it’s not just a very large number)
Think mathematically. To draw an infinite line all you need is y=x, boom! Infinite line. On the other hand if you try to draw a very large line that’s not infinite, you need to have the calculator stop at some inconvenient location.
In the end, iteration is a limitation. Without the need for limitation, there is no need for iteration.

I am not confused by infinity. I am confused by your objective. I have no idea what you mean by “can see every number at once! (With proper focus)”, nor what problem you are trying to solve and asking about. Speaking as a math student, the best way to make yourself understood when your intuitions are not clear to everyone (and I don’t think they are clear to anyone here) is to use a formal language with technical and well-defined terms. Otherwise, it is impossible to read your mind.

1 Like

If I knew the technical terms already I wouldn’t be asking this question :slight_smile:

Well, you might not know the most accurate terms, but you can try to explain what you mean with the words you use (‘adhere’, for example).

One thing that would also help is a bit of context. Are you a student solving assignments? Are you writing a module to do formal math? What is the background of your question?

2 Likes

Just to give you some background info:

I am in the middle of making an ASI to make the best possible output under any conditions.

Part of this requires a hierarchy of presence, aka set interpolation
Here

This can be done with Von Neumann natural numbers (set(), set(set()), set(set(set())) ect)

What is an ASI? I am too lazy to read all of ASI - Definition by AcronymFinder :slight_smile:

If the goal is to produce von Neumann numbers, does Dennis’ code not suffice? Namely, put in a function,

def number(n):
    result = frozenset()
    for i in range(n):
        result = frozenset({result})
    return result

By the way, you’re using an altered definition of von Neumann numbers, which are usually S(n) = n ∪ {n} rather than S(n) = {n} (I’m not sure why this is more usual, maybe it’s easier to work with in some respects?).