How do I exclude functions from properties on formal verification model? - pact-lang

I want to exclude the genesis mint function from the conserves-mass property
(module account GOVERNANCE
#doc "Account doc"
#model
[ (defproperty conserves-mass
(= (column-delta ledger 'balance ) 0.0))]
...
(defun transfer-create:string
( sender:string
receiver:string
receiver-guard:guard
amount:decimal )
#doc "create account when transfer doc"
#model [ (property conserves-mass)] <- I want to exclude mint function here
...
I found this example
https://github.com/kadena-io/pact/blob/4971ab6078b75eb612d83d56f1e7cd139a5a2ba8/examples/verified-accounts/accounts.pact#L27
where they do an except logic but it makes no sense to me how this 'except work and I can't make it work. I don't know what I'm missing.
I found nothing about this on the documentation
https://pact-language.readthedocs.io/en/stable/pact-properties.html
#model
[
...
; every function should conserve mass except for the admin fund-account,
; and debit / credit which should be private
(property conserves-mass
{'except: [fund-account, debit, credit]})
...
]

Related

Where to find a dataset with literal data already annotated with dbpedia property concepts (having their range in float or int)?

I'm working on a project that tries to map DBpedia concepts to table data columns. Specifically I wanted to map literal(numerical values; float, int..). Therefore I need adequate number of data to build a background knowledge base. I extract some data from T2D-golden-dataset as the given format at the end of this description. Actually I should use them as a bench mark for testing and it only contains less than 20 columns from overall tables. Could anyone help me to find such a literal valued and dbpedia annotated dataset ?
Literal valued dbpedia ranges;
"http://www.w3.org/2001/XMLSchema#float"
"http://www.w3.org/2001/XMLSchema#integer"
"http://www.w3.org/2001/XMLSchema#positiveInteger"
"http://www.w3.org/2001/XMLSchema#integer"
Some properties having these ranges;
"http://dbpedia.org/ontology/speaker",
"http://dbpedia.org/ontology/ranking",
"http://dbpedia.org/ontology/humanDevelopmentIndex",
"http://dbpedia.org/ontology/numberOfPlatformLevels",
"http://dbpedia.org/ontology/enginePower",
"http://dbpedia.org/ontology/graySubject",
"http://dbpedia.org/ontology/shareOfAudience",
"http://dbpedia.org/ontology/percentageLiteracyWomen",.........
Sample examples I need to found or somehow generate is an array corresponding to concepts given above. For an example;
"http://dbpedia.org/ontology/enginePower" : ["220", "125", "1300",....],
"http://dbpedia.org/ontology/humanDevelopmentIndex" : ["0.34", "0.78", "0.98", ...]
I don't need that exact format. It would be great If I can find enough number of data tables given as T2D golden dataset for dbpedia.
This query starts you down the road, as it gets you 100 typed literal values for <http://dbpedia.org/ontology/populationTotal>, which are all typed as <http://www.w3.org/2001/XMLSchema#nonNegativeInteger> --
PREFIX dbo: <http://dbpedia.org/ontology/>
SELECT DISTINCT ?value
WHERE
{ ?subject dbo:populationTotal ?value }
LIMIT 100
This rather more complex (and expensive) query gets you something like the end result I think you want -- but you will need to run it a number of times, for a few predicates at a time, to get everything you're asking for from the public endpoint. If needed, you could spin up your own DBpedia mirror instance in the AWS cloud, and adjust Virtuoso's timeouts and other limits, in order to build and run one query that would deliver one giant result set.
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX dbo: <http://dbpedia.org/ontology/>
SELECT # DISTINCT ?predicate ?value ?value_type ?value_str
?predicate ?value_type ( GROUP_CONCAT ( DISTINCT ?value_str ; separator=", " ) AS ?values )
WHERE
{ ?subject ?predicate ?value
VALUES ( ?predicate ) { ( dbo:numberOfPlatformLevels )
( dbo:shareOfAudience )
( dbo:populationTotal )
}
BIND ( DATATYPE ( ?value ) AS ?value_type )
BIND ( STR ( ?value ) AS ?value_str )
}
GROUP BY ?predicate ?value_type
ORDER BY ?predicate ?value_type
LIMIT 1000

How to add an attribute to an LDAP schema

I am trying to add a new attribute named sAMAccountName to an already existing LDAP schema definition which is read by IM-LDAP using UnboundID LDAP SDK.
I have added an attributeTypes entry and sAMAccountName to matchingRuleUse.
attributeTypes: ( 2.5.18.11 NAME 'sAMAccountName' DESC 'MS Sec Principal User' EQUALITY distinguishedNameMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )
matchingRuleUse: ( 2.5.13.1 NAME 'distinguishedNameMatch' APPLIES ( creatorsName $ ... $ sAMAccountName ) )
For every previously existing attribute a call to com.unboundid.ldap.sdk.schema.Schema.getAttributeType("attrName") returns the attribute type. But not for my new attribute.
What am I missing?
Edited 10/11/18 after #jwilleke comment:
What I am trying to achieve is a mock using IM-LDAP for a very limited functionality of an Active Directory server.
In the actual AD production environment, there are entries representing users with objectClass: person, organizationalPerson,simulatedMicrosoftSecurityPrincipal.
In AD these entries contain sAMAccountName and memberof attributes.
But they are not there in the schema that comes with IM-LDAP.
The authentication Java code first performs a search on
(&(objectClass=user)(sAMAccountName=userAccountName)
Then if an entry in found, it checks whether a given security group name is present in the multivalued attribute memberof.
An entry exported from the production AD server looks like this :
dn: cn=Smith\,John,ou=User Accounts,dc=ACME,dc=CORE,dc=INT
changetype: add
objectClass: person
objectClass: organizationalPerson
objectClass: simulatedMicrosoftSecurityPrincipal
cn: Smith,John
sn: JohnS
sAMAccountName: JohnS
userPassword: johnspasswd
memberof: ou=Service Accounts,dc=ACME,dc=CORE,dc=INT
The two new attributes are added to objectClass simulatedMicrosoftSecurityPrincipal in the schema by adding:
objectClasses: ( 2.5.6.24 NAME 'simulatedMicrosoftSecurityPrincipal' DESC 'MSSecurityPrincipal' SUP top AUXILIARY MUST sAMAccountName MAY memberof )
But when I try to import these entries into the LDAP mock I get an error telling me that sAMAccountName and memberof are not defined.
EDIT 2:
attributeTypes: ( 1.2.840.113556.1.4.221 NAME 'sAMAccountName' SYNTAX '1.3.6.1.4.1.1466.115.121.1.15' SINGLE-VALUE )
Wokrked for adding sAMAccountName, but still trying to figure out how to add memeberOf
Here is the complete .ldif file.
This is what finally worked for me
objectClasses: ( 1.2.840.113556.1.5.6 NAME 'microsoftSecurityPrincipal' DESC 'MS SecurityPrincipal' SUP top AUXILIARY MUST ( sAMAccountName $ memberOf ) )
attributeTypes: ( 1.2.840.113556.1.4.221 NAME 'sAMAccountName' SYNTAX '1.3.6.1.4.1.1466.115.121.1.15' SINGLE-VALUE )
attributeTypes: ( 1.2.840.113556.1.2.102 NAME 'memberOf' SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 )

What is object in the GRANT <permission> in SQL Server?

What could be [ OBJECT :: ][ schema_name ]. object_name in the
GRANT <permission> [ ,...n ] ON
[ OBJECT :: ][ schema_name ]. object_name [ ( column [ ,...n ] ) ]
TO <database_principal> [ ,...n ]
[ WITH GRANT OPTION ]
[ AS <database_principal> ]
Could it be a table or view?
OBJECT here refers to any of the things that exist in sys.objects. From the documentation for sys.objects, that could be any of
AGGREGATE_FUNCTION
CHECK_CONSTRAINT
CLR_SCALAR_FUNCTION
CLR_STORED_PROCEDURE
CLR_TABLE_VALUED_FUNCTION
CLR_TRIGGER
DEFAULT_CONSTRAINT
EXTENDED_STORED_PROCEDURE
FOREIGN_KEY_CONSTRAINT
INTERNAL_TABLE
PLAN_GUIDE
PRIMARY_KEY_CONSTRAINT
REPLICATION_FILTER_PROCEDURE
RULE
SEQUENCE_OBJECT
SERVICE_QUEUE
SQL_INLINE_TABLE_VALUED_FUNCTION
SQL_SCALAR_FUNCTION
SQL_STORED_PROCEDURE
SQL_TABLE_VALUED_FUNCTION
SQL_TRIGGER
SYNONYM
SYSTEM_TABLE
TABLE_TYPE
UNIQUE_CONSTRAINT
USER_TABLE
VIEW
Mind you, not every permission makes sense for every type of object. For instance, you can't grant execute permission to a table. Indeed, not every object type can be the target of a grant (primary keys, for instance). The documentation for grant has a nice list near the bottom of each type of securable and link to a documentation page for what permissions can be granted to it.
I'm not entirely sure if this is what you're asking, but the OBJECT :: keyword here isn't meant to be replaced by some sort of identifier such as TABLE ::, it's meant to be specified literally as OBJECT ::. It's used to indicate that you want to grant permissions to an object as opposed to, say, a schema. According to this page, an object is any schema-level securable, such as a table, view, stored procedure, sequence, etc.
Also according to that page, the OBJECT :: keyword is optional if schema_name is specified. That leads me to believe that the need for specifying OBJECT :: is simply to make sure the database it's what type of entity the permissions are being granted to, since permissions can be granted to objects, schemas, server principles, and more.

OWL 2 reasoning with SWRL rules

I'm trying to use the HermiT reasoner to compute inferences for an ontology which contains a set of OWL axioms and a SWRL rule:
Ontology(
ClassAssertion( :Student :Bob )
ClassAssertion( :Professor :DrBoffin )
ClassAssertion( :University :UF )
ObjectPropertyAssertion( :supervises :DrBoffin :Bob )
ObjectPropertyAssertion( :worksAt :DrBoffin :UF )
EquivalentClasses( :Student ObjectHasSelf( :r1 ))
EquivalentClasses(
ObjectHasSelf( :r2 )
ObjectSomeValuesFrom( :worksAt :University ))
SubObjectPropertyOf(
ObjectPropertyChain( :r2 :supervises :r1 ) :professorOf )
DLSafeRule(Body(ObjectPropertyAtom( :professorOf Variable( ?x ) Variable( ?y )))
Head(ObjectPropertyAtom( :instructorOf Variable( ?x ) Variable( ?y ))))
)
Basically, the OWL part is trying to express such a rule:
worksAt(x, y), University(y), supervises(x, z), Student(z) -> professorOf(x, z)
using property chain and rolification techniques:
The SWRL part is:
professorOf(x, y) -> instructorOf(x, y)
The expected output should contain both ObjectPropertyAssertion( :professorOf :DrBoffin :Bob ) and ObjectPropertyAssertion( :instructorOf :DrBoffin :Bob ). However, the actual output is (showing only object properties)
ObjectPropertyAssertion( :r1 :Bob :Bob )
ObjectPropertyAssertion( :professorOf :DrBoffin :Bob )
ObjectPropertyAssertion( :r2 :DrBoffin :DrBoffin )
ObjectPropertyAssertion( :supervises :DrBoffin :Bob )
ObjectPropertyAssertion( :worksAt :DrBoffin :UF)
Why isn't the expected SWRL result showing up? Any suggestions?
After re-reading your question, I realized that the rule you are trying to represent is
worksAt(x, y), University(y), supervises(x, z), Student(z) → professorOf(x, z)
but that you are trying to represent it, essentially by
(worksAt some University)(x), supervises(x, z), Student(z) → professorOf(x, z)
which is actually a valid SWRL rule, even though it has a complex class expression. (See Can OWL Class Expressions be used in SWRL Rules? for more information. Even though they're valid, the Protégé editor didn't accept that input, though it would display rules correctly if they are already in the ontology.)
Although it can be expressed in SWRL, that will only cover cases where the individuals are named, so the rolification based solution will cover more cases. So, the idea is to create a role rWorksAtSomeUniversity (the rolification of worksAt some University) and a role rStudent (the rolification of Student, and then to assert that
rWorksAtSomeUniversity o supervises o rStudent SubPropertyOf professorOf
Then, to relate professorOf and instructorOf, you can either use a SWRL rule
professorOf(x,y) → instructorOf(x,y)
or a subproperty axiom
professorOf SubPropertyOf instructorOf
As with rolification-based rule, the non-SWRL rule will cover more cases, and does not require that the reasoner have SWRL support.
Here's an ontology that contains these classes and axioms, in the OWL functional syntax. It's not wonderfully human readable, but it's complete; you should be able to download it and test it out with your reasoner.
Prefix(xsd:=<http://www.w3.org/2001/XMLSchema#>)
Prefix(owl:=<http://www.w3.org/2002/07/owl#>)
Prefix(ex:=<http://www.example.com/university#>)
Prefix(xml:=<http://www.w3.org/XML/1998/namespace>)
Prefix(rdf:=<http://www.w3.org/1999/02/22-rdf-syntax-ns#>)
Prefix(rdfs:=<http://www.w3.org/2000/01/rdf-schema#>)
Ontology(<http://www.example.com/university>
Declaration(Class(ex:Professor))
Declaration(Class(ex:Student))
EquivalentClasses(ex:Student ObjectHasSelf(ex:rStudent))
Declaration(Class(ex:University))
Declaration(ObjectProperty(ex:instructorOf))
Declaration(ObjectProperty(ex:professorOf))
SubObjectPropertyOf(ex:professorOf ex:instructorOf)
Declaration(ObjectProperty(ex:rStudent))
Declaration(ObjectProperty(ex:rWorksAtSomeUniversity))
Declaration(ObjectProperty(ex:supervises))
Declaration(ObjectProperty(ex:worksAt))
Declaration(NamedIndividual(ex:Bob))
ClassAssertion(ex:Student ex:Bob)
Declaration(NamedIndividual(ex:DrBoffin))
ClassAssertion(ex:Professor ex:DrBoffin)
ObjectPropertyAssertion(ex:supervises ex:DrBoffin ex:Bob)
ObjectPropertyAssertion(ex:worksAt ex:DrBoffin ex:UF)
Declaration(NamedIndividual(ex:UF))
ClassAssertion(ex:University ex:UF)
EquivalentClasses(ObjectHasSelf(ex:rWorksAtSomeUniversity) ObjectSomeValuesFrom(ex:worksAt ex:University))
SubObjectPropertyOf(ObjectPropertyChain(ex:rWorksAtSomeUniversity ex:supervises ex:rStudent) ex:professorOf)
)
Both Pellet and HermiT 1.3.7 can produce the inferences:
DrBoffin professorOf Bob
DrBoffin instructorOf Bob

Is there an Erwin Macro to pull out the table comment/definition?

I created a script template to generate the extendend properties to basically to include the data dictionary in the database, however, i couldn't find any macro to read-out the table comment from the model. Is there any hack for this?
The is DBMS specific in ERwin.
Depending on the dbms - SQL server or oracle will have a FET template.
for sql server.
if you edit the sql server template for creating schema. which in sql server is what generate comments or udp extended properties. here is what is shown.
/* Generate comments and UDP's as Extended Properties. */
[
/* Set the variables required by the "Clause: Specify Extended Properties". */
Set( "var_RemoveVariables", "true" )
Set( "var_Operation", "sp_addextendedproperty" )
Set( "var_Comment", "Definition" )
Set( "var_Level0Type", "SCHEMA" )
Set( "var_Level0Name", Property( "Name" ) )
/* Generate Schema comments and UDPs */
Execute( "Clause: Specify Extended Properties" )
]
[
FE::Bucket( "150" )
ForEachOwnee( "Permission" )
{
Execute( "Create Permission" )
}
]
]

Resources