This file is indexed.

/usr/share/axiom-20170501/src/algebra/SPLTREE.spad is in axiom-source 20170501-3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
)abbrev domain SPLTREE SplittingTree
++ Author: Marc Moereno Maza
++ Date Created: 07/05/1996
++ Date Last Updated:  07/19/1996
++ References:
++      M. MORENO MAZA "Calculs de pgcd au-dessus des tours
++      d'extensions simples et resolution des systemes d'equations
++      algebriques" These, Universite P.etM. Curie, Paris, 1997.
++ Description: 
++ This domain exports a modest implementation of splitting 
++ trees. Spliiting trees are needed when the 
++ evaluation of some quantity under some hypothesis
++ requires to split the hypothesis into sub-cases.
++ For instance by adding some new hypothesis on one
++ hand and its negation on another hand. The computations
++ are terminated is a splitting tree \axiom{a} when
++ \axiom{status(value(a))} is \axiom{true}. Thus,
++ if for the splitting tree \axiom{a} the flag
++ \axiom{status(value(a))} is \axiom{true}, then
++ \axiom{status(value(d))} is \axiom{true} for any
++ subtree \axiom{d} of \axiom{a}. This property
++ of splitting trees is called the termination
++ condition. If no vertex in a splitting tree \axiom{a}
++ is equal to another, \axiom{a} is said to satisfy
++ the no-duplicates condition. The splitting 
++ tree \axiom{a} will satisfy this condition 
++ if nodes are added to \axiom{a} by mean of 
++ \axiom{splitNodeOf!} and if \axiom{construct}
++ is only used to create the root of \axiom{a}
++ with no children.

SplittingTree(V,C) : SIG == CODE where
  V : Join(SetCategory,Aggregate)
  C : Join(SetCategory,Aggregate)

  B ==> Boolean
  O ==> OutputForm
  NNI ==> NonNegativeInteger
  VT ==> Record(val:V, tower:C)
  VTB ==> Record(val:V, tower:C, flag:B)
  S ==> SplittingNode(V,C)
  A ==> Record(root:S,subTrees:List(%))

  SIG ==> RecursiveAggregate(S) with

     shallowlyMutable

     finiteAggregate

     extractSplittingLeaf : % -> Union(%,"failed")
       ++ \axiom{extractSplittingLeaf(a)} returns the left
       ++ most leaf (as a tree) whose status is false
       ++ if any, else "failed" is returned.

     updateStatus! : % -> %
       ++ \axiom{updateStatus!(a)} returns a where the status
       ++ of the vertices are updated to satisfy 
       ++ the "termination condition".

     construct : S -> %
       ++ \axiom{construct(s)} creates a splitting tree
       ++ with value (root vertex) given by
       ++ \axiom{s} and no children. Thus, if the
       ++ status of \axiom{s} is false, \axiom{[s]}
       ++ represents the starting point of the 
       ++ evaluation \axiom{value(s)} under the 
       ++ hypothesis \axiom{condition(s)}.

     construct : (V,C, List %) -> %
       ++ \axiom{construct(v,t,la)} creates a splitting tree
       ++ with value (root vertex) given by
       ++ \axiom{[v,t]$S} and with \axiom{la} as 
       ++ children list.

     construct : (V,C,List S) -> %
       ++ \axiom{construct(v,t,ls)} creates a splitting tree
       ++ with value (root vertex) given by
       ++ \axiom{[v,t]$S} and with children list given by
       ++ \axiom{[[s]$% for s in ls]}.

     construct : (V,C,V,List C) -> %
       ++ \axiom{construct(v1,t,v2,lt)} creates a splitting tree
       ++ with value (root vertex) given by
       ++ \axiom{[v,t]$S} and with children list given by
       ++ \axiom{[[[v,t]$S]$% for s in ls]}.

     conditions : % -> List C
       ++ \axiom{conditions(a)} returns the list of the conditions
       ++ of the leaves of a 

     result : % -> List VT
       ++ \axiom{result(a)} where \axiom{ls} is the leaves list of \axiom{a}
       ++ returns \axiom{[[value(s),condition(s)]$VT for s in ls]}
       ++ if the computations are terminated in \axiom{a} else
       ++ an error is produced.

     nodeOf? : (S,%) -> B
       ++ \axiom{nodeOf?(s,a)} returns true iff some node of \axiom{a}
       ++ is equal to \axiom{s}

     subNodeOf? : (S,%,(C,C) -> B) -> B
       ++ \axiom{subNodeOf?(s,a,sub?)} returns true iff for some node
       ++ \axiom{n} in \axiom{a} we have \axiom{s = n} or
       ++ \axiom{status(n)} and \axiom{subNode?(s,n,sub?)}.

     remove : (S,%) -> %
       ++ \axiom{remove(s,a)} returns the splitting tree obtained 
       ++ from a by removing every sub-tree \axiom{b} such
       ++ that \axiom{value(b)} and \axiom{s} have the same
       ++ value, condition and status.

     remove! : (S,%) -> %
       ++ \axiom{remove!(s,a)} replaces a by remove(s,a)

     splitNodeOf! : (%,%,List(S)) -> %
       ++ \axiom{splitNodeOf!(l,a,ls)} returns \axiom{a} where the children
       ++ list of \axiom{l} has been set to
       ++ \axiom{[[s]$% for s in ls | not nodeOf?(s,a)]}.
       ++ Thus, if \axiom{l} is not a node of \axiom{a}, this
       ++ latter splitting tree is unchanged.

     splitNodeOf! : (%,%,List(S),(C,C) -> B) -> %
       ++ \axiom{splitNodeOf!(l,a,ls,sub?)} returns \axiom{a} where the 
       ++ children list of \axiom{l} has been set to
       ++ \axiom{[[s]$% for s in ls | not subNodeOf?(s,a,sub?)]}.
       ++ Thus, if \axiom{l} is not a node of \axiom{a}, this
       ++ latter splitting tree is unchanged.

  CODE ==> add

     Rep ==> A

     rep(n:%):Rep == n pretend Rep

     per(r:Rep):% == r pretend %

     construct(s:S) == 
        per [s,[]]$A

     construct(v:V,t:C,la:List(%)) ==
        per [[v,t]$S,la]$A

     construct(v:V,t:C,ls:List(S)) ==
        per [[v,t]$S,[[s]$% for s in ls]]$A

     construct(v1:V,t:C,v2:V,lt:List(C)) ==
        [v1,t,([v2,lt]$S)@(List S)]$%

     empty?(a:%) == empty?((rep a).root) and empty?((rep a).subTrees)

     empty() == [empty()$S]$%

     remove(s:S,a:%) ==
       empty? a => a
       (s = value(a)) and (status(s) = status(value(a))) => empty()$%
       la := children(a)
       lb : List % := []
       while (not empty? la) repeat
          lb := cons(remove(s,first la), lb)
          la := rest la
       lb := reverse remove(empty?,lb)
       [value(value(a)),condition(value(a)),lb]$%

     remove!(s:S,a:%) ==
       empty? a => a
       (s = value(a)) and (status(s) = status(value(a))) =>
         (rep a).root := empty()$S
         (rep a).subTrees := []
         a
       la := children(a)
       lb : List % := []
       while (not empty? la) repeat
          lb := cons(remove!(s,first la), lb)
          la := rest la
       lb := reverse remove(empty()$%,lb)
       setchildren!(a,lb)

     value(a:%) == 
        (rep a).root

     children(a:%) == 
        (rep a).subTrees

     leaf?(a:%) == 
        empty? a => false
        empty? (rep a).subTrees

     setchildren!(a:%,la:List(%)) == 
        (rep a).subTrees := la
        a

     setvalue!(a:%,s:S) ==
        (rep a).root := s
        s

     cyclic?(a:%) == false

     map(foo:(S -> S),a:%) ==
       empty? a => a
       b : % := [foo(value(a))]$%
       leaf? a => b
       setchildren!(b,[map(foo,c) for c in children(a)])

     map!(foo:(S -> S),a:%) ==
       empty? a => a
       setvalue!(a,foo(value(a)))
       leaf? a => a
       setchildren!(a,[map!(foo,c) for c in children(a)])

     copy(a:%) == 
       map(copy,a)

     eq?(a1:%,a2:%) ==
       error"in eq? from SPLTREE : la vache qui rit est-elle folle?"

     nodes(a:%) == 
       empty? a => []
       leaf? a => [a]
       cons(a,concat([nodes(c) for c in children(a)]))

     leaves(a:%) ==
       empty? a => []
       leaf? a => [value(a)]
       concat([leaves(c) for c in children(a)])

     members(a:%) ==
       empty? a => []
       leaf? a => [value(a)]
       cons(value(a),concat([members(c) for c in children(a)]))

     #(a:%) ==
       empty? a => 0$NNI
       leaf? a => 1$NNI
       reduce("+",[#c for c in children(a)],1$NNI)$(List NNI)

     a1:% = a2:% ==
       empty? a1 => empty? a2
       empty? a2 => false
       leaf? a1 =>
         not leaf? a2 => false
         value(a1) =$S value(a2)
       leaf? a2 => false
       value(a1) ~=$S value(a2) => false
       children(a1) = children(a2)

     localCoerce(a:%,k:NNI):O ==
       s : String
       if k = 1 then  s := "* " else s := "-> "
       for i in 2..k repeat s := concat("-+",s)$String
       ro : O := left(hconcat(message(s)$O,value(a)::O)$O)$O
       leaf? a => ro
       lo : List O := [localCoerce(c,k+1) for c in children(a)]
       lo := cons(ro,lo)
       vconcat(lo)$O

     coerce(a:%):O ==
       empty? a => vconcat(message(" ")$O,message("* []")$O)
       vconcat(message(" ")$O,localCoerce(a,1))
       
     extractSplittingLeaf(a:%) ==
       empty? a => "failed"::Union(%,"failed")
       status(value(a))$S => "failed"::Union(%,"failed")
       la := children(a)
       empty? la => a
       while (not empty? la) repeat
          esl := extractSplittingLeaf(first la)
          (esl case %) => return(esl)
          la := rest la
       "failed"::Union(%,"failed")
       
     updateStatus!(a:%) ==
       la := children(a)
       (empty? la) or (status(value(a))$S) => a
       done := true
       while (not empty? la) and done repeat
          done := done and status(value(updateStatus! first la))
          la := rest la
       setStatus!(value(a),done)$S
       a
     
     result(a:%) ==
       empty? a => []
       not status(value(a))$S => 
          error"in result from SLPTREE : mad cow!"
       ls : List S := leaves(a)
       [[value(s),condition(s)]$VT for s in ls]

     conditions(a:%) ==
       empty? a => []
       ls : List S := leaves(a)
       [condition(s) for s in ls]

     nodeOf?(s:S,a:%) ==
       empty? a => false
       s =$S value(a) => true
       la := children(a)
       while (not empty? la) and (not nodeOf?(s,first la)) repeat
          la := rest la
       not empty? la

     subNodeOf?(s:S,a:%,sub?:((C,C) -> B)) ==
       empty? a => false
       -- s =$S value(a) => true
       status(value(a)$%)$S and subNode?(s,value(a),sub?)$S => true
       la := children(a)
       while (not empty? la) and (not subNodeOf?(s,first la,sub?)) repeat
          la := rest la
       not empty? la

     splitNodeOf!(l:%,a:%,ls:List(S)) ==
       ln := removeDuplicates ls
       la : List % := []
       while not empty? ln repeat
          if not nodeOf?(first ln,a)
            then
              la := cons([first ln]$%, la)
          ln := rest ln
       la := reverse la
       setchildren!(l,la)$%
       if empty? la then (rep l).root := [empty()$V,empty()$C,true]$S
       updateStatus!(a)

     splitNodeOf!(l:%,a:%,ls:List(S),sub?:((C,C) -> B)) ==
       ln := removeDuplicates ls
       la : List % := []
       while not empty? ln repeat
          if not subNodeOf?(first ln,a,sub?)
            then
              la := cons([first ln]$%, la)
          ln := rest ln
       la := reverse la
       setchildren!(l,la)$%
       if empty? la then (rep l).root := [empty()$V,empty()$C,true]$S
       updateStatus!(a)