Skip to content

Commit

Permalink
0.0.1 show-ob.txt for expressing canonical obs in ob-exp form per #8
Browse files Browse the repository at this point in the history
The ob is expressed as a single string in ob-exp form tht uses ( ... )
only where necessary for "::" to associate properly.
  • Loading branch information
Dennis Hamilton committed Feb 4, 2018
1 parent 7818889 commit ffe054a
Show file tree
Hide file tree
Showing 2 changed files with 107 additions and 1 deletion.
7 changes: 6 additions & 1 deletion oMiser/oMiser.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
oMiser.txt 0.0.5 UTF-8 dh:2018-01-30
oMiser.txt 0.0.6 UTF-8 dh:2018-02-04

The Miser Project Code
======================
Expand Down Expand Up @@ -65,6 +65,10 @@ MANIFEST
specification of the grammar for expressions that determine obs by
computations using obs as procedure scripts and as data.

show-ob.txt
description of the grammar for Canonical Obs and a procedure for
expressiong them in ob-exp form that minimizes the use of ( ... ).

mockups/
subtree for experimental mock-ups that demonstrate oMiser
features
Expand Down Expand Up @@ -127,6 +131,7 @@ TODO

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

0.0.6 2018-02-04-11:52 Add show-ob.txt to the manifest
0.0.5 2018-01-30-18:28 Reflect addition of ob-exp.txt in the manifest.
0.0.4 2017-12-27-09:43 Touch-ups and some simplification. Manage TODOs.
Correct the GitHub location of this page.
Expand Down
101 changes: 101 additions & 0 deletions oMiser/show-ob.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
show-ob.txt 0.0.1 UTF-8 dh:2018-02-04
----|----1----|----2----|----3----|----4----|----5----|----6----|----7----|--*


The Miser Project Code
======================

<https://github.com/orcmid/miser/blob/master/oMiser/show-ob.txt>

FRUGALESE GRAMMAR FOR DISPLAYING CANONICAL OBS IN OB-EXP FORM
-------------------------------------------------------------

Show-ob is the grammar for Canonical Obs that exploits the right-
associativity of "::" to eliminate unnecessary parentheses. This
is, apart from the presence of white space, a unique ob-exp for
every Canonical Ob.

The grammar is essentially ob-exp without anything that involves
an application in its interpretation.

See also
<https://github.com/orcmid/miser/blob/master/oMiser/ob-exp.txt>

1. SUMMARY GRAMMAR

Here is the reduced summary grammar for the Canonical Obs. Any
of these forms are suitable. Reducing the use of parentheses is
handled in the procedure for expressing obs.

〈term〉 ::= 〈lindy〉 | 〈primitive〉

〈unary〉 ::= 〈term〉 | ( 〈canonical〉 ) | ‵ 〈unary〉

〈binary〉 ::= 〈unary〉 | 〈unary〉 :: 〈binary〉

〈canonical〉 ::= 〈binary〉

2. SIMPLE EXPRESSION

Using SML/NJ, the expression of an ob, x, is as follows:

def term(x: ob)
= case x
of obap.L(s) => s
| ob.A => ".A"
| ob.B => ".B"
| ob.C => ".C"
| ob.E => ".E"
| obap.D => ".D"
| obap.SELF => ".SELF"
| obap.ARG => ".ARG"
| obap.EV => ".EV"
| _ => "?!"

def canonical(x: ob)
= let unary(x)
= if ob.is_individual(x)
then term(x)
else if ob.is_singleton(x)
then "`" ^ unary(ob.a x)
else "( " ^ canonical(x) ^ " )"
in if ob.is_pair(x)
then unary(ob.a x) " :: " canonical(ob.b x)
else unary(x)
end;

To avoid Unicode console difficulties, the back-tick is used in
this procedure.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Copyright 2018 Dennis E. Hamilton

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

TODO

* In practice, we don't want to ever to insert more than one space at
any point in the ob-exp. The simple expression avoids that but it
is more involved when there are more forms.

* A pretty-print form that uses indentation is a bit trickier. That
needs to be done. Line wraps should be used to honor margins.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

0.0.1 2018-02-04-11:58 Provide direct basic expression.

*** end of show-ob.txt ***

0 comments on commit ffe054a

Please sign in to comment.