OpenMath Content Dictionary: patterns
Canonical URL:
http://www.openmath.org/cd/patterns.ocd
CD Base:
http://www.openmath.org/cd
CD File:
patterns.ocd
CD as XML Encoded OpenMath:
patterns.omcd
Defines:
all_of , any , any_of , argument , descendant , none_of , root , self_or_descendant
Date:
2019-09-23
Version:
1
Review Date:
Status:
experimental
This document is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
The copyright holder grants you permission to redistribute this
document freely as a verbatim copy. Furthermore, the copyright
holder permits you to develop any derived work from this document
provided that the following conditions are met.
a) The derived work acknowledges the fact that it is derived from
this document, and maintains a prominent reference in the
work to the original source.
b) The fact that the derived work is not the original OpenMath
document is stated prominently in the derived work. Moreover if
both this document and the derived work are Content Dictionaries
then the derived work must include a different CDName element,
chosen so that it cannot be confused with any works adopted by
the OpenMath Society. In particular, if there is a Content
Dictionary Group whose name is, for example, `math' containing
Content Dictionaries named `math1', `math2' etc., then you should
not name a derived Content Dictionary `mathN' where N is an integer.
However you are free to name it `private_mathN' or some such. This
is because the names `mathN' may be used by the OpenMath Society
for future extensions.
c) The derived work is distributed under terms that allow the
compilation of derived works, but keep paragraphs a) and b)
intact. The simplest way to do this is to distribute the derived
work under the OpenMath license, but this is not a requirement.
If you have questions about this license please contact the OpenMath
society at http://www.openmath.org .
This CD defines symbols for the representation of patterns
that can be matched against mathematical expressions.
Possible applications of such patterns can be formula search
or the rule-based transformation of expressions.
Author: Ken Wenzel, Fraunhofer IWU
Role:
application
Description:
This symbol represents a pattern constructor for matching
the conjunction of one or more patterns. The operator is most useful
for reusing multiple existing patterns.
Example:
An example for matching a set with exactly two elements.
OpenMath XML (source)
<OMOBJ xmlns="http://www.openmath.org/OpenMath" version="2.0" cdbase="http://www.openmath.org/cd">
<OMA>
<OMS cd="patterns" name="all_of"/>
<OMA>
<OMS cd="set1" name="set"/>
</OMA>
<OMA>
<OMS cd="patterns" name="any"/>
<OMS cd="patterns" name="any"/>
<OMS cd="patterns" name="any"/>
</OMA>
</OMA>
</OMOBJ>
Strict Content MathML
<math xmlns="http://www.w3.org/1998/Math/MathML">
<apply><csymbol cd="patterns">all_of</csymbol>
<apply><csymbol cd="set1">set</csymbol></apply>
<apply><csymbol cd="patterns">any</csymbol>
<csymbol cd="patterns">any</csymbol>
<csymbol cd="patterns">any</csymbol>
</apply>
</apply>
</math>
Prefix
Popcorn
patterns.all_of({}, patterns.any(patterns.any, patterns.any))
Rendered Presentation MathML
all_of
(
{
}
,
any
(
any
,
any
)
)
Signatures:
sts
Role:
constant
Description:
This symbol represents a wild card for matching any
expression.
Example:
An example for matching a lambda expression with parameter $y and
any body.
OpenMath XML (source)
<OMOBJ xmlns="http://www.openmath.org/OpenMath" version="2.0" cdbase="http://www.openmath.org/cd">
<OMBIND>
<OMS cd="fns1" name="lambda"/>
<OMBVAR>
<OMV name="y"/>
</OMBVAR>
<OMS cd="patterns" name="any"/>
</OMBIND>
</OMOBJ>
Strict Content MathML
<math xmlns="http://www.w3.org/1998/Math/MathML">
<bind><csymbol cd="fns1">lambda</csymbol>
<bvar><ci>y</ci></bvar>
<csymbol cd="patterns">any</csymbol>
</bind>
</math>
Prefix
Popcorn
fns1.lambda[$y -> patterns.any]
Rendered Presentation MathML
Example:
An example for matching lambda expressions with two parameters and
any body. In addition to the "any" symbol as defined by
this CD the example also uses a special variable named "_"
as a placeholder for any variable. This is required for matching
variables within <OMBVAR> that only allows variables as child
elements.
OpenMath XML (source)
<OMOBJ xmlns="http://www.openmath.org/OpenMath" version="2.0" cdbase="http://www.openmath.org/cd">
<OMBIND>
<OMS cd="fns1" name="lambda"/>
<OMBVAR>
<OMV name="_"/>
<OMV name="_"/>
</OMBVAR>
<OMS cd="patterns" name="any"/>
</OMBIND>
</OMOBJ>
Strict Content MathML
<math xmlns="http://www.w3.org/1998/Math/MathML">
<bind><csymbol cd="fns1">lambda</csymbol>
<bvar><ci>_</ci></bvar>
<bvar><ci>_</ci></bvar>
<csymbol cd="patterns">any</csymbol>
</bind>
</math>
Prefix
Popcorn
fns1.lambda[$_, $_ -> patterns.any]
Rendered Presentation MathML
Signatures:
sts
Role:
application
Description:
This symbol represents a pattern constructor for matching
the disjunction of the given arguments.
Example:
An example for matching function applications of either sine or
cosine.
OpenMath XML (source)
<OMOBJ xmlns="http://www.openmath.org/OpenMath" version="2.0" cdbase="http://www.openmath.org/cd">
<OMA>
<OMS cd="patterns" name="any_of"/>
<OMA>
<OMS cd="transc1" name="sin"/>
</OMA>
<OMA>
<OMS cd="transc1" name="cos"/>
</OMA>
</OMA>
</OMOBJ>
Strict Content MathML
<math xmlns="http://www.w3.org/1998/Math/MathML">
<apply><csymbol cd="patterns">any_of</csymbol>
<apply><csymbol cd="transc1">sin</csymbol></apply>
<apply><csymbol cd="transc1">cos</csymbol></apply>
</apply>
</math>
Prefix
Popcorn
patterns.any_of(sin(), cos())
Rendered Presentation MathML
any_of
(
sin
(
)
,
cos
(
)
)
Signatures:
sts
Role:
application
Description:
This symbol represents a pattern constructor for the
order-independent matching of multiple function arguments.
Example:
An example that matches the plus function applied to
the variables $a and $b without considering their order.
OpenMath XML (source)
<OMOBJ xmlns="http://www.openmath.org/OpenMath" version="2.0" cdbase="http://www.openmath.org/cd">
<OMA>
<OMS cd="arith1" name="plus"/>
<OMA>
<OMS cd="patterns" name="argument"/>
<OMV name="a"/>
<OMV name="b"/>
</OMA>
</OMA>
</OMOBJ>
Strict Content MathML
<math xmlns="http://www.w3.org/1998/Math/MathML">
<apply><csymbol cd="arith1">plus</csymbol>
<apply><csymbol cd="patterns">argument</csymbol><ci>a</ci><ci>b</ci></apply>
</apply>
</math>
Prefix
Popcorn
patterns.argument($a, $b)
Rendered Presentation MathML
Signatures:
sts
Role:
application
Description:
This symbol represents a pattern constructor for matching
the complement of its arguments.
Example:
An example for matching any sine function unless it is applied to the
variables $x or $z.
OpenMath XML (source)
<OMOBJ xmlns="http://www.openmath.org/OpenMath" version="2.0" cdbase="http://www.openmath.org/cd">
<OMA>
<OMS cd="transc1" name="sin"/>
<OMA>
<OMS cd="patterns" name="none_of"/>
<OMV name="x"/>
<OMV name="z"/>
</OMA>
</OMA>
</OMOBJ>
Strict Content MathML
<math xmlns="http://www.w3.org/1998/Math/MathML">
<apply><csymbol cd="transc1">sin</csymbol>
<apply><csymbol cd="patterns">none_of</csymbol><ci>x</ci><ci>z</ci></apply>
</apply>
</math>
Prefix
Popcorn
sin(patterns.none_of($x, $z))
Rendered Presentation MathML
sin
(
none_of
(
x
,
z
)
)
Signatures:
sts
Role:
application
Description:
This symbol represents a pattern constructor for matching
the root element of an expression.
Example:
An example for matching any sine function application that is the
root of an expression.
OpenMath XML (source)
<OMOBJ xmlns="http://www.openmath.org/OpenMath" version="2.0" cdbase="http://www.openmath.org/cd">
<OMA>
<OMS cd="patterns" name="root"/>
<OMA>
<OMS cd="transc1" name="sin"/>
</OMA>
</OMA>
</OMOBJ>
Strict Content MathML
<math xmlns="http://www.w3.org/1998/Math/MathML">
<apply><csymbol cd="patterns">root</csymbol><apply><csymbol cd="transc1">sin</csymbol></apply></apply>
</math>
Prefix
Popcorn
patterns.root(sin())
Rendered Presentation MathML
Signatures:
sts
Role:
application
Description:
This symbol represents a pattern constructor for matching
any descendant of the current element.
Example:
An example for matching sum applications that contain the Pochhammer
symbol.
OpenMath XML (source)
<OMOBJ xmlns="http://www.openmath.org/OpenMath" version="2.0" cdbase="http://www.openmath.org/cd">
<OMA>
<OMS cd="arith1" name="sum"/>
<OMS cd="patterns" name="any"/>
<OMA>
<OMS cd="patterns" name="descendant"/>
<OMA>
<OMS cd="hypergeo0" name="pochhammer"/>
</OMA>
</OMA>
</OMA>
</OMOBJ>
Strict Content MathML
<math xmlns="http://www.w3.org/1998/Math/MathML">
<apply><csymbol cd="arith1">sum</csymbol>
<csymbol cd="patterns">any</csymbol>
<apply><csymbol cd="patterns">descendant</csymbol><apply><csymbol cd="hypergeo0">pochhammer</csymbol></apply></apply>
</apply>
</math>
Prefix
Popcorn
arith1.sum(patterns.any, patterns.descendant(hypergeo0.pochhammer()))
Rendered Presentation MathML
∑
any
descendant
(
pochhammer
(
)
)
Signatures:
sts
Role:
application
Description:
This symbol represents a pattern constructor for matching
the current element itself or any of its descendants.
Example:
An example for matching a sum application itself or any expression
that contains a sum application.
OpenMath XML (source)
<OMOBJ xmlns="http://www.openmath.org/OpenMath" version="2.0" cdbase="http://www.openmath.org/cd">
<OMA>
<OMS cd="patterns" name="self_or_descendant"/>
<OMA>
<OMS cd="arith1" name="sum"/>
<OMS cd="patterns" name="any"/>
<OMS cd="patterns" name="any"/>
</OMA>
</OMA>
</OMOBJ>
Strict Content MathML
<math xmlns="http://www.w3.org/1998/Math/MathML">
<apply><csymbol cd="patterns">self_or_descendant</csymbol>
<apply><csymbol cd="arith1">sum</csymbol>
<csymbol cd="patterns">any</csymbol>
<csymbol cd="patterns">any</csymbol>
</apply>
</apply>
</math>
Prefix
Popcorn
patterns.self_or_descendant(arith1.sum(patterns.any, patterns.any))
Rendered Presentation MathML
self_or_descendant
(
∑
any
any
)
Signatures:
sts