This file is indexed.

/usr/share/minlog/lib/natinf.scm is in minlog 4.0.99.20100221-6.

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
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
; $Id: natinf.scm 2156 2008-01-25 13:25:12Z schimans $
(display "loading natinf.scm ...") (newline)

; The natural numbers plus an infinite object
; ===========================================

; We need the type nat yplus unit as range of the weight function.
; Since we want to use e.g. + for this type, we only load parts of nat.scm

; (load "~/minlog/init.scm")

(add-alg "nat" '("Zero" "nat") '("Succ" "nat=>nat"))

(define (make-numeric-term n)
  (if (= n 0)
      (pt "Zero")
      (make-term-in-app-form
       (pt "Succ")
       (make-numeric-term (- n 1)))))

(define (is-numeric-term? term)
  (or
   (and (term-in-const-form? term)
	(string=? "Zero" (const-to-name (term-in-const-form-to-const term))))
   (and (term-in-app-form? term)
	(let ((op (term-in-app-form-to-op term)))
	  (and (term-in-const-form? op)
	       (string=? "Succ" (const-to-name
				 (term-in-const-form-to-const op)))
	       (is-numeric-term? (term-in-app-form-to-arg term)))))))

(define (numeric-term-to-number term)
  (if (equal? term (pt "Zero"))
      0
      (+ 1 (numeric-term-to-number (term-in-app-form-to-arg term)))))

(add-program-constant "NatPlus" (py "nat=>nat=>nat") t-deg-one)

(add-token
 "+++" 'add-op
 (lambda (x y)
   (mk-term-in-app-form
    (make-term-in-const-form (pconst-name-to-pconst "NatPlus")) x y)))

(add-display
 (py "nat")
 (lambda (x)
   (if (term-in-app-form? x)
       (let ((op (term-in-app-form-to-final-op x))
	     (args (term-in-app-form-to-args x)))
	 (if (and (term-in-const-form? op)
		  (string=? "NatPlus"
			    (const-to-name (term-in-const-form-to-const op)))
		  (= 2 (length args)))
	     (list 'add-op "+++"
		   (term-to-token-tree (car args))
		   (term-to-token-tree (cadr args)))
	     #f))
       #f)))

(add-computation-rule (pt "nat+++0") (pt "nat"))
(add-computation-rule (pt "nat1+++Succ nat2") (pt "Succ(nat1+++nat2)"))

(quote (begin
(set-goal (pf "all nat 0+++nat=nat"))
(ind)
(use "Truth-Axiom")
(assume "nat" "IH")
(use "IH")

(set-goal (pf "all nat1,nat2 Succ nat1+++nat2=Succ(nat1+++nat2)"))
(assume "nat1")
(ind)
(use "Truth-Axiom")
(assume "nat2" "IH")
(use "IH")

(set-goal (pf "all nat1,nat2,nat3 nat1+++(nat2+++nat3)=nat1+++nat2+++nat3"))
(assume "nat1" "nat2")
(ind)
(use "Truth-Axiom")
(assume "nat3" "IH")
(use "IH")
)) ;matches quote

(add-rewrite-rule (pt "0+++nat") (pt "nat"))
(add-rewrite-rule (pt "Succ nat1+++nat2") (pt "Succ(nat1+++nat2)"))
(add-rewrite-rule (pt "nat1+++(nat2+++nat3)") (pt "nat1+++nat2+++nat3"))

(quote (begin
; "NatPlusComm"
(set-goal (pf "all nat1,nat2.nat1+++nat2=nat2+++nat1"))
(assume "nat1")
(ind)
(use "Truth-Axiom")
(assume "nat2" "IH")
(use "IH")
(save "NatPlusComm")
)) ;matches quote


(add-program-constant "NatLt" (py "nat=>nat=>boole") t-deg-one)

(add-token
 "<<" 'rel-op
 (lambda (x y)
   (mk-term-in-app-form
    (make-term-in-const-form (pconst-name-to-pconst "NatLt")) x y)))

(add-display
 (py "boole")
 (lambda (x)
   (if (term-in-app-form? x)
       (let ((op (term-in-app-form-to-final-op x))
	     (args (term-in-app-form-to-args x)))
	 (if (and (term-in-const-form? op)
		  (string=? "NatLt"
			    (const-to-name (term-in-const-form-to-const op)))
		  (= 2 (length args)))
	     (list 'rel-op "<<"
		   (term-to-token-tree (car args))
		   (term-to-token-tree (cadr args)))
	     #f))
       #f)))

(add-computation-rule (pt "nat<<0") (pt "False"))
(add-computation-rule (pt "0<<Succ nat") (pt "True"))
(add-computation-rule (pt "Succ nat1<<Succ nat2") (pt "nat1<<nat2"))

(add-rewrite-rule (pt "nat<<nat") (pt "False"))
(add-rewrite-rule (pt "nat<<Succ nat") (pt "True"))

(add-program-constant "Pred" (py "nat=>nat") t-deg-one)

(add-computation-rule (pt "Pred 0") (pt "0"))
(add-computation-rule (pt "Pred(Succ nat)") (pt "nat"))

(add-program-constant "NatMinus" (py "nat=>nat=>nat") t-deg-one)

(add-token
 "-" 'add-op
 (lambda (x y)
   (mk-term-in-app-form
    (make-term-in-const-form (pconst-name-to-pconst "NatMinus")) x y)))

(add-display
 (py "nat")
 (lambda (x)
   (if (term-in-app-form? x)
       (let ((op (term-in-app-form-to-final-op x))
	     (args (term-in-app-form-to-args x)))
	 (if (and (term-in-const-form? op)
		  (string=? "NatMinus"
			    (const-to-name (term-in-const-form-to-const op)))
		  (= 2 (length args)))
	     (list 'add-op "-"
		   (term-to-token-tree (car args))
		   (term-to-token-tree (cadr args)))
	     #f))
       #f)))

(add-computation-rule (pt "nat-0") (pt "nat"))
(add-computation-rule (pt "nat1-Succ nat2") (pt "Pred(nat1-nat2)"))

(add-rewrite-rule (pt "nat-nat") (pt "0"))
(add-rewrite-rule (pt "0-nat") (pt "0"))
(add-rewrite-rule (pt "Pred(Succ nat1-nat2)") (pt "nat1-nat2"))
(add-rewrite-rule (pt "nat1+++nat2-nat1") (pt "nat2"))
(add-rewrite-rule (pt "nat1+++nat2-nat2") (pt "nat1"))
(add-rewrite-rule (pt "nat1+++(nat2 - nat3)") (pt "nat1+++nat2-nat3"))

(add-var-name "n" "m" "k" (py "nat"))

; Now the general sum type-operator:

(add-param-alg "yplus" 'sum-typeop
	       '("Inleft" "alpha1=>yplus")
	       '("Inright" "alpha2=>yplus"))

(add-var-name "x" "y" "z" (py "nat yplus unit"))

; (pp (pt "(Inleft nat unit) 0"))
; (pp (pt "(Inleft nat unit) 1"))
; (pp (pt "(Inright unit nat) Dummy"))

(add-token
 "Inl"
 'prefix-op
 (lambda (x) (mk-term-in-app-form (pt "(Inleft nat unit)") x)))

(add-token
 "Inr"
 'prefix-op
 (lambda (x) (mk-term-in-app-form (pt "(Inright unit nat)") x)))

(add-display
 (py "nat yplus unit")
 (lambda (x)
   (let* ((op (term-in-app-form-to-final-op x))
	  (args (term-in-app-form-to-args x)))
     (cond ((and (term-in-const-form? op)
		 (string=? "Inleft"
			   (const-to-name (term-in-const-form-to-const op)))
		 (= 1 (length args)))
	    (list 'prefix-op "Inl" (term-to-token-tree (car args))))
	   ((and (term-in-const-form? op)
		 (string=? "Inright"
			   (const-to-name (term-in-const-form-to-const op)))
		 (= 1 (length args)))
	    (list 'prefix-op "Inr" (term-to-token-tree (car args))))
	   (else #f)))))

; (pp (pt "Inl 0"))
; (pp (pt "Inl 1"))
; (pp (pt "Inr Dummy"))

(add-program-constant
 "NatinfPlus"
 (py "nat yplus unit=>nat yplus unit=>nat yplus unit") t-deg-one)

(add-token
 "+" 'add-op
 (lambda (x y)
   (mk-term-in-app-form
    (make-term-in-const-form (pconst-name-to-pconst "NatinfPlus")) x y)))

(add-display
 (py "nat yplus unit")
 (lambda (x)
   (let* ((op (term-in-app-form-to-final-op x))
	  (args (term-in-app-form-to-args x)))
     (if (and (term-in-const-form? op)
	      (string=? "NatinfPlus"
			(const-to-name (term-in-const-form-to-const op)))
	      (= 2 (length args)))
	 (list 'add-op "+"
	       (term-to-token-tree (car args))
	       (term-to-token-tree (cadr args)))
	 #f))))

(add-computation-rule (pt "x+Inl 0") (pt "x"))
(add-computation-rule (pt "Inl n+Inl(Succ m)") (pt "Inl(Succ(n+++m))"))
(add-computation-rule (pt "Inr Dummy+Inl(Succ m)") (pt "Inr Dummy"))
(add-computation-rule (pt "x+Inr Dummy") (pt "Inr Dummy"))

(add-rewrite-rule (pt "Inl 0+x") (pt "x"))
(add-rewrite-rule (pt "Inl(Succ n)+Inl m") (pt "Inl(Succ(n+++m))"))
(add-rewrite-rule (pt "x1+(x2+x3)") (pt "x1+x2+x3"))

(add-program-constant
 "NatinfLe" (py "nat yplus unit=>nat yplus unit=>boole") t-deg-one)

(add-token
 "<=" 'rel-op
 (lambda (x y)
   (mk-term-in-app-form
    (make-term-in-const-form (pconst-name-to-pconst "NatinfLe")) x y)))

(add-display
 (py "boole")
 (lambda (x)
   (let* ((op (term-in-app-form-to-final-op x))
	  (args (term-in-app-form-to-args x)))
     (if (and (term-in-const-form? op)
	      (string=? "NatinfLe"
			(const-to-name (term-in-const-form-to-const op)))
	      (= 2 (length args)))
	 (list 'rel-op "<="
	       (term-to-token-tree (car args))
	       (term-to-token-tree (cadr args)))
	 #f))))

(add-computation-rule (pt "Inl 0<=y") (pt "True"))
(add-computation-rule (pt "Inl(Succ n)<=Inl 0") (pt "False"))
(add-computation-rule (pt "Inl(Succ n)<=Inl(Succ m)") (pt "Inl n<=Inl m"))
(add-computation-rule (pt "Inl(Succ n)<=Inr Dummy") (pt "True"))
(add-computation-rule (pt "Inr Dummy<=Inl m") (pt "False"))
(add-computation-rule (pt "Inr Dummy<=Inr Dummy") (pt "True"))

(add-rewrite-rule (pt "x<=x") (pt "True"))
(add-rewrite-rule (pt "x<=Inr Dummy") (pt "True"))
(add-rewrite-rule (pt "x<=x+y") (pt "True"))

(add-program-constant
 "NatinfLt" (py "nat yplus unit=>nat yplus unit=>boole") t-deg-one)

(add-token
 "<" 'rel-op
 (lambda (x y)
   (mk-term-in-app-form
    (make-term-in-const-form (pconst-name-to-pconst "NatinfLt")) x y)))

(add-display
 (py "boole")
 (lambda (x)
   (let* ((op (term-in-app-form-to-final-op x))
	  (args (term-in-app-form-to-args x)))
     (if (and (term-in-const-form? op)
	      (string=? "NatinfLt"
			(const-to-name (term-in-const-form-to-const op)))
	      (= 2 (length args)))
	 (list 'rel-op "<"
	       (term-to-token-tree (car args))
	       (term-to-token-tree (cadr args)))
	 #f))))

(add-computation-rule (pt "x<Inl 0") (pt "False"))
(add-computation-rule (pt "Inl 0<Inl(Succ m)") (pt "True"))
(add-computation-rule (pt "Inl(Succ n)<Inl(Succ m)") (pt "Inl n<Inl m"))
(add-computation-rule (pt "Inr Dummy<Inl(Succ m)") (pt "False"))
(add-computation-rule (pt "Inl n<Inr Dummy") (pt "True"))
(add-computation-rule (pt "Inr Dummy<Inr Dummy") (pt "False"))

(add-rewrite-rule (pt "x<x") (pt "False"))
(add-rewrite-rule (pt "x+y<x") (pt "False"))
(add-rewrite-rule (pt "Inr unit<y") (pt "False"))
(add-rewrite-rule (pt "Inl m<Inl(Succ m)") (pt "True"))


(add-program-constant
 "NatinfMin" (py "nat yplus unit=>nat yplus unit=>nat yplus unit") t-deg-one)

(add-token
 "min" 'mul-op
 (lambda (x y)
   (mk-term-in-app-form
    (make-term-in-const-form (pconst-name-to-pconst "NatinfMin")) x y)))

(add-display
 (py "nat yplus unit")
 (lambda (x)
   (let* ((op (term-in-app-form-to-final-op x))
	  (args (term-in-app-form-to-args x)))
     (if (and (term-in-const-form? op)
	      (string=? "NatinfMin"
			(const-to-name (term-in-const-form-to-const op)))
	      (= 2 (length args)))
	 (list 'mul-op "min"
	       (term-to-token-tree (car args))
	       (term-to-token-tree (cadr args)))
	 #f))))

(add-computation-rule (pt "Inl 0 min y") (pt "Inl 0"))
(add-computation-rule (pt "Inl(Succ n)min Inl 0") (pt "Inl 0"))
(add-computation-rule (pt "Inl(Succ n)min Inl(Succ m)")
		      (pt "(Inl n min Inl m)+Inl 1"))
(add-computation-rule (pt "Inl(Succ n)min Inr Dummy") (pt "Inl(Succ n)"))
(add-computation-rule (pt "Inr Dummy min y") (pt "y"))

(add-rewrite-rule (pt "x min Inl 0") (pt "Inl 0"))
(add-rewrite-rule (pt "x min x") (pt "x"))
(add-rewrite-rule (pt "(x+y) min x") (pt "x"))
(add-rewrite-rule (pt "x min (x+y)") (pt "x"))

(add-rewrite-rule (pt "x min y<=x") (pt "True"))
(add-rewrite-rule (pt "x min y<=y") (pt "True"))
(add-rewrite-rule (pt "x min y<x") (pt "True"))
(add-rewrite-rule (pt "x min y<y") (pt "True"))