{-# LANGUAGE CPP #-}
{-# LANGUAGE OverloadedStrings #-}

--------------------------------------------------------------------------------
--  See end of this file for licence information.
--------------------------------------------------------------------------------
-- |
--  Module      :  Integer
--  Copyright   :  (c) 2003, Graham Klyne, 2009 Vasili I Galchin, 2011, 2012, 2014, 2018, 2022, 2024 Douglas Burke
--  License     :  GPL V2
--
--  Maintainer  :  Douglas Burke
--  Stability   :  experimental
--  Portability :  CPP, OverloadedStrings
--
--  This module defines the structures used to represent and
--  manipulate RDF @xsd:integer@ datatyped literals.
--
--------------------------------------------------------------------------------

module Swish.RDF.Datatype.XSD.Integer
    ( rdfDatatypeXsdInteger
    , rdfDatatypeValXsdInteger
    , typeNameXsdInteger, namespaceXsdInteger
    , axiomsXsdInteger, rulesXsdInteger
    )
where

import Swish.Datatype
    ( Datatype(..)
    , DatatypeVal(..)
    , DatatypeRel(..), DatatypeRelPr
    , altArgs
    , UnaryFnTable,    unaryFnApp
    , BinaryFnTable,   binaryFnApp
    , BinMaybeFnTable, binMaybeFnApp
    , DatatypeMod(..) 
    , makeVmod11inv, makeVmod11
    , makeVmod21inv, makeVmod21
    , makeVmod20
    , makeVmod22
    )
import Swish.Namespace (Namespace, ScopedName)
import Swish.Namespace (namespaceToBuilder, makeNSScopedName)
import Swish.QName (LName)
import Swish.Ruleset (makeRuleset)

import Swish.RDF.Datatype (RDFDatatype, RDFDatatypeVal, RDFDatatypeMod)
import Swish.RDF.Datatype (makeRdfDtOpenVarBindingModifiers)
import Swish.RDF.Datatype.XSD.MapInteger (mapXsdInteger)

import Swish.RDF.Ruleset (RDFFormula, RDFRule, RDFRuleset)
import Swish.RDF.Ruleset (makeRDFGraphFromN3Builder, makeRDFFormula)

import Swish.RDF.ClassRestrictionRule (makeRDFDatatypeRestrictionRules)

import Swish.RDF.Vocabulary
    ( namespaceRDF
    , namespaceRDFS
    , namespaceRDFD
    , namespaceXSD
    , namespaceXsdType
    )

import Data.Maybe (maybeToList)

#if (!defined(__GLASGOW_HASKELL__)) || (__GLASGOW_HASKELL__ < 710)
import Data.Monoid (Monoid(..))
#endif

import qualified Data.Text.Lazy.Builder as B

------------------------------------------------------------
--  Misc values
------------------------------------------------------------

--  Local name for Integer datatype
nameXsdInteger :: LName
nameXsdInteger :: LName
nameXsdInteger = LName
"integer"

-- |Type name for @xsd:integer@ datatype.
typeNameXsdInteger :: ScopedName
typeNameXsdInteger :: ScopedName
typeNameXsdInteger  = Namespace -> LName -> ScopedName
makeNSScopedName Namespace
namespaceXSD LName
nameXsdInteger

-- |Namespace for @xsd:integer@ datatype functions.
namespaceXsdInteger :: Namespace
namespaceXsdInteger :: Namespace
namespaceXsdInteger = LName -> Namespace
namespaceXsdType LName
nameXsdInteger

-- | The RDFDatatype value for @xsd:integer@.
rdfDatatypeXsdInteger :: RDFDatatype
rdfDatatypeXsdInteger :: RDFDatatype
rdfDatatypeXsdInteger = DatatypeVal RDFGraph Integer RDFLabel RDFLabel -> RDFDatatype
forall ex lb vn vt. DatatypeVal ex vt lb vn -> Datatype ex lb vn
Datatype DatatypeVal RDFGraph Integer RDFLabel RDFLabel
rdfDatatypeValXsdInteger

--  Integer power (exponentiation) function
--  returns Nothing if exponent is negative.
--
intPower :: Integer -> Integer -> Maybe Integer
intPower :: Integer -> Integer -> Maybe Integer
intPower Integer
a Integer
b = if Integer
b Integer -> Integer -> Bool
forall a. Ord a => a -> a -> Bool
< Integer
0 then Maybe Integer
forall a. Maybe a
Nothing else Integer -> Maybe Integer
forall a. a -> Maybe a
Just (Integer -> Integer -> Integer
forall {a} {a}. (Integral a, Num a) => a -> a -> a
intPower1 Integer
a Integer
b)
    where
        intPower1 :: a -> a -> a
intPower1 a
x a
y
            | a
q a -> a -> Bool
forall a. Eq a => a -> a -> Bool
== a
1           = a
atopsqa -> a -> a
forall a. Num a => a -> a -> a
*a
x
            | a
p a -> a -> Bool
forall a. Eq a => a -> a -> Bool
== a
0           = a
1
            | Bool
otherwise        = a
atopsq
            where
                (a
p,a
q)  = a
y a -> a -> (a, a)
forall a. Integral a => a -> a -> (a, a)
`divMod` a
2
                atop :: a
atop   = a -> a -> a
intPower1 a
x a
p
                atopsq :: a
atopsq = a
atopa -> a -> a
forall a. Num a => a -> a -> a
*a
atop

------------------------------------------------------------
--  Implmentation of RDFDatatypeVal for xsd:integer
------------------------------------------------------------

-- |Define Datatype value for @xsd:integer@.
--
--  Members of this datatype are positive or negative integer values.
--
--  The lexical form consists of an optional @+@ or @-@
--  followed by a sequence of decimal digits.
--
--  The canonical lexical form has leading zeros and @+@ sign removed.
--
rdfDatatypeValXsdInteger :: RDFDatatypeVal Integer
rdfDatatypeValXsdInteger :: DatatypeVal RDFGraph Integer RDFLabel RDFLabel
rdfDatatypeValXsdInteger = DatatypeVal
    { tvalName :: ScopedName
tvalName      = ScopedName
typeNameXsdInteger
    , tvalRules :: Ruleset RDFGraph
tvalRules     = Ruleset RDFGraph
rdfRulesetXsdInteger  -- Ruleset RDFGraph
    , tvalMkRules :: RDFGraph -> [Rule RDFGraph]
tvalMkRules   = DatatypeVal RDFGraph Integer RDFLabel RDFLabel
-> RDFGraph -> [Rule RDFGraph]
forall vt. RDFDatatypeVal vt -> RDFGraph -> [Rule RDFGraph]
makeRDFDatatypeRestrictionRules DatatypeVal RDFGraph Integer RDFLabel RDFLabel
rdfDatatypeValXsdInteger
                                            -- RDFGraph -> [RDFRules]
    , tvalMkMods :: [OpenVarBindingModify RDFLabel RDFLabel]
tvalMkMods    = DatatypeVal RDFGraph Integer RDFLabel RDFLabel
-> [OpenVarBindingModify RDFLabel RDFLabel]
forall vt.
RDFDatatypeVal vt -> [OpenVarBindingModify RDFLabel RDFLabel]
makeRdfDtOpenVarBindingModifiers DatatypeVal RDFGraph Integer RDFLabel RDFLabel
rdfDatatypeValXsdInteger
    , tvalMap :: DatatypeMap Integer
tvalMap       = DatatypeMap Integer
mapXsdInteger         -- DatatypeMap Integer
    , tvalRel :: [DatatypeRel Integer]
tvalRel       = [DatatypeRel Integer]
relXsdInteger         -- [DatatypeRel Integer]
    , tvalMod :: [DatatypeMod Integer RDFLabel RDFLabel]
tvalMod       = [DatatypeMod Integer RDFLabel RDFLabel]
modXsdInteger         -- [DatatypeMod Integer]
    }

-- |relXsdInteger contains arithmetic and other relations for xsd:Integer values.
--
--  The functions are inspired by those defined by CWM as math: properties
--  (<http://www.w3.org/2000/10/swap/doc/CwmBuiltins.html>).
--
relXsdInteger :: [DatatypeRel Integer]
relXsdInteger :: [DatatypeRel Integer]
relXsdInteger =
    [ DatatypeRel Integer
relXsdIntegerAbs
    , DatatypeRel Integer
relXsdIntegerNeg
    , DatatypeRel Integer
relXsdIntegerSum
    , DatatypeRel Integer
relXsdIntegerDiff
    , DatatypeRel Integer
relXsdIntegerProd
    , DatatypeRel Integer
relXsdIntegerDivMod
    , DatatypeRel Integer
relXsdIntegerPower
    , DatatypeRel Integer
relXsdIntegerEq
    , DatatypeRel Integer
relXsdIntegerNe
    , DatatypeRel Integer
relXsdIntegerLt
    , DatatypeRel Integer
relXsdIntegerLe
    , DatatypeRel Integer
relXsdIntegerGt
    , DatatypeRel Integer
relXsdIntegerGe
    ]

mkIntRel2 ::
    LName -> DatatypeRelPr Integer -> UnaryFnTable Integer
    -> DatatypeRel Integer
mkIntRel2 :: LName
-> DatatypeRelPr Integer
-> UnaryFnTable Integer
-> DatatypeRel Integer
mkIntRel2 LName
nam DatatypeRelPr Integer
pr UnaryFnTable Integer
fns = DatatypeRel
    { dtRelName :: ScopedName
dtRelName = Namespace -> LName -> ScopedName
makeNSScopedName Namespace
namespaceXsdInteger LName
nam
    , dtRelFunc :: DatatypeRelFn Integer
dtRelFunc = DatatypeRelPr Integer
-> UnaryFnTable Integer
-> ((Integer -> Bool)
    -> UnaryFnDescr Integer -> [Maybe Integer] -> Maybe [Integer])
-> DatatypeRelFn Integer
forall vt b.
Eq vt =>
DatatypeRelPr vt
-> [(vt -> Bool, [b])]
-> ((vt -> Bool) -> b -> [Maybe vt] -> Maybe [vt])
-> DatatypeRelFn vt
altArgs DatatypeRelPr Integer
pr UnaryFnTable Integer
fns (Integer -> Bool)
-> UnaryFnDescr Integer -> [Maybe Integer] -> Maybe [Integer]
forall a. UnaryFnApply a
unaryFnApp
    }

mkIntRel3 ::
    LName -> DatatypeRelPr Integer -> BinaryFnTable Integer
    -> DatatypeRel Integer
mkIntRel3 :: LName
-> DatatypeRelPr Integer
-> BinaryFnTable Integer
-> DatatypeRel Integer
mkIntRel3 LName
nam DatatypeRelPr Integer
pr BinaryFnTable Integer
fns = DatatypeRel
    { dtRelName :: ScopedName
dtRelName = Namespace -> LName -> ScopedName
makeNSScopedName Namespace
namespaceXsdInteger LName
nam
    , dtRelFunc :: DatatypeRelFn Integer
dtRelFunc = DatatypeRelPr Integer
-> BinaryFnTable Integer
-> ((Integer -> Bool)
    -> BinaryFnDescr Integer -> [Maybe Integer] -> Maybe [Integer])
-> DatatypeRelFn Integer
forall vt b.
Eq vt =>
DatatypeRelPr vt
-> [(vt -> Bool, [b])]
-> ((vt -> Bool) -> b -> [Maybe vt] -> Maybe [vt])
-> DatatypeRelFn vt
altArgs DatatypeRelPr Integer
pr BinaryFnTable Integer
fns (Integer -> Bool)
-> BinaryFnDescr Integer -> [Maybe Integer] -> Maybe [Integer]
forall a. BinaryFnApply a
binaryFnApp
    }

mkIntRel3maybe ::
    LName -> DatatypeRelPr Integer -> BinMaybeFnTable Integer
    -> DatatypeRel Integer
mkIntRel3maybe :: LName
-> DatatypeRelPr Integer
-> BinMaybeFnTable Integer
-> DatatypeRel Integer
mkIntRel3maybe LName
nam DatatypeRelPr Integer
pr BinMaybeFnTable Integer
fns = DatatypeRel
    { dtRelName :: ScopedName
dtRelName = Namespace -> LName -> ScopedName
makeNSScopedName Namespace
namespaceXsdInteger LName
nam
    , dtRelFunc :: DatatypeRelFn Integer
dtRelFunc = DatatypeRelPr Integer
-> BinMaybeFnTable Integer
-> ((Integer -> Bool)
    -> BinMaybeFnDescr Integer -> [Maybe Integer] -> Maybe [Integer])
-> DatatypeRelFn Integer
forall vt b.
Eq vt =>
DatatypeRelPr vt
-> [(vt -> Bool, [b])]
-> ((vt -> Bool) -> b -> [Maybe vt] -> Maybe [vt])
-> DatatypeRelFn vt
altArgs DatatypeRelPr Integer
pr BinMaybeFnTable Integer
fns (Integer -> Bool)
-> BinMaybeFnDescr Integer -> [Maybe Integer] -> Maybe [Integer]
forall a. BinMaybeFnApply a
binMaybeFnApp
    }

relXsdIntegerAbs :: DatatypeRel Integer
relXsdIntegerAbs :: DatatypeRel Integer
relXsdIntegerAbs = LName
-> DatatypeRelPr Integer
-> UnaryFnTable Integer
-> DatatypeRel Integer
mkIntRel2 LName
"abs" (Bool -> DatatypeRelPr Integer
forall a b. a -> b -> a
const Bool
True)
    [ ( (Integer -> Integer -> Bool
forall a. Ord a => a -> a -> Bool
>= Integer
0),     [ (Integer -> Integer
forall a. Num a => a -> a
abs,Int
1) ] )
    , ( Bool -> Integer -> Bool
forall a b. a -> b -> a
const Bool
True, [ (Integer -> Integer
forall a. a -> a
id,Int
0), (Integer -> Integer
forall a. Num a => a -> a
negate,Int
0) ] )
    ]

relXsdIntegerNeg :: DatatypeRel Integer
relXsdIntegerNeg :: DatatypeRel Integer
relXsdIntegerNeg = LName
-> DatatypeRelPr Integer
-> UnaryFnTable Integer
-> DatatypeRel Integer
mkIntRel2 LName
"neg" (Bool -> DatatypeRelPr Integer
forall a b. a -> b -> a
const Bool
True)
    [ ( Bool -> Integer -> Bool
forall a b. a -> b -> a
const Bool
True, [ (Integer -> Integer
forall a. Num a => a -> a
negate,Int
1) ] )
    , ( Bool -> Integer -> Bool
forall a b. a -> b -> a
const Bool
True, [ (Integer -> Integer
forall a. Num a => a -> a
negate,Int
0) ] )
    ]

relXsdIntegerSum :: DatatypeRel Integer
relXsdIntegerSum :: DatatypeRel Integer
relXsdIntegerSum = LName
-> DatatypeRelPr Integer
-> BinaryFnTable Integer
-> DatatypeRel Integer
mkIntRel3 LName
"sum" (Bool -> DatatypeRelPr Integer
forall a b. a -> b -> a
const Bool
True)
    [ ( Bool -> Integer -> Bool
forall a b. a -> b -> a
const Bool
True, [ (Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
(+),Int
1,Int
2) ] )
    , ( Bool -> Integer -> Bool
forall a b. a -> b -> a
const Bool
True, [ ((-),Int
0,Int
2) ] )
    , ( Bool -> Integer -> Bool
forall a b. a -> b -> a
const Bool
True, [ ((-),Int
0,Int
1) ] )
    ]

relXsdIntegerDiff :: DatatypeRel Integer
relXsdIntegerDiff :: DatatypeRel Integer
relXsdIntegerDiff = LName
-> DatatypeRelPr Integer
-> BinaryFnTable Integer
-> DatatypeRel Integer
mkIntRel3 LName
"diff" (Bool -> DatatypeRelPr Integer
forall a b. a -> b -> a
const Bool
True)
    [ ( Bool -> Integer -> Bool
forall a b. a -> b -> a
const Bool
True, [ ((-),Int
1,Int
2) ] )
    , ( Bool -> Integer -> Bool
forall a b. a -> b -> a
const Bool
True, [ (Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
(+),Int
0,Int
2) ] )
    , ( Bool -> Integer -> Bool
forall a b. a -> b -> a
const Bool
True, [ ((-),Int
1,Int
0) ] )
    ]

relXsdIntegerProd :: DatatypeRel Integer
relXsdIntegerProd :: DatatypeRel Integer
relXsdIntegerProd = LName
-> DatatypeRelPr Integer
-> BinaryFnTable Integer
-> DatatypeRel Integer
mkIntRel3 LName
"prod" (Bool -> DatatypeRelPr Integer
forall a b. a -> b -> a
const Bool
True)
    [ ( Bool -> Integer -> Bool
forall a b. a -> b -> a
const Bool
True, [ (Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
(*),Int
1,Int
2) ] )
    , ( Bool -> Integer -> Bool
forall a b. a -> b -> a
const Bool
True, [ (Integer -> Integer -> Integer
forall a. Integral a => a -> a -> a
div,Int
0,Int
2) ] )
    , ( Bool -> Integer -> Bool
forall a b. a -> b -> a
const Bool
True, [ (Integer -> Integer -> Integer
forall a. Integral a => a -> a -> a
div,Int
0,Int
1) ] )
    ]

relXsdIntegerDivMod :: DatatypeRel Integer
relXsdIntegerDivMod :: DatatypeRel Integer
relXsdIntegerDivMod = LName
-> DatatypeRelPr Integer
-> BinaryFnTable Integer
-> DatatypeRel Integer
mkIntRel3 LName
"divmod" (Bool -> DatatypeRelPr Integer
forall a b. a -> b -> a
const Bool
True)
    [ ( Bool -> Integer -> Bool
forall a b. a -> b -> a
const Bool
True, [ (Integer -> Integer -> Integer
forall a. Integral a => a -> a -> a
div,Int
2,Int
3) ] )
    , ( Bool -> Integer -> Bool
forall a b. a -> b -> a
const Bool
True, [ (Integer -> Integer -> Integer
forall a. Integral a => a -> a -> a
mod,Int
2,Int
3) ] )
    , ( Bool -> Integer -> Bool
forall a b. a -> b -> a
const Bool
True, [ ] )
    , ( Bool -> Integer -> Bool
forall a b. a -> b -> a
const Bool
True, [ ] )
    ]

--  Compose with function of two arguments
c2 :: (b -> c) -> (a -> d -> b) -> a -> d -> c
c2 :: forall b c a d. (b -> c) -> (a -> d -> b) -> a -> d -> c
c2 = ((d -> b) -> d -> c) -> (a -> d -> b) -> a -> d -> c
forall b c a. (b -> c) -> (a -> b) -> a -> c
(.) (((d -> b) -> d -> c) -> (a -> d -> b) -> a -> d -> c)
-> ((b -> c) -> (d -> b) -> d -> c)
-> (b -> c)
-> (a -> d -> b)
-> a
-> d
-> c
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (b -> c) -> (d -> b) -> d -> c
forall b c a. (b -> c) -> (a -> b) -> a -> c
(.)

relXsdIntegerPower :: DatatypeRel Integer
relXsdIntegerPower :: DatatypeRel Integer
relXsdIntegerPower = LName
-> DatatypeRelPr Integer
-> BinMaybeFnTable Integer
-> DatatypeRel Integer
mkIntRel3maybe LName
"power" (Bool -> DatatypeRelPr Integer
forall a b. a -> b -> a
const Bool
True)
    [ ( Bool -> Integer -> Bool
forall a b. a -> b -> a
const Bool
True, [ ((Integer -> [Integer]) -> Maybe Integer -> Maybe [Integer]
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Integer -> [Integer] -> [Integer]
forall a. a -> [a] -> [a]
:[]) (Maybe Integer -> Maybe [Integer])
-> (Integer -> Integer -> Maybe Integer)
-> Integer
-> Integer
-> Maybe [Integer]
forall b c a d. (b -> c) -> (a -> d -> b) -> a -> d -> c
`c2` Integer -> Integer -> Maybe Integer
intPower,Int
1,Int
2) ] )
    , ( Bool -> Integer -> Bool
forall a b. a -> b -> a
const Bool
True, [ ] )
    , ( (Integer -> Integer -> Bool
forall a. Ord a => a -> a -> Bool
>= Integer
0),     [ ] )
    ]

lcomp ::
  (a -> a -> Bool)
  -> [a] -- ^ this list must have at least two elements
  -> Bool
lcomp :: forall a. (a -> a -> Bool) -> [a] -> Bool
lcomp a -> a -> Bool
p (a
a1:a
a2:[a]
_) = a -> a -> Bool
p a
a1 a
a2
lcomp a -> a -> Bool
_ [a]
_ = [Char] -> Bool
forall a. HasCallStack => [Char] -> a
error [Char]
"internal error"


-- eq

relXsdIntegerEq :: DatatypeRel Integer
relXsdIntegerEq :: DatatypeRel Integer
relXsdIntegerEq = LName
-> DatatypeRelPr Integer
-> UnaryFnTable Integer
-> DatatypeRel Integer
mkIntRel2 LName
"eq" ((Integer -> Integer -> Bool) -> DatatypeRelPr Integer
forall a. (a -> a -> Bool) -> [a] -> Bool
lcomp Integer -> Integer -> Bool
forall a. Eq a => a -> a -> Bool
(==))
    ( (Integer -> Bool, [UnaryFnDescr Integer]) -> UnaryFnTable Integer
forall a. a -> [a]
repeat (Bool -> Integer -> Bool
forall a b. a -> b -> a
const Bool
True, []) )

-- ne

relXsdIntegerNe :: DatatypeRel Integer
relXsdIntegerNe :: DatatypeRel Integer
relXsdIntegerNe = LName
-> DatatypeRelPr Integer
-> UnaryFnTable Integer
-> DatatypeRel Integer
mkIntRel2 LName
"ne" ((Integer -> Integer -> Bool) -> DatatypeRelPr Integer
forall a. (a -> a -> Bool) -> [a] -> Bool
lcomp Integer -> Integer -> Bool
forall a. Eq a => a -> a -> Bool
(/=))
    ( (Integer -> Bool, [UnaryFnDescr Integer]) -> UnaryFnTable Integer
forall a. a -> [a]
repeat (Bool -> Integer -> Bool
forall a b. a -> b -> a
const Bool
True, []) )

-- lt

relXsdIntegerLt :: DatatypeRel Integer
relXsdIntegerLt :: DatatypeRel Integer
relXsdIntegerLt = LName
-> DatatypeRelPr Integer
-> UnaryFnTable Integer
-> DatatypeRel Integer
mkIntRel2 LName
"lt" ((Integer -> Integer -> Bool) -> DatatypeRelPr Integer
forall a. (a -> a -> Bool) -> [a] -> Bool
lcomp Integer -> Integer -> Bool
forall a. Ord a => a -> a -> Bool
(<))
    ( (Integer -> Bool, [UnaryFnDescr Integer]) -> UnaryFnTable Integer
forall a. a -> [a]
repeat (Bool -> Integer -> Bool
forall a b. a -> b -> a
const Bool
True, []) )

-- le

relXsdIntegerLe :: DatatypeRel Integer
relXsdIntegerLe :: DatatypeRel Integer
relXsdIntegerLe = LName
-> DatatypeRelPr Integer
-> UnaryFnTable Integer
-> DatatypeRel Integer
mkIntRel2 LName
"le" ((Integer -> Integer -> Bool) -> DatatypeRelPr Integer
forall a. (a -> a -> Bool) -> [a] -> Bool
lcomp Integer -> Integer -> Bool
forall a. Ord a => a -> a -> Bool
(<=))
    ( (Integer -> Bool, [UnaryFnDescr Integer]) -> UnaryFnTable Integer
forall a. a -> [a]
repeat (Bool -> Integer -> Bool
forall a b. a -> b -> a
const Bool
True, []) )

-- gt

relXsdIntegerGt :: DatatypeRel Integer
relXsdIntegerGt :: DatatypeRel Integer
relXsdIntegerGt = LName
-> DatatypeRelPr Integer
-> UnaryFnTable Integer
-> DatatypeRel Integer
mkIntRel2 LName
"gt" ((Integer -> Integer -> Bool) -> DatatypeRelPr Integer
forall a. (a -> a -> Bool) -> [a] -> Bool
lcomp Integer -> Integer -> Bool
forall a. Ord a => a -> a -> Bool
(>))
    ( (Integer -> Bool, [UnaryFnDescr Integer]) -> UnaryFnTable Integer
forall a. a -> [a]
repeat (Bool -> Integer -> Bool
forall a b. a -> b -> a
const Bool
True, []) )

-- ge

relXsdIntegerGe :: DatatypeRel Integer
relXsdIntegerGe :: DatatypeRel Integer
relXsdIntegerGe = LName
-> DatatypeRelPr Integer
-> UnaryFnTable Integer
-> DatatypeRel Integer
mkIntRel2 LName
"ge" ((Integer -> Integer -> Bool) -> DatatypeRelPr Integer
forall a. (a -> a -> Bool) -> [a] -> Bool
lcomp Integer -> Integer -> Bool
forall a. Ord a => a -> a -> Bool
(>=))
    ( (Integer -> Bool, [UnaryFnDescr Integer]) -> UnaryFnTable Integer
forall a. a -> [a]
repeat (Bool -> Integer -> Bool
forall a b. a -> b -> a
const Bool
True, []) )

-- |modXsdInteger contains variable binding modifiers for xsd:Integer values.
--
--  The functions are selected from those defined by CWM as math:
--  properties
--  (<http://www.w3.org/2000/10/swap/doc/CwmBuiltins.html>).
--
modXsdInteger :: [RDFDatatypeMod Integer]
modXsdInteger :: [DatatypeMod Integer RDFLabel RDFLabel]
modXsdInteger =
    [ DatatypeMod Integer RDFLabel RDFLabel
modXsdIntegerAbs
    , DatatypeMod Integer RDFLabel RDFLabel
modXsdIntegerNeg
    , DatatypeMod Integer RDFLabel RDFLabel
modXsdIntegerSum
    , DatatypeMod Integer RDFLabel RDFLabel
modXsdIntegerDiff
    , DatatypeMod Integer RDFLabel RDFLabel
modXsdIntegerProd
    , DatatypeMod Integer RDFLabel RDFLabel
modXsdIntegerDivMod
    , DatatypeMod Integer RDFLabel RDFLabel
modXsdIntegerPower
    , DatatypeMod Integer RDFLabel RDFLabel
modXsdIntegerEq
    , DatatypeMod Integer RDFLabel RDFLabel
modXsdIntegerNe
    , DatatypeMod Integer RDFLabel RDFLabel
modXsdIntegerLt
    , DatatypeMod Integer RDFLabel RDFLabel
modXsdIntegerLe
    , DatatypeMod Integer RDFLabel RDFLabel
modXsdIntegerGt
    , DatatypeMod Integer RDFLabel RDFLabel
modXsdIntegerGe
    ]

modXsdIntegerAbs :: RDFDatatypeMod Integer
modXsdIntegerAbs :: DatatypeMod Integer RDFLabel RDFLabel
modXsdIntegerAbs = DatatypeMod
    { dmName :: ScopedName
dmName = Namespace -> LName -> ScopedName
makeNSScopedName Namespace
namespaceXsdInteger LName
"abs"
    , dmModf :: [[Integer] -> [Integer]]
dmModf = [ [Integer] -> [Integer]
forall {a}. (Eq a, Num a) => [a] -> [a]
f0, [Integer] -> [Integer]
forall {a}. Num a => [a] -> [a]
f1 ]
    , dmAppf :: ApplyModifier RDFLabel RDFLabel
dmAppf = ApplyModifier RDFLabel RDFLabel
forall lb vn. (Ord lb, Ord vn) => ApplyModifier lb vn
makeVmod11
    }
    where
        f0 :: [a] -> [a]
f0 vs :: [a]
vs@[a
v1,a
v2] = if a
v1 a -> a -> Bool
forall a. Eq a => a -> a -> Bool
== a -> a
forall a. Num a => a -> a
abs a
v2 then [a]
vs else []
        f0 [a]
_          = []
        f1 :: [a] -> [a]
f1 [a
v2]       = [a -> a
forall a. Num a => a -> a
abs a
v2]
        f1 [a]
_          = []

modXsdIntegerNeg :: RDFDatatypeMod Integer
modXsdIntegerNeg :: DatatypeMod Integer RDFLabel RDFLabel
modXsdIntegerNeg = DatatypeMod
    { dmName :: ScopedName
dmName = Namespace -> LName -> ScopedName
makeNSScopedName Namespace
namespaceXsdInteger LName
"neg"
    , dmModf :: [[Integer] -> [Integer]]
dmModf = [ [Integer] -> [Integer]
forall {a}. (Eq a, Num a) => [a] -> [a]
f0, [Integer] -> [Integer]
forall {a}. Num a => [a] -> [a]
f1, [Integer] -> [Integer]
forall {a}. Num a => [a] -> [a]
f1 ]
    , dmAppf :: ApplyModifier RDFLabel RDFLabel
dmAppf = ApplyModifier RDFLabel RDFLabel
forall lb vn. (Ord lb, Ord vn) => ApplyModifier lb vn
makeVmod11inv
    }
    where
        f0 :: [a] -> [a]
f0 vs :: [a]
vs@[a
v1,a
v2] = if a
v1 a -> a -> Bool
forall a. Eq a => a -> a -> Bool
== a -> a
forall a. Num a => a -> a
negate a
v2 then [a]
vs else []
        f0 [a]
_          = []
        f1 :: [a] -> [a]
f1 [a
vi]       = [-a
vi]
        f1 [a]
_          = []

modXsdIntegerSum :: RDFDatatypeMod Integer
modXsdIntegerSum :: DatatypeMod Integer RDFLabel RDFLabel
modXsdIntegerSum = DatatypeMod
    { dmName :: ScopedName
dmName = Namespace -> LName -> ScopedName
makeNSScopedName Namespace
namespaceXsdInteger LName
"sum"
    , dmModf :: [[Integer] -> [Integer]]
dmModf = [ [Integer] -> [Integer]
forall {a}. (Eq a, Num a) => [a] -> [a]
f0, [Integer] -> [Integer]
forall {a}. Num a => [a] -> [a]
f1, [Integer] -> [Integer]
forall {a}. Num a => [a] -> [a]
f2, [Integer] -> [Integer]
forall {a}. Num a => [a] -> [a]
f2 ]
    , dmAppf :: ApplyModifier RDFLabel RDFLabel
dmAppf = ApplyModifier RDFLabel RDFLabel
forall lb vn. (Ord lb, Ord vn) => ApplyModifier lb vn
makeVmod21inv
    }
    where
        f0 :: [a] -> [a]
f0 vs :: [a]
vs@[a
v1,a
v2,a
v3] = if a
v1 a -> a -> Bool
forall a. Eq a => a -> a -> Bool
== a
v2 a -> a -> a
forall a. Num a => a -> a -> a
+ a
v3 then [a]
vs else []
        f0 [a]
_             = []
        f1 :: [a] -> [a]
f1 [a
v2,a
v3]       = [a
v2 a -> a -> a
forall a. Num a => a -> a -> a
+ a
v3]
        f1 [a]
_             = []
        f2 :: [a] -> [a]
f2 [a
v1,a
vi]       = [a
v1 a -> a -> a
forall a. Num a => a -> a -> a
- a
vi]
        f2 [a]
_             = []

modXsdIntegerDiff :: RDFDatatypeMod Integer
modXsdIntegerDiff :: DatatypeMod Integer RDFLabel RDFLabel
modXsdIntegerDiff = DatatypeMod
    { dmName :: ScopedName
dmName = Namespace -> LName -> ScopedName
makeNSScopedName Namespace
namespaceXsdInteger LName
"diff"
    , dmModf :: [[Integer] -> [Integer]]
dmModf = [ [Integer] -> [Integer]
forall {a}. (Eq a, Num a) => [a] -> [a]
f0, [Integer] -> [Integer]
forall {a}. Num a => [a] -> [a]
f1, [Integer] -> [Integer]
forall {a}. Num a => [a] -> [a]
f2, [Integer] -> [Integer]
forall {a}. Num a => [a] -> [a]
f3 ]
    , dmAppf :: ApplyModifier RDFLabel RDFLabel
dmAppf = ApplyModifier RDFLabel RDFLabel
forall lb vn. (Ord lb, Ord vn) => ApplyModifier lb vn
makeVmod21inv
    }
    where
        f0 :: [a] -> [a]
f0 vs :: [a]
vs@[a
v1,a
v2,a
v3] = if a
v1 a -> a -> Bool
forall a. Eq a => a -> a -> Bool
== a
v2 a -> a -> a
forall a. Num a => a -> a -> a
- a
v3 then [a]
vs else []
        f0 [a]
_             = []
        f1 :: [a] -> [a]
f1 [a
v2,a
v3]       = [a
v2 a -> a -> a
forall a. Num a => a -> a -> a
- a
v3]
        f1 [a]
_             = []
        f2 :: [a] -> [a]
f2 [a
v1,a
v3]       = [a
v1 a -> a -> a
forall a. Num a => a -> a -> a
+ a
v3]
        f2 [a]
_             = []
        f3 :: [a] -> [a]
f3 [a
v1,a
v2]       = [a
v2 a -> a -> a
forall a. Num a => a -> a -> a
- a
v1]
        f3 [a]
_             = []

modXsdIntegerProd :: RDFDatatypeMod Integer
modXsdIntegerProd :: DatatypeMod Integer RDFLabel RDFLabel
modXsdIntegerProd = DatatypeMod
    { dmName :: ScopedName
dmName = Namespace -> LName -> ScopedName
makeNSScopedName Namespace
namespaceXsdInteger LName
"prod"
    , dmModf :: [[Integer] -> [Integer]]
dmModf = [ [Integer] -> [Integer]
forall {a}. (Eq a, Num a) => [a] -> [a]
f0, [Integer] -> [Integer]
forall {a}. Num a => [a] -> [a]
f1, [Integer] -> [Integer]
forall {a}. Integral a => [a] -> [a]
f2, [Integer] -> [Integer]
forall {a}. Integral a => [a] -> [a]
f2 ]
    , dmAppf :: ApplyModifier RDFLabel RDFLabel
dmAppf = ApplyModifier RDFLabel RDFLabel
forall lb vn. (Ord lb, Ord vn) => ApplyModifier lb vn
makeVmod21inv
    }
    where
        f0 :: [a] -> [a]
f0 vs :: [a]
vs@[a
v1,a
v2,a
v3] = if a
v1 a -> a -> Bool
forall a. Eq a => a -> a -> Bool
== a
v2 a -> a -> a
forall a. Num a => a -> a -> a
* a
v3 then [a]
vs else []
        f0 [a]
_             = []
        f1 :: [a] -> [a]
f1 [a
v2,a
v3]       = [a
v2 a -> a -> a
forall a. Num a => a -> a -> a
* a
v3]
        f1 [a]
_             = []
        f2 :: [a] -> [a]
f2 [a
v1,a
vi]       = [a
q | a
r a -> a -> Bool
forall a. Eq a => a -> a -> Bool
== a
0]
            where (a
q,a
r)  = a -> a -> (a, a)
forall a. Integral a => a -> a -> (a, a)
quotRem a
v1 a
vi
        f2 [a]
_             = []

modXsdIntegerDivMod :: RDFDatatypeMod Integer
modXsdIntegerDivMod :: DatatypeMod Integer RDFLabel RDFLabel
modXsdIntegerDivMod = DatatypeMod
    { dmName :: ScopedName
dmName = Namespace -> LName -> ScopedName
makeNSScopedName Namespace
namespaceXsdInteger LName
"divmod"
    , dmModf :: [[Integer] -> [Integer]]
dmModf = [ [Integer] -> [Integer]
forall {a}. Integral a => [a] -> [a]
f0, [Integer] -> [Integer]
forall {a}. Integral a => [a] -> [a]
f1 ]
    , dmAppf :: ApplyModifier RDFLabel RDFLabel
dmAppf = ApplyModifier RDFLabel RDFLabel
forall lb vn. (Ord lb, Ord vn) => ApplyModifier lb vn
makeVmod22
    }
    where
        f0 :: [b] -> [b]
f0 vs :: [b]
vs@[b
v1,b
v2,b
v3,b
v4] = if (b
v1,b
v2) (b, b) -> (b, b) -> Bool
forall a. Eq a => a -> a -> Bool
== b -> b -> (b, b)
forall a. Integral a => a -> a -> (a, a)
divMod b
v3 b
v4 then [b]
vs else []
        f0 [b]
_                = []
        f1 :: [a] -> [a]
f1 [a
v3,a
v4]          = [a
v1,a
v2] where (a
v1,a
v2) = a -> a -> (a, a)
forall a. Integral a => a -> a -> (a, a)
divMod a
v3 a
v4
        f1 [a]
_                = []

modXsdIntegerPower :: RDFDatatypeMod Integer
modXsdIntegerPower :: DatatypeMod Integer RDFLabel RDFLabel
modXsdIntegerPower = DatatypeMod
    { dmName :: ScopedName
dmName = Namespace -> LName -> ScopedName
makeNSScopedName Namespace
namespaceXsdInteger LName
"power"
    , dmModf :: [[Integer] -> [Integer]]
dmModf = [ [Integer] -> [Integer]
f0, [Integer] -> [Integer]
f1 ]
    , dmAppf :: ApplyModifier RDFLabel RDFLabel
dmAppf = ApplyModifier RDFLabel RDFLabel
forall lb vn. (Ord lb, Ord vn) => ApplyModifier lb vn
makeVmod21
    }
    where
        f0 :: [Integer] -> [Integer]
f0 vs :: [Integer]
vs@[Integer
v1,Integer
v2,Integer
v3] = if Integer -> Maybe Integer
forall a. a -> Maybe a
Just Integer
v1 Maybe Integer -> Maybe Integer -> Bool
forall a. Eq a => a -> a -> Bool
== Integer -> Integer -> Maybe Integer
intPower Integer
v2 Integer
v3 then [Integer]
vs else []
        f0 [Integer]
_             = []
        f1 :: [Integer] -> [Integer]
f1 [Integer
v2,Integer
v3]       = Maybe Integer -> [Integer]
forall a. Maybe a -> [a]
maybeToList (Integer -> Integer -> Maybe Integer
intPower Integer
v2 Integer
v3)
        f1 [Integer]
_             = []

modXsdIntegerEq, modXsdIntegerNe, modXsdIntegerLt, modXsdIntegerLe, modXsdIntegerGt, modXsdIntegerGe :: RDFDatatypeMod Integer 
modXsdIntegerEq :: DatatypeMod Integer RDFLabel RDFLabel
modXsdIntegerEq = LName
-> (Integer -> Integer -> Bool)
-> DatatypeMod Integer RDFLabel RDFLabel
modXsdIntegerCompare LName
"eq" Integer -> Integer -> Bool
forall a. Eq a => a -> a -> Bool
(==)
modXsdIntegerNe :: DatatypeMod Integer RDFLabel RDFLabel
modXsdIntegerNe = LName
-> (Integer -> Integer -> Bool)
-> DatatypeMod Integer RDFLabel RDFLabel
modXsdIntegerCompare LName
"ne" Integer -> Integer -> Bool
forall a. Eq a => a -> a -> Bool
(/=)
modXsdIntegerLt :: DatatypeMod Integer RDFLabel RDFLabel
modXsdIntegerLt = LName
-> (Integer -> Integer -> Bool)
-> DatatypeMod Integer RDFLabel RDFLabel
modXsdIntegerCompare LName
"lt" Integer -> Integer -> Bool
forall a. Ord a => a -> a -> Bool
(<)
modXsdIntegerLe :: DatatypeMod Integer RDFLabel RDFLabel
modXsdIntegerLe = LName
-> (Integer -> Integer -> Bool)
-> DatatypeMod Integer RDFLabel RDFLabel
modXsdIntegerCompare LName
"le" Integer -> Integer -> Bool
forall a. Ord a => a -> a -> Bool
(<=)
modXsdIntegerGt :: DatatypeMod Integer RDFLabel RDFLabel
modXsdIntegerGt = LName
-> (Integer -> Integer -> Bool)
-> DatatypeMod Integer RDFLabel RDFLabel
modXsdIntegerCompare LName
"gt" Integer -> Integer -> Bool
forall a. Ord a => a -> a -> Bool
(>)
modXsdIntegerGe :: DatatypeMod Integer RDFLabel RDFLabel
modXsdIntegerGe = LName
-> (Integer -> Integer -> Bool)
-> DatatypeMod Integer RDFLabel RDFLabel
modXsdIntegerCompare LName
"ge" Integer -> Integer -> Bool
forall a. Ord a => a -> a -> Bool
(>=)

modXsdIntegerCompare ::
    LName -> (Integer->Integer->Bool) -> RDFDatatypeMod Integer
modXsdIntegerCompare :: LName
-> (Integer -> Integer -> Bool)
-> DatatypeMod Integer RDFLabel RDFLabel
modXsdIntegerCompare LName
nam Integer -> Integer -> Bool
rel = DatatypeMod
    { dmName :: ScopedName
dmName = Namespace -> LName -> ScopedName
makeNSScopedName Namespace
namespaceXsdInteger LName
nam
    , dmModf :: [[Integer] -> [Integer]]
dmModf = [ [Integer] -> [Integer]
f0 ]
    , dmAppf :: ApplyModifier RDFLabel RDFLabel
dmAppf = ApplyModifier RDFLabel RDFLabel
forall lb vn.
(Eq lb, Show lb, Eq vn, Show vn) =>
ApplyModifier lb vn
makeVmod20
    }
    where
        f0 :: [Integer] -> [Integer]
f0 vs :: [Integer]
vs@[Integer
v1,Integer
v2] = if Integer -> Integer -> Bool
rel Integer
v1 Integer
v2 then [Integer]
vs else []
        f0 [Integer]
_          = []

-- |rulesetXsdInteger contains rules and axioms that allow additional
--  deductions when xsd:integer values appear in a graph.
--
--  The rules defined here are concerned with basic integer arithmetic
--  operations: +, -, *, div, rem
--
--  makeRuleset :: Namespace -> [Formula ex] -> [Rule ex] -> Ruleset ex
--
rdfRulesetXsdInteger :: RDFRuleset
rdfRulesetXsdInteger :: Ruleset RDFGraph
rdfRulesetXsdInteger =
    Namespace
-> [Formula RDFGraph] -> [Rule RDFGraph] -> Ruleset RDFGraph
forall ex. Namespace -> [Formula ex] -> [Rule ex] -> Ruleset ex
makeRuleset Namespace
namespaceXsdInteger [Formula RDFGraph]
axiomsXsdInteger [Rule RDFGraph]
rulesXsdInteger

prefixXsdInteger :: B.Builder
prefixXsdInteger :: Builder
prefixXsdInteger = 
  [Builder] -> Builder
forall a. Monoid a => [a] -> a
mconcat ([Builder] -> Builder) -> [Builder] -> Builder
forall a b. (a -> b) -> a -> b
$ (Namespace -> Builder) -> [Namespace] -> [Builder]
forall a b. (a -> b) -> [a] -> [b]
map Namespace -> Builder
namespaceToBuilder
              [ Namespace
namespaceRDF
              , Namespace
namespaceRDFS
              , Namespace
namespaceRDFD
              , Namespace
namespaceXSD
              , Namespace
namespaceXsdInteger
              ]

mkAxiom :: LName -> B.Builder -> RDFFormula
mkAxiom :: LName -> Builder -> Formula RDFGraph
mkAxiom LName
local Builder
gr =
    Namespace -> LName -> Builder -> Formula RDFGraph
makeRDFFormula Namespace
namespaceXsdInteger LName
local (Builder
prefixXsdInteger Builder -> Builder -> Builder
forall a. Monoid a => a -> a -> a
`mappend` Builder
gr)

-- | The axioms for @xsd:integer@, which are
--
-- > xsd:integer a rdfs:Datatype .
--
axiomsXsdInteger :: [RDFFormula]
axiomsXsdInteger :: [Formula RDFGraph]
axiomsXsdInteger =
    [ LName -> Builder -> Formula RDFGraph
mkAxiom LName
"dt"      Builder
"xsd:integer rdf:type rdfs:Datatype ."
    ]

-- | The rules for @xsd:integer@.
rulesXsdInteger :: [RDFRule]
rulesXsdInteger :: [Rule RDFGraph]
rulesXsdInteger = DatatypeVal RDFGraph Integer RDFLabel RDFLabel
-> RDFGraph -> [Rule RDFGraph]
forall vt. RDFDatatypeVal vt -> RDFGraph -> [Rule RDFGraph]
makeRDFDatatypeRestrictionRules DatatypeVal RDFGraph Integer RDFLabel RDFLabel
rdfDatatypeValXsdInteger RDFGraph
gr
    where
        gr :: RDFGraph
gr = Builder -> RDFGraph
makeRDFGraphFromN3Builder Builder
rulesXsdIntegerBuilder

--- I have removed the newline which was added between each line
--- to improve the clarity of parser errors.
---
rulesXsdIntegerBuilder :: B.Builder
rulesXsdIntegerBuilder :: Builder
rulesXsdIntegerBuilder = 
  [Builder] -> Builder
forall a. Monoid a => [a] -> a
mconcat
  [ Builder
prefixXsdInteger
    , Builder
"xsd_integer:Abs a rdfd:GeneralRestriction ; "
    , Builder
"  rdfd:onProperties (rdf:_1 rdf:_2) ; "
    , Builder
"  rdfd:constraint xsd_integer:abs ; "
    , Builder
"  rdfd:maxCardinality \"1\"^^xsd:nonNegativeInteger . "
    , Builder
"xsd_integer:Neg a rdfd:GeneralRestriction ; "
    , Builder
"  rdfd:onProperties (rdf:_1 rdf:_2) ; "
    , Builder
"  rdfd:constraint xsd_integer:neg ; "
    , Builder
"  rdfd:maxCardinality \"1\"^^xsd:nonNegativeInteger . "
    , Builder
"xsd_integer:Sum a rdfd:GeneralRestriction ; "
    , Builder
"  rdfd:onProperties (rdf:_1 rdf:_2 rdf:_3) ; "
    , Builder
"  rdfd:constraint xsd_integer:sum ; "
    , Builder
"  rdfd:maxCardinality \"1\"^^xsd:nonNegativeInteger . "
    , Builder
"xsd_integer:Diff a rdfd:GeneralRestriction ; "
    , Builder
"  rdfd:onProperties (rdf:_1 rdf:_2 rdf:_3) ; "
    , Builder
"  rdfd:constraint xsd_integer:diff ; "
    , Builder
"  rdfd:maxCardinality \"1\"^^xsd:nonNegativeInteger . "
    , Builder
"xsd_integer:Prod a rdfd:GeneralRestriction ; "
    , Builder
"  rdfd:onProperties (rdf:_1 rdf:_2 rdf:_3) ; "
    , Builder
"  rdfd:constraint xsd_integer:prod ; "
    , Builder
"  rdfd:maxCardinality \"1\"^^xsd:nonNegativeInteger . "
    , Builder
"xsd_integer:DivMod a rdfd:GeneralRestriction ; "
    , Builder
"  rdfd:onProperties (rdf:_1 rdf:_2 rdf:_3 rdf:_4) ; "
    , Builder
"  rdfd:constraint xsd_integer:divmod ; "
    , Builder
"  rdfd:maxCardinality \"1\"^^xsd:nonNegativeInteger . "
    , Builder
"xsd_integer:Power a rdfd:GeneralRestriction ; "
    , Builder
"  rdfd:onProperties (rdf:_1 rdf:_2 rdf:_3) ; "
    , Builder
"  rdfd:constraint xsd_integer:power ; "
    , Builder
"  rdfd:maxCardinality \"1\"^^xsd:nonNegativeInteger . "
    , Builder
"xsd_integer:Eq a rdfd:GeneralRestriction ; "
    , Builder
"  rdfd:onProperties (rdf:_1 rdf:_2) ; "
    , Builder
"  rdfd:constraint xsd_integer:eq ; "
    , Builder
"  rdfd:maxCardinality \"1\"^^xsd:nonNegativeInteger . "
    , Builder
"xsd_integer:Ne a rdfd:GeneralRestriction ; "
    , Builder
"  rdfd:onProperties (rdf:_1 rdf:_2) ; "
    , Builder
"  rdfd:constraint xsd_integer:ne ; "
    , Builder
"  rdfd:maxCardinality \"1\"^^xsd:nonNegativeInteger . "
    , Builder
"xsd_integer:Lt a rdfd:GeneralRestriction ; "
    , Builder
"  rdfd:onProperties (rdf:_1 rdf:_2) ; "
    , Builder
"  rdfd:constraint xsd_integer:lt ; "
    , Builder
"  rdfd:maxCardinality \"1\"^^xsd:nonNegativeInteger . "
    , Builder
"xsd_integer:Le a rdfd:GeneralRestriction ; "
    , Builder
"  rdfd:onProperties (rdf:_1 rdf:_2) ; "
    , Builder
"  rdfd:constraint xsd_integer:le ; "
    , Builder
"  rdfd:maxCardinality \"1\"^^xsd:nonNegativeInteger . "
    , Builder
"xsd_integer:Gt a rdfd:GeneralRestriction ; "
    , Builder
"  rdfd:onProperties (rdf:_1 rdf:_2) ; "
    , Builder
"  rdfd:constraint xsd_integer:gt ; "
    , Builder
"  rdfd:maxCardinality \"1\"^^xsd:nonNegativeInteger . "
    , Builder
"xsd_integer:Ge a rdfd:GeneralRestriction ; "
    , Builder
"  rdfd:onProperties (rdf:_1 rdf:_2) ; "
    , Builder
"  rdfd:constraint xsd_integer:ge ; "
    , Builder
"  rdfd:maxCardinality \"1\"^^xsd:nonNegativeInteger . "
    ]
  
--------------------------------------------------------------------------------
--
--  Copyright (c) 2003, Graham Klyne, 2009 Vasili I Galchin,
--    2011, 2012, 2014, 2018, 2022, 2024 Douglas Burke
--  All rights reserved.
--
--  This file is part of Swish.
--
--  Swish is free software; you can redistribute it and/or modify
--  it under the terms of the GNU General Public License as published by
--  the Free Software Foundation; either version 2 of the License, or
--  (at your option) any later version.
--
--  Swish is distributed in the hope that it will be useful,
--  but WITHOUT ANY WARRANTY; without even the implied warranty of
--  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
--  GNU General Public License for more details.
--
--  You should have received a copy of the GNU General Public License
--  along with Swish; if not, write to:
--    The Free Software Foundation, Inc.,
--    59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
--
--------------------------------------------------------------------------------