[seqfan] Re: metadata for Mathematica code

hv at crypt.org hv at crypt.org
Tue Nov 3 00:50:33 CET 2015


It's great to see someone thinking along these lines; I think it would
be valuable to state (or develop) the definitions in one or more pages
on the OEIS wiki.

Is it intended that these special comments would be significant iff they
appear on their own as a comment, or even if the label appears as a
word in a longer comment? (Given the examples TermFunction and
TermFunctionDefinition, I guess "substring" already doesn't cut it;
I'm in two minds about whether that's wise.)

I think I understand what most of the labels represent, but I'd be more
comfortable if they were expressed in a more formal maths/computing style.
I've never used Mathematica, so the given example is of limited value
(and a range of examples in other languages would be useful).

I'm confused about TermFunction and TermFunctionDefinition: I'd have
expected the example of the former would require that the example of
the latter define a function called 'CatalanNumber'.

Is it intended that the comment, along with the choice of language, be
sufficient in themselves to let you automatically invoke a function
appropriately? Or is it expected that invokers will still need to inspect
the source code or additional documentation to do that? I believe the former
would be incredibly useful, but the mechanism to get from comment to valid
invocation would probably need to be specified on a language-by-language
basis.

Note that some languages have explicit mechanisms to specify metadata
separate from comments (eg Java); there'd be some (limited) value in
specifying the use of comments as the fallback only when the language
doesn't already provide a better mechanism, rather than sanctifying it
as the one true way.

I think it may also be useful to define a mechanism to tag characteristics
of a particular implementation: you might have, for example, a simplest
possible algorithm for didactic purposes, and multiple additional versions
that make different trades between CPU and memory use. I could imagine
that developing over time into machine-readable performance characteristics
that are simultaneously human-readable (variants of) big-O notation.

Hugo

Eric Rowland <rowland at lacim.ca> wrote:
:Hi all,
:
:Wolfram Research has a mentorship student, JungHwan Min, who is going to be
:contributing Mathematica / Wolfram Language code to OEIS entries.  I think
:this is a great opportunity to start adding metadata identifying what each
:program does (computes the nth term vs. computes the first n terms, etc.).
:Having more structured data in the OEIS will make it that much more useful,
:especially for programmatic tasks.  You can imagine eventually being able
:to query for a list of all functions that define the nth term of a
:2-automatic sequence, for example.
:
:Charles Greathouse and I discussed this at length about a year ago and came
:up with an initial list of labels.  It makes sense to put labels in
:comments, so for example the Mathematica field for A000108 would look like
:this:
:
:(* TermFunction *)
:CatalanNumber
:(* TermFunctionDefinition *)
:A000108[ n_ ] := (2 n)!/n!/(n+1)!
:(* TermFunctionDefinition *)
:A000108[n_] := Hypergeometric2F1[1 - n, -n, 2, 1] (* Richard L. Ollerton, Sep
:13 2006 *)
:(* TermListByIndexFunctionDefinition *)
:A000108list[nmax_] := Table[ CatalanNumber@ n, {n, 0, nmax}] (* Robert G.
:Wilson v, Feb 15 2011 *)
:(* TermListByIndexFunctionDefinition *)
:A000108list[nmax_] := CoefficientList[InverseSeries[Series[x/Sum[x^n, {n,
:0, nmax+1}], {x, 0, nmax+1}]]/x, x] (* Mats Granvik, Nov 24 2013 *)
:
:Here is an initial list of labels:
:
:* TermFunction - function that computes the nth term (respecting the offset)
:* TermListByIndexFunction - function that computes the list of terms up to
:the nth term
:* TermListByMaximumFunction - function for computing the list of terms <= m
:for a non-decreasing sequence
:* TermListFunction - other function for computing a list of terms (where it
:may not be clear in advance how many terms it computes)
:* MembershipTestFunction - predicate function for testing membership,
:returning True or False
:
:For a function definition, append "Definition" to the label (getting
:TermFunctionDefinition / TermListByIndexFunctionDefinition /
:TermListByMaximumFunctionDefinition / TermListFunctionDefinition /
:MembershipTestFunctionDefinition).  For example,
:   CatalanNumber
:and
:   Function[n, CatalanNumber[n]]
:would get the label TermFunction, whereas
:   a[n_] := CatalanNumber[n]
:is a TermFunctionDefinition.
:
:Some entries have programs with hard-coded parameters, so they are not
:functions or function definitions.  These could get labels such as the
:following.
:
:* TermList - code that produces some list of terms
:* Visualization - code that produces related graphics
:
:Undoubtedly there will be others.
:
:Comments?  Where is the right place to document a list of "official"
:metadata labels?
:
:Eric
:
:_______________________________________________
:
:Seqfan Mailing list - http://list.seqfan.eu/



More information about the SeqFan mailing list