-
Notifications
You must be signed in to change notification settings - Fork 50
/
Copy pathstandard_form_extras.pvs
418 lines (330 loc) · 11.1 KB
/
standard_form_extras.pvs
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
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
standard_form_extras % Welcome
: THEORY
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%| This is extra properties of standard |%
%| form, to help show uniqueness |%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Author: AD, JTS
%----- %
BEGIN
% -----%
%-------------------------------------------
%%Importing definitions of standard_form
% and evalation with all favorable properties
%-------------------------------------------
IMPORTING
standard_form_mult_poly,
eval_MultPoly,
map_perm[monomial, monomial],
eval_properties
%-------------------------------------------
%%Max_length of cons
%-------------------------------------------
cons_max_length: LEMMA
FORALL (m: monomial, p:MultPoly):
max_length(cons(m, p)) >= max_length(p)
%-------------------------------------------
%%The cutting of a monomial is null if every
% entry of it is zero
%-------------------------------------------
cutting_null: LEMMA
FORALL (m:monomial):
cutting(m`alpha) = null IFF
every( lambda(n:nat): n=0)(m`alpha)
%-------------------------------------------
%%Property of cutting
%-------------------------------------------
cutting_cons: LEMMA
FORALL (l:(cons?[nat])):
cons?(cutting(l)) IMPLIES
cutting(l) = cons(car(l), cutting(cdr(l)))
%-------------------------------------------
%%Max length of lft properties
%-------------------------------------------
lft_ml_n: LEMMA
FORALL (p:MultPoly, (n: nat |n>=max_length(p))):
cons?(p) IMPLIES
max_length(lft(p)(n)) =n
lft_max_length: LEMMA
FORALL (p:MultPoly):
max_length(p) = max_length(lft(p)(max_length(p)))
permutations_max_length: LEMMA
FORALL (p, q: MultPoly):
permutations(p,q) IMPLIES
max_length(p) = max_length(q)
%-------------------------------------------
%%Sorted and cons mean the sortedsimplify
% is cons
%-------------------------------------------
sortedsimplify_cons: LEMMA
FORALL (p: MultPoly ):
(is_sorted?(p) AND cons?(p))
IMPLIES cons?(sortedsimplify(p))
%-------------------------------------------
%%Simplify max_length property
%-------------------------------------------
simplify_max_length: LEMMA
FORALL (p:MultPoly):
max_length(p)= max_length(simplify(p))
%-------------------------------------------
%%Max_length of mv_standard_form
%-------------------------------------------
mv_standard_form_max_length: LEMMA
FORALL (p:MultPoly):
max_length(p) >= max_length(mv_standard_form(p))
%-------------------------------------------
%%Evaluation identity
%-------------------------------------------
eval_vals_0: LEMMA
FORALL (c:real, vals:list[real]):
full_eval((# C:= c, alpha:= null[nat] #))(vals)
= c
%-------------------------------------------
%%Evaluation is map
%-------------------------------------------
eval_is_map: LEMMA
FORALL (p:MultPoly, index: list[nat],
(vals: list[real] | length(vals) = length(index))):
eval(p, index)(vals) =
map(lambda(m:monomial): eval(m,index)(vals))(p)
%-------------------------------------------
%%Property of sum and remove
%-------------------------------------------
sum_C_remove: LEMMA
FORALL (n:posnat,
(p:MultPoly | length(p) =n), i:below(length(p))):
sum_C(p) = nth(p,i)`C + sum_C(remove(p, i))
%-------------------------------------------
%%Permutations have the same sum
%-------------------------------------------
sum_C_perm: LEMMA
FORALL (p,q:MultPoly):
permutations(p,q) IMPLIES
sum_C(p) = sum_C(q)
%------------------------------------------
%%Max length of mult
%------------------------------------------
mult_max_length: LEMMA
FORALL( r: real, p: MultPoly):
max_length(mult(r,p)) = max_length(p)
%------------------------------------------
%%Max length of adding functions
%------------------------------------------
sorted_sans_add__max_length: LEMMA
FORALL(n:nat, p:(mv_standard_sans_cut?(n)),
q:(mv_standard_sans_cut?(n))):
max_length(sorted_sans_add(n,p,q)) <=
max(max_length(p),max_length(q))
sorted_add_max_length: LEMMA
FORALL(p,q: (mv_standard_form?)):
max_length(sorted_add(p,q)) <=
max(max_length(p),max_length(q))
sort_add_max_length: LEMMA
FORALL(p,q: MultPoly):
max_length(sort_add(p,q)) <=
max(max_length(mv_standard_form(p)),
max_length(mv_standard_form(q)))
min_add_max_length: LEMMA
FORALL(p,q: MultPoly):
max_length(min_add(p,q)) <=
max(max_length(mv_standard_form(p)),
max_length(mv_standard_form(q)))
add_max_length: LEMMA
FORALL (p,q: MultPoly):
max_length(add(p,q))<= max(max_length(p),
max_length(q))
mp_mult_max_length: LEMMA
FORALL (p,q: MultPoly):
max_length(mp_mult(p,q))<= max(max_length(p),
max_length(q))
%------------------------------------------
%%Allnonzero of a polynomial is null
% iff every entry is 0
%------------------------------------------
null_allnonzero: LEMMA
FORALL (p:MultPoly):
null?(allnonzero(p))
IFF
every(LAMBDA (m:monomial): m`C =0)(p)
%------------------------------------------
%%Lft keeps the same constant
%------------------------------------------
lft_constants: LEMMA
FORALL (p:MultPoly, i:below(length(p)),
(n: nat | n>=max_length(p))):
nth(p, i)`C = nth(lft(p)(n), i)`C
%------------------------------------------
%%Mult retains length
%------------------------------------------
mult_length_monom: LEMMA
FORALL (m:monomial, r:real):
length(mult(r,m)`alpha) = length(m`alpha)
mult_length: LEMMA
FORALL (p:MultPoly, r:real):
length(mult(r,p)) = length(p)
%------------------------------------------
%%nth mult property
%------------------------------------------
scale_constants: LEMMA
FORALL (p:MultPoly, i:below(length(p)), r:real):
nth(mult(r,p), i)`C = r*nth(p, i)`C
%------------------------------------------
%%Mult is a map
%------------------------------------------
mult_map: LEMMA
FORALL (p:MultPoly, r:real):
mult(r, p) = map(LAMBDA (m:monomial):
(# C:= m`C*r , alpha := m`alpha #))(p)
mult_mv_sans: LEMMA
FORALL (n:nat, p:(mv_standard_sans_cut?(n)), r:nzreal):
mv_standard_sans_cut?(n)(mult(r, p))
%------------------------------------------
%%Mult with nonzero real number
% is in standard form
%------------------------------------------
mult_mv_standard: LEMMA
FORALL (p:(mv_standard_form?), r:nzreal):
mv_standard_form?(mult(r,p))
%------------------------------------------
%%max_length not the same means that
% polynomials are not equal somewhere
%------------------------------------------
max_length_different_lft_nth: LEMMA
FORALL (p,q: (minlength?)):
length(p) = length(q) AND
max_length(p) /= max_length(q)
IMPLIES
EXISTS (i:below(length(p))):
nth(lft(p)(max(max_length(p),
max_length(q))),i)`alpha /=
nth(lft(q)(max(max_length(p),
max_length(q))),i)`alpha
%------------------------------------------
%%Lft identity
%------------------------------------------
lft_max_on_minlength: LEMMA
FORALL (p: (minlength?)):
lft(p)(max_length(p)) = p
%------------------------------------------
%%Sorted_sans never has a zero coeffiecent
%------------------------------------------
sorted_sans_add_never_zero: LEMMA
FORALL(nn:nat,p,q:MultPoly,n:nat):
(n=length(p) AND mv_standard_sans_cut?(nn)(p)
AND mv_standard_sans_cut?(nn)(q))
IMPLIES (
FORALL(i:below(length(sorted_sans_add(nn,p,q)))):
nth(sorted_sans_add(nn,p,q),i)`C /= 0 )
%------------------------------------------
%%Every property of sorted_sanes_add
%------------------------------------------
sorted_sans_add_zero: LEMMA
FORALL (nn:nat, p, q: MultPoly, n:nat):
(n=length(p) AND mv_standard_sans_cut?(nn)(p)
AND mv_standard_sans_cut?(nn)(q))
IMPLIES
(every(LAMBDA (m:monomial): m`C = 0)
( sorted_sans_add(nn, p, q) )
IFF
(length(p) = length(q)
AND FORALL (i:below(length(p))):
nth(p, i) = mult(-1, nth(q, i))))
%------------------------------------------
%%Every alpha from sorted_sans_add is
% is an alpha from the original polynomials
%------------------------------------------
sorted_sans_nth: LEMMA
FORALL(n:nat,p:(mv_standard_sans_cut?(n)),
q:(mv_standard_sans_cut?(n))):
FORALL(i:below(length(sorted_sans_add(n,p,q)))):
(EXISTS(j:below(length(p))):
nth(sorted_sans_add(n,p,q),i)`alpha = nth(p,j)`alpha)
OR
(EXISTS(j:below(length(q))):
nth(sorted_sans_add(n,p,q),i)`alpha = nth(q,j)`alpha)
%------------------------------------------
%%Showing that sorted_sans_add has properties
% very close to standard_form
%------------------------------------------
sorted_sans_add_Unif: LEMMA
FORALL(n:nat,p:(mv_standard_sans_cut?(n)),
q:(mv_standard_sans_cut?(n))):
Unif?(sorted_sans_add(n,p,q))
sorted_sans_add_sort: LEMMA
FORALL(n:nat,p:(mv_standard_sans_cut?(n)),
q:(mv_standard_sans_cut?(n))):
is_sorted?(sorted_sans_add(n,p,q))
sorted_add_sorted: LEMMA
FORALL (p1:(mv_standard_form?),
p2:(mv_standard_form?)): is_sorted?(sorted_add(p1,p2))
sorted_sans_add_simp: LEMMA
FORALL(n:nat,p:(mv_standard_sans_cut?(n)),
q:(mv_standard_sans_cut?(n))):
simplified?(sorted_sans_add(n,p,q))
%------------------------------------------
%%Add is nonzero
%------------------------------------------
add_nonzero: LEMMA
FORALL(p,q:MultPoly):
allnonzero?(add(p,q))
%------------------------------------------
%%Add is simplfied
%------------------------------------------
add_simplified: LEMMA
FORALL(p,q:MultPoly):
simplified?(add(p,q))
%------------------------------------------
%%Add is minlength
%------------------------------------------
add_minlength: LEMMA
FORALL(p,q:MultPoly):
minlength?(add(p,q))
%------------------------------------------
%%Add is sorted
%------------------------------------------
add_sorted: LEMMA
FORALL(p,q:MultPoly):
is_sorted?(add(p,q))
%------------------------------------------
%%Add is in standard form
%------------------------------------------
add_standard_form: LEMMA
FORALL (p,q: MultPoly):
mv_standard_form?(add(p,q))
mult_standard_form: LEMMA
FORALL (p,q: MultPoly):
mv_standard_form?(mp_mult(p,q))
%------------------------------------------
%%Pull out scalar from full evaluation
%------------------------------------------
scal_full_eval_monom: LEMMA
FORALL(r:real,m:monomial,
vals:list[real] | length(vals) >= length(m`alpha)):
full_eval(mult(r,m))(vals) = r * full_eval(m)(vals)
scale_full_eval: LEMMA
FORALL (r:real, p:MultPoly,
(vals: list[real] | length(vals) >= max_length(p))):
full_eval(mult(r,p))(vals) = r*full_eval(p)(vals)
%------------------------------------------
%%Pad vals with ones
%------------------------------------------
vals_pad(vals:list[real], n:nat):
{l:list[real]| length(l) = length(vals)+n} =
append(vals, (: 1 :)^n)
%------------------------------------------
%%Pad vals properties
%------------------------------------------
vals_pad_cdr: LEMMA
FORALL(vals:list[real],n:nat):
cons?(vals) IMPLIES
cdr(vals_pad(vals,n)) = vals_pad(cdr(vals),n)
vals_extend_monom: LEMMA
FORALL(m:monomial,
(vals: list[real] | length(vals) >= length(m`alpha)), n:nat):
full_eval(m)(vals_pad(vals,n)) = full_eval(m)(vals)
vals_extend: LEMMA
FORALL (p: MultPoly,
(vals: list[real] | length(vals) >= max_length(p)), n:nat):
full_eval(p)(vals_pad(vals,n)) = full_eval(p)(vals)
%~~~ The End ~~~%
END standard_form_extras