noughtmare / parsing-ddgs

Parsing Data-Dependent Grammars using Derivatives
0 stars 0 forks source link

Meeting 7 Nov #17

Open noughtmare opened 2 weeks ago

noughtmare commented 2 weeks ago

TODO:

Alternative view: Language is an abstract syntax class equipped with an equivalence relation.

noughtmare commented 2 weeks ago

Here’s an example of a grammar where you need to nest fix (which I discussed with Benedikt after you left Casper):

-- X ::= X '+' X | Y
-- Y ::= Y '*' Y | '(' X ')' | 'x'
--
-- expr2 = fix (λ X → (X ⋆ '+' ⋆ X)
--                  ∪ fix (λ Y → Y ⋆ '*' ⋆ Y
--                             ∪ '(' ⋆ X ⋆ ')'
--                             ∪ 'x'))
--
expr2 : Desc 0
expr2 =
  fix ((var Fin.zero ⋆ ‵ ‵+ ⋆ var Fin.zero)
      ∪ fix (var Fin.zero ⋆ ‵ ‵* ⋆ var Fin.zero
           ∪ ‵ ‵[ ⋆ var (Fin.suc Fin.zero) ⋆ ‵ ‵]
           ∪ ‵ ‵x))
noughtmare commented 2 weeks ago

@benediktahrens I don't think the alternative representation of languages as abstract syntax with equivalence relations works, because two different strings may have the same abstract syntax. For example "1+2" and "1 + 2" (with spaces).

benediktahrens commented 2 weeks ago

@noughtmare : I had not thought of that. But I disagree with your conclusion. Instead, I would say that the equivalence relation on strings is not the trivial one (as we said in our discussion), but instead one that throws away meaningless characters (like the spaces).

More generally, I would not say that a mathematical model "works" or "does not work". It might capture, or not, certain phenomena. If it does not capture a given phenomenon that we want it to capture, then it needs to be refined. ("Refinement" usually means that it needs to be made more complicated.) This is an iterative process, in my experience.

Here, this could mean that instead of considering one morphism of setoids, it could be useful to consider a commutative triangle of setoids, or some such thing - that's the research part!