I need an expert

I have tried again and again with various snippets and ideas as to how to do this with no avail. I have been told that my programming makes no sense and I must admit, it does not.
I am trying to write a program using the Omniscience Principle and a Generic Convergent Sequence as seen Here

Using This

And This under “topology”

It’s time to bring it to the experts. I’ve done all I can.

A program to do what, exactly? What do you want this program to achieve?

Python seems like the wrong language for this sort of thing (I’d recommend something like Lean instead), but here for example is some Python code that demonstrates the omniscience of the generic convergent sequence. In Lean, you’d be able to do something similar but you’d also be able to produce a formally verified proof that omniscience does what it claims to do, following the proofs in the paper you linked to.

import typing

# We represent elements of N_∞ as functions f : int -> bool, where we only care about
# the values of those functions for nonnegative inputs n, and the functions are
# assumed to satisfy f(n) >= f(n+1) for all n >= 0.
Ninf = typing.Callable[[int], bool]

# Type for maps from Ninf to bool
Ninf_map = typing.Callable[[Ninf], bool]

def inj(k: int) -> Ninf:
    Element of Ninf corresponding to an element k of N.
    return lambda n: n < k

def eps(p : Ninf_map) -> Ninf:
    Selection function for Ninf.
    return lambda n: min(p(inj(k)) for k in range(n + 1))

def omniscience(p : Ninf_map) -> typing.Optional[Ninf]:
    Function demonstrating that Ninf is omniscient.

    Given a function p from Ninf to bool, return either:

    - an element x of Ninf such that p(x) is False, or
    - None, indicating that p(x) is True for all x
    return None if p(x := eps(p)) else x

lol quick question

on the last block of code you have an if statement without a colon. was this intentional?

also how do I call “omniscience()”? what parameters do I use?

See Python 3 Reference: Conditional expressions.


That really depends on what you want to do with it! My original question still stands: what is it that you want this program of yours to do? I can’t really imagine too many practical applications of the main theorem of the paper for a program written in Python. (Don’t get me wrong: it’s a really interesting paper, and I thank you for the link.)

As the type hints suggest, omniscience accepts a function f from Ninf to bool, and returns either an element of Ninf or None, telling you whether f has a root or not (i.e., an input for which the returned value is False rather than True). If f has a root (possibly many roots), omniscience(f) returns one of those roots. If f has no root, it returns None. The truly remarkable part (and the point of the paper) is that this is possible at all - that there’s a decision algorithm to determine whether f has a root. There’s no such decision algorithm if you replace Ninf with the natural numbers, even though Ninf is in some sense larger than the natural numbers, being a copy of the natural numbers plus one extra “point at infinity”.

Here are some examples in Python, using the functions defined in my previous post. First, here’s a function that has a roots at 3 and 5 (really at inj(3) and inj(5)):

def f(x : Ninf) -> bool:
    return x(2) <= x(3) and x(4) <= x(5)

Checking those roots:

>>> f(inj(3))  # 3 is a root
>>> f(inj(5))  # 5 is a root
>>> f(inj(17))  # all other inputs give True - no root
>>> f(inj(0))
>>> f(inj(2))
>>> f(lambda n: True)  # no root at infinity, either

Now because f has roots, omniscience(f) should return one of those roots (in fact, it always returns the first root), and it does: it returns an element of Ninf equivalent to inj(3).

>>> x = omniscience(f)
>>> x(2)
>>> x(3)

In contrast, if f has no roots, omniscience(f) is None:

>>> def f(x: Ninf) -> bool:
...     return True
>>> omniscience(f)
>>> omniscience(f) is None

Note that all our functions need to be pure, total functions: completely deterministic, no dependence on external state, no exceptions, no infinite loops, etc… This is why something like Lean (or Agda, or Coq, or …) is much better suited to this kind of experimentation than Python - these restrictions are built in.


well I was really just trying to retrieve the value of x from outside the function…

You’ve not managed to answer the question of what you want your program to do and your posts are very vague. We had this over on python-forum too. Here’s perhaps another way to try and describe what you want: given/when/then. For example:

Given a list of names
When I sort them
Then the names should be in alphabetical order

Can you perhaps try and express what you’re trying to do like that? It would be much easier for people if they understood what you were trying to do.

I am trying to call omniscience() for the value of x

given the parameters (p : Ninf_map) it should use the same parameters when I call it.

Your posts don’t make any sense. You need to address the fundamental questions that you’ve been asked several times: what is this program for? What is it supposed to do? What is the end result you’re aiming for?

It doesn’t make any sense to try and help you program something if we don’t understand what the something is.

People have tried getting these answers before (e.g. here), to no avail, though.

Further to ND’s comments, you need to give us something like this:

  • my intention is for this program to do …
  • the purpose of this is …
  • when the input is AAAA, then output is BBBB
  • the reason why it is BBBB is because …
  • when the input is CCCC, then output is DDDD.

Otherwise we can’t help you. Its not because we don’t want to help. Its because we don’t understand what you want.

sorry lemme get infinite tries at this…
not being able to fully explain this is part of the problem I am having as well…

im defining the arguments in the parameters
I need those values to stay the same when I call the function

No, you’re missing the point. Stop talking about code. Stick to what Steven is asking of you.

Programs are written to solve a problem, but as of yet, we don’t know what problem you’re trying to solve. Talking about the solution isn’t helping anyone.

“I need those values to stay the same when I call the function”

Here you go:

def function(parameter1, parameter2):

value1 = "hippopotomus"
value2 = "purple"
function(value1, value2)
if value1 == "hippopotomus" and value2 == "purple":
    print("values stayed the same")

That function does exactly what you asked for. Does that help? If not, then you have to tell us what you expect the function to do.

Show us an example of how you would use it, and what happens when you use it. Like this:

If I call the function like this:

function("hippopotomus", "purple")

then the function will return this:

"yellow submarine"

because … (explain what happens and why it happens).

Otherwise we are lost. We cannot read your mind.

Your questions appear to be not only an XY problem, but a recursive one (at times, I wonder if perhaps an infinitely so).

Given that, we need to understand your ultimate objective here (prove a theorem? evaluate a set property? build an omniscient AI?), or this conversation is likely to continue going in circles forever—at least until the finite reserves of time, energy and patience of those volunteering their time to try to help you are exhausted.

Looking back at the long, cyclic history of your many threads on here, Python-List and the freecodecamp forum, maybe the real infinite loop was the discussions you had along the way…


Ive been told before that its the thought that counts…

however I do believe someone should write the omniscient AI before things get out of hand again…

you smoked that cig G.A.F. btw thank you

Problems like:
What is the best medicine
How do I bring people back to life
How can we have freedom for animals
How do we colonize other planets
How can we do quantum Thermodynamics more efficiently
How do we know what’s out there in the metaphysical realms
What is the best music
What are the best graphics
Write _____ program for me
Write a good book
Invent Something
Find the mathematical formula for _____

But most importantly:
How do we logically prove these things are what is said

The limited principle of omniscience (LPO) has nothing to do with someone/something being all-knowing. It’s just another case of mathematicians re-using English words and coming up with a technical definition for them. “Field theory” has nothing to do with a field of grass, and “ring theory” has nothing to do with wedding rings. Sometimes, there’s a nice analogy or inspiration for terminology, and that Wikipedia article has some sort of justification for why the word “omniscience” is used, but it’s not used to mean literally “knowing everything”.

LPO says the equivalent of facts like “it either rains every day, or there’s some day it doesn’t rain”. Most humans and most mathematics would just count this as obvious. It’s only non-obvious when someone decides to do “constructive mathematics” (nothing to do with hammers or nails or hardhats :), in which they only consider a theorem to be proved if they can produce an example. Constructive mathematics is rather strange to work with sometimes, since you can’t assume basic things like “any given proposition is either true or its negation is true”. Constructive reasoning is apparently useful for some theorem-proving systems like Lean or Coq or Agda. By itself though, LPO won’t tell you any information that isn’t already obvious.

One more thing: there are limitations on what a computer can compute, even theoretical super-powerful computers. For example, the Halting problem is uncomputable, so it’s impossible to make a computer that detects whether a given program will finish. So I’m afraid that omniscience in the “knowing/proving literally everything” sense is impossible to achieve.

But at this point we’re rather off-topic for a Python forum.


You seem to have forgotten one:

What is the answer to the ultimate question of life, the universe and everything?

And in that case, it is indeed the (Deep) Thought that counts…

1 Like

Since this is a Python forum, we must of course offer a Python solution. :wink:

The answers to life’s most important questions can always be found either in the Python reference material …

… or in a movie …

Now we’re ready to start coding. First, we bring in the essential modules …

import this

1 Like

And for

there’s always

import antigravity
1 Like

what do I import to call a function if my functions include definitions in their parameters