-
Notifications
You must be signed in to change notification settings - Fork 0
/
OCL_Examples.thy
644 lines (501 loc) · 21.9 KB
/
OCL_Examples.thy
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
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
(* Title: Safe OCL
Author: Denis Nikiforov, March 2019
Maintainer: Denis Nikiforov <denis.nikif at gmail.com>
License: LGPL
*)
chapter \<open>Examples\<close>
theory OCL_Examples
imports OCL_Normalization
begin
(*
instantiation expr :: (type) numeral
begin
definition "one_expr \<equiv> Literal (IntegerLiteral 1)"
fun plus_expr :: "'a expr \<Rightarrow> 'a expr \<Rightarrow> 'a expr" where
"plus_expr (Literal (IntegerLiteral x)) (Literal (IntegerLiteral y)) =
(Literal (IntegerLiteral (x + y)))"
| "plus_expr _ _ = Literal NullLiteral"
lemma literal_expr_add_assoc:
"(Literal a + Literal b) + Literal c = Literal a + (Literal b + Literal c)"
for a b c :: "'a literal_expr"
by (cases a; simp; cases b; simp; cases c; simp)
lemma expr_add_assoc:
"(a + b) + c = a + (b + c)"
for a b c :: "'a expr"
by (cases a; simp; cases b; simp; cases c; simp add: literal_expr_add_assoc)
instance
apply standard
by (simp add: expr_add_assoc)
end
term "Set{}"
term "Set{\<^bold>1..\<^bold>2, \<^bold>3, 3}"
term "Set{\<^bold>1, \<^bold>2}"
term "Set{\<^bold>1 .. \<^bold>2, \<^bold>3}"
term "Set Integer[\<^bold>1]"
*)
(*** Symbols ****************************************************************)
section \<open>Symbols\<close>
abbreviation "self \<equiv> STR ''self''"
abbreviation "it \<equiv> STR ''it''"
abbreviation "name \<equiv> STR ''name''"
abbreviation "position \<equiv> STR ''position''"
abbreviation "vip \<equiv> STR ''vip''"
abbreviation "cost \<equiv> STR ''cost''"
abbreviation "description \<equiv> STR ''description''"
abbreviation "priority \<equiv> STR ''priority''"
abbreviation "Priority \<equiv> STR ''Priority''"
abbreviation "Low \<equiv> STR ''Low''"
abbreviation "Medium \<equiv> STR ''Medium''"
abbreviation "High \<equiv> STR ''High''"
abbreviation "ProjectManager \<equiv> STR ''ProjectManager''"
abbreviation "projects \<equiv> STR ''projects''"
abbreviation "manager \<equiv> STR ''manager''"
abbreviation "ProjectMember \<equiv> STR ''ProjectMember''"
abbreviation "memberOf \<equiv> STR ''memberOf''"
abbreviation "members \<equiv> STR ''members''"
abbreviation "ManagerEmployee \<equiv> STR ''ManagerEmployee''"
abbreviation "lineManager \<equiv> STR ''lineManager''"
abbreviation "projectManager \<equiv> STR ''projectManager''"
abbreviation "employees \<equiv> STR ''employees''"
abbreviation "ProjectCustomer \<equiv> STR ''ProjectCustomer''"
abbreviation "customer \<equiv> STR ''customer''"
abbreviation "ProjectTask \<equiv> STR ''ProjectTask''"
abbreviation "project \<equiv> STR ''project''"
abbreviation "tasks \<equiv> STR ''tasks''"
abbreviation "SprintTaskAssignee \<equiv> STR ''SprintTaskAssignee''"
abbreviation "sprint \<equiv> STR ''sprint''"
abbreviation "assignee \<equiv> STR ''assignee''"
abbreviation "membersCount \<equiv> STR ''membersCount''"
abbreviation "membersByName \<equiv> STR ''membersByName''"
abbreviation "allProjects \<equiv> STR ''allProjects''"
definition "symbol_kinds \<equiv> fmap_of_list [
(name, Attribute),
(position, Attribute),
(vip, Attribute),
(cost, Attribute),
(description, Attribute),
(priority, Attribute),
(projects, AssociationEnd None),
(members, AssociationEnd None),
(memberOf, AssociationEnd None),
(manager, AssociationEnd None),
(lineManager, AssociationEnd None),
(projectManager, AssociationEnd None),
(employees, AssociationEnd None),
(customer, AssociationEnd None),
(project, AssociationEnd None),
(tasks, AssociationEnd None),
(sprint, AssociationEnd None),
(assignee, AssociationEnd None)]"
definition "symbol_to_call_expr lit \<equiv> the (fmlookup symbol_kinds lit) lit"
(*** Model ******************************************************************)
section \<open>Model\<close>
datatype classes1 =
Object | Person | Employee | Customer | Project | Task | Sprint
inductive subclass1 where
"c \<noteq> Object \<Longrightarrow>
subclass1 c Object"
| "subclass1 Employee Person"
| "subclass1 Customer Person"
abbreviation "\<Gamma>\<^sub>0 \<equiv> fmempty :: classes1 type\<^sub>N\<^sub>E env"
declare [[coercion "ObjectType :: classes1 \<Rightarrow> classes1 type"]]
declare [[coercion "phantom :: String.literal \<Rightarrow> classes1 enum_type"]]
declare [[coercion "Enum :: classes1 enum_type \<Rightarrow> classes1 type"]]
declare [[coercion "StringLiteral :: string \<Rightarrow> classes1 literal_expr"]]
declare [[coercion "symbol_to_call_expr :: String.literal \<Rightarrow> classes1 call_expr"]]
(* TODO: Заменить бесконечность на звездочку *)
definition "model_spec \<equiv>
enum Priority { Low, Medium, High }
class Person
name : String[1]
class Employee
name : String[1]
position : String[1]
class Customer
vip : Boolean[1]
class Project
name : String[1]
cost : Real[?]
class Task
description : String[1]
priority : Priority[1]
association ProjectManager
projects : Project[0..\<infinity>] {unique}
manager : Employee[1..1]
association ProjectMember
memberOf : Project[0..\<infinity>]
members : Employee[1..20] {ordered,unique}
association ManagerEmployee
lineManager : Employee[0..1]
projectManager : Employee[0..\<infinity>]
employees : Employee[3..7]
association ProjectCustomer
projects : Project[0..\<infinity>] {unique}
customer : Customer[1..1]
association ProjectTask
project : Project[1..1]
tasks : Task[0..\<infinity>] {ordered,unique}
association SprintTaskAssignee
sprint : Sprint[0..10] {unique}
tasks : Task[0..5] {unique}
assignee : Employee[0..1]
context Project[1]
def: membersCount() : Integer[1] = \<lparr>self\<rparr>\<^bold>.members->size()
def: membersByName(name : String[1]) : (Set Employee[\<^bold>1])[1] =
\<lparr>self\<rparr>\<^bold>.members->select(it | \<lparr>it\<rparr>\<^bold>.name \<^bold>= \<lparr>name\<rparr>)
static def: allProjects() : (Set Project[\<^bold>1])[1] =
(MetaOperationCall Project[1] AllInstancesOp)"
(*** Upper Semilattice of Classes *******************************************)
section \<open>Upper Semilattice of Classes\<close>
instantiation classes1 :: semilattice_sup
begin
definition "(<) \<equiv> subclass1"
definition "(\<le>) \<equiv> subclass1\<^sup>=\<^sup>="
primrec sup_classes1 where
"Object \<squnion> _ = Object"
| "Person \<squnion> c = (if c = Person \<or> c = Employee \<or> c = Customer
then Person else Object)"
| "Employee \<squnion> c = (if c = Employee then Employee else
if c = Person \<or> c = Customer then Person else Object)"
| "Customer \<squnion> c = (if c = Customer then Customer else
if c = Person \<or> c = Employee then Person else Object)"
| "Project \<squnion> c = (if c = Project then Project else Object)"
| "Task \<squnion> c = (if c = Task then Task else Object)"
| "Sprint \<squnion> c = (if c = Sprint then Sprint else Object)"
lemma less_le_not_le_classes1:
"c < d \<longleftrightarrow> c \<le> d \<and> \<not> d \<le> c"
for c d :: classes1
unfolding less_classes1_def less_eq_classes1_def
using subclass1.simps by auto
lemma order_refl_classes1:
"c \<le> c"
for c :: classes1
unfolding less_eq_classes1_def by simp
lemma order_trans_classes1:
"c \<le> d \<Longrightarrow> d \<le> e \<Longrightarrow> c \<le> e"
for c d e :: classes1
unfolding less_eq_classes1_def
using subclass1.simps by auto
lemma antisym_classes1:
"c \<le> d \<Longrightarrow> d \<le> c \<Longrightarrow> c = d"
for c d :: classes1
unfolding less_eq_classes1_def
using subclass1.simps by auto
lemma sup_ge1_classes1:
"c \<le> c \<squnion> d"
for c d :: classes1
by (induct c; auto simp add: less_eq_classes1_def less_classes1_def subclass1.simps)
lemma sup_ge2_classes1:
"d \<le> c \<squnion> d"
for c d :: classes1
by (induct c; auto simp add: less_eq_classes1_def less_classes1_def subclass1.simps)
lemma sup_least_classes1:
"c \<le> e \<Longrightarrow> d \<le> e \<Longrightarrow> c \<squnion> d \<le> e"
for c d e :: classes1
by (induct c; induct d;
auto simp add: less_eq_classes1_def less_classes1_def subclass1.simps)
instance
apply intro_classes
apply (simp add: less_le_not_le_classes1)
apply (simp add: order_refl_classes1)
apply (rule order_trans_classes1; auto)
apply (simp add: antisym_classes1)
apply (simp add: sup_ge1_classes1)
apply (simp add: sup_ge2_classes1)
by (simp add: sup_least_classes1)
end
code_pred subclass1 .
primrec subclass1_fun where
"subclass1_fun Object \<C> = False"
| "subclass1_fun Person \<C> = (\<C> = Object)"
| "subclass1_fun Employee \<C> = (\<C> = Object \<or> \<C> = Person)"
| "subclass1_fun Customer \<C> = (\<C> = Object \<or> \<C> = Person)"
| "subclass1_fun Project \<C> = (\<C> = Object)"
| "subclass1_fun Task \<C> = (\<C> = Object)"
| "subclass1_fun Sprint \<C> = (\<C> = Object)"
lemma less_classes1_code [code]:
"(<) = subclass1_fun"
proof (intro ext iffI)
fix \<C> \<D> :: "classes1"
show "\<C> < \<D> \<Longrightarrow> subclass1_fun \<C> \<D>"
unfolding less_classes1_def
by (cases \<C>; erule subclass1.cases; simp)
show "subclass1_fun \<C> \<D> \<Longrightarrow> \<C> < \<D>"
by (cases \<C>; auto simp add: less_classes1_def subclass1.intros)
qed
lemma less_eq_classes1_code [code]:
"(\<le>) = (\<lambda>x y. subclass1_fun x y \<or> x = y)"
unfolding dual_order.order_iff_strict less_classes1_code
by auto
(*** Object Model ***********************************************************)
section \<open>Object Model\<close>
instantiation classes1 :: ocl_object_model
begin
definition "classes_classes1 \<equiv>
{|Object, Person, Employee, Customer, Project, Task, Sprint|}"
definition "attributes_classes1 \<equiv> model_spec_attributes model_spec"
definition "associations_classes1 \<equiv> model_spec_assoc_ens model_spec"
definition "association_classes_classes1 \<equiv> fmempty :: classes1 \<rightharpoonup>\<^sub>f assoc"
definition "operations_classes1 \<equiv> model_spec_operations model_spec"
definition "literals_classes1 \<equiv> model_spec_enum_literals model_spec"
abbreviation "assoc_ends \<equiv> model_spec_assoc_ens model_spec"
lemma assoc_end_min_less_eq_max:
"assoc |\<in>| fmdom assoc_ends \<Longrightarrow>
fmlookup assoc_ends assoc = Some ends \<Longrightarrow>
role |\<in>| fmdom ends \<Longrightarrow>
fmlookup ends role = Some end \<Longrightarrow>
assoc_end_min end \<le> assoc_end_max end"
unfolding object_model_simps object_model_notation_simps model_spec_def
using zero_enat_def one_enat_def numeral_eq_enat apply auto
by (metis enat_ord_number(1) numeral_One one_le_numeral)
lemma association_ends_unique:
assumes "association_ends' classes assoc_ends \<C> from role end\<^sub>1"
and "association_ends' classes assoc_ends \<C> from role end\<^sub>2"
shows "end\<^sub>1 = end\<^sub>2"
proof -
have "\<not> association_ends_not_unique' classes assoc_ends" by eval
with assms show ?thesis
using association_ends_not_unique'.simps by blast
qed
instance
apply standard
unfolding associations_classes1_def
using assoc_end_min_less_eq_max apply blast
using association_ends_unique by blast
end
(*** Simplification Rules ***************************************************)
section \<open>Simplification Rules\<close>
lemma logic_alt_simps [simp]:
"\<exists>x. x"
"\<exists>x. \<not> x"
"(\<exists>x. (x \<longrightarrow> P) \<and> x) = P"
"(\<exists>x. \<not> x \<and> (\<not> x \<longrightarrow> P)) = P"
"(\<exists>x. \<not> x \<and> P \<and> \<not> x) = P"
"(\<exists>x. x \<and> P \<and> \<not> x) = False"
"(\<exists>x. x \<and> Q x) = Q True"
"(\<exists>x. \<not> x \<and> Q x) = Q False"
"(\<forall>x. x) = False"
"(\<forall>x y. R y \<longrightarrow> x \<or> S y) = (\<forall>y. R y \<longrightarrow> S y)"
"(\<forall>x. R x \<longrightarrow> x \<noteq> T) = (\<not> (\<exists>x. R x \<and> x = T))"
by auto
declare numeral_eq_enat [simp]
declare fmrel_on_fset_alt_def [simp]
declare ocl_syntax_simps [simp]
declare ocl_object_model_simps [simp]
declare ocl_type_helper_simps [simp]
declare ocl_typing_simps [simp]
declare ocl_normalization_simps [simp]
declare model_spec_def [simp]
declare subclass1.simps [simp]
declare less_classes1_def [simp]
declare symbol_to_call_expr_def [simp]
declare symbol_kinds_def [simp]
declare literals_classes1_def [simp]
lemma attribute_Employee_name [simp]:
"attribute Employee STR ''name'' \<D> \<tau> =
(\<D> = Employee \<and> \<tau> = String[1])"
proof -
have "attribute Employee STR ''name'' Employee String[1]"
by eval
thus ?thesis
using attribute_det by blast
qed
lemma association_end_Project_members [simp]:
"association_end Project None STR ''members'' \<D> \<tau> =
(\<D> = Project \<and> \<tau> = (Employee, 1, 20, True, True))"
proof -
have "association_end Project None STR ''members''
Project (Employee, 1, 20, True, True)"
by eval
thus ?thesis
using association_end_det by blast
qed
lemma association_end_Employee_projects_simp [simp]:
"association_end Employee None STR ''projects'' \<D> \<tau> =
(\<D> = Employee \<and> \<tau> = (Project, 0, \<infinity>, False, True))"
proof -
have "association_end Employee None STR ''projects''
Employee (Project, 0, \<infinity>, False, True)"
by eval
thus ?thesis
using association_end_det by blast
qed
lemma static_operation_Project_allProjects [simp]:
"static_operation \<langle>Project\<rangle>\<^sub>\<T>[1] STR ''allProjects'' [] oper =
(oper = (\<langle>Project\<rangle>\<^sub>\<T>[1], STR ''allProjects'', [], (Set \<langle>Project\<rangle>\<^sub>\<T>[\<^bold>1])[1], True,
Some (MetaOperationCall \<langle>Project\<rangle>\<^sub>\<T>[1] AllInstancesOp)))"
proof -
have "static_operation \<langle>Project\<rangle>\<^sub>\<T>[1] STR ''allProjects'' []
(\<langle>Project\<rangle>\<^sub>\<T>[1], STR ''allProjects'', [], (Set \<langle>Project\<rangle>\<^sub>\<T>[\<^bold>1])[1], True,
Some (MetaOperationCall \<langle>Project\<rangle>\<^sub>\<T>[1] AllInstancesOp))"
by eval
thus ?thesis
using static_operation_det by blast
qed
(*** Basic Types ************************************************************)
section \<open>Basic Types\<close>
subsection \<open>Positive Cases\<close>
lemma "Integer < (Real :: classes1 type)" by simp
lemma "\<langle>Employee\<rangle>\<^sub>\<T> < \<langle>Person\<rangle>\<^sub>\<T>" by auto
lemma "\<langle>Person\<rangle>\<^sub>\<T> \<le> OclAny" by simp
subsection \<open>Negative Cases\<close>
lemma "\<not> String \<le> (Boolean :: classes1 type)" by simp
(*** Types ******************************************************************)
section \<open>Types\<close>
subsection \<open>Positive Cases\<close>
lemma
"Integer[?] < (OclAny[?] :: classes1 type\<^sub>N\<^sub>E)"
by simp
lemma
"(Collection Real[\<^bold>?])[1] < (OclAny[1] :: classes1 type\<^sub>N\<^sub>E)"
by simp
lemma
"(Set (Collection Boolean[\<^bold>1])[\<^bold>1])[1] < (OclAny[?] :: classes1 type\<^sub>N\<^sub>E)"
by simp
lemma
"(Set (Bag Boolean[\<^bold>1])[\<^bold>1])[1] <
(Set (Collection (Boolean[\<^bold>?] :: classes1 type\<^sub>N))[\<^bold>1])[?]"
by simp
lemma
"Tuple(STR ''a'' : Boolean[\<^bold>1], STR ''b'' : Integer[\<^bold>1])[1] <
Tuple(STR ''a'' : Boolean[\<^bold>?] :: classes1 type\<^sub>N)[1!]"
by simp
lemma
"Integer[1] \<squnion> (Real[?] :: classes1 type\<^sub>N\<^sub>E) = Real[?]"
by simp
lemma
"Set Integer[\<^bold>1] \<squnion> Set (Real[\<^bold>1] :: classes1 type\<^sub>N) = Set Real[\<^bold>1]"
by simp
lemma
"Set Integer[\<^bold>1] \<squnion> Bag (Boolean[\<^bold>?] :: classes1 type\<^sub>N) = Collection OclAny[\<^bold>?]"
by simp
lemma
"(Set Integer[\<^bold>1])[1] \<squnion> (Real[1!] :: classes1 type\<^sub>N\<^sub>E) = OclAny[1!]"
by simp
subsection \<open>Negative Cases\<close>
lemma
"\<not> (OrderedSet Boolean[\<^bold>1])[1] < (Set (Boolean[\<^bold>1] :: classes1 type\<^sub>N))[1]"
by simp
(*** Typing *****************************************************************)
section \<open>Typing\<close>
subsection \<open>Positive Cases\<close>
lemma
"\<Gamma>\<^sub>0 \<turnstile> Priority\<^bold>:\<^bold>:High : Priority[1]"
by simp
lemma
"\<Gamma>\<^sub>0 \<turnstile> true or false : Boolean[1]"
by simp
lemma
"\<Gamma>\<^sub>0 \<turnstile> null and true : Boolean[?]"
by simp
lemma
"\<Gamma>\<^sub>0 \<turnstile> let x : Real[1] = \<^bold>5 in \<lparr>x\<rparr> \<^bold>/ \<^bold>7 : Real[1!]"
by simp
lemma
"\<Gamma>\<^sub>0 \<turnstile> null\<^bold>.oclIsUndefined() : Boolean[1]"
by simp
lemma
"\<Gamma>\<^sub>0 \<turnstile> Sequence{\<^bold>1..\<^bold>5, null} : (Sequence Integer[\<^bold>?])[1]"
by simp
lemma
"\<Gamma>\<^sub>0 \<turnstile> Sequence{\<^bold>1..\<^bold>5, null}\<^bold>.oclIsUndefined() : (Sequence Boolean[\<^bold>1])[1]"
by simp
lemma
"\<Gamma>\<^sub>0 \<turnstile> Sequence{\<^bold>1\<^bold>/\<^bold>0} : (Sequence Real[\<^bold>1])[1!]"
by simp
lemma
"\<Gamma>\<^sub>0 \<turnstile> Sequence{\<^bold>1\<^bold>/\<^bold>0, null}->selectByKind(Integer[1]) : (Sequence Integer[\<^bold>1])[1!]"
by simp
lemma
"\<Gamma>\<^sub>0 \<turnstile> Sequence{\<^bold>1\<^bold>/\<^bold>0}->collect(it | \<lparr>it\<rparr>) : (Sequence Real[\<^bold>1])[1!]"
by simp
lemma
"\<Gamma>\<^sub>0 \<turnstile> Sequence{\<^bold>1}->exists(it | \<lparr>it\<rparr> \<^bold>/ \<^bold>0 \<^bold>> \<^bold>1) : Boolean[1!]"
by simp
lemma
"\<Gamma>\<^sub>0 \<turnstile> Sequence{\<^bold>1..\<^bold>5}->product(Set{''a'', ''b''}) :
(Set (Tuple(STR ''first'' : Integer[\<^bold>1], STR ''second'' : String[\<^bold>1]))[\<^bold>1])[1]"
by simp
lemma
"\<Gamma>\<^sub>0 \<turnstile> Sequence{\<^bold>1..\<^bold>5, null}?->
iterate(x; acc : Real[1] = \<^bold>0 | \<lparr>acc\<rparr> \<^bold>+ \<lparr>x\<rparr>) : Real[1]"
by simp
lemma
"\<Gamma>\<^sub>0 \<turnstile> Sequence{\<^bold>1..\<^bold>5, null}?->max() : Integer[1]"
by simp
lemma
"\<Gamma>\<^sub>0 \<turnstile> let x : (Sequence String[\<^bold>?])[1] = Sequence{''abc'', ''zxc''} in
\<lparr>x\<rparr>->any(it | \<lparr>it\<rparr> \<^bold>= ''test'') : String[?!]"
by simp
values "{x. \<Gamma>\<^sub>0 \<turnstile> let STR ''x'' : (Sequence String[\<^bold>1])[1] =
Sequence{''abc'', ''zxc''} in
\<lparr>STR ''x''\<rparr>?->closure(it | \<lparr>it\<rparr>) : x}"
values "{x. \<Gamma>\<^sub>0 \<turnstile> let STR ''x'' : (Sequence String[\<^bold>1])[1] =
Sequence{''abc'', ''zxc''} in
\<lparr>STR ''x''\<rparr>->closure(it | \<lparr>it\<rparr>) : x}"
values "{x. \<Gamma>\<^sub>0 \<turnstile> let STR ''x'' : (Sequence String[\<^bold>?])[1] =
Sequence{''abc'', ''zxc''} in
\<lparr>STR ''x''\<rparr>?->closure(it | \<lparr>it\<rparr>) : x}"
values "{x. \<Gamma>\<^sub>0 \<turnstile> Sequence{''abc'', ''zxc''}->closure(it | \<lparr>it\<rparr>) : x}"
values "{x. \<Gamma>\<^sub>0 \<turnstile> Sequence{''abc'', ''zxc''}->closure(it | \<lparr>it\<rparr>\<^bold>.oclAsSet()) : x}"
values "{x. \<Gamma>\<^sub>0 \<turnstile> Sequence{''abc'', ''zxc''}->closure(it | \<lparr>it\<rparr>) \<Rrightarrow> x}"
values "{x. \<Gamma>\<^sub>0 \<turnstile> Sequence{''abc'', ''zxc''}->collect(it | \<lparr>it\<rparr>) \<Rrightarrow> x}"
lemma
"\<Gamma>\<^sub>0 \<turnstile> let x : (Sequence String[\<^bold>?])[1] =
Sequence{''abc'', ''zxc''} in
\<lparr>x\<rparr>?->closure(it | \<lparr>it\<rparr>) : (OrderedSet String[\<^bold>1])[1]"
by simp
lemma
"\<Gamma>\<^sub>0(self \<mapsto>\<^sub>f Employee[1]) \<turnstile> \<lparr>self\<rparr>\<^bold>.name : String[1]"
by simp
lemma
"\<Gamma>\<^sub>0(self \<mapsto>\<^sub>f Employee[1]) \<turnstile> \<lparr>self\<rparr>\<^bold>.projects : (Set Project[\<^bold>1])[1]"
by simp
lemma
"\<Gamma>\<^sub>0(self \<mapsto>\<^sub>f Employee[1]) \<turnstile> \<lparr>self\<rparr>\<^bold>.projects\<^bold>.members : (Bag Employee[\<^bold>1])[1]"
by simp
lemma
"\<Gamma>\<^sub>0 \<turnstile> Project[?]\<^bold>.allInstances() : (Set Project[\<^bold>?])[1]"
by simp
lemma
"\<Gamma>\<^sub>0 \<turnstile> Project[1]::allProjects() : (Set Project[\<^bold>1])[1]"
by simp
subsection \<open>Negative Cases\<close>
lemma
"\<nexists>\<tau>. \<Gamma>\<^sub>0 \<turnstile> true \<^bold>= null : \<tau>"
by simp
lemma
"\<nexists>\<tau>. \<Gamma>\<^sub>0 \<turnstile> let x : Boolean[1] = \<^bold>5 in \<lparr>x\<rparr> and true : \<tau>"
by simp
lemma
"\<nexists>\<tau>. \<Gamma>\<^sub>0 \<turnstile> Sequence{\<^bold>1\<^bold>/\<^bold>0}->selectByKind(Integer[1!]) : \<tau>"
by simp
lemma
"\<nexists>\<tau>. \<Gamma>\<^sub>0 \<turnstile> let x : (Sequence String[\<^bold>?])[1] = Sequence{''abc'', ''zxc''} in
\<lparr>x\<rparr>->closure(it | \<^bold>1) : \<tau>"
by simp
lemma
"\<nexists>\<tau>. \<Gamma>\<^sub>0 \<turnstile> Sequence{\<^bold>1..\<^bold>5, null}->max() : \<tau>"
proof -
have
"\<not> operation_defined (Integer[?] :: classes1 type\<^sub>N\<^sub>E) STR ''max'' [Integer[?]]"
by eval
thus ?thesis by simp
qed
(*** Code *******************************************************************)
section \<open>Code\<close>
subsection \<open>Positive Cases\<close>
values "{(\<D>, \<tau>). attribute Employee name \<D> \<tau>}"
(* TODO: Тут ошибка. Потому, что если выражение имеет тип,
то должно иметь и значение. А, нет норм для 1-го варианта
будут все значения без фильтрации. Но это нужно явно отметить *)
values "{(\<D>, end). association_end Employee None employees \<D> end}"
values "{(\<D>, end).
association_end Employee (Some projectManager) employees \<D> end}"
values "{op. operation Project[1] membersCount [] op}"
values "{op. operation Project[1] membersByName [String[1]] op}"
values "{\<tau>. \<Gamma>\<^sub>0(self \<mapsto>\<^sub>f Employee[1]) \<turnstile> \<lparr>self\<rparr>\<^bold>.projects\<^bold>.members : \<tau>}"
subsection \<open>Negative Cases\<close>
values "{(\<D>, \<tau>). attribute Employee STR ''name2'' \<D> \<tau>}"
values "{\<tau>. \<Gamma>\<^sub>0 \<turnstile> Sequence{\<^bold>1..\<^bold>5, null}->max() : \<tau>}"
end