>>14419211Done in Haskell with several caveats:
1) Boilerplate required. Will answer any questions.
2) Uses some things for convenience (like isomorphism between Peano numbers as natural numbers and Integers). Based on Peano numbers but could be Church encoded.
3) Set represented as a list of objects for simplicity (in hindset "Element" would be a better name than "Obj")
4) Utility functions originally created for demonstration purposes, but probably need to be discussed
5) To show the output, had to rely on string conversion, which obviously doesn't fully work for polynomial functions and Rings.
5a) The polynomial function is trivial to create once the set of Reals is defined. It's just the function itself mapped over it's entire domain
5b) The Ring of reals is trickier with a program. IIRC every real can be expressed as a series expansion? If that's the case, this function can be applied for all series. It helps that natural numbers can be expressed by functions and are a subset of the reals as it means we have access to some reals already for use. From what I briefly saw on the Ring aspect, on which I'm not that informed, it's an Abelian group under addition, a monoid under multiplication, and multiplication is distributive. Please correct me if I'm wrong and ask any questions. This was a very quick demo and doesn't show the full scope of the idea.
6) You provided a heterogenous Set, so for quickness I used a technique to create it that limits some functionality. If you need to see more, please advise.
Main points:
1) Natural numbers represented as functions
2) Set of Natural numbers done via functions
3) Generation of your set done via anamorphism (unfold) mapping subset of natural numbers from (2) to a new set
4) customSet is the set requested with the mentioned caveats. Printing customSet yields:
Set [(1,2),(1,3),[],\'lambda x -> x ** 2 - 1'\,\Ring\]