range restriction/domain restriction in Isabelle - set

I am trying to input a schema into Isabelle however when I add range restriction or domain restriction into the theorem prover it doesn't want to parse. I have the following schema in LaTeX:
\begin{schema}{VideoShop}
members: \power PERSON \\
rented: PERSON \rel TITLE \\
stockLevel: TITLE \pfun \nat
\where
\dom rented \subseteq members \\
\ran rented \subseteq \dom stockLevel \\
\forall t: \ran rented # \# (rented \rres \{t\}) \leq stockLevel~t
\end{schema}
When inputting this into Isabelle I get the following:
locale videoshop =
fixes members :: "PERSON set"
and rented :: "(PERSON * TITLE) set"
and stockLevel :: "(TITLE * nat) set"
assumes "Domain rented \<subseteq> members"
and "Range rented \<subseteq> Domain stockLevel"
and "(\<forall> t. (t \<in> Range rented) \<and> (card (rented \<rhd> {t}) \<le> stockLevel t))"
begin
.....
It all parses except for the last expression \<forall> t.....
I just don't understand how to add range restriction into Isabelle.

There are multiple problems with your input.
The ⊳ symbol you are using in the expression
(rented ⊳ {t})
is not associated with any operator, so it can't be parsed. I'm not quite sure what it's supposed to mean. From the high-level idea of the specification I'm guessing something along the lines of "all persons who rented a specific title". This can be expressed most easily with a set comprehension:
{p. (p, t) ∈ rented}
You translated the bounded universal quantifier into a quantifier containing a conjunction. This is likely not what you want, because it says "for all t, t is in the range of rented and something else". Isabelle has notation for bounded quantifiers.
∀t ∈ Range rented. ...
You are trying to use stockLevel as a function, which it isn't. From your LaTeX input I gather that it's supposed to be a partial function. Isabelle calls these maps. The appropriate type is:
TITLE ⇀ nat
Note the "harpoon" symbol instead of a function arrow. The domain function for maps is called dom. The second locale assumption can be expressed as:
Range rented ⊆ dom stockLevel
Given that, you can use stockLevel as a function from TITLE to nat option.

Related

are z3 variables with same name in z3 python API always treated as equals?

In following examples z3 assumes that 2 symbols with same name are equal.
solve(Int('z')<Int('z'))
returns: "no solution"
from z3 import *
x1=Int('x')
x2=Int('x')
x3=Int('x')
solve(x1*x2*x3==27)
returns:"[x = 3]"
Can I assume that z3 always treats symbols with same name and type as equals? For example if I have an equation with variable Int type variable z - can replace "z" with "Int('z')" everywhere in the equation and be sure that output will be the same?
Can I assume that z3 always treats function-symbols with same name and same type of arguments as equals like in following example:
S1 = DeclareSort('S1')
S2 = DeclareSort('S2')
x1=Const("x",S1)
x2=Const("x",S2)
f1=Function('F', S1, S1,S2,IntSort())
f2=Function('F', S1, S1,S2,IntSort())
solve(f1(x1,x1,x2)<f2(x1,x1,x2))
returns:"no solution"
Can I assume that z3 never treats function-symbols with same name, but different type or number of arguments as equals like in following example:
S1 = DeclareSort('S1')
S2 = DeclareSort('S2')
x1=Const("x",S1)
x2=Const("x",S2)
f1=Function('F', S1, S1,S2,IntSort())
f2=Function('F', S1, S2,S2,IntSort())
solve(f1(x1,x1,x2)<f2(x1,x2,x2))
returns:"
[x = S2!val!0,
x = S1!val!0,
F = [else -> 1],
F = [else -> 0]]
"
In Z3 variables are identified by name and sort. So, if two variables have the same name and sort then they are the same. Correspondingly, if they either have different names OR sorts, then they are different. The sort is the type and for function names the type is a function type. (i.e. there’s no special treatment for function names. You can think of ordinary variables as functions that take 0 arguments.)
In particular, two different variables can have the same name so long as they have different sorts. This can be rather confusing, however, since when z3 prints the corresponding SMTLib or models, you won’t have an obvious indication showing which one is which. So I’d advise against using the same name even if the sorts differ.

Description Logics and Ontologies: How to denote role domain-restrictions to blank nodes

Request for assistance denoting a domain-restriction to a blank node.
Figure 1: Modelling a many-to-many relationship with a blank node.
Business Rule: An Enrolment maps one Student to one Section, once.
My attempt:
∃hasStudent.⊤ ≡ ∃hasSection.⊤ ≡ ∃grade_code.⊤
i.e. "the set of individuals that have some value for the role 'hasStudent' is the same set of individuals that have some value for the role 'hasSection' ...e.t.c."
I assume equivalence here instead of inclusion since the inclusions would be in both directions.
Restricting further:
∃hasStudent.⊤ ≡ ∃hasSection.⊤ ≡ ∃grade_code.⊤ ≡ =1hasStudent.⊤ ≡ =1hasSection.⊤ ≡ =1grade_code.⊤
i.e. "the set of individuals that have values for the roles 'hasStudent', 'hasSection' and 'grade_code', have one and only one value for them."
Assistance or comments on correctly denoting the domain-restrictions of the object properties in figure 1 would be appreciated.
Thanks!!
OWL's Open World assumption is going to prevent you from finding "the set of individuals that have values for the roles 'hasStudent', 'hasSection' and 'grade_code', have one and only one value for them."
However, using SPARQL, you could create an ASK query that does just what you are asking for:
ASK {
SELECT (count(?student) AS ?stcount) (count(?section) AS ?secount) (count(?course) AS ?ccount)
WHERE {
?indiv :hasStudent ?student .
?indiv :hasSection ?section .
?indiv :grade_course ?course .
} GROUP BY ?student ?section ?course
HAVING (stcount = 1 && ?secount = 1 && ?ccount = 1)
}
A bit akward syntactically, since the aggregates need to be computed by a SELECT statement. The ASK will return true if the 'constraints' (see the HAVING clause) are all true and false otherwise.
For future reference the SHACL (RDF Shapes Constraint Language) work at W3C is intended to shore up these kinds of constraint violation problems that are not possible to answer with OWL.
If I understand your intent correctly, you want these restrictions to apply to any use of these properties rather than only for a specific class.
Under this assumption, you can achieve this by declaring the properties functional and setting their domain to C. In Functional syntax:
Prefix(owl:=<http://www.w3.org/2002/07/owl#>)
Prefix(rdf:=<http://www.w3.org/1999/02/22-rdf-syntax-ns#>)
Prefix(xml:=<http://www.w3.org/XML/1998/namespace>)
Prefix(xsd:=<http://www.w3.org/2001/XMLSchema#>)
Prefix(rdfs:=<http://www.w3.org/2000/01/rdf-schema#>)
Ontology(
Declaration(Class(<urn:test:C>))
Declaration(ObjectProperty(<urn:test:hasSection>))
Declaration(ObjectProperty(<urn:test:hasStudent>))
Declaration(DataProperty(<urn:test:grade_code>))
FunctionalObjectProperty(<urn:test:hasSection>)
ObjectPropertyDomain(<urn:test:hasSection> <urn:test:C>)
FunctionalObjectProperty(<urn:test:hasStudent>)
ObjectPropertyDomain(<urn:test:hasStudent> <urn:test:C>)
FunctionalDataProperty(<urn:test:grade_code>)
DataPropertyDomain(<urn:test:grade_code> <urn:test:C>)
SubClassOf(<urn:test:C> ObjectIntersectionOf(ObjectSomeValuesFrom(<urn:test:hasSection> owl:Thing) ObjectSomeValuesFrom(<urn:test:hasStudent> owl:Thing) DataSomeValuesFrom(<urn:test:grade_code> rdfs:Literal)))
)

Alloy constraint specification

I wrote the following code block in Alloy:
one h: Human | h in s.start => {
s'.currentCall = h.from
}
I want to pick one 'human' from a set of humans (s.start) and set a variable (s'.currentCall) equal to h.from.
However I think this code is saying: There is only one human in s.start, where
s'.currentCall = h.from
is true.
Is my assumption correct? And how should I fix this?
You are absolutely correct, the meaning of the one quantifier is that there is exactly one element in the given domain (set) such that the quantifier body holds true.
Regarding your original goal of picking one element from a set and setting its field value to something: that sounds like an imperative update, and you can't really do that directly in Alloy; Alloy is fully declarative, so you can only assert logical statements about the sets and relations for a bounded universe of discourse.
If you just change one to some and also change the implication to conjunction, and then run the analysis (a simple run command to find a valid instance), the Alloy Analyzer will find a model in which the value s'.currentCall is equal to h.from for some (arbitrary) h from s.start:
pred p[s, s': S] {
some h: s.start | s'.currentCall = h.from
}
run p
I hope this is what you want to achieve.

How do I make a function use the altered version of a list in Mathematica?

I want to make a list with its elements representing the logic map given by
x_{n+1} = a*x_n(1-x_n)
I tried the following code (which adds stuff manually instead of a For loop):
x0 = Input["Enter x0"]
a = Input["a"]
M = {x0}
L[n_] := If[n < 1, x0, a*M[[n]]*(1 - M[[n]])]
Print[L[1]]
Append[M, L[1]]
Print[M]
Append[M, L[2]]
Print[M]
The output is as follows:
0.3
2
{0.3}
0.42
{0.3,0.42}
{0.3}
Part::partw: Part 2 of {0.3`} does not exist. >>
Part::partw: Part 2 of {0.3`} does not exist. >>
{0.3, 2 (1 - {0.3}[[2]]) {0.3}[[2]]}
{0.3}
It seems that, when the function definition is being called in Append[M,L[2]], L[2] is calling M[[2]] in the older definition of M, which clearly does not exist.
How can I make L use the newer, bigger version of M?
After doing this I could use a For loop to generate the entire list up to a certain index.
P.S. I apologise for the poor formatting but I could find out how to make Latex code work here.
Other minor question: What are the allowed names for functions and lists? Are underscores allowed in names?
It looks to me as if you are trying to compute the result of
FixedPointList[a*#*(1-#)&, x0]
Note:
Building lists element-by-element, whether you use a loop or some other construct, is almost always a bad idea in Mathematica. To use the system productively you need to learn some of the basic functional constructs, of which FixedPointList is one.
I'm not providing any explanation of the function I've used, nor of the interpretation of symbols such as # and &. This is all covered in the documentation which explains matters better than I can and with which you ought to become familiar.
Mathematica allows alphanumeric (only) names and they must start with a letter. Of course, Mathematic recognises many Unicode characters other than the 26 letters in the English alphabet as alphabetic. By convention (only) intrinsic names start with an upper-case letter and your own with a lower-case.
The underscore is most definitely not allowed in Mathematica names, it has a specific and widely-used interpretation as a short form of the Blank symbol.
Oh, LaTeX formatting doesn't work hereabouts, but Mathematica code is plenty readable enough.
It seems that, when the function definition is being called in
Append[M,L2], L2 is calling M[2] in the older definition of M,
which clearly does not exist.
How can I make L use the newer, bigger version of M?
M is never getting updated here. Append does not modify the parameters you pass to it; it returns the concatenated value of the arrays.
So, the following code:
A={1,2,3}
B=Append[A,5]
Will end up with B={1,2,3,5} and A={1,2,3}. A is not modfied.
To analyse your output,
0.3 // Output of x0 = Input["Enter x0"]. Note that the assignment operator returns the the assignment value.
2 // Output of a= Input["a"]
{0.3} // Output of M = {x0}
0.42 // Output of Print[L[1]]
{0.3,0.42} // Output of Append[M, L[1]]. This is the *return value*, not the new value of M
{0.3} // Output of Print[M]
Part::partw: Part 2 of {0.3`} does not exist. >> // M has only one element, so M[[2]] doesn't make sense
Part::partw: Part 2 of {0.3`} does not exist. >> // ditto
{0.3, 2 (1 - {0.3}[[2]]) {0.3}[[2]]} (* Output of Append[M, L[2]]. Again, *not* the new value of M *)
{0.3} // Output of Print[M]
The simple fix here is to use M=Append[M, L[1]].
To do it in a single for loop:
xn=x0;
For[i = 0, i < n, i++,
M = Append[M, xn];
xn = A*xn (1 - xn)
];
A faster method would be to use NestList[a*#*(1-#)&, x0,n] as a variation of the method mentioned by Mark above.
Here, the expression a*#*(1-#)& is basically an anonymous function (# is its parameter, the & is a shorthand for enclosing it in Function[]). The NestList method takes a function as one argument and recursively applies it starting with x0, for n iterations.
Other minor question: What are the allowed names for functions and lists? Are underscores allowed in names?
No underscores, they're used for pattern matching. Otherwise a variable can contain alphabets and special characters (like theta and all), but no characters that have a meaning in mathematica (parentheses/braces/brackets, the at symbol, the hash symbol, an ampersand, a period, arithmetic symbols, underscores, etc). They may contain a dollar sign but preferably not start with one (these are usually reserved for system variables and all, though you can define a variable starting with a dollar sign without breaking anything).

opennlp chunker and postag results

Java - opennlp
I am new to opennlp and i am try to analyze the sentence and have the post tag and chunk result but I could not understand the values meaning. Is there any table which can explain the post tag and chunk result values full form meaning ?
Tokens: [My, name, is, Chris, corrale, and, I, live, in, Philadelphia, USA, .]
Post Tags: [PRP$, NN, VBZ, NNP, NN, CC, PRP, VBP, IN, NNP, NNP, .]
chunk Result: [B-NP, I-NP, B-VP, B-NP, I-NP, O, B-NP, B-VP, B-PP, B-NP, I-NP, O]
The POS tags are from the Penn Treebank tagset. The chunks are noun phrases (NP), verb phrases (VP), and prepositions (PP). "B-.." marks the beginning of such a phrase, "I-.." means something like "inner", i.e. the phrase continues here (see OpenNLP docs).
S -> Simple declarative clause, i.e. one that is not introduced by a
(possible empty) subordinating
conjunction or a wh-word and that does not exhibit subject-verb
inversion.
SBAR -> Clause introduced by a (possibly empty) subordinating conjunction.
SBARQ -> Direct question introduced by a wh-word or a wh-phrase.
Indirect questions and relative clauses should be bracketed as
SBAR, not SBARQ.
SINV -> Inverted declarative sentence, i.e. one in which the subject
follows the tensed verb or modal.
SQ -> Inverted yes/no question, or main clause of a wh-question, following
the wh-phrase in SBARQ.
ADJP -> Adjective Phrase.
ADVP -> Adverb Phrase.
CONJP -> Conjunction Phrase.
FRAG -> Fragment.
INTJ -> Interjection. Corresponds approximately to the part-of-speech tag
UH.
LST -> List marker. Includes surrounding punctuation.
NAC -> Not a Constituent; used to show the scope of certain prenominal
modifiers within an NP.
NP -> Noun Phrase.
NX -> Used within certain complex NPs to mark the head of the NP.
Corresponds very roughly to N-bar
PP -> Prepositional Phrase.
PRN -> Parenthetical.
PRT -> Particle. Category for words that should be tagged RP.
QP -> Quantifier Phrase (i.e. complex measure/amount phrase); used within
NP.
RRC -> Reduced Relative Clause.
UCP -> Unlike Coordinated Phrase.
VP -> Verb Phrase.
WHADJP -> Wh-adjective Phrase. Adjectival phrase containing a wh-adverb, as
in how hot.
WHAVP -> Wh-adverb Phrase. Introduces a clause with an NP gap. May be null
(containing the 0 complementizer)
or lexical, containing a wh-adverb such as how or why.
WHNP -> Wh-noun Phrase. Introduces a clause with an NP gap. May be null
(containing the 0 complementizer)
or lexical, containing some wh-word, e.g. who, which book, whose
daughter, none of which, or how
many leopards.
WHPP -> Wh-prepositional Phrase. Prepositional phrase containing a wh-noun
phrase
(such as of which or by whose authority) that either introduces a
PP gap or is contained by a WHNP.
X -> Unknown, uncertain, or unbracketable. X is often used for bracketing
typos and in bracketing
the...the-constructions.
Credit: http://mail-archives.apache.org/mod_mbox/opennlp-users/201402.mbox/%3CCACQuOSXOeyw2O-AZtW3m=iABo1=3cpZOdPiWFXoNwN-SVWo4gQ#mail.gmail.com%3E
Please refer the POSTag list to get the tags details.
Chunk tags like "B-NP" are made up of two or three parts:
First part:
B - marks the beginning of a chunk
I - marks the continuation of a chunk
E - marks the end of a chunk
As a chunk,it may be only one word long (like "She" in the example above), it can be both beginning and end of a chunk at the same time.
Second part:
NP - noun chunk
VP - verb chunk
For more reference you can refer the OpenNLP Documentation.

Resources