activefacts 0.8.10 → 0.8.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. data/Rakefile +3 -2
  2. data/bin/afgen +25 -23
  3. data/bin/cql +9 -8
  4. data/css/orm2.css +23 -3
  5. data/examples/CQL/CompanyDirectorEmployee.cql +1 -1
  6. data/examples/CQL/Diplomacy.cql +3 -3
  7. data/examples/CQL/Insurance.cql +27 -21
  8. data/examples/CQL/Metamodel.cql +12 -8
  9. data/examples/CQL/MetamodelNext.cql +172 -149
  10. data/examples/CQL/ServiceDirector.cql +17 -17
  11. data/examples/CQL/Supervision.cql +3 -5
  12. data/examples/CQL/WaiterTips.cql +1 -1
  13. data/examples/CQL/unit.cql +1 -1
  14. data/index.html +0 -0
  15. data/lib/activefacts/cql/FactTypes.treetop +41 -8
  16. data/lib/activefacts/cql/Language/English.treetop +10 -0
  17. data/lib/activefacts/cql/ObjectTypes.treetop +3 -1
  18. data/lib/activefacts/cql/Terms.treetop +34 -53
  19. data/lib/activefacts/cql/compiler.rb +1 -1
  20. data/lib/activefacts/cql/compiler/clause.rb +21 -8
  21. data/lib/activefacts/cql/compiler/constraint.rb +3 -1
  22. data/lib/activefacts/cql/compiler/entity_type.rb +1 -1
  23. data/lib/activefacts/cql/compiler/fact_type.rb +9 -3
  24. data/lib/activefacts/cql/compiler/join.rb +3 -0
  25. data/lib/activefacts/cql/compiler/value_type.rb +9 -4
  26. data/lib/activefacts/cql/parser.rb +11 -3
  27. data/lib/activefacts/generate/oo.rb +3 -3
  28. data/lib/activefacts/generate/ordered.rb +0 -4
  29. data/lib/activefacts/input/orm.rb +305 -250
  30. data/lib/activefacts/persistence/tables.rb +6 -0
  31. data/lib/activefacts/support.rb +18 -0
  32. data/lib/activefacts/version.rb +1 -1
  33. data/lib/activefacts/vocabulary/extensions.rb +59 -20
  34. data/lib/activefacts/vocabulary/metamodel.rb +23 -13
  35. data/lib/activefacts/vocabulary/verbaliser.rb +5 -3
  36. data/spec/absorption_spec.rb +3 -2
  37. data/spec/cql/comparison_spec.rb +1 -3
  38. data/spec/cql/context_spec.rb +1 -1
  39. data/spec/cql/entity_type_spec.rb +2 -2
  40. data/spec/cql/expressions_spec.rb +2 -4
  41. data/spec/cql/fact_type_matching_spec.rb +55 -3
  42. data/spec/cql/parser/fact_types_spec.rb +3 -0
  43. data/spec/cql/role_matching_spec.rb +8 -7
  44. data/spec/cql/samples_spec.rb +10 -2
  45. data/spec/cql_dm_spec.rb +2 -1
  46. data/spec/helpers/array_matcher.rb +18 -35
  47. data/spec/helpers/diff_matcher.rb +34 -13
  48. data/spec/helpers/file_matcher.rb +27 -43
  49. data/spec/helpers/string_matcher.rb +23 -33
  50. data/spec/norma_cql_spec.rb +1 -0
  51. data/spec/norma_tables_spec.rb +1 -2
  52. metadata +95 -102
data/Rakefile CHANGED
@@ -1,6 +1,7 @@
1
1
  %w[rubygems hoe rake rake/clean fileutils newgem thread rubigen].each { |f|
2
2
  require f
3
3
  }
4
+ Hoe.plugin :gemspec
4
5
 
5
6
  require 'rspec'
6
7
  require 'rspec/core/rake_task'
@@ -21,13 +22,13 @@ formal logic, producing a formal language that reads like plain
21
22
  English. ActiveFacts converts semantic models from CQL to relational
22
23
  and object models in SQL, Ruby and other languages.
23
24
  }
24
- p.url = "http://dataconstellation.com/ActiveFacts/"
25
+ # p.url = "http://dataconstellation.com/ActiveFacts/"
25
26
  p.developer('Clifford Heath', 'cjh@dataconstellation.org')
26
27
  p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
27
28
  p.post_install_message = 'For more information on ActiveFacts, see http://dataconstellation.com/ActiveFacts'
28
29
  p.rubyforge_name = "cjheath@rubyforge.org"
29
30
  p.extra_deps = [
30
- ['activefacts-api','>= 0.8.10'],
31
+ ['activefacts-api','>= 0.8.12'],
31
32
  ['treetop','>= 1.4.1'],
32
33
  ['rake','>= 0.8.7'],
33
34
  ]
data/bin/afgen CHANGED
@@ -8,20 +8,10 @@ $:.unshift File.dirname(File.expand_path(__FILE__))+"/../lib"
8
8
 
9
9
  require 'rubygems'
10
10
 
11
- # Load the ruby debugger before everything else, if requested
12
- if d = ENV['DEBUG'] and d.split(/,/).include?('debug')
13
- begin
14
- require 'ruby-debug'
15
- Debugger.start(:post_mortem => true) # Stop when an exception is thrown, but before it's rescued
16
- rescue LoadError
17
- # Ok, no debugger, tough luck.
18
- end
19
- end
20
-
21
11
  require 'activefacts'
22
12
  require 'activefacts/vocabulary'
23
13
 
24
- arg = ARGV.shift
14
+ arg = ARGV.shift || "--help"
25
15
 
26
16
  # Load the required generator, or the default "text" generator:
27
17
  generator = "text"
@@ -33,29 +23,41 @@ if arg =~ /^--([^=]*)(?:=(.*))?/
33
23
  end
34
24
 
35
25
  output_handler = "activefacts/generate/#{generator.downcase}"
36
- require output_handler
26
+ begin
27
+ require output_handler
28
+ rescue LoadError
29
+ $stderr.puts "Could not find output generator #{generator}. Try --help"
30
+ exit 1
31
+ end
37
32
  output_class = generator.upcase.gsub(%r{[/\\]+},'::')
38
33
  output_klass = eval("ActiveFacts::Generate::#{output_class}")
39
34
  raise "Expected #{output_handler} to define #{output_class}" unless output_klass
40
35
 
41
36
  # Load the file type input method
42
- arg, *options = *arg.split(/=/)
43
- extension = arg.sub(/\A.*\./,'').downcase
44
- input_handler = "activefacts/input/#{extension}"
45
- require input_handler
46
-
47
- input_class = extension.upcase
48
- input_klass = ActiveFacts::Input.const_get(input_class.to_sym)
49
- raise "Expected #{input_handler} to define #{input_class}" unless input_klass
37
+ if arg
38
+ arg, *options = *arg.split(/=/)
39
+ extension = arg.sub(/\A.*\./,'').downcase
40
+ input_handler = "activefacts/input/#{extension}"
41
+ require input_handler
42
+
43
+ input_class = extension.upcase
44
+ input_klass = ActiveFacts::Input.const_get(input_class.to_sym)
45
+ raise "Expected #{input_handler} to define #{input_class}" unless input_klass
46
+ end
50
47
 
51
48
  # Read the input file:
52
49
  begin
53
- vocabulary = input_klass.readfile(arg, *options)
50
+ if input_klass
51
+ vocabulary = input_klass.readfile(arg, *options)
52
+ else
53
+ vocabulary = true
54
+ end
54
55
 
55
56
  # Generate the output:
56
57
  output_klass.new(vocabulary, *generator_options).generate if vocabulary
57
58
  rescue => e
58
- puts "#{e.message}"
59
+ $stderr.puts "#{e.message}"
59
60
  # puts "\t#{e.backtrace*"\n\t"}"
60
- puts "\t#{e.backtrace*"\n\t"}" if debug :exception
61
+ $stderr.puts "\t#{e.backtrace*"\n\t"}" if debug :exception
62
+ exit 1
61
63
  end
data/bin/cql CHANGED
@@ -1,4 +1,5 @@
1
1
  #! /usr/bin/env ruby
2
+ # encoding: UTF-8
2
3
  #
3
4
  # ActiveFacts: Interactive CQL command-line. Incomplete; only parses CQL and shows the parse trees
4
5
  #
@@ -7,14 +8,14 @@
7
8
  require 'readline'
8
9
 
9
10
  # Load the ruby debugger before everything else, if requested
10
- if d = ENV['DEBUG'] and d.split(/,/).include?('debug')
11
- begin
12
- require 'ruby-debug'
13
- Debugger.start(:post_mortem => true) # Stop when an exception is thrown, but before it's rescued
14
- rescue LoadError
15
- # Ok, no debugger, tough luck.
16
- end
17
- end
11
+ #if d = ENV['DEBUG'] and d.split(/,/).include?('debug')
12
+ # begin
13
+ # require 'ruby-debug'
14
+ # Debugger.start(:post_mortem => true) # Stop when an exception is thrown, but before it's rescued
15
+ # rescue LoadError
16
+ # # Ok, no debugger, tough luck.
17
+ # end
18
+ #end
18
19
 
19
20
  require 'activefacts'
20
21
  require 'activefacts/cql/compiler'
@@ -1,3 +1,11 @@
1
+ ul {
2
+ margin: 0px 0px 0px 2em;
3
+ -webkit-margin-before: 0px;
4
+ -webkit-margin-after: 0px;
5
+ -webkit-padding-start: 0px;
6
+ padding: 0px;
7
+ }
8
+
1
9
  pre {
2
10
  background-color: #000;
3
11
  padding: 5px;
@@ -7,18 +15,30 @@ pre {
7
15
  border-color: #BBB;
8
16
  }
9
17
 
18
+ span {
19
+ font-family: "Frutiger", sans-serif;
20
+ }
21
+
10
22
  .keyword {
11
23
  Xcolor: #00F;
12
24
  color: #66F;
13
25
  }
14
- .concept {
26
+ .term, .concept {
15
27
  Xcolor: #808;
16
28
  color: #E0E;
17
29
  }
18
- .copula {
30
+ .vocabulary, .object_type {
31
+ Xcolor: #808;
32
+ color: #E0E;
33
+ }
34
+ .linking, .copula {
19
35
  Xcolor: #060;
20
36
  color: #0C0;
21
37
  }
22
- .value {
38
+ .literal, .value {
23
39
  color: #FF990E;
24
40
  }
41
+
42
+ dd {
43
+ margin-bottom: 0.5em;
44
+ }
@@ -49,4 +49,4 @@ Manager is ceo;
49
49
  /*
50
50
  * Constraints:
51
51
  */
52
- either Employee is supervised by Manager(2) or Employee is a Manager(1) that is ceo but not both;
52
+ either Employee is supervised by Manager(1) or Employee is a Manager(2) that is ceo but not both;
@@ -38,10 +38,10 @@ Representation is where
38
38
  for each Diplomat, Country at most one of these holds:
39
39
  Diplomat serves in Country,
40
40
  Diplomat represents Country;
41
- Diplomat is an Ambassador that is from Country(2) to Country(1)
42
- only if Diplomat represents Country(2);
43
41
  Diplomat is an Ambassador that is from Country(1) to Country(2)
44
- only if Diplomat serves in Country(2);
42
+ only if Diplomat represents Country(1);
43
+ Diplomat is an Ambassador that is from Country(2) to Country(1)
44
+ only if Diplomat serves in Country(1);
45
45
  Diplomat serves in Country
46
46
  only if Diplomat speaks Language that is spoken in Country;
47
47
  each Ambassador occurs at least one time in
@@ -18,10 +18,10 @@ Cover Type Code is written as Char;
18
18
  Cover Type Name is written as String;
19
19
  Date is written as Date;
20
20
  Date Time is written as Date Time;
21
- Demerit Kind Name is written as String;
22
21
  Description is written as String(1024);
23
22
  Email is written as String;
24
23
  Engine Number is written as String;
24
+ Hospital Name is written as String;
25
25
  ITC Claimed is written as Decimal(18,2) restricted to {0.0..100.0};
26
26
  Intoxication is written as String;
27
27
  Liability Code is written as Char(1) restricted to {'D', 'L', 'R', 'U'};
@@ -41,7 +41,6 @@ Policy Serial is written as Unsigned Integer(32) restricted to {1..99999};
41
41
  Policy Wording Text is written as String;
42
42
  Postcode is written as String;
43
43
  Price is written as Decimal(18,2);
44
- Prod Description is written as String(80);
45
44
  Product Code is written as Unsigned Integer(8) restricted to {1..99};
46
45
  Reason is written as String;
47
46
  Registration Nr is written as Char(8);
@@ -50,8 +49,10 @@ State Code is written as Unsigned Integer(8) restricted to {0..9};
50
49
  State Name is written as String(256);
51
50
  Street is written as String(256);
52
51
  Test Result is written as String;
52
+ Text is written as String;
53
53
  Time is written as Time;
54
54
  Title is written as String;
55
+ Underwriting Question ID is written as Auto Counter;
55
56
  VIN is written as Unsigned Integer(32);
56
57
  Year Nr is written as Signed Integer(32);
57
58
 
@@ -70,7 +71,7 @@ Cover Type is identified by its Code;
70
71
  Cover Type has one Cover Type Name,
71
72
  Cover Type Name is of at most one Cover Type;
72
73
 
73
- Demerit Kind is independent identified by its Name;
74
+ Hospital is identified by its Name;
74
75
 
75
76
  Incident is identified by Claim where
76
77
  Claim concerns at most one Incident,
@@ -123,8 +124,8 @@ Policy Wording is identified by its Text;
123
124
  Product is identified by its Code;
124
125
  Alias is of at most one Product,
125
126
  Product has at most one Alias;
126
- Prod Description is of at most one Product,
127
- Product has at most one Prod Description;
127
+ Description is of at most one Product,
128
+ Product has at most one Description;
128
129
 
129
130
  Registration is identified by its Nr;
130
131
 
@@ -132,6 +133,10 @@ State is independent identified by its Code;
132
133
  State Name is of at most one State,
133
134
  State has at most one State Name;
134
135
 
136
+ Underwriting Question is identified by its ID;
137
+ Text is of at most one Underwriting Question,
138
+ Underwriting Question has one Text;
139
+
135
140
  Vehicle is a kind of Asset identified by VIN where
136
141
  Vehicle has one VIN,
137
142
  VIN is of at most one Vehicle;
@@ -177,8 +182,6 @@ Witness lives at at most one Address;
177
182
 
178
183
  Authorised Rep is a kind of Party;
179
184
 
180
- Client is a kind of Party;
181
-
182
185
  Company is a kind of Party;
183
186
  Company has one contact-Person,
184
187
  Person is contact for Company;
@@ -205,17 +208,14 @@ Cover Wording is where
205
208
  Dealer is a kind of Party;
206
209
  Vehicle was sold by at most one Dealer;
207
210
 
208
- Driver is a kind of Person;
209
-
210
211
  Driving is where
211
- Vehicle Incident involves one Driver,
212
- Driver drove covered vehicle in at least one Vehicle Incident;
212
+ Vehicle Incident occurred while being driven;
213
213
  Driving followed at most one Intoxication;
214
- Driving resulted in at most one blood-Test Result;
215
214
  Driving resulted in at most one breath-Test Result;
216
- Driving (as driver_hospitalised) resulted in driver taken to at most one hospital-Name;
217
215
  Driving was without owners consent for at most one nonconsent-Reason;
218
216
  Driving was unlicenced for at most one unlicensed-Reason;
217
+ Person was Driving,
218
+ Driving was by one Person;
219
219
 
220
220
  Driving Charge is where
221
221
  Driving resulted in one Charge;
@@ -224,13 +224,19 @@ Driving Charge is a warning;
224
224
  Finance Institution is a kind of Company;
225
225
  Vehicle is subject to finance with at most one Finance Institution;
226
226
 
227
+ Hospitalization is where
228
+ Driving resulted in driver taken to one Hospital;
229
+ Hospitalization resulted in at most one blood-Test Result;
230
+
231
+ Insured is a kind of Party;
232
+
227
233
  Insurer is a kind of Company;
228
234
 
229
235
  Investigator is a kind of Contractor;
230
236
 
231
- License is identified by Driver where
232
- Driver holds at most one License,
233
- License is held by one Driver;
237
+ License is identified by Person where
238
+ Person holds at most one License,
239
+ License is held by one Person;
234
240
  License has one License Number,
235
241
  License Number is of at most one License;
236
242
  License is of one License Type,
@@ -255,8 +261,8 @@ ITC Claimed is for Policy,
255
261
  Policy has at most one ITC Claimed;
256
262
  Policy was sold by at most one Authorised Rep,
257
263
  Authorised Rep sold Policy;
258
- Policy belongs to one Client,
259
- Client has Policy;
264
+ Policy belongs to one Insured,
265
+ Insured has Policy;
260
266
 
261
267
  Property Damage is identified by Incident and Address where
262
268
  Incident caused Property Damage,
@@ -277,11 +283,11 @@ Third Party vehicle is of at most one Vehicle Type;
277
283
  Third Party vehicle is of at most one model-Year;
278
284
  Third Party drove at most one vehicle-Registration;
279
285
 
280
- Underwriting Demerit is identified by Vehicle Incident and Demerit Kind where
286
+ Underwriting Demerit is identified by Vehicle Incident and Underwriting Question where
281
287
  Vehicle Incident occurred despite Underwriting Demerit,
282
288
  Underwriting Demerit preceded one Vehicle Incident,
283
- Underwriting Demerit has one Demerit Kind,
284
- Demerit Kind is of Underwriting Demerit;
289
+ Underwriting Demerit has one Underwriting Question,
290
+ Underwriting Question is of Underwriting Demerit;
285
291
  Underwriting Demerit occurred at most one occurrence-Count times;
286
292
 
287
293
  Assessor is a kind of Contractor;
@@ -154,11 +154,12 @@ Subset Constraint covers one superset-Role Sequence;
154
154
  Unit is identified by its Id;
155
155
  Ephemera URL provides Unit coefficient,
156
156
  Unit uses coefficient from at most one Ephemera URL;
157
- Name is of Unit,
157
+ Name is of at most one Unit,
158
158
  Unit is called one Name;
159
159
  Unit has at most one Coefficient;
160
160
  Unit has at most one Offset;
161
- Unit has at most one plural-Name;
161
+ Unit has at most one plural-Name,
162
+ plural-Name id of at most one Unit;
162
163
  Unit is fundamental;
163
164
 
164
165
  Value is identified by Literal and Value is a string and Unit where
@@ -333,7 +334,7 @@ Value Type has at most one Scale,
333
334
  Value Type is of at most one Unit;
334
335
  Value Type has at most one Value Constraint,
335
336
  Value Constraint constrains at most one Value Type;
336
- Value Type has at most one auto- assigned Transaction Timing;
337
+ Value Type has at most one auto-- assigned Transaction Timing;
337
338
  Value Type is subtype of at most one super-Value Type (as Supertype) [acyclic],
338
339
  Supertype is supertype of Value Type;
339
340
 
@@ -343,6 +344,7 @@ Allowed Range is where
343
344
  Entity Type is a kind of Object Type;
344
345
  Entity Type nests at most one Fact Type,
345
346
  Fact Type is nested as at most one Entity Type;
347
+ Entity Type is implied by objectification;
346
348
 
347
349
  Facet is where
348
350
  Value Type has facet called Name,
@@ -376,8 +378,8 @@ either Object Type is an Entity Type or Object Type is a Value Type but not both
376
378
  for each Role Sequence exactly one of these holds:
377
379
  Role Sequence is for Reading,
378
380
  Presence Constraint covers Role Sequence,
379
- Subset Constraint(1) covers subset-Role Sequence,
380
- Subset Constraint(2) covers superset-Role Sequence,
381
+ Subset Constraint (1) covers subset-Role Sequence,
382
+ Subset Constraint (2) covers superset-Role Sequence,
381
383
  Role Sequence is Ordinal in Set Comparison Constraint;
382
384
  either Set Comparison Constraint is a Set Exclusion Constraint or Set Comparison Constraint is a Set Equality Constraint but not both;
383
385
  either Set Constraint is a Set Comparison Constraint or Set Constraint is a Subset Constraint but not both;
@@ -389,10 +391,10 @@ for each Instance at most one of these holds:
389
391
  Instance has Value,
390
392
  Instance objectifies Fact;
391
393
  for each Join Role at most one of these holds:
392
- Join Step(1) has input-Join Role,
394
+ Join Step (1) has input-Join Role,
393
395
  Join Role is incidentally involved in Join Step;
394
396
  for each Join Role at most one of these holds:
395
- Join Step(1) has output-Join Role,
397
+ Join Step (1) has output-Join Role,
396
398
  Join Role is incidentally involved in Join Step;
397
399
  Join Node is for Object Type that plays Role
398
400
  if and only if
@@ -402,7 +404,9 @@ Role Value is of Instance that is of Object Type
402
404
  Role Value is of Role that is played by Object Type;
403
405
  Role Value fulfils Fact that is of Fact Type
404
406
  if and only if
405
- Role Value is of Role (where Fact Type has Ordinal role);
407
+ Role Value is of Role (in which Fact Type has Ordinal role);
408
+ Entity Type is implied by objectification
409
+ only if Entity Type nests Fact Type;
406
410
  Presence Constraint is preferred identifier
407
411
  only if Presence Constraint has max Frequency;
408
412
  Value Type has Scale
@@ -5,7 +5,7 @@ vocabulary Metamodel;
5
5
  */
6
6
  Adjective is written as String(64);
7
7
  Agent Name is written as String;
8
- Assimilation is written as String restricted to {'partitioned', 'separate'};
8
+ Assimilation is written as String restricted to {'absorbed', 'partitioned', 'separate'};
9
9
  Context Note Kind is written as String restricted to {'as_opposed_to', 'because', 'so_that', 'to_avoid'};
10
10
  Date is written as Date;
11
11
  Denominator is written as Unsigned Integer(32);
@@ -22,10 +22,11 @@ Literal is written as String;
22
22
  Name is written as String(64);
23
23
  Numerator is written as Decimal;
24
24
  Offset is written as Decimal;
25
- Ordinal is written as Unsigned Integer(16);
25
+ Position is written as Unsigned Integer(16);
26
26
  Pronoun is written as String(20) restricted to {'feminine', 'masculine', 'neuter', 'personal'};
27
27
  Ring Type is written as String;
28
28
  Rotation Setting is written as String restricted to {'left', 'right'};
29
+ SID is written as GUID;
29
30
  Scale is written as Unsigned Integer(32);
30
31
  Subscript is written as Unsigned Integer(16);
31
32
  Text is written as String(256);
@@ -39,22 +40,28 @@ Y is written as Signed Integer(32);
39
40
  */
40
41
  Agent is identified by its Name;
41
42
 
43
+ Alternatives is identified by GUID where
44
+ Alternatives has one GUID,
45
+ GUID is of at most one Alternatives;
46
+ Alternatives are exclusive;
47
+
42
48
  Coefficient is identified by Numerator and Denominator and Coefficient is precise where
43
49
  Coefficient has one Numerator,
44
50
  Coefficient has one Denominator,
45
51
  Coefficient is precise;
46
52
 
47
- Concept is identified by GUID where
48
- Concept has one GUID,
49
- GUID is of at most one Concept;
53
+ Concept is identified by SID where
54
+ Concept has one SID,
55
+ SID is of at most one Concept;
56
+ Concept has at most one model-Name;
50
57
 
51
- Constraint is a kind of Concept;
58
+ Constraint is a kind of Concept [separate];
52
59
  Name is of Constraint,
53
60
  Constraint is called at most one Name;
54
61
 
55
- Context Note is identified by GUID where
56
- Context Note has one GUID,
57
- GUID is of at most one Context Note;
62
+ Context Note is identified by SID where
63
+ Context Note has one SID,
64
+ SID is of at most one Context Note;
58
65
  Concept has Context Note,
59
66
  Context Note applies to at most one Concept;
60
67
  Context Note has one Context Note Kind,
@@ -69,69 +76,54 @@ Enforcement notifies at most one Agent;
69
76
  Enforcement has one Enforcement Code,
70
77
  Enforcement Code is of Enforcement;
71
78
 
72
- Fact is identified by GUID where
73
- Fact has one GUID,
74
- GUID is of at most one Fact;
79
+ Fact is a kind of Concept [separate];
75
80
 
76
- Fact Type is a kind of Concept;
81
+ Fact Type is a kind of Concept [separate];
77
82
  Fact is of one Fact Type;
78
83
 
79
84
  Implicit Fact Type is a kind of Fact Type;
80
85
 
81
- Instance is identified by GUID where
82
- Instance has one GUID,
83
- GUID is of at most one Instance;
86
+ Instance is a kind of Concept;
84
87
  Instance objectifies at most one Fact,
85
88
  Fact is objectified as at most one Instance;
86
89
 
87
- Join is identified by GUID where
88
- Join has one GUID,
89
- GUID is of at most one Join;
90
-
91
- Join Node is identified by Join and Ordinal where
92
- Join includes Join Node,
93
- Join Node is in one Join,
94
- Join Node has one Ordinal position;
95
- Join Node has at most one Subscript,
96
- Subscript is of Join Node;
97
- Join Node has at most one role-Name,
98
- Name is of Join Node;
99
-
100
90
  Language is identified by its Code;
101
91
 
102
- Object Type is a kind of Concept;
103
- Instance is of one Object Type;
104
- Join Node is for one Object Type,
105
- Object Type is referenced in Join Node;
106
- Object Type uses at most one Pronoun;
107
- Object Type is independent;
92
+ Location is identified by X and Y where
93
+ Location is at one X,
94
+ Location is at one Y;
108
95
 
109
- Position is identified by X and Y where
110
- Position is at one X,
111
- Position is at one Y;
96
+ ObjectType is a kind of Concept;
97
+ Instance is of one ObjectType;
98
+ ObjectType is independent;
112
99
 
113
- Presence Constraint is a kind of Constraint;
100
+ Presence Constraint is a kind of Constraint [partitioned];
114
101
  Presence Constraint has at most one max-Frequency restricted to {1..};
115
102
  Presence Constraint has at most one min-Frequency restricted to {2..};
116
103
  Presence Constraint is mandatory;
117
104
  Presence Constraint is preferred identifier;
118
105
 
119
- Reading is identified by Fact Type and Ordinal where
106
+ Query is independent identified by GUID where
107
+ Query has one GUID,
108
+ GUID is of at most one Query;
109
+
110
+ Reading is identified by Fact Type and Position where
120
111
  Fact Type has Reading,
121
112
  Reading is for one Fact Type,
122
- Reading is in one Ordinal position,
123
- Ordinal reading for fact type is Reading;
124
- Reading has one Text;
113
+ Reading is in one Position,
114
+ Position is of Reading;
115
+ Reading has one leading-Text;
125
116
 
126
- Ring Constraint is a kind of Constraint;
117
+ Ring Constraint is a kind of Constraint [partitioned];
127
118
  Ring Constraint is of one Ring Type;
128
119
 
129
- Role is a kind of Concept where
130
- Fact Type has at least one Ordinal role;
120
+ Role is a kind of Concept identified by Fact Type and Position [separate] where
121
+ Fact Type includes role of at least one ObjectType,
122
+ ObjectType plays role in Fact Type,
123
+ Role is in at most one Position,
124
+ Position is occupied by at least one Role;
131
125
  Implicit Fact Type is implied by one Role (as Implying Role),
132
126
  Implying Role implies at most one Implicit Fact Type;
133
- Object Type plays Role,
134
- Role is played by one Object Type;
135
127
  Ring Constraint has at most one other-Role,
136
128
  other-Role is of Ring Constraint;
137
129
  Role is of Ring Constraint; // Avoid ambiguity; this is a new fact type
@@ -142,23 +134,21 @@ Role Sequence is identified by GUID where
142
134
  Role Sequence has one GUID,
143
135
  GUID is of at most one Role Sequence;
144
136
  Presence Constraint covers one Role Sequence;
145
- Reading is in one Role Sequence,
146
- Role Sequence is for Reading;
147
137
  Role Sequence has unused dependency to force table in norma;
148
138
 
149
139
  Role Value is identified by Instance and Fact where
150
140
  Instance plays Role Value,
151
141
  Role Value is of one Instance,
152
142
  Role Value fulfils one Fact,
153
- Fact includes at least one Role Value;
143
+ Fact includes Role Value;
154
144
  Role Value is of one Role;
155
145
 
156
- Set Constraint is a kind of Constraint;
146
+ Set Constraint is a kind of Constraint [partitioned];
157
147
 
158
- Shape is identified by GUID where
159
- Shape has one GUID,
160
- GUID is of at most one Shape;
161
- Shape is at at most one Position;
148
+ Shape is identified by SID where
149
+ Shape has one SID,
150
+ SID is of at most one Shape;
151
+ Shape is at at most one Location;
162
152
  Shape is expanded;
163
153
 
164
154
  Subset Constraint is a kind of Set Constraint;
@@ -187,27 +177,30 @@ Value is identified by Literal and Value is a string and Unit where
187
177
  Unit is of Value;
188
178
  Instance has at most one Value,
189
179
  Value is of Instance;
190
- Join Node has at most one Value;
191
180
 
192
- Value Constraint is a kind of Constraint;
181
+ Value Constraint is a kind of Constraint [partitioned];
193
182
  Role has at most one role-Value Constraint,
194
183
  Value Constraint applies to at most one Role;
195
184
 
196
- Value Type is a kind of Object Type;
197
- Value Type has at most one Length,
198
- Length is of Value Type;
199
- Value Type has at most one Scale,
200
- Scale is of Value Type;
201
- Value Type is of at most one Unit;
202
- Value Type has at most one Value Constraint,
203
- Value Constraint constrains at most one Value Type;
204
- Value Type has at most one auto- assigned Transaction Timing;
205
- Value Type is subtype of at most one super-Value Type (as Supertype) [acyclic],
206
- Supertype is supertype of Value Type;
207
-
208
- Vocabulary is where
209
- Topic is described in Language,
210
- Language describes Topic;
185
+ Variable is identified by Query and Position where
186
+ Query includes Variable,
187
+ Variable is in one Query,
188
+ Variable occupies one Position,
189
+ Position is occupied by Variable;
190
+ Variable references one ObjectType,
191
+ ObjectType is referenced in Variable;
192
+ Variable projects at most one Role;
193
+ Variable has at most one Subscript,
194
+ Subscript is of Variable;
195
+ Variable is bound to at most one Value;
196
+ Variable has at most one role-Name,
197
+ Name is of Variable;
198
+
199
+ Vocabulary is identified by Topic and Language where
200
+ Topic is described in Vocabulary,
201
+ Vocabulary describes one Topic,
202
+ Language provides Vocabulary,
203
+ Vocabulary uses at most one Language;
211
204
  Reading is for at most one Vocabulary,
212
205
  Vocabulary contains Reading;
213
206
  Vocabulary contains Constraint,
@@ -238,6 +231,8 @@ Context Agreed By is where
238
231
  Agreement was reached by Agent,
239
232
  Agent agreed on Agreement;
240
233
 
234
+ Data Type is a kind of ObjectType;
235
+
241
236
  Derivation is where
242
237
  Unit (as Derived Unit) is derived from base-Unit (as Base Unit) [acyclic, intransitive];
243
238
  Derivation has at most one Exponent;
@@ -250,18 +245,13 @@ Diagram is identified by Vocabulary and Name where
250
245
  Shape is in one Diagram,
251
246
  Diagram includes Shape;
252
247
 
253
- Entity Type is a kind of Object Type;
248
+ Domain Object Type is a kind of ObjectType;
249
+ Domain Object Type uses at most one Pronoun;
250
+
251
+ Entity Type is a kind of Domain Object Type;
254
252
  Entity Type objectifies at most one Fact Type,
255
253
  Fact Type is objectified as at most one Entity Type;
256
-
257
- Facet is where
258
- Value Type has facet called Name,
259
- Name is a facet of Value Type;
260
- Facet has values of at most one Value Type;
261
-
262
- Facet Value is where
263
- Value Type defines Facet as having one Value,
264
- Value for Facet applies to Value Type;
254
+ Entity Type results from implicit objectification;
265
255
 
266
256
  Fact Type Shape is a kind of Shape;
267
257
  Fact Type Shape has at most one Display Role Names Setting;
@@ -269,28 +259,12 @@ Fact Type Shape is for one Fact Type,
269
259
  Fact Type has Fact Type Shape;
270
260
  Fact Type Shape has at most one Rotation Setting;
271
261
 
272
- Implicit Boolean Value Type is a kind of Value Type;
273
-
274
- Join Role is independent where
275
- Join Node includes at least one Role,
276
- Role connects to Join Node;
277
-
278
- Join Step is identified by input-Join Role and output-Join Role where
279
- Join Step has one input-Join Role,
280
- Join Step has one output-Join Role;
281
- Join Step traverses one Fact Type,
282
- Fact Type directs Join Step;
283
- Join Step involves incidental-Join Role,
284
- Join Role is incidentally involved in at most one Join Step;
285
- is anti Join Step;
286
- Join Step is outer;
287
-
288
262
  Model Note Shape is a kind of Shape;
289
263
  Model Note Shape is for one Context Note;
290
264
 
291
265
  Object Type Shape is a kind of Shape;
292
- Object Type Shape is for one Object Type,
293
- Object Type has Object Type Shape;
266
+ Object Type Shape is for one Domain Object Type,
267
+ Domain Object Type has Object Type Shape;
294
268
  Object Type Shape has expanded reference mode;
295
269
 
296
270
  Objectified Fact Type Name Shape is a kind of Shape identified by Fact Type Shape where
@@ -309,6 +283,12 @@ Population includes Instance,
309
283
  Population includes Role Value,
310
284
  Role Value belongs to one Population;
311
285
 
286
+ ReadingRole is where
287
+ Role has Position in Reading;
288
+ ReadingRole has at most one following-Text;
289
+ ReadingRole has at most one leading-Adjective;
290
+ ReadingRole has at most one trailing-Adjective;
291
+
312
292
  Reading Shape is a kind of Shape identified by Fact Type Shape where
313
293
  Fact Type Shape has at most one Reading Shape,
314
294
  Reading Shape is for one Fact Type Shape;
@@ -319,39 +299,52 @@ Ring Constraint Shape is a kind of Constraint Shape;
319
299
  Ring Constraint Shape is attached to one Fact Type;
320
300
 
321
301
  Role Display is where
322
- Fact Type Shape displays Role in Ordinal position,
323
- Fact Type Shape displays in Ordinal position one Role;
302
+ Fact Type Shape displays Role in Position,
303
+ Fact Type Shape fills Position with one Role;
324
304
 
325
305
  Role Name Shape is a kind of Shape;
326
306
  Role Name Shape is for one Role Display,
327
307
  Role Display has at most one Role Name Shape;
328
308
 
329
309
  Role Ref is where
330
- Role Sequence in Ordinal position includes one Role,
331
- Role is in Role Sequence in one Ordinal place,
332
- Role Sequence includes Role in Ordinal place,
333
- Role has Ordinal place in Role Sequence;
334
- Join Role projects at most one Role Ref;
335
- Role Ref has at most one leading-Adjective;
336
- Role Ref has at most one trailing-Adjective;
310
+ Role Sequence fills Position with one Role,
311
+ Role Sequence places Role in one Position,
312
+ Role occupies Position in Role Sequence;
337
313
 
338
314
  Set Comparison Constraint is a kind of Set Constraint;
339
315
 
340
316
  Set Comparison Roles is where
341
- Set Comparison Constraint has in Ordinal position one Role Sequence,
342
- Role Sequence is Ordinal in Set Comparison Constraint,
343
- in Ordinal position Set Comparison Constraint has Role Sequence,
344
- Set Comparison Constraint has Role Sequence in one Ordinal position;
317
+ Set Comparison Constraint fills Position with one Role Sequence,
318
+ Role Sequence occupies Position in Set Comparison Constraint,
319
+ Position in Set Comparison Constraint is occupied by Role Sequence,
320
+ Set Comparison Constraint places Role Sequence in one Position;
345
321
 
346
322
  Set Equality Constraint is a kind of Set Comparison Constraint;
347
323
 
348
324
  Set Exclusion Constraint is a kind of Set Comparison Constraint;
349
325
  Set Exclusion Constraint is mandatory;
350
326
 
327
+ Span is independent where
328
+ Variable allows players of at least one Role,
329
+ Role populates Variable;
330
+
331
+ Step is identified by input-Span and output-Span where
332
+ Step has one input-Span,
333
+ Step has one output-Span;
334
+ Alternatives include at least one Step,
335
+ Step has at most one Alternatives;
336
+ Step traverses one Fact Type,
337
+ Fact Type directs Step;
338
+ Step involves incidental-Span,
339
+ Span is incidentally involved in at most one Step;
340
+ Step is disallowed;
341
+ Step is optional;
342
+
351
343
  Term is where
352
- Vocabulary uses Name for one Object Type,
353
- Vocabulary refers to Object Type as Name,
354
- Name applies to Object Type in Vocabulary;
344
+ Vocabulary uses Name,
345
+ Name applies in Vocabulary;
346
+ Term applies to at most one Domain Object Type;
347
+ Term applies to at most one Instance;
355
348
  Term (as Role Name) is name of Role,
356
349
  Role has at most one Role Name;
357
350
  Term is preferred;
@@ -375,28 +368,54 @@ Value Range is identified by minimum-Bound and maximum-Bound where
375
368
  Value Range has at most one minimum-Bound,
376
369
  Value Range has at most one maximum-Bound;
377
370
 
371
+ Value Type is a kind of Domain Object Type;
372
+ Value Type maps to at most one Data Type;
373
+ Value Type has at most one Length,
374
+ Length is of Value Type;
375
+ Value Type has at most one Scale,
376
+ Scale is of Value Type;
377
+ Value Type is of at most one Unit;
378
+ Value Type has at most one Value Constraint,
379
+ Value Constraint constrains at most one Value Type;
380
+ Value Type is at most one auto-- assigned at Transaction Timing;
381
+ Value Type is subtype of at most one super-Value Type (as Supertype) [acyclic, intransitive],
382
+ Supertype is supertype of Value Type;
383
+
378
384
  Allowed Range is where
379
385
  Value Constraint allows at least one Value Range;
380
386
 
387
+ Facet is where
388
+ Value Type has facet called Name,
389
+ Name is a facet of Value Type;
390
+ Facet has values of at most one facet-Value Type;
391
+
392
+ Facet Value is where
393
+ Value Type defines Facet as having one Value,
394
+ Value for Facet applies to Value Type;
395
+
396
+ Implicit Boolean Value Type is a kind of Value Type;
397
+
381
398
  /*
382
399
  * Constraints:
383
400
  */
384
401
  for each Concept exactly one of these holds:
385
- Concept is an Object Type,
386
402
  Concept is a Fact Type,
387
403
  Concept is a Constraint,
388
- Concept is a Role;
404
+ Concept is a Role,
405
+ Concept is a Fact,
406
+ Concept is an Instance,
407
+ Concept is an ObjectType;
389
408
  for each Constraint exactly one of these holds:
390
409
  Constraint is a Presence Constraint,
391
410
  Constraint is a Set Constraint,
392
- Constraint is a Ring Constraint;
393
- either Object Type is an Entity Type or Object Type is a Value Type but not both;
411
+ Constraint is a Ring Constraint,
412
+ Constraint is a Value Constraint;
413
+ either Domain Object Type is an Entity Type or Domain Object Type is a Value Type but not both;
394
414
  for each Role Sequence exactly one of these holds:
395
- Role Sequence is for Reading,
396
415
  Presence Constraint covers Role Sequence,
397
- Subset Constraint(1) covers subset-Role Sequence,
398
- Subset Constraint(2) covers superset-Role Sequence,
399
- Role Sequence is Ordinal in Set Comparison Constraint;
416
+ Subset Constraint (1) covers subset-Role Sequence,
417
+ Subset Constraint (2) covers superset-Role Sequence,
418
+ Role Sequence occupies Position in Set Comparison Constraint;
400
419
  either Set Comparison Constraint is a Set Exclusion Constraint or Set Comparison Constraint is a Set Equality Constraint but not both;
401
420
  either Set Constraint is a Set Comparison Constraint or Set Constraint is a Subset Constraint but not both;
402
421
  either Unit uses coefficient from Ephemera URL or Unit has Coefficient but not both;
@@ -406,29 +425,25 @@ either Value Constraint constrains Value Type or Value Constraint applies to Rol
406
425
  for each Instance at most one of these holds:
407
426
  Instance has Value,
408
427
  Instance objectifies Fact;
409
- for each Join Role at most one of these holds:
410
- Join Step(1) has input-Join Role,
411
- Join Role is incidentally involved in Join Step;
412
- for each Join Role at most one of these holds:
413
- Join Step(1) has output-Join Role,
414
- Join Role is incidentally involved in Join Step;
415
- Join Node is for Object Type that plays Role
416
- if and only if
417
- Join Node includes Role;
418
- Role Value is of Instance that is of Object Type
419
- if and only if
420
- Role Value is of Role that is played by Object Type;
421
- Role Value fulfils Fact that is of Fact Type
422
- if and only if
423
- Role Value is of Role (where Fact Type has Ordinal role);
428
+ for each Span at most one of these holds:
429
+ Step (1) has input-Span,
430
+ Span is incidentally involved in Step;
431
+ for each Span at most one of these holds:
432
+ Step (1) has output-Span,
433
+ Span is incidentally involved in Step;
434
+ for each Term at most one of these holds:
435
+ Term applies to Domain Object Type,
436
+ Term is name of Role;
437
+ Entity Type results from implicit objectification
438
+ only if Entity Type objectifies Fact Type;
424
439
  Presence Constraint is preferred identifier
425
440
  only if Presence Constraint has max Frequency;
426
441
  Value Type has Scale
427
442
  only if Value Type has Length;
428
443
  either Agreement was reached by Agent or Agreement was on Date;
429
- each combination Diagram, Position occurs at most one time in
444
+ each combination Diagram, Location occurs at most one time in
430
445
  Shape is in Diagram,
431
- Shape is at Position;
446
+ Shape is at Location;
432
447
  each combination Entity Type(1), Type Inheritance occurs at most one time in
433
448
  Entity Type(1) is subtype of super Entity Type(2),
434
449
  Type Inheritance provides identification;
@@ -436,19 +451,27 @@ each Presence Constraint occurs at least one time in
436
451
  Presence Constraint has min Frequency(2),
437
452
  Presence Constraint has max Frequency(1),
438
453
  Presence Constraint is mandatory;
439
- each Role Ref occurs at most one time in
440
- Join Role projects Role Ref;
454
+ each combination Reading, Position occurs one time in
455
+ Role has Position in Reading;
456
+ each combination Reading, Role occurs one time in
457
+ Role has Position in Reading;
441
458
  each Role Sequence occurs at least one time in
442
- Role Sequence in Ordinal position includes Role;
459
+ Role Sequence fills Position with Role;
460
+ each Role occurs at most one time in
461
+ Variable projects Role;
443
462
  each Set Comparison Constraint occurs at least 2 times in
444
- Set Comparison Constraint has in Ordinal position Role Sequence;
463
+ Set Comparison Constraint fills Position with Role Sequence;
445
464
  either Value Range has minimum Bound(2) or Value Range has maximum Bound(1);
465
+ either Value Type(1) maps to Data Type or Value Type(1) is subtype of super Value Type(2);
446
466
  each combination Vocabulary, Name occurs at most one time in
447
467
  Constraint belongs to Vocabulary,
448
468
  Constraint is called Name;
449
469
  each combination Vocabulary, Name occurs at most one time in
450
470
  Unit is in Vocabulary,
451
471
  Unit is called Name;
452
- each combination Vocabulary, Object Type, Term occurs at most one time in
453
- Vocabulary uses Name for Object Type,
454
- Term is preferred;
472
+ /*
473
+ each combination Vocabulary, Term, Domain Object Type occurs at most one time in
474
+ Vocabulary uses Name,
475
+ Term is preferred,
476
+ Term applies to Domain Object Type;
477
+ */