Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parser for GDOL, first attempt #1911

Draft
wants to merge 33 commits into
base: master
Choose a base branch
from
Draft

parser for GDOL, first attempt #1911

wants to merge 33 commits into from

Conversation

mcodescu
Copy link
Collaborator

@mcodescu mcodescu commented Aug 9, 2019

Not intended for merging, ignore any style issue or use of tracing messages.
Issues:


pattern ValSet [Class: Val;  {Individual: v0} :: vS; ? ObjectProperty: greater] 
= %% all individuals vi from v0::vS become members of Val
let pattern OrderStep [Individual: vi; {Individual: vj} :: vS] =
     Individual: vj Types: Val Facts: greater vi
    then OrderStep[vj; vS]
    end
in   Individual: v0 Types: Val
then SimpleOrder[greater; Val] and OrderStep[v0; vS]
then { DifferentIndividuals: vs, vS
       Class: Val EquivalentTo: {vj, vS} } 

gives a parse error because the list is not the last element in the list of parameters. Moving the optional argument before it makes the example go through. The fact that the parameter following the list is optional has no relevance (removing the ? still gives an error).
I would have the same problem in instantiations P[A; X::Xs; B] so I have not implemented this yet.

logic OWL 

pattern GradedRels 
  [Class: S; Class: T; 
   ObjectProperty: p Domain: S Range: T; 
   Class: Val;
   {Individual: v Types: Val} :: valS  ]
= %% a sheaf of graded relations p[vi], one for each vi in v::valS
let pattern Step[Individual: x :: xs] =
     ObjectProperty: p[x] Domain: S Range: T SubPropertyOf: p 
     then Step[xs]
    end
    pattern Test [Class: C] =
     Class: C SubClassOf: S
    end
in Onto and Step[v::valS] and 
   { ObjectProperty: has[Val] Domain: T Range: Val } and Test[S]

goes through, but removing the optional end after the local patterns makes the parser fail (skip as a separator most likely not the best idea). At the level of libItems, that also have an optional end, these are parsed with a recursive function that also tries to parse annotation. Should follow the same approach here?

logic OWL

pattern P[Class: C; ?ObjectProperty: p; Class: D] =
 Class: C SubClassOf: p only D
end
ontology O = P[A; ;B] 

How should I parse the missing optional parameter?

logic OWL
pattern SimpleOrder [Class: C] =
 TransitiveRelation[greater[C]; C] 

Using hetIRI to parse greater[C] does not work. I have used compoundIriCurie. But I wonder if hetIRI does what it should.

@mcodescu mcodescu requested a review from tillmo August 9, 2019 12:02
@mcodescu
Copy link
Collaborator Author

Adding "pattern" to Common/Keywords.hs/startingKeywords and ";" and "::" to Common/Keywords.hs/terminatingKeywords makes first two issues work. This is not a solution because ";" is used in CASL as a separator. I wonder if it wouldn't have been easier to consider sort s; op c : s as two arguments instead of one (works with sequential semantics).

@mcodescu
Copy link
Collaborator Author

With

logic CASL

pattern FixPoint[sort s; op c : s; op f : s -> s] =
 . f(c) = c
end

I get only one parameter:

[OntoParam False (Annoted {item = Basic_spec Basic_spec [Annoted {item = Sig_items (Sort_items NonEmptySorts [Annoted {item = Sort_decl [s] nullRange, opt_pos = nullRange, l_annos = [], r_annos = []}] nullRange), opt_pos = nullRange, l_annos = [], r_annos = []},Annoted {item = Sig_items (Op_items [Annoted {item = Op_decl [c] (Op_type Total [] s nullRange) [] nullRange, opt_pos = nullRange, l_annos = [], r_annos = []}] nullRange), opt_pos = nullRange, l_annos = [], r_annos = []},Annoted {item = Sig_items (Op_items [Annoted {item = Op_decl [f] (Op_type Total [s] s nullRange) [] nullRange, opt_pos = nullRange, l_annos = [], r_annos = []}] nullRange), opt_pos = nullRange, l_annos = [], r_annos = []}] nullRange, opt_pos = nullRange, l_annos = [], r_annos = []})

This surprises me a bit, I thought ";" as a terminating would make me have 3 parameters. We can get 3 parameters using the notation of the paper pattern FixPoint[{sort s}; {op c : s}; {op f : s -> s}] =..., which is good news.

@tillmo
Copy link
Contributor

tillmo commented Aug 13, 2019

I think the reason is that the basic spec parser uses other terminating keywords than the structured spec and library parsers.

@tillmo tillmo marked this pull request as draft August 24, 2023 07:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants