|
Post by sumedhghaisas on May 24, 2014 12:53:55 GMT -8
According to the Definition 15 in GDL Specs logic.stanford.edu/classes/cs227/2013/readings/gdl_spec.pdf description ( role robot1 ) ( role robot2 ) ( <= ( test ?x ) ( test2 ?x ) ) ( <= ( test2 ?x ) ( test ?x ) ( role ?x ) ) is valid But considering model there are more than one model which satisfies this For Example Model 1: ( role robot1 ) ( role robot2 ) Model 2: ( role robot1 ) ( role robot2 ) ( test robot1 ) ( test2 robot1 ) Model 3: ( role robot1 ) ( role robot2 ) ( test robot1 ) ( test robot2 ) ( test2 robot1 ) ( test2 robot2 ) All these models can be infered by this description... So is this description valid?? If it is then how to the player will decide between models??
|
|
levb
New Member
Posts: 18
|
Post by levb on May 25, 2014 8:35:36 GMT -8
Model 1 is the correct one, because it's minimal.
This is a rather tricky case of applying the minimality rule.
|
|
|
Post by sumedhghaisas on May 25, 2014 13:14:54 GMT -8
Yes you are right. I am trying to create a robust parser of GDL with Bison. Even though role, input, etc are reserved relations, if I type (role (role robot)) into online gamechecker it does not give me any errors. Is this correct?? I believe there should be a formalized construct for any language.
|
|
levb
New Member
Posts: 18
|
Post by levb on May 25, 2014 22:16:45 GMT -8
Interesting. Is there a rule saying that a symbol can't be both a relation and a function? Anyway, the gamechecker might have errors.
|
|
|
Post by sumedhghaisas on May 26, 2014 13:47:30 GMT -8
hummm... I searched a little I didn't find any such rule. But I guess for code readability at least reserved keywords should be reserved. As role should only be used as relation and only with 1 argument to it. Comments??
|
|
|
Post by sumedhghaisas on May 26, 2014 16:04:24 GMT -8
One more thing... What about (not (not (test ?x))).. In this is variable x bounded?? Logically it should be. Still gamechecker gives error on this.
|
|
|
Post by Stephan Schiffel on May 27, 2014 7:26:20 GMT -8
One more thing... What about (not (not (test ?x))).. In this is variable x bounded?? Logically it should be. Still gamechecker gives error on this. No its not bound. "not" is not the same as logical negation. It has a negation as failure semantics. AFAIK, there is no rule preventing the same symbol to be used both as a relation and as function or even for several relations or functions of different arity. The specification of GDL does not say anything about that. Anyway, it should probably be avoided when writing game descriptions because it is confusing to read and may break some players. In my code I typically try support all these cases but print a warning message when I detect them.
|
|
|
Post by alandau on May 27, 2014 14:29:22 GMT -8
If you're testing the validity of game descriptions, I believe the StaticValidator in GGP-Base is more complete than the online gamechecker. (There's a comment in the code indicating what it does and doesn't test.)
It's still ambiguous whether a constant can be used as both a sentence name and a function name, though. The StaticValidator returns this as a warning, but not an error.
My understanding is that "not" should have a sentence as its contents, and not any other type of literal.
|
|
|
Post by sumedhghaisas on May 28, 2014 14:32:51 GMT -8
Yes the interesting question would be what restrictions do we have in GDL semantics?? Same symbol can be used as both function and relations or even several relations or functions of different arity. Only restriction I can think of is goal relation or arity 2 has to have number or variable as second argument. So that goal values can be compared. What other restriction do we have??
|
|
|
Post by sumedhghaisas on May 28, 2014 17:02:34 GMT -8
Okay I found this in Coursera GGP notes - "A GDL description is an open logic program with the following input and output relations. (1) A GDL game description must give complete definitions for role, base, input, init. (2) It must define legal and goal and terminal in terms of an input true relation. (3) It must define next in terms of input true and does relations. Since does and true are treated as inputs, there must not be any rules with either of these relations in the head."
So relation does and true cannot appear as head. But as relation is defined by both its identifier and arity we can say that does/2 and true/1 cannot appear as head. Also I don't think not/1, or/*(expect 0) and distinct/2 can appear as head. If role/1, base/1, input/2 and init/1 appears as head, does/2 and true/1 cannot appear as premiss.
Okay about statement numbered 2... It says legal, goal and terminal has to be defined in terms of relations true. Does that mean it is necessary to have atleast one term having relation true in its premisses?? if it is then they cannot appear as a fact. But then in the game of Untwisty Corridor legal moves are defined as a fact. I guess defining legal moves without true/1 relation makes sense. But the case is different for goal/2 relation and terminal/0 relation. Defining terminal relation without true/1 will make the game worthless as game won't will end before it starts. But still i this illegal?? Same case with goal relation. And in this whole discussion we missed does/2 relation.
Same case with next/1 relation described in rule 3. I think a formal document describing the semantics of language GDL should be there. This will help both the development of games and development of this language itself...
|
|
|
Post by alandau on May 28, 2014 21:15:27 GMT -8
The GDL spec (which you linked to in your original post) says, in Definition 16, "A set of relation constants with associated arity" and "A set of function constants with associated arity". I read that as saying that a given relation constant or function constant should have only one arity associated with it, and this is a restriction the StaticValidator checks. "not", "or", and "distinct" can't appear in the head because they're just part of the Datalog variant that GDL is embedded in (much like the "<=" operator); they aren't sentences, unlike the other keywords. You may want to get to know the structure of the Gdl classes in the GGP-Base codebase: - A rule has a sentence as its head and literals in the body - A literal may be a sentence or an "or", "not", or "distinct" - An "or" has literals as its contents - A "not" has a literal as its contents, though arguably it should only be allowed to have a sentence as its contents - A "distinct" has terms as its contents - A sentence may be a relation or a proposition, depending on whether its arity is 0, but this usually doesn't matter; it has a constant as its name, and if it's a relation, it has terms in its body - A term may be a constant, variable, or function - A function has a constant as a name and terms in its body More details/examples here: alloyggp.blogspot.com/2013/02/a-quick-guide-to-gdl-terminology.html"If role/1, base/1, input/2 and init/1 appears as head, does/2 and true/1 cannot appear as premises." It's a little more restrictive than that; there shouldn't even be any recursive dependencies from role/init/base/input on true/does. They should be fixed and not depend on the state of the game. In fact, "role" should not be in the head of a rule at all. That would mess up the way the GGP communication protocol depends on the ordering of the roles within the game. As for defining legal/goal/terminal "in terms of true", this is just loosely saying that they're allowed to depend on the current state of the game. They may do so directly or indirectly, or not at all. You can think of it like a function on the true state; you can use the state or ignore it in your function output, but you're not allowed to use the "does" contents, since those aren't known to you. Only "next" can use "does", and it can also use "true". Having a game that is terminal in its initial state is pretty useless, though I don't know that it's ever been called out as being illegal. Incidentally, I found that implementing and testing a PropNetStateMachine helped me understand these relationships better.
|
|
|
Post by sumedhghaisas on May 29, 2014 11:11:14 GMT -8
Thank you very much alandau... I guess this clarifies all the doubts I had till now.
|
|
|
Post by sumedhghaisas on May 29, 2014 14:27:25 GMT -8
So I have finally fixed the grammar I am going to use (after lot of revisions).
terminals: Obracket :- ")" Cbracket :- "(" role :- "role" base :- "base" input :- "input" and like this all reserved keywords are terminals id :- any symbols appearing except reserved keywords, variables and numbers num :- any number var :- variable clause_command :- "<="
S : Fact S S : Clause S S : %empty
Fact : Obracket role Ground_term Cbracket Fact : Obracket base Ground_term Cbracket Fact : Obracket input Ground_term Ground_term Cbracket Fact : Obracket init Ground_term Cbracket Fact : Obracket goal Ground_term num Cbracket Fact : Obracket next Ground_term Cbracket Fact : Obracket legal Ground_term Ground_term Cbracket Fact : terminal Fact : Obracket Id_num Ground_term Ground_terms Cbracket Fact : Id_num
Ground_term : Obracket Id_num Ground_term Ground_terms Cbracket Ground_term : Id_num
Ground_terms : Ground_term Ground_terms Ground_terms : %empty
Id_num : id Id_num : num
Clause : Obracket clause_command Head ORelation Relations Cbracket
Head : Obracket role Term Cbracket Head : Obracket base Term Cbracket Head : Obracket input Term Term Cbracket Head : Obracket init Term Cbracket Head : Obracket legal Term Term Cbracket Head : Obracket goal Term Num_var Cbracket Head : Obracket next Term Cbracket Head : terminal Head : Id_num Head : Obracket Term Terms Cbracket
ORelation : Obracket role CTerm Cbacket ORelation : Obracket base CTerm Cbracket ORelation : Obracket input CTerm Cbracket ORelation : Obracket init CTerm Cbracket ORelation : Obracket goal CTerm CTerm Cbracket ORelation : Obracket next CTerm Cbracket ORelation : Obracket legal CTerm CTerm Cbracket ORelation : terminal ORelation : Obracket does CTerm CTerm Cbracket ORelation : Obracket not ORelation Cbracket ORelation : Obracket or ORelation ORelations Cbracket ORelation : Obracket distinct CTerm CTerm Cbracket ORelation : Obracket true CTrem CTerm Cbracket ORelation : Obracket Id_num ORelation ORelations Cbracket ORelation : Id_num
ORelations : ORelation ORelations ORelations : %empty
Term : Obracket Id_num Term Terms Cbracket Term : Id_num Term : var
Terms : Term Terms Terms : %empty
CTerm : Obracket Id_num CTerm CTerms Cbracket CTerm : Id_num CTerm : var
CTerms : CTerm CTerms CTerms : %empty
Num_var : num Num_var : var
The above grammar is modified to produce following error -
1) With the help of symbol table using relation of function with more than one arity produces error. 2) With the help of symbol table produces error if symbol is used for both function and relation 3) Stratified Negation and other errors mentioned in GDL spec can be detected with symbol table and dependency graph 4) All the semantical errors.. such as true, does, not etc. cannot appear as head 5) Goal relation can only accept number as its second argument. (Or it can be a variable in which case error detection is little difficult. Haven't found a way to do so. )
The above grammer is modified to produce following warnings -
1) Is Defined?? :- A symbol is defined if it appear in at least one fact or head of one rule. 2) terminal and goal relation appearing as a fact
Any more errors and warnings that can be added??
|
|
|
Post by alandau on May 31, 2014 17:39:43 GMT -8
Is that a straight copy-paste of your grammar? I see a few issues: 1) Obracket should be "(", Cbracket should be ")" 2) In the "Fact" definitions, the first argument of each of role, input, goal, and legal should be an Id_num instead of a Ground_term, since player names shouldn't be functions 3) "Head : Obracket role Term Cbracket" -> I'd remove this, as roles shouldn't be defined in rules. (Unless this is a way to turn this into a custom error in the semantic stage of compilation?) 4) "Head : Obracket Term Terms Cbracket" -> This should have an Id_num before the Term. 5) "ORelation : Obracket true CTrem CTerm Cbracket" -> Should be just one CTerm 6) "ORelation : Obracket Id_num ORelation ORelations Cbracket" -> This should have "CTerm CTerms" in place of "ORelation ORelations" 7) I'd remove "ORelation : Obracket base CTerm Cbracket" and the corresponding ORelation definitions for input, init, terminal, and next, as these aren't supposed to be used in further rules. I've also heard this about legal and goal, but have seen those two used as arguments in practice. Again, this may not apply if you intend to handle these as errors elsewhere in the compilation process. I don't know why Term and CTerm have to be different, but I'm not a compiler expert and don't know how you might be able to use that distinction. A goal relation appearing as a fact can be fine, when used to create randomness; see Beat-Mania: www.ggp.org/view/tiltyard/games/base/beatMania/v0/ However, if the goal value is anything other than 100 this should generate a warning, based on the winnability criterion. There should probably be a warning if a "not" ORelation contains a "not", "or", or "distinct" ORelation, as these can all be expressed in different, better ways.
|
|
|
Post by sumedhghaisas on Jun 1, 2014 15:14:43 GMT -8
Okay yeah.. very sorry... few typos there
1) Obracket is "(" and Cbracket is ")" 2) Yes I certainly did forgot that... so I have made the appropriate changes there Fact : Obracket role Id_num Cbracket 3) Yes this is there for a custom error in the semantic stage of compilation But now I think for the first primary step this should be removed.. Later can be added with no difficulties... 4) Another Typo... Its Head : Obracket Id_num Term Terms Cbracket 5) Yet another typo... Its Head : Obracket true Cterm Cbracket 6) So many typos now... Its ORelation : Obracket Id_num CTerm CTerms Cbracket 7) According to Definition 20 of GDl_spec I have removed init from appearing in bodies. But about role, base, input, terminal, goal and legal it does not mention anything?? Is there any complication faced when we do use these relations in bodies??
CTerm is introduced to produce a warning of undefined symbol. Yet there is no restriction in GDL which specifies that symbol has to be defined, but debugging typos will be simplied by these warning. For example if someone writes a clause with relation "testing" as its head and then uses "testin" in body of some other clause then this typo can be detected with undefined symbol "testin" warning. As I have mentioned a symbol is defined if it appears in at-least a fact or a head...
About the goal value not being 100, I agree... This can be taken care in semantic stage. I am noting all the semantical warning. This is certaily added now.
About the last point... I did add the functionality of producing warning when "not", "or" appearing inside "not"... But then I removed it as even though these situations can be expressed in different better ways... there is no syntactical or semantical flaw in it... rather this case should be taken as a possible optimization... like parser will optimize these situations and produce simple clauses...
As you can see Head uses Term and tail uses CTerm which stands for checking
|
|