<?xml version="1.0" encoding="UTF-8"?>
<xs:schema targetNamespace="http://www.wsmo.org/wsml/wsml-syntax#" xmlns="http://www.wsmo.org/wsml/wsml-syntax#" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
        <xs:annotation>
                <xs:documentation>
                        date: $Date: 2008-07-23 09:43:30 $
                        author: Jos de Bruijn, Reto Krummenacher, Ioan Toma

                        this schema is a module, which belongs to the WSML/XML schema specification.
                        This schema provides WSML/XML syntax for logical expressions. This syntax for logical expressions is inspired by the RuleML FOL (First-Order Logic) variant.
                        Necessary additions for WSML-Full were the introduction of negation-as-failure, LP implication  and constraints 
                </xs:documentation>
        </xs:annotation>
        <!-- the following schema contains the definitions for the auxiliary identifiers -->
        <xs:include schemaLocation="http://www.wsmo.org/TR/d36/v0.1/xml-syntax/wsml_identifiers.xsd"/>
        <!-- start of the elements ofthe  WSML-Full logical expression syntax -->
        <xs:element name="constraint" type="complexExpressionType">
                <xs:annotation>
                        <xs:documentation>Database-style constraint. Corresponds with the '!-' symbol in the human readable syntax.</xs:documentation>
                </xs:annotation>
        </xs:element>
        <xs:element name="impliedByLP" type="binaryComplexExpressionType">
                <xs:annotation>
                        <xs:documentation>Logic Programming rule. This rule has a head and a body. This XML element corresponds with the ':-' symbol in the human-readable syntax.</xs:documentation>
                </xs:annotation>
        </xs:element>
        <xs:complexType name="logicalExpressionType">
                <xs:annotation>
                        <xs:documentation>A WSML logical expression is either a constraint, an LP rule or a formula. The formula corresponds to an LP rule with an empty body.</xs:documentation>
                </xs:annotation>
                <xs:choice maxOccurs="unbounded">
                        <xs:element ref="constraint" maxOccurs="unbounded"/>
                        <xs:element ref="impliedByLP" maxOccurs="unbounded"/>
                        <xs:element ref="atom" maxOccurs="unbounded"/>
                        <xs:element ref="molecule" maxOccurs="unbounded"/>
                        <xs:element ref="and" maxOccurs="unbounded"/>
                        <xs:element ref="or" maxOccurs="unbounded"/>
                        <xs:element ref="neg" maxOccurs="unbounded"/>
                        <xs:element ref="naf" maxOccurs="unbounded"/>
                        <xs:element ref="implies" maxOccurs="unbounded"/>
                        <xs:element ref="impliedBy" maxOccurs="unbounded"/>
                        <xs:element ref="equivalent" maxOccurs="unbounded"/>
                        <xs:element ref="forall" maxOccurs="unbounded"/>
                        <xs:element ref="exists" maxOccurs="unbounded"/>
                </xs:choice>
        </xs:complexType>
        <xs:element name="and" type="binaryComplexExpressionType">
                <xs:annotation>
                        <xs:documentation>Conjunction</xs:documentation>
                </xs:annotation>
        </xs:element>
        <xs:element name="or" type="binaryComplexExpressionType">
                <xs:annotation>
                        <xs:documentation>Disjunction</xs:documentation>
                </xs:annotation>
        </xs:element>
        <xs:element name="neg" type="complexExpressionType">
                <xs:annotation>
                        <xs:documentation>Classical negation</xs:documentation>
                </xs:annotation>
        </xs:element>
        <xs:element name="naf" type="complexExpressionType">
                <xs:annotation>
                        <xs:documentation>Negation-as-failure</xs:documentation>
                </xs:annotation>
        </xs:element>
        <xs:element name="implies" type="binaryComplexExpressionType">
                <xs:annotation>
                        <xs:documentation>Right implication (corresponds with necessary conditions). The first formula nested inside the 'implies' element, implies the second formula. For an implication, exactly two formulas must be nested inside the implication element.</xs:documentation>
                </xs:annotation>
        </xs:element>
        <xs:element name="impliedBy" type="binaryComplexExpressionType">
                <xs:annotation>
                        <xs:documentation>Left implication (corresponds with sufficient conditions). The first formula nested inside the 'impliedBy' element, is implied by the second formula. For an implication, exactly two formulas must be nested inside the implication element.</xs:documentation>
                </xs:annotation>
        </xs:element>
        <xs:element name="equivalent" type="binaryComplexExpressionType">
                <xs:annotation>
                        <xs:documentation>Dual implication (corresponds with necessary and sufficient conditions). The first formula nested inside the 'implies' element, is implied by the second formula. For an implication, exactly two formulas must be nested inside the implication element.</xs:documentation>
                </xs:annotation>
        </xs:element>
        <xs:element name="forall" type="quantifiedComplexExpressionType">
                <xs:annotation>
                        <xs:documentation>Universal quantification.</xs:documentation>
                </xs:annotation>
        </xs:element>
        <xs:element name="exists" type="quantifiedComplexExpressionType">
                <xs:annotation>
                        <xs:documentation>Existential quantification</xs:documentation>
                </xs:annotation>
        </xs:element>
        <xs:complexType name="quantifiedComplexExpressionType">
                <xs:annotation>
                        <xs:documentation>For now the complexExpressionType is repeated after the 'var' element, because I don't know how to include it *after* 'var'.</xs:documentation>
                </xs:annotation>
                <xs:sequence>
                        <xs:element name="variable" type="wsmlVariable" maxOccurs="unbounded"/>
                        <xs:choice>
                                <xs:element ref="atom"/>
                                <xs:element ref="molecule"/>
                                <xs:element ref="and"/>
                                <xs:element ref="or"/>
                                <xs:element ref="neg"/>
                                <xs:element ref="naf"/>
                                <xs:element ref="implies"/>
                                <xs:element ref="impliedBy"/>
                                <xs:element ref="equivalent"/>
                                <xs:element ref="forall"/>
                                <xs:element ref="exists"/>
                        </xs:choice>
                </xs:sequence>
        </xs:complexType>
        <xs:complexType name="complexExpressionType">
                <xs:annotation>
                        <xs:documentation>The basic type for WSML-Full expressions, allowing exactly one expression</xs:documentation>
                </xs:annotation>
                <xs:choice>
                        <xs:element ref="atom"/>
                        <xs:element ref="molecule"/>
                        <xs:element ref="and"/>
                        <xs:element ref="or"/>
                        <xs:element ref="neg"/>
                        <xs:element ref="naf"/>
                        <xs:element ref="implies"/>
                        <xs:element ref="impliedBy"/>
                        <xs:element ref="equivalent"/>
                        <xs:element ref="forall"/>
                        <xs:element ref="exists"/>
                </xs:choice>
        </xs:complexType>
        <xs:complexType name="binaryComplexExpressionType">
                <xs:annotation>
                        <xs:documentation>The basic type for WSML-Full expressions, allowing exactly two expressions to each side of the operator</xs:documentation>
                </xs:annotation>
                <xs:choice minOccurs="2" maxOccurs="2">
                        <xs:element ref="atom"/>
                        <xs:element ref="molecule"/>
                        <xs:element ref="and"/>
                        <xs:element ref="or"/>
                        <xs:element ref="neg"/>
                        <xs:element ref="naf"/>
                        <xs:element ref="implies"/>
                        <xs:element ref="impliedBy"/>
                        <xs:element ref="equivalent"/>
                        <xs:element ref="forall"/>
                        <xs:element ref="exists"/>
                </xs:choice>
        </xs:complexType>
        <xs:element name="atom">
                <xs:annotation>
                        <xs:documentation>An atom denotes a relation with an n-ary domain, where n is the arity of the predicate</xs:documentation>
                </xs:annotation>
                <xs:complexType>
                        <xs:sequence>
                                <xs:element name="arg" type="termType" minOccurs="0" maxOccurs="unbounded"/>
                        </xs:sequence>
                        <xs:attribute name="name" use="required"/>
                </xs:complexType>
        </xs:element>
        <xs:complexType name="termType" mixed="true">
                <xs:annotation>
                        <xs:documentation>
                                A term can be a IRI or a variable, or any indentifier,
                                or a constructed term (corresponsing to a function symbol), where the arguments are terms themselves. 
                                In the latter case, the name may not be a variable. It is possible to use regular content instead of 
                                arguments for the first argument; the content is either an IRI or a variables; in case the type of 
                                information is apparent from the name of the term (i.e. either wsml#string, wsml#integer, or wsml#decimal), 
                                the content is of this type.
                        </xs:documentation>
                </xs:annotation>
                <xs:sequence>
                    <xs:element name="arg" type="termType" minOccurs="0" maxOccurs="unbounded" />
                </xs:sequence>
                <xs:attribute name="name" type="xs:string" use="required"/>                
        </xs:complexType>
        <xs:element name="molecule">
                <xs:complexType>
                        <xs:sequence>
                                <xs:element name="term" type="termType"/>
                                <xs:choice maxOccurs="unbounded">
                                        <xs:element name="attributeDefinition" minOccurs="0" maxOccurs="unbounded">
                                                <xs:complexType>
                                                        <xs:sequence>
                                                                <xs:element name="name" type="termType"/>
                                                                <xs:element name="type" type="termType" maxOccurs="unbounded"/>
                                                        </xs:sequence>
                                                        <xs:attribute name="type" default="constraining">
                                                                <xs:simpleType>
                                                                        <xs:restriction base="xs:string">
                                                                                <xs:enumeration value="inferring"/>
                                                                                <xs:enumeration value="constraining"/>
                                                                        </xs:restriction>
                                                                </xs:simpleType>
                                                        </xs:attribute>
                                                </xs:complexType>
                                        </xs:element>
                                        <xs:element name="attributeValue" minOccurs="0" maxOccurs="unbounded">
                                                <xs:complexType>
                                                        <xs:sequence>
                                                                <xs:element name="name" type="termType"/>
                                                                <xs:element name="value" type="termType" maxOccurs="unbounded"/>
                                                        </xs:sequence>
                                                </xs:complexType>
                                        </xs:element>
                                        <xs:element name="isa" minOccurs="0">
                                                <xs:complexType>
                                                        <xs:sequence>
                                                                <xs:element name="term" type="termType" maxOccurs="unbounded"/>
                                                        </xs:sequence>
                                                        <xs:attribute name="type">
                                                                <xs:simpleType>
                                                                        <xs:restriction base="xs:string">
                                                                                <xs:enumeration value="memberOf"/>
                                                                                <xs:enumeration value="subConceptOf"/>
                                                                        </xs:restriction>
                                                                </xs:simpleType>
                                                        </xs:attribute>
                                                </xs:complexType>
                                        </xs:element>
                                </xs:choice>
                        </xs:sequence>
                </xs:complexType>
        </xs:element>
</xs:schema>

