Created
October 11, 2017 04:13
-
-
Save suissa/80d11259bde05086c2ed795a276d228f to your computer and use it in GitHub Desktop.
Adição e Produto por axioma de peano
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const sucessor = x => x + 1; | |
const predecessor = x => x - 1; | |
// 1. P(a, 0) = a | |
// 2. P(a,S(b)) = S(P(a, b)) | |
const adicaoPeano = ( a, b ) => | |
( a === 0 ) | |
? b | |
: adicaoPeano( predecessor( a ), sucessor( b ) ); | |
// 1. M(a, 0) = 0 | |
// 2. M(a, S(b)) = P(a, M(a, a)) | |
const produtoPeano = ( a, b ) => | |
( a === 0 ) | |
? 0 | |
: adicaoPeano( b, produtoPeano( predecessor( a ), b ) ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment