Functional Languages Should Allow Expr Within repo

From RuleML Wiki
Jump to: navigation, search


--Boleyh (talk) 17:42, 2 August 2017 (ADT)

1 Issue Description

In http://deliberation.ruleml.org/1.03/exa/Holog/nafhologeq/serialise_fail.ruleml (explained in http://www.cs.unb.ca/~boley/talks/RuleMLInductiveProgramming.pdf ), function calls are done inside <repo>s to splice values into larger <Expr>s/<Plex>es.

E.g., for avoiding a cons operator as in cons([X,Y],pairlists(L,M)), the tup operator as in

A = tup([X,Y]|pairlists(L,M)).

can be used. This example's serialization

    <Equal>
      <Var>a</Var>
      <Expr>
        <Fun per="value">Plex</Fun>
        <Plex>
          <Var>x</Var>
          <Var>y</Var>
        </Plex>
        <repo>
          <Expr>
            <Fun per="value">pairlists</Fun>
            <Var>l</Var>
            <Var>m</Var>
          </Expr>
        </repo>
      </Expr>
    </Equal>

marks up the 'rest' infix "|" as a <repo> edge. [This example is somewhat ad hoc as it uses both <Fun per="value">Plex</Fun> and <Plex>].

We need to first identify the language(s) capturing this expressivity, e.g Hornlog and/or beyond, and then generalize the content model of <repo> for those to allow <repo> with <Expr>.

2 Options

2.1 Option 0

Status quo - no change.

2.2 Option 1

E.g., with a fresh variable R, the above nesting can be flattened to the conjunction

R = pairlists(L,M), A = tup([X,Y]|R)

which has the serialization

<And>
    <Equal>
        <Var>r</Var>
        <Expr>
          <Fun per="value">pairlists</Fun>
          <Var>l</Var>
          <Var>m</Var>
        </Expr>
    </Equal>
    <Equal>
      <Var>a</Var>
      <Expr>
        <Fun per="value">Plex</Fun>
        <Plex>
          <Var>x</Var>
          <Var>y</Var>
        </Plex>
        <repo>
          <Var>r</Var>
        </repo>
      </Expr>
    </Equal>
</And>

Hence the functional languages semantically require <Equal> (for returning-by-binding answer variables and for rest-flattening variables), thus would be Hornlogeq and beyond. At least for those we should allow <Expr> within <repo>.

However, since we are doing modularization syntactically, we should start with a repoexpr version of Hornlog itself.

2.3 Option 2

Second possible change.

2.4 Refinement A

Create fresh anchor language (driver manually generated) called hornlogrepoexpr.

2.5 Refinement B

Implement the extension of the repo content model in a new module called repoexpr.

2.6 Refinement C1

Modify bash/batch_xslt_test-normal.sh so that the repoexpr (ultimately, e.g. repoexpr_temp) instance files are excluded from testing for validity against nafhologeq_normal.xsd and nafhologeq_normal.rnc as follows:

   if [[ ! "${file}" =~ fail ]] && [[ ! "${file}" =~ repoexpr ]] && [[ "${exitvalue}" -ne "0" ]]; then
         echo "XSD Validation Failed for Normal ${file}"
         exit 1
   fi
   if [[ ! "${file}" =~ fail ]] && [[ ! "${file}" =~ repoexpr ]] && [[ "${exitvalue}" -ne "0" ]]; then
         echo "RNC Validation Failed for Normal ${file}"
         exit 1
   fi       

2.7 Refinement C2

Add the include statement to supremum schemas nafhologeq*.rnc

3 Discussion

3.1 Recommended Option

3.2 Accepted Option

Option 1, Refinements A, B, C2.

3.3 Related Issues

Holog Should Allow per Attribute in Any Term Within op Child of Expr

4 Resolution

4.1 Relax NG Modules

4.2 Relax NG Drivers

4.3 MYNG Engine

4.4 MYNG GUI

4.5 XSDs

4.6 Unit Tests

4.7 XSLTs

5 References