Questions tagged [peano-numbers]

Peano numbers are a simple way of representing the natural numbers using only a zero value and a successor function.

Peano numbers are a simple way of representing the natural numbers using only a zero value and a successor function. In it is easy to create a type of Peano number values, but since unary representation is inefficient, they are more often used to do type arithmetic due to their simplicity.

25 questions
1
vote
1 answer

What is type declaration for in definition of Nat in shapeless?

This is the definition of Nat in package shapeless: trait Nat { type N <: Nat } case class Succ[P <: Nat]() extends Nat { type N = Succ[P] } class _0 extends Nat with Serializable { type N = _0 } What are the type…
mjaskowski
  • 1,479
  • 1
  • 12
  • 16
0
votes
1 answer

How to define induction on natural numbers in Scala 2.13?

Consider the following definition of natural numbers. sealed trait Nat final case object Z extends Nat final case class S[N <: Nat]() extends Nat And the following definition of vectors. sealed trait Vec[N <: Nat, +A] final case object Nil…
Aadit M Shah
  • 72,912
  • 30
  • 168
  • 299
0
votes
0 answers

What code would allow me to implement a cursor within a peano algorithm (using arcpy & Arcgis)

Could someone explain the steps and rationale of this code? (Creating a Peano Curve function within ArcGIS)
0
votes
0 answers

Need help writing the cursor function to implement the peano algorithm within arcpy

I am using the arcpy module for arcGIS to implement a peano curve algorithm and provide each object in the GIS Project with a spatial order value. I have currently defined the Peano curve but need to write cursor functions that will compute and add…
Maggie H
  • 9
  • 2
0
votes
1 answer

Haskell: Exception: stack overflow

I tried to run this code, but it failed with Exception: stack overflow. I tried to increase stack size to its maximum limit, but it didn't help I only understand that this code uses peano arithmetics, and functions represent some basic logical and…
0
votes
1 answer

How can I make this Peano addition algorithm work without using a loop?

Can someone please explain how to do make this work without a loop? let x = prompt("Enter a first number to add:"); let y = prompt("Enter a second number to add:"); parseFloat(x); parseFloat(y); alert(peanoAddition(x, y)); function…
0
votes
0 answers

Addition on Peano numbers at type level

I have defined types for the Peano numbers class Plus (n :: T) (m :: T) (r :: T) | r n -> m instance Plus 'Zero m m instance Plus n m r => Plus ('Succ n) m ('Succ r) Now I find myself having two constraints Plus a b c and Plus c d e. How can I…
marcosh
  • 8,780
  • 5
  • 44
  • 74
0
votes
2 answers

How to test Peano numbers

I'm going through the course Functional Programming Principles in Scala on Coursera. There is an example of implementation of the Peano numbers which goes like this: abstract class Nat { def isZero: Boolean def predecessor: Nat def successor:…
Vít Kotačka
  • 1,472
  • 1
  • 15
  • 40
0
votes
1 answer

Is there an error in this textbook about Peano Arithmetic?

I encountered this doubt in an online intro-logic open course offered by Stanford Uni. Under the section 9.4 of this textbook here: http://logic.stanford.edu/intrologic/secondary/notes/chapter_09.html It says: The axioms shown here define the same…
badbye
  • 299
  • 2
  • 12
-9
votes
3 answers

This Java program converts a natural number into a set-theoretic encoding using iteration. Request help/strategies for a recursive solution?

I'm trying to get a better understanding of ZFC set theory, in particular how a computer program might model the axiom of infinity to "construct" natural numbers. The typical symbols I've seen used to construct the natural numbers are: "{", "}", and…
1
2