Next: The Uncertainty Translator Up: Uncertainty-Valued Horn Clauses Previous: References

# An Application of Uncertainty in RELFUN

```
rfi-l> style lisp
rfi-l> inter
rfi-l> destroy
rfi-l>
rfi-l> ;**************************************************************
rfi-l> ;With this translator a new structure is defined. It is called
rfi-l> ;uncertainty structure: (uc (c...) (ucfb1...) ... (ucfbM ...)
rfi-l> ;                                                     UC-FACTOR)
rfi-l> ;The premises are functional and their return value represents
rfi-l> ;an uncertainty factor in [0 .. 1] ((ucfb1) .. (ucfbM)).
rfi-l> ;The function uncertain translates all uncertainty clauses of
rfi-l> ;the relfun database *rfi-database* into footed clauses whose
rfi-l> ;return values are the uc factors calculated with a combination
rfi-l> ;rule applied to  the uc factors of the rules and of the premises.
rfi-l> ;All other structures (hornish  and footed clauses) remain
rfi-l> ;unmodified.
rfi-l> ;
rfi-l> ;***************FACTS******************************************
rfi-l> ;
rfi-l> ;***************************************************************
rfi-l> ;                     /      \
rfi-l> ;                    /        \
rfi-l> ;                 storm       cold
rfi-l> ;                 /  \        /  \
rfi-l> ;                /    \      /    \
rfi-l> ;             rain   windy snow  no_sun
rfi-l> ;***************************************************************
rfi-l>
rfi-l> ;Nothing happens with hornish and footed clauses!
rfi-l>
rfi-l> ;hn facts
rfi-l> az (hn (snow 12.10.92))
rfi-l> az (hn (snow 12.24.92))
rfi-l> az (hn (no_sun 10.10.92))
rfi-l>
rfi-l> ;ft facts
rfi-l> az (ft (no_sun 6.10.92) 0.4)
rfi-l> az (ft (rain 6.10.92) 0)
rfi-l> az (ft (rain 10.10.92) 0.5) ;could mean half day rain
rfi-l>
rfi-l> uncertain min
rfi-l> l
(hn (snow 12.10.92))
(hn (snow 12.24.92))
(hn (no_sun 10.10.92))
(ft (no_sun 6.10.92)
0.4 )
(ft (rain 6.10.92)
0 )
(ft (rain 10.10.92)
0.5 )
rfi-l> ;PROLOG Style analog
rfi-l> (pause)

rfi-l> bye
true
rfi-l>
rfi-l> ;uc facts
rfi-l>
rfi-l> az (uc (rain 11.11.92) 0.13)  ; 3 hours rain on 11. nov 1992
rfi-l>
rfi-l>
rfi-l> ;Translate uncertain clauses into footed clauses with the given
rfi-l> ;uc factor as return value.
rfi-l> ;Since this is a fact and no premises are given, the uc factor
rfi-l> ;needs no calculation and stays unchanged.
rfi-l>
rfi-l> uncertain min
rfi-l> l rain
(ft (rain 6.10.92)
0 )
(ft (rain 10.10.92)
0.5 )
(ft (rain 11.11.92)
0.13 )
rfi-l> (pause)

rfi-l> bye
true
rfi-l>
rfi-l> ;PROLOG Style
rfi-l> sp
rfi-p> l rain
rain(6.10.92) :-& 0.
rain(10.10.92) :-& 0.5.
rain(11.11.92) :-& 0.13.
rfi-p> pause()

rfi-p> bye
true
rfi-p> sl
rfi-l> ;**************RULES*******************************************
rfi-l> ;nothing happens with hornish  and footed rules
rfi-l>
rfi-l> ;hn rules
rfi-l> az (hn (cold _x) (snow _x))
rfi-l> az (hn (storm _x) (rain _x) (< (windforce _x) 6))
rfi-l>
rfi-l> ;ft rules
rfi-l> az (ft (storm _x) (windy _x) (/ (windforce _x) 12))
rfi-l> az (ft (storm _x) (rain _x) (< (windforce _x) 6))
rfi-l>
rfi-l> uncertain *
rfi-l>
rfi-l>
rfi-l> l cold
(hn (cold _x)
(snow _x) )
rfi-l>
rfi-l>
rfi-l> l storm
(hn (storm _x)
(rain _x)
(< (windforce _x) 6) )
(ft (storm _x)
(windy _x)
(/ (windforce _x) 12) )
(ft (storm _x)
(rain _x)
(< (windforce _x) 6) )
rfi-l> ;PROLOG Style analog
rfi-l> (pause)

rfi-l> bye
true
rfi-l>
rfi-l>
rfi-l> ;uc rules
rfi-l> az (uc (cold _x) (no_sun _x) 0.3)
rfi-l> az (uc (bad_weather _x) (storm _x) 0.65)
rfi-l> az (uc (bad_weather _x) (cold _x) 0.25)
rfi-l>
rfi-l>
rfi-l> ;PROLOG Style
rfi-l> sp
rfi-p> pause()

rfi-p> bye
true
rfi-p>
rfi-p> sl
rfi-l> ;Translate uc clauses into footed clauses with a given uc factor
rfi-l> ;and combination rule.
rfi-l> uncertain *
rfi-l>
rfi-l>
(* (storm _x) 0.65) )
(* (cold _x) 0.25) )
rfi-l>
rfi-l>
rfi-l> (pause)

rfi-l> bye
true
rfi-l>
rfi-l>
rfi-l> ;PROLOG Style
rfi-l> sp
rfi-p> pause()

rfi-p> bye
true
rfi-p>
rfi-p> sl
rfi-l> ;*****************************************************************
rfi-l> ;Becauce every premise has to return a uc value, the hornish
rfi-l> ;clauses have to be translated into footed clauses.
rfi-l> ;We declare all hn clauses as certain (uc factor = 1)
rfi-l>
rfi-l> footer 1
rfi-l> ;**************************QUERY***********************************
rfi-l> (pause)

rfi-l> bye
true
rfi-l>
rfi-l>
rfi-l> (snow _x)
1
(_x = 12.10.92)
rfi-l> m
1
(_x = 12.24.92)
rfi-l>
rfi-l> m
unknown
rfi-l>
rfi-l> ;same query with tupof
rfi-l> (tupof (is _uc (snow _x)) `(tup _x _uc))
`(tup (tup 12.10.92 1) (tup 12.24.92 1))
rfi-l> (pause)

rfi-l> bye
true
rfi-l>
rfi-l> (tupof (is _uc (no_sun _x)) `(tup _x _uc))
`(tup (tup 10.10.92 1) (tup 6.10.92 0.4))
rfi-l>
rfi-l>
rfi-l>
rfi-l> l cold
(ft (cold _x)
(snow _x)
1 )
(ft (cold _x)
(* (no_sun _x) 0.3) )
rfi-l>
rfi-l>
rfi-l>
rfi-l> (tupof (is _uc (cold _x)) `(tup _x _uc))
`(tup (tup 12.10.92 1) (tup 12.24.92 1) (tup 10.10.92 0.3) (tup 6.10.92 0.12))
rfi-l>
rfi-l>
rfi-l>
rfi-l> (pause)

rfi-l> bye
true
rfi-l>
rfi-l>
rfi-l> ;*************************************************************
rfi-l> ;*************************************************************
rfi-l> ;
rfi-l> ;In German law the pet owner is not always  responsible
rfi-l> ;for the damage caused by his pet. Responsible can be the owner,
rfi-l> ;the horseman, the buyer ...
rfi-l> ;So the judge has to decide who is the `pet holder`. The pet
rfi-l> ;holder is described by a few attributes.
rfi-l> ;
rfi-l> ;                           pet holder
rfi-l> ;                          /    E     \
rfi-l> ;                         /            \
rfi-l> ;                        /              \
rfi-l> ;                       /                \
rfi-l> ;                   interest              master
rfi-l> ;                    / C  \              /  D   \
rfi-l> ;                   /      \            /        \
rfi-l> ;            immediate  non straight  possession  authority
rfi-l> ;             interest    interest
rfi-l> ;            /   A  \     /  B  \
rfi-l> ;           /        |   |       \
rfi-l> ;          /         |   |        \
rfi-l> ;    costs of|advantage| profit | loss
rfi-l> ; maintenance| of use  | chances| chances
rfi-l> ;     -1-       -2-      -3-       -4-   -5-     -6-
rfi-l> ;
rfi-l> ;This attributs are measured in terms like:
rfi-l> ;
rfi-l> ; -1- shelter, food, nurture, doctor etc.
rfi-l> ; -2- receipts of work, hiring etc.
rfi-l> ; -3- costs of procuring
rfi-l> ; -4- initial costs, costs of education etc.
rfi-l> ; -5- actual power, use, shelter, nuture in the own household or
rfi-l> ;     farm...
rfi-l> ; -6- decision about the existance of the pet (life and use )
rfi-l> ;
rfi-l> ;From experience it is known that the combination rules in this
rfi-l> ;example differ:
rfi-l> ; A : max                    `normal or`
rfi-l> ; B : square root            `and with compensation`
rfi-l> ; C : cubical root with 1:2  `or with compensation 1:2`
rfi-l> ; D :  max                   `normal or`
rfi-l> ; E : cubical root with 2:1  `or with compensation 2:1`
rfi-l> ;
rfi-l> ;
rfi-l> ;For more details see Jan Heithecker in KI 3/1993.
rfi-l> ;*****************************************************************
rfi-l> ;*****************************************************************
rfi-l> (pause)

rfi-l> bye
true
rfi-l> destroy
rfi-l>
rfi-l> az (uc (pet_hol _x) (int _x) (res _x) 1)
rfi-l>
rfi-l> ;combination rule `cubical root with 2:1`
rfi-l> azft (cubroot2 _x _y 1) (expt (* _x _x _y) 1/3)
rfi-l>
rfi-l> uncertain cubroot2
rfi-l>
rfi-l> l
(ft (pet_hol _x)
(cubroot2 (int _x) (res _x) 1) )
(ft (cubroot2 _x _y 1)
(expt (* _x _x _y) 1/3) )
rfi-l>
rfi-l> (pause)

rfi-l> bye
true
rfi-l>
rfi-l> ;PROLOG style
rfi-l> sp
rfi-p> l
pet_hol(X) :-& cubroot2(int(X), res(X), 1).
cubroot2(X, Y, 1) :-& expt(*(X, X, Y), 1/3).
rfi-p> pause()

rfi-p> bye
true
rfi-p> sl
rfi-l>
rfi-l> az (uc (int _x) (im_int _x) (ns_int _x) 1)
rfi-l>
rfi-l> ;combination rule `cubical root with 1:2`
rfi-l> azft (cubroot1 _x _y 1) (expt (* _x _y _y) 1/3)
rfi-l>
rfi-l> uncertain cubroot1
rfi-l>
rfi-l> l int
(ft (int _x)
(cubroot1 (im_int _x) (ns_int _x) 1) )
rfi-l>
rfi-l> (pause)

rfi-l> bye
true
rfi-l>
rfi-l> ;PROLOG style
rfi-l> sp
rfi-p> l int
int(X) :-& cubroot1(im_int(X), ns_int(X), 1).
rfi-p> pause()

rfi-p> bye
true
rfi-p> sl
rfi-l>
rfi-l>
rfi-l>
rfi-l> az (uc (ns_int _x) (prof _x ) (loss _x ) 1)
rfi-l>
rfi-l> ; square root
rfi-l> azft (sq _x _y 1) (sqrt (* _x _y))
rfi-l>
rfi-l> uncertain sq
rfi-l>
rfi-l> l ns_int
(ft (ns_int _x)
(sq (prof _x) (loss _x) 1) )
rfi-l>
rfi-l> (pause)

rfi-l> bye
true
rfi-l>
rfi-l> ;PROLOG style
rfi-l> sp
rfi-p> l ns_int
ns_int(X) :-& sq(prof(X), loss(X), 1).
rfi-p> pause()

rfi-p> bye
true
rfi-p> sl
rfi-l>
rfi-l>
rfi-l> az (uc (im_int _x) (cos_main _x) (use_adv _x) 0)
rfi-l> az (uc (res _x) (poss _x) (auth _x) 0)
rfi-l>
rfi-l> uncertain max
rfi-l>
rfi-l> l im_int
(ft (im_int _x)
(max (cos_main _x) (use_adv _x) 0) )
rfi-l> l res
(ft (res _x)
(max (poss _x) (auth _x) 0) )
rfi-l>
rfi-l> (pause)

rfi-l> bye
true
rfi-l>
rfi-l> ;PROLOG style
rfi-l> sp
rfi-p> l im_int
rfi-p> l res
res(X) :-& max(poss(X), auth(X), 0).
rfi-p> pause()

rfi-p> bye
true
rfi-p> sl
rfi-l>
rfi-l> ;*****************************************************************
rfi-l> ;*****************************************************************
rfi-l> ;These attributes are given in natural language. So they have to
rfi-l> ;be translated into numerical values.
rfi-l> ;*****************************************************************
rfi-l> ;*****************************************************************
rfi-l>
rfi-l> az (uc (nl null) 0.01)
rfi-l> az (uc (nl very_few) 0.1)
rfi-l> az (uc (nl few) 0.25)
rfi-l> az (uc (nl medium) 0.5)
rfi-l> az (uc (nl high) 0.75)
rfi-l> az (uc (nl very_high) 0.9)
rfi-l> az (uc (nl total) 1)
rfi-l>
rfi-l> az (ft (cos_main john) (nl very_few))
rfi-l> az (ft (use_adv  john) (nl  few))
rfi-l> az (ft (prof     john) (nl few))
rfi-l> az (ft (loss     john) (nl null))
rfi-l> az (ft (poss     john)  (nl total))
rfi-l> az (ft (auth     john) (nl medium))
rfi-l>
rfi-l> az (ft (cos_main mary)(nl total))
rfi-l> az (ft (use_adv  mary)(nl null))
rfi-l> az (ft (prof     mary) (nl few))
rfi-l> az (ft (loss     mary) (nl high))
rfi-l> az (ft (poss     mary) (nl null))
rfi-l> az (ft (auth     mary) (nl high))
rfi-l>
rfi-l> az (ft (cos_main bob) (nl total))
rfi-l> az (ft (use_adv  bob) (nl few))
rfi-l> az (ft (prof     bob) (nl total))
rfi-l> az (ft (loss     bob) (nl total))
rfi-l> az (ft (poss     bob) (nl null))
rfi-l> az (ft (auth     bob) (nl high))
rfi-l>
rfi-l> ;Translate hornish facts into certain footed facts (certain =1)
rfi-l> footer 1
rfi-l>
rfi-l> ;Translate uncertain facts into footed facts with a given
rfi-l> ;uc factor. The rule given to uncertain is at this point of
rfi-l> ;no importance, because facts only change their tags.
rfi-l>
rfi-l> uncertain *
rfi-l> (pause)

rfi-l> bye
true
rfi-l>
rfi-l> l
(ft (pet_hol _x)
(cubroot2 (int _x) (res _x) 1) )
(ft (cubroot2 _x _y 1)
(expt (* _x _x _y) 1/3) )
(ft (int _x)
(cubroot1 (im_int _x) (ns_int _x) 1) )
(ft (cubroot1 _x _y 1)
(expt (* _x _y _y) 1/3) )
(ft (ns_int _x)
(sq (prof _x) (loss _x) 1) )
(ft (sq _x _y 1)
(sqrt (* _x _y)) )
(ft (im_int _x)
(max (cos_main _x) (use_adv _x) 0) )
(ft (res _x)
(max (poss _x) (auth _x) 0) )
(ft (nl null)
0.01 )
(ft (nl very_few)
0.1 )
(ft (nl few)
0.25 )
(ft (nl medium)
0.5 )
(ft (nl high)
0.75 )
(ft (nl very_high)
0.9 )
(ft (nl total)
1 )
(ft (cos_main john)
(nl very_few) )
(nl few) )
(ft (prof john)
(nl few) )
(ft (loss john)
(nl null) )
(ft (poss john)
(nl total) )
(ft (auth john)
(nl medium) )
(ft (cos_main mary)
(nl total) )
(nl null) )
(ft (prof mary)
(nl few) )
(ft (loss mary)
(nl high) )
(ft (poss mary)
(nl null) )
(ft (auth mary)
(nl high) )
(ft (cos_main bob)
(nl total) )
(nl few) )
(ft (prof bob)
(nl total) )
(ft (loss bob)
(nl total) )
(ft (poss bob)
(nl null) )
(ft (auth bob)
(nl high) )
rfi-l> ;PROLOG style analog
rfi-l> (pause)

rfi-l> bye
true
rfi-l>
rfi-l>
rfi-l>
rfi-l> ;The query for `Is john a pet holder`
rfi-l> (pet_hol john)
0.19407667236782145
rfi-l>
rfi-l>
rfi-l> (pause)

rfi-l> bye
true
rfi-l>
rfi-l> ;The query for all pet holders
rfi-l> (pet_hol _x)
0.19407667236782145
(_x = john)
rfi-l>
rfi-l> m
0.6263231749593858
(_x = mary)
rfi-l>
0.9085602964160698
(_x = bob)
rfi-l> m
unknown
rfi-l>
rfi-l> (pause)

rfi-l> bye
true
rfi-l>
rfi-l>
rfi-l>
rfi-l> ;******************APPLICATIONS********************************
rfi-l>
rfi-l> ;*****************  >  ****************************************
rfi-l>
rfi-l> ;Now we can make a useful definition of pet holder, if the
rfi-l> ;uc factor of pet_hol is greater or equal to 0.5
rfi-l> (>= (pet_hol _x) 0.5)
false
(_x = john)
rfi-l>
rfi-l> m
true
(_x = mary)
rfi-l>
rfi-l> m
true
(_x = bob)
rfi-l>
rfi-l>
rfi-l> ;Enumerate all pet holders
rfi-l>  (tupof (>=  (pet_hol _x)  0.5) _x)
`(tup mary bob)
rfi-l>
unknown
rfi-l> ;Enumerate all pet holders with uc factors
rfi-l>  (tupof (is _val (pet_hol _x)) (>= _val 0.5) `(tup _x _val))
`(tup (tup mary 0.6263231749593858) (tup bob 0.9085602964160698))
rfi-l>
rfi-l>
rfi-l> (pause)

rfi-l> bye
true
rfi-l>
rfi-l> ;*****************reduce******************************************
rfi-l> ;The function reduce expects two arguments, where the first is a
rfi-l> ;function and the second is a list. It applies fct to all
rfi-l> ;elements of the list.
rfi-l> ;     (tup a b c) --> (fct a b c)
rfi-l>
rfi-l> az (ft (reduce _fct (tup _x)) _x)
rfi-l> az (ft (reduce _fct (tup _x _y | _rest))
(_fct _x (reduce _fct `(tup _y | _rest))))
rfi-l>
rfi-l> ;The function maxp returns, given two tups, the tup with the
rfi-l> ;greater second argument (uc factor)
rfi-l> az (ft (maxp (tup _c1 _uc1) (tup _c2 _uc2))
(>= _uc1 _uc2) `(tup _c1 _uc1))
rfi-l> azi (ft (maxp (tup _c1 _uc1) (tup _c2 _uc2))
(<  _uc1 _uc2) `(tup _c2 _uc2))
error (tup-to-list): (vari uc1 5) structure or free variable can't be arg to lisp builtin
rfi-l>
rfi-l> ;Query for pet holder with the greatest uc factor
rfi-l> (reduce maxp  (tupof (is _uc (pet_hol _x)) `(tup _x _uc)))
unknown
rfi-l>
rfi-l> (pause)

rfi-l> bye
true
rfi-l>
rfi-l> ;***********************fetch*************************************
rfi-l> ;* * * * * * * * after an idea of Rick LeFaivre * * * * * * * * *
rfi-l> ;* * * * * * * * see `Fuzzy Reference Manual'* * * * * * * * * *
rfi-l> ;
rfi-l> ;Fetch is called with one, three or four variabels. The required
rfi-l> ;first argument is the name of the predicate of which fetch
rfi-l> ;returns an assertion whose uncertainty factor is in the proper
rfi-l> ;range which is given through the last two arguments. It fails if
rfi-l> ;no assertion is found.If more than one solution is found, it
rfi-l> ;returns the one whose uncertainty value is closest to the lower
rfi-l> ;bound. The default range is [1,0]. Notice that you receive the
rfi-l> ;highest uncertainty value by specifying the range as
rfi-l> ;[upper, lower] and the lowest uncertainty value by
rfi-l> ;specifying it as [lower, upper]. For that you fetch the maximum
rfi-l> ;with the range [1, 0] and the minimum by [0, 1].
rfi-l> ;The second argument is the argument to which the predicate is
rfi-l> ;applied. It gets interesting if there is more than one solution
rfi-l> ;for such a query. Also here you can fetch the `surest' or
rfi-l> ;`unsurest' solution.
rfi-l> ;The output of fetch is a list. In the first place is the
rfi-l> ;difference between the left bound and the uncertainty factor,
rfi-l> ;next is the uncertainty factor and last there is the binding.
rfi-l>
rfi-l>
rfi-l> az (ft (fetch _pred _from _to) (<= _from _to)
(reduce minp (tupof  (is _val (_pred _x))
(<= _val _to)
(>= _val _from)
(is _diff (- _val _from))
`(tup _diff _val _x))))
rfi-l>
rfi-l> az (ft (fetch _pred _from _to) (> _from _to)
(reduce minp (tupof  (is _val (_pred _x))
(>= _val _to)
(<= _val _from)
(is _diff (- _from _val))
`(tup  _diff _val _x))))
rfi-l>
rfi-l> az (ft (fetch _pred) (fetch _pred 1 0))
rfi-l>
rfi-l> az (ft (fetch _pred _predarg  _from _to) (<= _from _to)
(reduce minp (tupof (is _val (_pred _predarg))
(<= _val _to)
(>= _val _from)
(is _diff (- _val _from))
`(tup _diff _val _predarg))))
rfi-l>
rfi-l> az (ft (fetch _pred _predarg _from _to) (> _from _to)
(reduce minp (tupof (is _val (_pred _predarg))
(>= _val _to)
(<= _val _from)
(is _diff (- _from _val))
`(tup _diff _val _predarg))))
rfi-l>
rfi-l> az (ft (fetch _pred _predarg) (fetch _pred _predarg 1 0))
rfi-l>
rfi-l> az (ft (minp (tup _diff1 _val1 _x1) (tup _diff2 _val2 _x2))
(<= _diff1 _diff2) `(tup _diff1 _val1 _x1))
rfi-l> az (ft (minp (tup _diff1 _val1 _x1) (tup _diff2 _val2 _x2))
(> _diff1 _diff2) `(tup _diff2 _val2 _x2))
rfi-l>
rfi-l>
rfi-l>
rfi-l>
rfi-l> (fetch  pet_hol 0 1)
`(tup 0.19407667236782145 0.19407667236782145 john)
rfi-l>
rfi-l>
rfi-l>
rfi-l> (fetch pet_hol 1 0)
`(tup 0.09143970358393017 0.9085602964160698 bob)
rfi-l>
rfi-l>
rfi-l>
rfi-l> (fetch pet_hol)
`(tup 0.09143970358393017 0.9085602964160698 bob)
rfi-l>
rfi-l> (pause)

rfi-l> bye
true
rfi-l>
rfi-l> ;If there is more than one solution, you can fetch the one with
rfi-l> ;the greatest (smallest) uc factor.
rfi-l> ;Therefore we need another clause for mary:
rfi-l> az (ft (cos_main mary)(nl few))
rfi-l>
rfi-l> (fetch pet_hol mary 0 1)
`(tup 0.46026438677468706 0.46026438677468706 mary)
rfi-l>
rfi-l>
rfi-l>
rfi-l> (fetch pet_hol mary 1 0)
`(tup 0.37367682504061417 0.6263231749593858 mary)
rfi-l>
rfi-l>
rfi-l> (fetch pet_hol mary )
`(tup 0.37367682504061417 0.6263231749593858 mary)
rfi-l>
rfi-l>
rfi-l>
rfi-l> ;Also is it possible to fetch a pet holder with a special
rfi-l> ;uncertainty value. The first query here has to fail, because
rfi-l> ;no 100% certain pet holder exists.
rfi-l> (fetch  pet_hol 1 1)
unknown
rfi-l>
rfi-l>
rfi-l>
rfi-l> (fetch pet_hol  0.9085602964160698  0.9085602964160698)
`(tup 0.0 0.9085602964160698 bob)
rfi-l>
rfi-l> (pause)

rfi-l> bye
true
rfi-l>
rfi-l> ;******************quick sort*************************************
rfi-l> ;quick sort with an higher order function. It removes all double
rfi-l> az (ft ((qsort _cr) (tup)) `(tup) )
rfi-l> az (ft ((qsort _cr) (tup _x | _y))
(`(partition _cr) _x _y _sm _gr)
(appfun (`(qsort _cr) _sm)
(tup _x | (`(qsort _cr) _gr)) ) )
rfi-l>
rfi-l>
rfi-l> az (hn ((partition _cr) _x (tup) (tup) (tup)))
rfi-l> az (hn ((partition _cr) _x (tup _x | _z) _l1 _l2 )
(`(partition _cr) _x _z _l1 _l2) )
rfi-l> az (hn ((partition _cr) _x (tup _y | _z) (tup _y | _sm) _gr )
(_cr _y _x)
(`(partition _cr) _x _z _sm _gr) )
rfi-l> az (hn ((partition _cr) _x (tup _y | _z) _sm (tup _y | _gr) )
(_cr _x _y)
(`(partition _cr) _x _z _sm _gr) )
rfi-l>
rfi-l> az (ft (appfun (tup) _l) _l )
rfi-l> az (ft (appfun (tup _h | _r) _l) (tup _h | (appfun _r _l)) )
rfi-l>
rfi-l>
rfi-l>
rfi-l> ;function secnd<= and secnd>=
rfi-l> az (hn (secnd<= ( id _m) ( id _n)) (<= _m _n) )
rfi-l> az (hn (secnd>= ( id _m) ( id _n)) (>= _m _n) )
rfi-l>
rfi-l>
rfi-l> (`(qsort secnd<=) (tupof (is _uc (pet_hol _x)) `(_x _uc)))
`(tup
(john 0.19407667236782145)
(mary 0.46026438677468706)
(mary 0.6263231749593858)
(bob 0.9085602964160698) )
rfi-l> (pause)

rfi-l> bye
true
rfi-l>
rfi-l>
rfi-l> ;**********************higher order combination rule *************
rfi-l> ;It is also possible to give the combination rule as a higher
rfi-l> ;order function.
rfi-l>
rfi-l> az (uc (cos_main _x) (shelter _x) (food _x)(nurture _x)(doctor _x) 0.8)
rfi-l>
rfi-l> uncertain  (cr)
rfi-l>
rfi-l> l cos_main
(ft (cos_main john)
(nl very_few) )
(ft (cos_main mary)
(nl total) )
(ft (cos_main bob)
(nl total) )
(ft (cos_main mary)
(nl few) )
(ft (cos_main _x)
((cr)
(shelter _x)
(food _x)
(nurture _x)
(doctor _x)
0.8 ) )
rfi-l>
rfi-l> azft (cr) max
rfi-l>
rfi-l> azft (shelter tom) (nl high)
rfi-l> azft (food tom) (nl few)
rfi-l> azft (nurture tom) (nl very_high)
rfi-l> azft (doctor tom) (nl very_few)
rfi-l>
rfi-l> (cos_main tom)
0.9
rfi-l>
rfi-l>
rfi-l> (pause)

rfi-l> bye
true
rfi-l>
rfi-l>
rfi-l> ;change the higher order function
rfi-l>
rfi-l> rxft (cr) max
rfi-l> azft (cr)  *
rfi-l>
rfi-l> (cos_main tom)
0.013500000000000002```

Harold Boley & Victoria Hall (hall@dfki.uni-kl.de)