forked from singnet/ai-dsl
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTrivialServices.kif
63 lines (52 loc) · 1.9 KB
/
TrivialServices.kif
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
;; SUO-KIF port of trivial services incrementer, twicer and halfer of
;; experimental/registry-dtl.
;;
;; It uses Integer, EvenInteger and operators defined in Merge.kif.
;;
;; TODO: explore how to retrieve functions matching a certain
;; signature and check which compositions are permitted.
;;;;;;;;;;;;;;;;;;;
;; IncrementerFn ;;
;;;;;;;;;;;;;;;;;;;
(instance IncrementerFn UnaryFunction)
(documentation IncrementerFn EnglishLanguage "(&%IncrementerFn ?INTEGER) returns ?INTEGER + 1.")
(domain IncrementerFn 1 Integer)
(range IncrementerFn Integer)
;; IncrementerFn is simply equals to SuccessorFn over the domain of
;; integers.
(forall (?INTEGER)
(=>
(instance ?INTEGER Integer)
(equal (IncrementerFn ?INTEGER) (SuccessorFn ?INTEGER))))
;; Moreover incrementing an even integer returns an odd integer.
(forall (?EVEN_INTEGER)
(=>
(instance ?EVEN_INTEGER EvenInteger)
(instance (IncrementerFn ?EVEN_INTEGER) OddInteger)))
;; Vice versa, incrementing an odd integer returns an even integer.
(forall (?ODD_INTEGER)
(=>
(instance ?ODD_INTEGER OddInteger)
(instance (IncrementerFn ?ODD_INTEGER) EvenInteger)))
;;;;;;;;;;;;;;
;; TwicerFn ;;
;;;;;;;;;;;;;;
(instance TwicerFn UnaryFunction)
(documentation TwicerFn EnglishLanguage "(&%TwicerFn ?INTEGER) returns 2*?INTEGER, an instance of EvenInteger.")
(domain TwicerFn 1 Integer)
(range TwicerFn EvenInteger)
(forall (?INTEGER)
(=>
(instance ?INTEGER Integer)
(equal (TwicerFn ?INTEGER) (MultiplicationFn ?INTEGER 2))))
;;;;;;;;;;;;;;
;; HalferFn ;;
;;;;;;;;;;;;;;
(instance HalferFn UnaryFunction)
(documentation HalferFn EnglishLanguage "(&%HalferFn ?EVEN_INTEGER) returns ?EVEN_INTEGER / 2, given that ?EVEN_INTEGER is an instance of EvenInteger.")
(domain HalferFn 1 EvenInteger)
(range HalferFn Integer)
(forall (?INTEGER)
(=>
(instance ?EVEN_INTEGER EvenInteger)
(equal (HalferFn ?EVEN_INTEGER) (DivisionFn ?EVEN_INTEGER 2))))