| 1 |
# ---------------- |
| 2 |
# Peano arithmetic |
| 3 |
# ---------------- |
| 4 |
# |
| 5 |
# See https://en.wikipedia.org/wiki/Peano_axioms |
| 6 |
|
| 7 |
@prefix log: <http://www.w3.org/2000/10/swap/log#>. |
| 8 |
@prefix : <urn:example:>. |
| 9 |
|
| 10 |
# declare components |
| 11 |
:add a log:Component. |
| 12 |
:multiply a log:Component. |
| 13 |
:factorial a log:Component. |
| 14 |
:fac a log:Component. |
| 15 |
|
| 16 |
# add |
| 17 |
(_:A) log:onNegativeSurface { |
| 18 |
() log:onNegativeSurface { |
| 19 |
(_:A 0) :add _:A. |
| 20 |
}. |
| 21 |
}. |
| 22 |
|
| 23 |
(_:A _:B _:C) log:onNegativeSurface { |
| 24 |
() log:onNegativeSurface { |
| 25 |
(_:A (:s _:B)) :add (:s _:C). |
| 26 |
}. |
| 27 |
(_:A _:B) :add _:C. |
| 28 |
}. |
| 29 |
|
| 30 |
# multiply |
| 31 |
(_:A) log:onNegativeSurface { |
| 32 |
() log:onNegativeSurface { |
| 33 |
(_:A 0) :multiply 0. |
| 34 |
}. |
| 35 |
}. |
| 36 |
|
| 37 |
(_:A _:B _:C _:D) log:onNegativeSurface { |
| 38 |
() log:onNegativeSurface { |
| 39 |
(_:A (:s _:B)) :multiply _:C. |
| 40 |
}. |
| 41 |
(_:A _:B) :multiply _:D. |
| 42 |
(_:A _:D) :add _:C. |
| 43 |
}. |
| 44 |
|
| 45 |
# factorial |
| 46 |
(_:A _:B) log:onNegativeSurface { |
| 47 |
() log:onNegativeSurface { |
| 48 |
_:A :factorial _:B. |
| 49 |
}. |
| 50 |
(_:A (:s 0)) :fac _:B. |
| 51 |
}. |
| 52 |
|
| 53 |
(_:A) log:onNegativeSurface { |
| 54 |
() log:onNegativeSurface { |
| 55 |
(0 _:A) :fac _:A. |
| 56 |
}. |
| 57 |
}. |
| 58 |
|
| 59 |
(_:A _:B _:C _:D) log:onNegativeSurface { |
| 60 |
() log:onNegativeSurface { |
| 61 |
((:s _:A) _:B) :fac _:C. |
| 62 |
}. |
| 63 |
(_:B (:s _:A)) :multiply _:D. |
| 64 |
(_:A _:D) :fac _:C. |
| 65 |
}. |
| 66 |
|
| 67 |
# question |
| 68 |
(_:A _:B _:C) log:onNegativeSurface { |
| 69 |
((:s 0) (:s (:s 0))) :add _:A. |
| 70 |
(_:A (:s (:s 0))) :multiply _:B. |
| 71 |
_:B :factorial _:C. |
| 72 |
() log:onNegativeAnswerSurface { |
| 73 |
((:s 0) (:s (:s 0))) :add _:A. |
| 74 |
(_:A (:s (:s 0))) :multiply _:B. |
| 75 |
_:B :factorial _:C. |
| 76 |
}. |
| 77 |
}. |