# EARL 0.9 to 0.95 Conversion Filter
# 
# One thing that the Semantic Web enables us to do is to convert from 
# one version of a language to another with relative ease. The only 
# pre-requisite for doing so is some kind of universally recognized 
# inference language; here we use terms from TimBL's logic namespace 
# (log:), and grok the rules using the Closed World Machine. Notes on 
# how to use this file are given at:-
# 
#  <http://www.w3.org/2001/03/earl/0.9to0.95.html>
# 
# You'll also need to have the schemata and some additional rules files 
# to make the transformations work.

@prefix : <#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix daml: <http://www.daml.org/2001/03/daml+oil#> .
@prefix log: <http://www.w3.org/2000/10/swap/log#> .
@prefix earl: <http://www.w3.org/2001/03/earl/0.95#> .
@prefix earl9: <http://www.w3.org/2001/03/earl/0.9#> .
@prefix dc: <http://purl.org/dc/elements/1.1/> .

# Change the 0.9 Assertor stuff into 0.95 Assertor stuff

{ { :x earl9:hasEmail :z; a earl9:Assertor } log:implies
  { :x earl:email :z; a earl:Assertor } } a log:Truth; 
log:forAll :x , :z .

{ { :x earl9:hasName :z; a earl9:Assertor } log:implies
  { :x earl:name :z; a earl:Assertor } } a log:Truth; 
log:forAll :x , :z .

{ { :x earl9:address :z; a earl9:Assertor } log:implies
  { :x earl9:address :z; a earl:Assertor . 
    earl9:address rdfs:subPropertyOf earl:contactInfo } } a log:Truth; 
log:forAll :x , :z .

{ { :x earl9:hasPlatform :z; a earl9:Assertor } log:implies
  { :x earl:platform :z; a earl:Assertor } } a log:Truth; 
log:forAll :x , :z .

# Change the 0.9 TestSubject stuff into 0.95 TestSubject stuff

{ { :x a earl9:TestSubject, earl9:WebContent } log:implies
  { :x a earl:TestSubject, earl:WebContent } } a log:Truth; 
log:forAll :x .

{ { :x a earl9:TestSubject, earl9:Tool } log:implies
  { :x a earl:TestSubject, earl:Tool } } a log:Truth; 
log:forAll :x .

{ { :x a earl9:TestSubject; earl9:testSubject :y } log:implies
  { :x a earl:TestSubject; earl:testSubject :y } } a log:Truth; 
log:forAll :x , :y .

{ { :x a earl9:TestSubject; earl9:lastModified [ dc:date :y ] } log:implies
  { :x a earl:TestSubject; earl:lastModified :y } } a log:Truth; 
log:forAll :x , :y .

{ { :x a earl9:TestSubject; earl9:released [ dc:date :y ] } log:implies
  { :x a earl:TestSubject; earl:released :y } } a log:Truth; 
log:forAll :x , :y .

{ { :x a earl9:TestSubject; earl9:hasSnapshot :y } log:implies
  { :x a earl:TestSubject; earl:snapshot :y } } a log:Truth; 
log:forAll :x , :y .

{ { :x a earl9:TestSubject; earl9:version :y } log:implies
  { :x a earl:TestSubject; earl:version :y } } a log:Truth; 
log:forAll :x , :y .

# Convert the TestResult stuff to ResultProperty

{ { :x earl9:validity earl9:Pass; a earl9:TestResult } log:implies
  { :x earl:validity earl:Pass; a earl:ResultProperty } } a log:Truth; 
log:forAll :x , :z .

{ { :x earl9:validity earl9:Fail; a earl9:TestResult } log:implies
  { :x earl:validity earl:Fail; a earl:ResultProperty } } a log:Truth; 
log:forAll :x , :z .

{ { :x earl9:validity earl9:NotTested; a earl9:TestResult } log:implies
  { :x earl:validity earl:NotTested; a earl:ResultProperty } } a log:Truth; 
log:forAll :x , :z .

{ { :x earl9:validity earl9:NotApplicable; a earl9:TestResult } log:implies
  { :x earl:validity earl:NotApplicable; a earl:ResultProperty } } a log:Truth; 
log:forAll :x , :z .

{ { :x earl9:validity earl9:CannotTell; a earl9:TestResult } log:implies
  { :x earl:validity earl:CannotTell; a earl:ResultProperty } } a log:Truth; 
log:forAll :x , :z .

{ { :x earl9:confidence earl9:High; a earl9:TestResult } log:implies
  { :x earl:confidence earl:High; a earl:ResultProperty } } a log:Truth; 
log:forAll :x , :z .

{ { :x earl9:confidence earl9:Medium; a earl9:TestResult } log:implies
  { :x earl:confidence earl:Medium; a earl:ResultProperty } } a log:Truth; 
log:forAll :x , :z .

{ { :x earl9:confidence earl9:Low; a earl9:TestResult } log:implies
  { :x earl:confidence earl:Low; a earl:ResultProperty } } a log:Truth; 
log:forAll :x , :z .

{ { :x rdfs:comment :z; a earl9:TestResult } log:implies
  { :x earl:note :z; a earl:ResultProperty } } a log:Truth; 
log:forAll :x , :z .

{ { :x earl9:date [ dc:date :z ]; a earl9:TestResult } log:implies
  { :x earl:date :z; a earl:ResultProperty } } a log:Truth; 
log:forAll :x , :z .

# Change the 0.9 TestCase stuff into 0.95 TestCase stuff

{ { :x earl9:testMode earl9:Auto; a earl9:TestCase } log:implies
  { :x earl:testMode earl:Auto; a earl:TestCase } } a log:Truth; 
log:forAll :x .

{ { :x earl9:testMode earl9:Manual; a earl9:TestCase } log:implies
  { :x earl:testMode earl:Manual; a earl:TestCase } } a log:Truth; 
log:forAll :x .

{ { :x earl9:testMode earl9:Heuristic; a earl9:TestCase } log:implies
  { :x earl:testMode earl:Heuristic; a earl:TestCase } } a log:Truth; 
log:forAll :x .

{ { :x earl9:expectedResult :z; a earl9:TestCase } log:implies
  { :x earl:repairInfo [ earl:expectedResult :z ]; a earl:TestCase } } 
a log:Truth; log:forAll :x , :z .

{ { :x earl9:operatorInstructions :z; a earl9:TestCase } log:implies
  { :x earl:operatorInstructions :z; a earl:TestCase } } a log:Truth; 
log:forAll :x , :z .

{ { :x earl9:reproducableStep :z; a earl9:TestCase } log:implies
  { :x earl:reproducableStep :z; a earl:TestCase } } a log:Truth; 
log:forAll :x , :z .

{ { :x earl9:purpose :z; a earl9:TestCase } log:implies
  { :x earl:purpose :z; a earl:TestCase } } a log:Truth; log:forAll :x , :z .

{ { :x earl9:suite :z; a earl9:TestCase } log:implies
  { :x earl:testSuite :z; a earl:TestCase } } a log:Truth; log:forAll :x , :z .

{ { :x earl9:id :z; a earl9:TestCase } log:implies
  { :x earl:id :z; a earl:TestCase } } a log:Truth; log:forAll :x , :z .

{ { :x earl9:comment :z; a earl9:TestCase } log:implies
  { :x earl:note :z; a earl:TestCase } } a log:Truth; log:forAll :x , :z .

{ { :x rdfs:comment :z; a earl9:TestCase } log:implies
  { :x earl:note :z; a earl:TestCase } } a log:Truth; log:forAll :x , :z .

# Change the EARL 0.9 Evaluation into an EARL 0.95 Evaluation

{ { :x a earl9:Assertor; earl9:asserts :y . :y a earl9:Assertion } log:implies
  { :x a earl:Assertor; earl:asserts :y . :y a earl:Assertion } } 
a log:Truth; log:forAll :x , :y .

# Swap the predicate and object around (without changing the URIs - hack!)

{ { :x a earl9:Assertion; rdf:subject :a; rdf:predicate :b; rdf:object :c } 
  log:implies
  { :x a earl:Assertion; rdf:subject :a; rdf:predicate :c; rdf:object :b } } 
 a log:Truth; log:forAll :x , :a , :b , :c .