public
Description: Pomegranate is a Ruby library for inferencing over a corpus of triples with RDFS and OWL properties.
Homepage: http://pius.github.com/pomegranate
Clone URL: git://github.com/pius/pomegranate.git
pomegranate / .yardoc
100644 693 lines (602 sloc) 24.85 kb
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
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
[IC:SymbolHash{: Tripleo:#YARD::CodeObjects::ClassObject:@namespaceo:"YARD::CodeObjects::RootObject ;0:@docstring":@childrenIC:&YARD::CodeObjects::CodeObjectList[ o;;@;
"; IC; [o:$YARD::CodeObjects::MethodObject;@ ;
"Mdef initialize(e)
  lemmas.each {|lemma| e.assert lemma }
  super(e)
end:@signature"def rules:@short_docstring0:
@tags[:
@name:
rules: @scope: instance:@explicitT:
@linei:@visibility: public: @source"1def rules
  rdfs_rules
  rdfs_plus_rules
end:
@file"#lib/room/rdfs_plus_rulebook.rbo; ;@ ;
"def lemmas
  lemmas = []
  #implements "owl:equivalentClass"
  lemmas << Triple.new("owl:equivalentClass", "rdf:type", "owl:SymmetricProperty")
  lemmas << Triple.new("owl:equivalentClass", "rdfs:subPropertyOf", "rdfs:subClassOf")
  
  #implements "owl:equivalentProperty"
  lemmas << Triple.new("owl:equivalentProperty", "rdf:type", "owl:SymmetricProperty")
  lemmas << Triple.new("owl:equivalentProperty", "rdfs:subPropertyOf", "rdfs:subPropertyOf")
  
  return lemmas
end
nodoc;"def rdfs_plus_rules;0;[;:rdfs_plus_rules;;;T: @dynamicT;i.;;;")def rdfs_plus_rules
  ##
  # Implements Type Propagation through owl:inverseOf
  #
  # ==== Semantics
  # Given:
  # P owl:inverseOf Q
  # x P y
  #
  # Infer:
  # y Q x
  #
  # ==== Example
  # p = Triple.new(":Pius", ":took_a_class_taught_by", ":Winston");
  # h = Triple.new(":took_a_class_taught_by", "owl:inverseOf", ":taught")
  # assert p; assert h; #=> infers a triple ~= Triple.new(":Winston", "taught", ":Pius")
  #
  # @author Pius Uzamere
  def owl_inverse_of
  end
  
  rule :owl_inverse_of,
    [Triple,:fact,{m.predicate=>:pred, m.object => :new_subj, m.subject => :new_obj}],
    [Triple,:ont_statement,{m.object => :inferred_pred},m.predicate=="owl:inverseOf", m.subject == b(:pred)],
    [:not, Triple, m.predicate==b(:inferred_pred), m.subject==b(:new_subj), m.object==b(:new_obj)] do |v|
      inferred_property = v[:ont_statement].object
      obj = v[:fact].subject
      subj = v[:fact].object
      assert Triple.new(subj, inferred_property, obj)
      puts "Made type inference based on owl:inverseOf: Triple(#{subj}, #{inferred_property}, #{obj})"
  end
  
  ##
  # Implements Type Propagation through owl:SymmetricProperty
  #
  # ==== Semantics
  # Given:
  # P rdf:type owl:SymmetricProperty
  #
  # Infer:
  # P owl:inverseOf P
  #
  # ==== Example
  # p = Triple.new(":Pius", ":was_in_a_class_with", ":Adam");
  # h = Triple.new(":was_in_a_class_with", "rdf:type", "owl:SymmetricProperty")
  # assert p; assert h; #=> infers a triple ~= Triple.new(":Adam", ":was_in_a_class_with", ":Pius")
  #
  # @author Pius Uzamere
  def owl_symmetric_property
  end
  
  rule :owl_symmetric_property,
    [Triple,:ont_statement,m.predicate=="rdf:type",m.object=="owl:SymmetricProperty"] do |v|
      prop = v[:ont_statement].subject
      assert Triple.new(prop, "owl:inverseOf", prop)
      puts "Made type inference based on owl:SymmetricProperty: Triple(#{prop}, owl:inverseOf, #{prop})"
  end
  
  ##
  # Implements Type Propagation through owl:TransitiveProperty
  #
  # ==== Semantics
  # Given:
  # P rdf:type owl:TransitiveProperty
  # X P Y
  # X P Z
  #
  # Infer:
  # X P Z
  #
  # ==== Example
  # p = Triple.new(":Dirichlet", ":is_an_academic_ancestor_of", ":Minsky");
  # h = Triple.new(":Poisson", ":is_an_academic_ancestor_of", ":Dirichlet");
  # j = Triple.new(":is_an_academic_ancestor_of", "rdf:type", "owl:TransitiveProperty");
  # assert p; assert h; assert j; #=> infers a triple ~= Triple.new(":Poisson", ":is_an_academic_ancestor_of", ":Minsky")
  #
  # @author Pius Uzamere
  def owl_transitive_property
  end
      
  rule :owl_transitive_property,
    [Triple,:ont_statement,{m.subject => :trans_prop},m.predicate=="rdf:type",m.object=="owl:TransitiveProperty"],
    [Triple,:fact1,{m.predicate=>:predi, m.subject => :sub, m.object => :trans_obj}, m.predicate == b(:trans_prop), m.subject.not== m.object],
    [Triple,:fact2, m.predicate==b(:predi), m.subject==b(:trans_obj), m.predicate.not=="owl:inverseOf", m.object.not== b(:sub) ] do |v|
      subj = v[:fact1].subject
      obj = v[:fact2].object
      prop = v[:ont_statement].subject
      assert Triple.new(subj, prop, obj)
      puts "Made type inference based on owl:TransitiveProperty: Triple(#{subj}, #{prop}, #{obj})"
      if subj == ":Pius" && obj == ":Uzamere" && prop == ":is_an_academic_ancestor_of"
        raise "ho" + v[:ont_statement].inspect + v[:fact1].inspect + v[:fact2].inspect
      end
      
  end
  
  ##
  # Implements Class Equivalence through owl:equivalentClass
  #
  # ==== Semantics
  # Given:
  # A owl:equivalentClass B
  # r rdf:type A
  #
  # Infer:
  # r rdf:type B
  #
  # AND
  #
  # Given:
  # C owl:equivalentClass D
  # C rdfs:subClassOf D
  # z rdf:type D
  #
  # Infer:
  # z rdf:type C
  #
  # ==== Example
  # p = Triple.new("mit:class", "owl:equivalentClass", "mit:subject");
  # h = Triple.new(":6.111", "rdf:type", "mit:class");
  # assert p; assert h; #=> infers a triple ~= Triple.new(":6.111", ":rdf:type", ":mit:subject")
  #
  # @author Pius Uzamere
  def owl_equivalent_class
  end
  
  rule :owl_equivalent_class,
    [Triple,:ont_statement,m.predicate=="owl:equivalentClass"] do |v|
      assert Triple.new("owl:equivalentClass", "rdf:type", "owl:SymmetricProperty")
      assert Triple.new("owl:equivalentClass", "rdfs:subPropertyOf", "rdfs:subClassOf")
      #this is cute . . . only annoying thing is that you don't get the downstream explanation of the inferences
  end
  
  
  ##
  # Implements Property Equivalence through owl:equivalentProperty
  #
  # ==== Semantics
  # Given:
  # A owl:equivalentProperty B
  # r A c
  #
  # Infer:
  # r B C
  #
  # AND
  #
  # Given:
  # C owl:equivalentClass D
  # C rdfs:subClassOf D
  # z rdf:type D
  #
  # Infer:
  # z rdf:type C
  #
  # ==== Example
  # p = Triple.new("mit:took_class", "owl:equivalentProperty", "mit:took_course");
  # h = Triple.new(":Pius", "mit:took_course", ":6.111");
  # assert p; assert h; #=> infers a triple ~= Triple.new(":Pius", "mit:took_class", ":6.111")
  #
  # @author Pius Uzamere
  
  def owl_equivalent_property
  end
  
  rule :owl_equivalent_property,
    [Triple,:ont_statement,m.predicate=="owl:equivalentProperty"] do |v|
      assert Triple.new("owl:equivalentProperty", "rdf:type", "owl:SymmetricProperty")
      assert Triple.new("owl:equivalentProperty", "rdfs:subPropertyOf", "rdfs:subPropertyOf")
      #this is cute . . . only annoying thing is that you don't get the downstream explanation of the inferences
  end
 
  ##
  # Implements Individual Equivalence through owl:sameAs
  #
  # ==== Semantics
  # Given:
  # x owl:sameAs y
  # o P x
  #
  # Infer:
  # o P y
  #
  # AND
  #
  # Given:
  # x owl:sameAs y
  # x P o
  #
  # Infer:
  # z rdf:type C
  #
  # ==== Example
  # p = Triple.new(":Pius", "owl:sameAs", ":Uzamere");
  # h = Triple.new(":Pius", "mit:took_course", ":6.171");
  # assert p; assert h; #=> infers a triple ~= Triple.new(":Uzamere", "mit:took_course", ":6.171")
  #
  # @author Pius Uzamere
  
  def owl_same_as
  end
  
  rule :owl_same_as_symmetricity,
    [Triple,:ont_statement, m.predicate=="owl:sameAs"] do |v|
    assert Triple.new("owl:sameAs", "rdf:type", "owl:SymmetricProperty")
    puts "asserting the symmetricity of owl:sameAs"
  end
  
  
  rule :owl_same_as_when_subject,
 
    [Triple,:ont_statement,{m.subject => :original, m.object => :doppelganger}, m.predicate=="owl:sameAs"],
    [Triple,:fact, {m.predicate => :p, m.object => :common_object}, m.subject == b(:original), m.subject.not== b(:doppelganger), m.predicate.not== "owl:sameAs"],
    [:not, Triple, m.predicate==b(:p), m.subject==b(:doppelganger), m.object==b(:common_object)] do |v|
 
    subj = v[:ont_statement].object
    pred = v[:fact].predicate
    obj = v[:fact].object
    
    puts "Made type inference based on owl:sameAs: Triple(#{subj}, #{pred}, #{obj})"
    assert Triple.new(subj, pred, obj)
    #this is cute . . . only annoying thing is that you don't get the downstream explanation of the inferences
  end
  
  rule :owl_same_as_when_object,
    [Triple,:ont_statement,{m.object => :original, m.subject => :doppelganger}, m.predicate=="owl:sameAs"],
    [Triple,:fact, {m.predicate => :p, m.object => :ob, m.subject => :common_subject}, m.object == b(:original), m.object.not== b(:doppelganger), m.predicate.not== "owl:sameAs"],
    [:not, Triple, m.predicate==b(:p), m.subject==b(:common_subject), m.object==b(:doppelganger)] do |v|
 
    obj = v[:ont_statement].subject
    pred = v[:fact].predicate
    subj = v[:fact].subject
    
    puts "Made type inference based on owl:sameAs: Triple(#{subj}, #{pred}, #{obj})"
    assert Triple.new(subj, pred, obj)
    #this is cute . . . only annoying thing is that you don't get the downstream explanation of the inferences
  end
  
  ##
  # owl:FunctionalProperty
  #
  # ==== Semantics
  # Given:
  # P rdf:type owl:FunctionalProperty
  # x P y
  # x P z
  #
  # Infer:
  # y owl:sameAs z
  #
  # ==== Example
  # p = Triple.new("mit:had_academic_advisor", "rdf:type", "owl:FunctionalProperty");
  # h = Triple.new(":Pius", "mit:had_academic_advisor", ":Hal");
  # d = Triple.new(":Pius", "mit:had_academic_advisor", ":Dude_Who_Wrote_SICP_With_Gerald_Sussman");
  # assert p; assert h; assert d; #=> infers a triple ~= Triple.new(":Hal", "owl:sameAs", ":Dude_Who_Wrote_SICP_With_Gerald_Sussman")
  #
  # @author Pius Uzamere
  
  def owl_functional_property
  end
  
  rule :owl_functional_property,
    [Triple,:ont_statement,{m.subject => :the_prop}, m.predicate == "rdf:type", m.object=="owl:FunctionalProperty"],
    [Triple,:fact1, {m.subject => :common_subject, m.object => :first_object}, m.predicate == b(:the_prop)],
    [Triple,:fact2, {m.object => :second_object}, m.subject == b(:common_subject), m.predicate == b(:the_prop)] do |v|
 
      subj = v[:fact1].object
      obj = v[:fact2].object
      
      puts "Made type inference based on owl:FunctionalProperty: Triple(#{subj}, owl:sameAs, #{obj})"
      assert Triple.new(subj, "owl:sameAs", obj)
  end
  
  ##
  # owl:InverseFunctionalProperty
  #
  # ==== Semantics
  # Given:
  # P rdf:type owl:InverseFunctionalProperty
  # z P x
  # y P x
  #
  # Infer:
  # y owl:sameAs z
  #
  # ==== Example
  # p = Triple.new("mit:lived_alone_fall_2004_in", "rdf:type", "owl:FunctionalProperty");
  # h = Triple.new(":Pius", "mit:lived_alone_fall_2004_in", ":room_314_at_Next_House");
  # d = Triple.new(":2004_UA_President", "mit:lived_alone_fall_2004_in", ":room_314_at_Next_House");
  # assert p; assert h; assert d; #=> infers a triple ~= Triple.new(":Pius", "owl:sameAs", ":2004_UA_President")
  #
  # @author Pius Uzamere
  
  def owl_inverse_functional_property
  end
  
  rule :owl_inverse_functional_property,
    [Triple,:ont_statement,{m.subject => :the_prop}, m.predicate == "rdf:type", m.object=="owl:InverseFunctionalProperty"],
    [Triple,:fact1, {m.object => :common_object, m.subject => :first_subject}, m.predicate == b(:the_prop)],
    [Triple,:fact2, {m.subject => :second_subject}, m.object == b(:common_object), m.predicate == b(:the_prop)] do |v|
 
      subj = v[:fact1].subject
      obj = v[:fact2].subject
      
      puts "Made type inference based on owl:InverseFunctionalProperty: Triple(#{subj}, owl:sameAs, #{obj})"
      assert Triple.new(subj, "owl:sameAs", obj)
  end
 
end;@o; ;@ ;
"jImplements Type Propagation through owl:inverseOf
 
==== Semantics
  Given:
  P owl:inverseOf Q
  x P y
 
  Infer:
  y Q x
 
==== Example
  p = Triple.new(":Pius", ":took_a_class_taught_by", ":Winston");
  h = Triple.new(":took_a_class_taught_by", "owl:inverseOf", ":taught")
  assert p; assert h; #=> infers a triple ~= Triple.new(":Winston", "taught", ":Pius");"def owl_inverse_of;0;[o:YARD::Tags::Tag :
@text"Pius Uzamere;0: @types0:@tag_name" author;:owl_inverse_of;;;T;T;i@;;;"def owl_inverse_of
end;@o; ;@ ;
"Implements Type Propagation through owl:SymmetricProperty
 
==== Semantics
  Given:
  P rdf:type owl:SymmetricProperty
 
  Infer:
  P owl:inverseOf P
 
==== Example
  p = Triple.new(":Pius", ":was_in_a_class_with", ":Adam");
  h = Triple.new(":was_in_a_class_with", "rdf:type", "owl:SymmetricProperty")
  assert p; assert h; #=> infers a triple ~= Triple.new(":Adam", ":was_in_a_class_with", ":Pius");"def owl_symmetric_property;0;[o; ;"Pius Uzamere;0;0; " author;:owl_symmetric_property;;;T;T;i^;;;"#def owl_symmetric_property
end;@o; ;@ ;
"Implements Type Propagation through owl:TransitiveProperty
 
==== Semantics
  Given:
  P rdf:type owl:TransitiveProperty
  X P Y
  X P Z
 
  Infer:
  X P Z
 
==== Example
  p = Triple.new(":Dirichlet", ":is_an_academic_ancestor_of", ":Minsky");
  h = Triple.new(":Poisson", ":is_an_academic_ancestor_of", ":Dirichlet");
  j = Triple.new(":is_an_academic_ancestor_of", "rdf:type", "owl:TransitiveProperty");
  assert p; assert h; assert j; #=> infers a triple ~= Triple.new(":Poisson", ":is_an_academic_ancestor_of", ":Minsky");" def owl_transitive_property;0;[o; ;"Pius Uzamere;0;0; " author;:owl_transitive_property;;;T;T;i{;;;"$def owl_transitive_property
end;@o; ;@ ;
"Implements Class Equivalence through owl:equivalentClass
 
==== Semantics
  Given:
  A owl:equivalentClass B
  r rdf:type A
  
  Infer:
  r rdf:type B
 
     AND
 
  Given:
  C owl:equivalentClass D
  C rdfs:subClassOf D
  z rdf:type D
 
  Infer:
  z rdf:type C
 
==== Example
  p = Triple.new("mit:class", "owl:equivalentClass", "mit:subject");
  h = Triple.new(":6.111", "rdf:type", "mit:class");
  assert p; assert h; #=> infers a triple ~= Triple.new(":6.111", ":rdf:type", ":mit:subject");"def owl_equivalent_class;0;[o; ;"Pius Uzamere;0;0; " author;:owl_equivalent_class;;;T;T;i;;;"!def owl_equivalent_class
end;@o; ;@ ;
"Implements Property Equivalence through owl:equivalentProperty
 
==== Semantics
  Given:
  A owl:equivalentProperty B
  r A c
  
  Infer:
  r B C
 
     AND
 
  Given:
  C owl:equivalentClass D
  C rdfs:subClassOf D
  z rdf:type D
 
  Infer:
  z rdf:type C
 
==== Example
  p = Triple.new("mit:took_class", "owl:equivalentProperty", "mit:took_course");
  h = Triple.new(":Pius", "mit:took_course", ":6.111");
  assert p; assert h; #=> infers a triple ~= Triple.new(":Pius", "mit:took_class", ":6.111");" def owl_equivalent_property;0;[o; ;"Pius Uzamere;0;0; " author;:owl_equivalent_property;;;T;T;i;;;"$def owl_equivalent_property
end;@o; ;@ ;
"Implements Individual Equivalence through owl:sameAs
 
==== Semantics
  Given:
  x owl:sameAs y
  o P x
  
  Infer:
  o P y
 
     AND
 
  Given:
  x owl:sameAs y
  x P o
 
  Infer:
  z rdf:type C
 
==== Example
  p = Triple.new(":Pius", "owl:sameAs", ":Uzamere");
  h = Triple.new(":Pius", "mit:took_course", ":6.171");
  assert p; assert h; #=> infers a triple ~= Triple.new(":Uzamere", "mit:took_course", ":6.171");"def owl_same_as;0;[o; ;"Pius Uzamere;0;0; " author;:owl_same_as;;;T;T;i;;;"def owl_same_as
end;@o; ;@ ;
"owl:FunctionalProperty
 
==== Semantics
  Given:
  P rdf:type owl:FunctionalProperty
  x P y
  x P z
  
  Infer:
  y owl:sameAs z
 
==== Example
  p = Triple.new("mit:had_academic_advisor", "rdf:type", "owl:FunctionalProperty");
  h = Triple.new(":Pius", "mit:had_academic_advisor", ":Hal");
  d = Triple.new(":Pius", "mit:had_academic_advisor", ":Dude_Who_Wrote_SICP_With_Gerald_Sussman");
  assert p; assert h; assert d; #=> infers a triple ~= Triple.new(":Hal", "owl:sameAs", ":Dude_Who_Wrote_SICP_With_Gerald_Sussman");" def owl_functional_property;0;[o; ;"Pius Uzamere;0;0; " author;:owl_functional_property;;;T;T;i*;;;"$def owl_functional_property
end;@o; ;@ ;
"owl:InverseFunctionalProperty
 
==== Semantics
  Given:
  P rdf:type owl:InverseFunctionalProperty
  z P x
  y P x
  
  Infer:
  y owl:sameAs z
 
==== Example
  p = Triple.new("mit:lived_alone_fall_2004_in", "rdf:type", "owl:FunctionalProperty");
  h = Triple.new(":Pius", "mit:lived_alone_fall_2004_in", ":room_314_at_Next_House");
  d = Triple.new(":2004_UA_President", "mit:lived_alone_fall_2004_in", ":room_314_at_Next_House");
  assert p; assert h; assert d; #=> infers a triple ~= Triple.new(":Pius", "owl:sameAs", ":2004_UA_President");"(def owl_inverse_functional_property;0;[o; ;"Pius Uzamere;0;0; " author;:$owl_inverse_functional_property;;;T;T;iM;;;",def owl_inverse_functional_property
end;@: @owner@ ;[: @aliases{;:RdfsPlusRulebook:@superclasso:YARD::CodeObjects::Proxy;@;:RdfsRulebook: @objo;;@;
"; IC; [ o; ;@\;
";"def rules;[;;;;;T;i*;;;"def rules
  rdfs_rules
end;"lib/room/rdfs_rulebook.rbo; ;@\;
"
nodoc;"def rdfs_rules;0;[;:rdfs_rules;;;T;T;i/;;;"def rdfs_rules
  
  ##
  # Implements Type Propagation through rdfs:subClassOf
  #
  # ==== Semantics
  # Given:
  # A rdfs:subClassOf B
  # r rdf:type A
  #
  # Infer:
  # r rdf:type B
  #
  # ==== Example
  # p = Triple.new(":Pius", "rdf:type", ":male");
  # h = Triple.new(":male", "rdfs:subClassOf", ":human")
  # assert p; assert h; #=> infers a triple ~= Triple.new(":Pius", "rdf:type", ":human")
  #
  # @author Pius Uzamere
  def rdfs_sub_class_of
  end
  
  rule :rdfs_sub_class_of,
  #TODO: add a patch to ruleby whereby the parser will raise when there's a no method error (e.g. m.subj)
    [Triple,:fact,{m.subject => :subj, m.object=>:obj},m.predicate=="rdf:type"],
    [Triple,:ont_statement,{m.object => :inferred_class },m.predicate=="rdfs:subClassOf", m.subject == b(:obj)],
    [:not, Triple, m.predicate=="rdf:type", m.subject==b(:subj), m.object==b(:inferred_class)] do |v|
      inferred_class = v[:ont_statement].object
      subj = v[:fact].subject
      assert Triple.new(subj, "rdf:type", inferred_class)
      puts "Made type inference based on rdfs:subClassOf: Triple(#{subj}, rdf:type, #{inferred_class})"
  end
  
 
  ##
  # Implements Type Propagation through rdfs:subPropertyOf
  #
  # ==== Semantics
  # Given:
  # P rdfs:subPropertyOf R
  # A P B
  #
  # Infer:
  # A R B
  #
  # ==== Example
  # p = Triple.new(":Pius", "mit:majored_in", ":Course_6");
  # h = Triple.new("mit:majored_in", "rdfs:subPropertyOf", "mit:took_some_classes_in")
  # assert p; assert h; #=> infers a triple ~= Triple.new(":Pius", "mit:took_some_classes_in", ":Course_6")
  #
  # @author Pius Uzamere
  def rdfs_sub_property_of
  end
  
  rule :rdfs_sub_property_of,
    [Triple,:fact,{m.predicate=>:pred, m.subject => :subj, m.object=>:obj}],
    [Triple,:ont_statement, {m.object => :inferred_pred}, m.predicate=="rdfs:subPropertyOf", m.subject == b(:pred)],
    [:not, Triple, m.predicate==b(:inferred_pred), m.subject==b(:subj), m.object==b(:obj)] do |v|
      inferred_property = v[:ont_statement].object
      subj = v[:fact].subject
      obj = v[:fact].object
      assert Triple.new(subj, inferred_property, obj)
      puts "Made type inference based on subPropertyOf: Triple(#{subj},#{inferred_property}, #{obj})"
  end
  
  ##
  # Implements Type Propagation through rdfs:domain
  #
  # ==== Semantics
  # Given:
  # P rdfs:domain D
  # x P y
  #
  # Infer:
  # x rdf:type D
  #
  # ==== Example
  # p = Triple.new("mit:majored_in", "rdfs:domain", ":student");
  # h = Triple.new(":Pius", "mit:majored_in", ":Course_17")
  # assert p; assert h; #=> infers a triple ~= Triple.new(":Pius", "rdf:type", ":student")
  #
  # @author Pius Uzamere
  def rdfs_domain
  end
  
  rule :rdfs_domain,
    [Triple,:fact,{m.predicate=>:pred}],
    [Triple,:ont_statement,m.predicate=="rdfs:domain", m.subject == b(:pred)] do |v|
      inferred_type = v[:ont_statement].object
      subj = v[:fact].subject
      assert Triple.new(subj, "rdf:type", inferred_type)
      puts "Made type inference based on rdfs:domain: Triple(#{subj},rdf:type, #{inferred_type})"
  end
  
  ##
  # Implements Type Propagation through rdfs:range
  #
  # ==== Semantics
  # Given:
  # P rdfs:range R
  # x P y
  #
  # Infer:
  # y rdf:type R
  #
  # ==== Example
  # p = Triple.new("mit:majored_in", "rdfs:range", ":major");
  # h = Triple.new(":Pius", "mit:majored_in", ":Course_17")
  # assert p; assert h; #=> infers a triple ~= Triple.new(":Pius", "rdf:type", ":student")
  #
  # @author Pius Uzamere
  def rdfs_range
  end
  
  rule :rdfs_range,
    [Triple,:fact,{m.predicate=>:pred}],
    [Triple,:ont_statement,m.predicate=="rdfs:range", m.subject == b(:pred)] do |v|
      inferred_type = v[:ont_statement].object
      subj = v[:fact].object
      assert Triple.new(subj, "rdf:type", inferred_type)
      puts "Made type inference based on rdfs:range: Triple(#{subj},rdf:type, #{inferred_type})"
  end
  
end;@do; ;@\;
"YImplements Type Propagation through rdfs:subClassOf
 
==== Semantics
  Given:
  A rdfs:subClassOf B
  r rdf:type A
 
  Infer:
  r rdf:type B
 
==== Example
  p = Triple.new(":Pius", "rdf:type", ":male");
  h = Triple.new(":male", "rdfs:subClassOf", ":human")
  assert p; assert h; #=> infers a triple ~= Triple.new(":Pius", "rdf:type", ":human");"def rdfs_sub_class_of;0;[o; ;"Pius Uzamere;0;0; " author;:rdfs_sub_class_of;;;T;T;iB;;;"def rdfs_sub_class_of
end;@do; ;@\;
"Implements Type Propagation through rdfs:subPropertyOf
 
==== Semantics
  Given:
  P rdfs:subPropertyOf R
  A P B
 
  Infer:
  A R B
 
==== Example
  p = Triple.new(":Pius", "mit:majored_in", ":Course_6");
  h = Triple.new("mit:majored_in", "rdfs:subPropertyOf", "mit:took_some_classes_in")
  assert p; assert h; #=> infers a triple ~= Triple.new(":Pius", "mit:took_some_classes_in", ":Course_6");"def rdfs_sub_property_of;0;[o; ;"Pius Uzamere;0;0; " author;:rdfs_sub_property_of;;;T;T;ib;;;"!def rdfs_sub_property_of
end;@do; ;@\;
"^Implements Type Propagation through rdfs:domain
 
==== Semantics
  Given:
  P rdfs:domain D
  x P y
 
  Infer:
  x rdf:type D
 
==== Example
  p = Triple.new("mit:majored_in", "rdfs:domain", ":student");
  h = Triple.new(":Pius", "mit:majored_in", ":Course_17")
  assert p; assert h; #=> infers a triple ~= Triple.new(":Pius", "rdf:type", ":student");"def rdfs_domain;0;[o; ;"Pius Uzamere;0;0; " author;:rdfs_domain;;;T;T;i|;;;"def rdfs_domain
end;@do; ;@\;
"YImplements Type Propagation through rdfs:range
 
==== Semantics
  Given:
  P rdfs:range R
  x P y
 
  Infer:
  y rdf:type R
 
==== Example
  p = Triple.new("mit:majored_in", "rdfs:range", ":major");
  h = Triple.new(":Pius", "mit:majored_in", ":Course_17")
  assert p; assert h; #=> infers a triple ~= Triple.new(":Pius", "rdf:type", ":student");"def rdfs_range;0;[o; ;"Pius Uzamere;0;0; " author;:rdfs_range;;;T;T;i;;;"def rdfs_range
end;@d;)@\;[;*{;;.;,o;-
;o;-;@;: Ruleby;/0:@origname"Ruleby::Rulebook:@orignamespace@;: Rulebook;/0;i(:@attributesIC;{;IC;{:@symbolize_valueT:
classIC;{;:T;:T;@d: @mixinsIC; [;)@\;i;9IC;{;IC;{;:T;;IC;{;:T;:T;@;<IC; [;)@ @@\o;;@;
"; IC; [o; ;@;
";"def /(path);[;:/;;;T;i;;;"0def /(path)
  (self + path).expand_path
end;"lib/room.rb;)@;[;*{;: Pathname;,o;-;@;: Object;/0;i;9IC;{;IC;{;:T;;IC;{;:T;:T;@;<IC; [;)@;)@;[;*{;: root;9IC;{;IC;{;:T;;IC;{;:T;:T;<IC; [o;-;@;;5;/0;)@;
"; IC; [o; ;@;
";"-def initialize(subject,predicate,object);[;:initialize;;;T;i;;;"sdef initialize(subject,predicate,object)
  @subject = subject
  @predicate = predicate
  @object= object
end ;@do; ;@;
";"def ==(obj);[;:==;;;T;T;i!;;;"ldef ==(obj)
  (@subject == obj.subject) && (@object == obj.object) && (@predicate == obj.predicate)
end;@d;)@;[;*{;;;,o;-;@;;?;/0;i;9IC;{;IC;{;:T;;IC;{;:T;:T;@d;<IC; [;)@:&RdfsRulebook#rdfs_sub_property_of@r:Triple#==@:RdfsRulebook#rules@_:*RdfsPlusRulebook#owl_equivalent_class@1:$RdfsPlusRulebook#owl_inverse_of@:-RdfsPlusRulebook#owl_functional_property@I:Pathname#/@:RdfsRulebook#rdfs_rules@e:RdfsRulebook#rdfs_domain@z;.@\:,RdfsPlusRulebook#owl_symmetric_property@!:RdfsPlusRulebook#rules@:-RdfsPlusRulebook#owl_equivalent_property@9;>@:5RdfsPlusRulebook#owl_inverse_functional_property@Q:#RdfsRulebook#rdfs_sub_class_of@j:Triple#initialize@:RdfsRulebook#rdfs_range@}:-RdfsPlusRulebook#owl_transitive_property@):%RdfsPlusRulebook#rdfs_plus_rules@:!RdfsPlusRulebook#owl_same_as@A;+@ ;@@;:T{ " Ruleby: module"Ruleby::Rulebook;;"RdfsRulebook;;" Object;;