Representation of mathematical formulas

The representation of mathematical formulas is based on OpenMath-RDF. This RDF encoding for Openmath is currently work in progress but can already be used to encode arbitrary OpenMath objects in RDF.

POPCORN-LD: A textual syntax

POPCORN-LD is a compact textual notation for OpenMath objects that is aligned to the syntax used by SPARQL and Turtle for URI references.

Predefined operators

The POPCORN language provides common infix and other operators for the concise representation of mathematical expressions.

Operator

Corresponding Symbol

Arity

;

prog1:block

n

:=

prog1:assign

2

==>

logic1:implies

2

⇐>

logic1:equivalent

2

or

logic1:or

n

and

logic1:and

n

<

relation1:lt

2

<=

relation1:leq

2

>

relation1:gt

2

=

relation1:eq

2

>=

relation1:geq

2

<>

relation1:neq

2

!=

relation1:neq

2

..

interval1:interval

n

+

arith1:plus

n

-

arith1:minus

2

*

arith1:times

n

/

arith1:divide

2

^

arith1:power

2

|

complex1:complex_cartesian

2

//

nums1:rational

2

[…​]

list1:list

n

{…​}

set1:set

n

if…​then…​else…​endif

prog1:if

n

while…​do…​endwhile

prog1:while

n

Shortcut symbols

The POPCORN language provides shorthand notations for common mathematical functors and constants.

abs

arith1:abs

binomial

combinat1:binomial

cos

transc1:cos

cosh

transc1:cosh

cot

transc1:cot

coth

transc1:coth

csc

transc1:csc

csch

transc1:csch

defint

calculus1:defint

diff

calculus1:diff

e

nums1:e

exp

transc1:exp

factorial

integer1:factorial

false

logic1:false

i

nums1:i

infinity

nums1:infinity

int

calculus1:int

lambda

fns1:lambda

max

minmax1:max

min

minmax1:min

pi

nums1:pi

product

arith1:product

root

arith1:root

sec

transc1:sec

sech

transc1:sech

sin

transc1:sin

sinh

transc1:sinh

sum

arith1:sum

tan

transc1:tan

tanh

transc1:tanh

true

logic1:true

Grammar

Non-terminal symbols

<expr>

<blockExpr>

<blockExpr>

<assignExpr> (';' <assignExpr>)*

<assignExpr>

<implExpr> (':=' <implExpr>)?

<implExpr>

<orExpr> (('=⇒' | '<⇒') <orExpr>)?

<orExpr>

<andExpr> ('or' <andExpr>)*

<andExpr>

<relExpr> ('and' <relExpr>)*

<relExpr>

<intervalExpr> (('=' | '<' | '⇐' | '>' | '>=' | '!=' | '<>') <intervalExpr>)?

<intervalExpr>

<addExpr> ('..' <addExpr>)?

<addExpr>

<multExpr> (('-' | '+') <multExpr>)*

<multExpr>

<powerExpr> (('/' | '*') <powerExpr>)*

<powerExpr>

<complexExpr> ('^' <complexExpr>)?

<complexExpr>

<rationalExpr> ('|' <rationalExpr>)?

<rationalExpr>

<negExpr> ('//' <negExpr>)?

<negExpr>

('-' | 'not') <compExpr> | <compExpr>;

<compExpr>

<paraExpr> | <ecall> | <attribution> | <binding> | <listExpr> | <setExpr> | <lambdaExpr> | <anchor>

<arguments>

| <expr> (',' <expr>)*

<call>

<anchor> '(' <arguments> ')'

<ecall>

<anchor> '!' '(' <arguments> ')'

<listExpr>

'[' <arguments> ']'

<setExpr>

'{' <arguments> '}'

<lambdaExpr>

<varList> '→' <assignExpr>

<attribution>

<anchor> '{' <attributionList> '}'

<attributionList>

<attributionPair> (',' <attributionPair>)*

<attributionPair>

<expr> '→' <expr>

<binding>

<anchor> '[' <varList> '→' <expr> ']'

<anchor>

<atom> (':' <ID>)

<atom>

<paraExpr> | <var> | <Rdf> | <ifExpr> | <whileExpr> | <ref> | <symbol> | <number> | <OMB> | <FOREIGN> | <string>

<paraExpr>

'(' <expr> ')'

<ifExpr>

'if' <expr> 'then' <expr> 'else' <expr> 'endif'

<whileExpr>

'while' <expr> 'do' <expr> 'endwhile'

<unaryOp>

'-' | 'not'

<ref>

'#' <iri>

<symbol>

<iri>

<iri>

<IRIREF> | <prefixedName> | [0-9]* <PN_CHARS_U> <PN_LOCAL>?

<prefixedName>

<PNAME_LN> | <PNAME_NS>

<var>

'\$' <ID>

<varList>

| <var> (',' <var>)*

<number>

<INTEGER> | <DECIMAL> | <DOUBLE>

<string>

<STRING_LITERAL1> | <STRING_LITERAL2> | <STRING_LITERAL_LONG1> | <STRING_LITERAL_LONG2>

<Rdf>

'@@' <RdfResourceSet> | '@' <RdfResource> | '@@' <RdfValueSet> | '@' <RdfValue>

<RdfResourceSet>

'[' <ManchesterDescription> ']'

<RdfResource>

'(' <iri> ')'

<RdfValue>

<iri> ( '(' <expr> ')' )?

<RdfValueSet>

<iri> ( '(' <expr> ')' )? ( '[' <ManchesterDescription> ']' )?

Terminal symbols

<ID>

<PN_CHARS_U> ( [0-9] | <PN_CHARS_U> )*

<OMB>

'\%' ([a-z] | [A-Z] | [0-9] | '=')+ '\%'

<INTEGER>

[-]? [0-9]

<DECIMAL>

[-]? [0-9]* '.' [0-9]

<DOUBLE>

[-]? ([0-9] '.' [0-9]* <EXPONENT> | '.' [0-9]+ <EXPONENT> | \\ [0-9]+ <EXPONENT>)

<EXPONENT>

[eE] [-]? [0-9]

<FOREIGN>

"'" .* '<' .+ '>'

<WS>

(' ' | '\\t' | '\\n' | '\\r')+

<COMMENT>

'/*' .* '*/'

<IRIREF>

'<' ([^<>''|^'\]-[#x00-#x20])* '>'

<PNAME_NS>

<PN_PREFIX>? ':'

<PNAME_LN>

<PNAME_NS> <PN_LOCAL>

<STRING_LITERAL1>

"'" ( ([^#x27#x5C#xA#xD]) | <ECHAR> )* "'"

<STRING_LITERAL2>

'"' ( ([^#x27#x5C#xA#xD]) | <ECHAR> )* '"'

<STRING_LITERAL_LONG1>

"'''" ( ( "'" | "''" )? ( [^'\] | <ECHAR> ) )* "'''"

<STRING_LITERAL_LONG2>

'"""' ( ( '"' | '""' )? ( [^''\\] | <ECHAR> ) )* '"""'

<PN_CHARS_BASE>

[A-Z] | [a-z] | [#x00C0-#x00D6] | [#x00D8-#x00F6] | \\ [#x00F8-#x02FF] | [#x0370-#x037D] | [#x037F-#x1FFF] | \\ [#x200C-#x200D] | [#x2070-#x218F] | [#x2C00-#x2FEF] | \\ [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF]

<PN_CHARS_U>

<PN_CHARS_BASE> | '_'

<PN_CHARS>

<PN_CHARS_U> | '-' | [0-9] | #x00B7 | [#x0300-#x036F] | \\ [#x203F-#x2040]

<PN_PREFIX>

[0-9]* <PN_CHARS_BASE> ((<PN_CHARS> | '.')* <PN_CHARS>)?

<PN_LOCAL>

(<PN_CHARS_U> | ':' | [0-9] | <PLX> ) <PN_CHARS> | '.' | ':' | <PLX>)* (<PN_CHARS> | ':' | <PLX>?

<PLX>

<PERCENT> | <PN_LOCAL_ESC>

<PERCENT>

'\%' <HEX> <HEX>

<HEX>

[0-9] | [A-F] | [a-f]

<PN_LOCAL_ESC>

'\' ( '_' | '~' | '.' | '-' | '!' | '$' | '&' | "'" | '(' | ')' | '*' | '+' | ',' | ';' | '=' | '/' | '?' | '#' | '@' | '\%' )

Computation rules

RDF syntax

TBD

Textual syntax

Mathematical rules can be expressed using an extended Manchester OWL Syntax.

Example rule file for process planning
Prefix: : <http://example.org/model#>

Ontology: <http://example.org/model>
  Import: <http://numerateweb.org/vocab/math/rules>

Class: Plan
  Constraint:
    partsPerHour = @partsPerYear / @workHoursPerYear(@masterData),
    taktTime = 3600 / @partsPerHour

Class: Process
  Constraint:
    costsPerPart = @machineHourRate / 3600 * @processTime / @partsPerCycle,
    costsPerYear = @resourceCount * @depreciation(@resource) + @imputedInterest + @occupancyCosts + @maintenanceCosts + @energyCosts,
    energyCosts = @energyCostsElectrical,
    energyCostsElectrical = @resourceCount * @energyElectrical * @energyPriceElectrical(@masterData(@plan)),
    energyElectrical = @inputPowerElectrical(@resource) * @fullLoadHours,
    fullLoadHours = @utilization * @workHoursPerYear(@masterData(@plan)),
    imputedInterest = @resourceCount * @investmentCosts(@resource) / 2 * @interestRate(@masterData(@plan)),
    machineHourRate = @costsPerYear / @fullLoadHours,
    maintenanceCosts = @resourceCount * (@maintenanceCosts(@resource) + sum(@@uses(@resource), $w -> @maintenanceCosts($w))),
    maxPartsPerHour = 3600 / @processTime * @capacity(@resource),
    occupancyCosts = @resourceCount * @requiredSpace(@resource) * @occupanyCostRate(@masterData(@plan)),
    partsPerCycle = @resourceCount * @capacity(@resource),
    processTime = @processTime(@resource),
    resourceCount = ceiling((@processTime / @capacity(@resource)) / @taktTime(@plan)),
    utilization = (@partsPerHour(@plan) / @maxPartsPerHour) / @resourceCount

Class: ProcessWithGas
  Constraint:
    energyCosts = @energyCostsElectrical + @energyCostsGas
    energyCostsGas = @resourceCount * @energyGas * @energyPriceGas(@masterData(@plan)),
    energyGas = @inputPowerGas(@resource) * @fullLoadHours

Class: Resource
  Constraint:
    depreciation = @price / @economicLife + sum(@@uses, $w -> @depreciation($w)),
    investmentCosts = @price + sum(@@uses, $w -> @investmentCosts($w))