openmath 0.1.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/README.adoc +45 -5
  3. data/data/binding-table-1.yml +76 -0
  4. data/data/pmquant.ocd +89 -0
  5. data/data/pmquant.sts +60 -0
  6. data/data/portable-bindings.json +1 -0
  7. data/data/replay-vectors.yml +70 -0
  8. data/lib/openmath/base/omforeign.rb +18 -4
  9. data/lib/openmath/base/omobj.rb +7 -0
  10. data/lib/openmath/binary.rb +699 -0
  11. data/lib/openmath/canonical.rb +127 -0
  12. data/lib/openmath/cd/cds_namespace.rb +13 -0
  13. data/lib/openmath/cd/group_collection.rb +160 -0
  14. data/lib/openmath/cd/group_document.rb +50 -0
  15. data/lib/openmath/cd/namespace.rb +6 -0
  16. data/lib/openmath/cd/signature_document.rb +53 -0
  17. data/lib/openmath/cd/signatures.rb +63 -0
  18. data/lib/openmath/cd.rb +10 -0
  19. data/lib/openmath/common_elements.rb +9 -0
  20. data/lib/openmath/content_mathml.rb +443 -0
  21. data/lib/openmath/content_mathml_operators.rb +51 -0
  22. data/lib/openmath/evaluation/closure.rb +11 -0
  23. data/lib/openmath/evaluation/errors.rb +30 -0
  24. data/lib/openmath/evaluation/evaluator.rb +192 -32
  25. data/lib/openmath/evaluation/interval.rb +17 -0
  26. data/lib/openmath/evaluation/operations.rb +394 -12
  27. data/lib/openmath/evaluation/portable.rb +114 -0
  28. data/lib/openmath/evaluation/signature_checker.rb +173 -0
  29. data/lib/openmath/evaluation/stochastic.rb +113 -0
  30. data/lib/openmath/evaluation/uncertain.rb +64 -0
  31. data/lib/openmath/evaluation.rb +12 -2
  32. data/lib/openmath/foreign.rb +146 -0
  33. data/lib/openmath/tagged.rb +41 -0
  34. data/lib/openmath/v2.rb +1 -1
  35. data/lib/openmath/v3.rb +1 -1
  36. data/lib/openmath/version.rb +1 -1
  37. data/lib/openmath.rb +41 -3
  38. data/schemas/PROVENANCE.md +3 -0
  39. data/schemas/omcdgroup2.rnc +33 -0
  40. data/schemas/omcdgroup2.rng +86 -0
  41. metadata +26 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: afafbcbc28919518be2680eb0550abd7b5ebbe76b1cfc9ab9d87c81781d50469
4
- data.tar.gz: a04e6ff1fa464d389c295baa6b35c250f348f6fb070fdc72ad96478f447e1a46
3
+ metadata.gz: 8739a7997d9d1f630dfdb1ae21680dd0a845649d9faa4b8504830a06c94c72a3
4
+ data.tar.gz: 27b61e94a7251f5ceab8c0af2fde88c2c4928227c487f1e70ec37e4f742a23e0
5
5
  SHA512:
6
- metadata.gz: 0ee4631a002a6841e53c66f8bb454c3fb7e41d66e44d4c27e36a5d22587bcd483f505c44cedba37cc0150f1ff9bd1bb3c572499e68da8f1621bede85f579c321
7
- data.tar.gz: 81033d334dd8536385eb41d52e8540ce98bb25ba6a60e67d92b1ff118d3ae58876cdaf2b916076959fa634df5d09f8d47864588a20c287e6f1722443d5e2c01b
6
+ metadata.gz: 04f4bb07f445f212eecc7af549aef25e2446fb9c478232e6bc3caa06f2258568f16feea86f58ff588ea6b92618530b5922197359672b4ae5555836a9d9a9c6a9
7
+ data.tar.gz: 946ffd791fbacbbb8b1879b6fea8c4e2c667d159ab65078b73aec0ad2ab7785d4191b9b368947024e99aa83421db1571cfd74ee115bd8470cea19833d64acd2e
data/README.adoc CHANGED
@@ -23,14 +23,54 @@ OpenMath/OMSVN). Namespaced documents parse in both the unprefixed and the
23
23
  symbol resolution with cdbase matching, and CD validation against
24
24
  `omcd2.rng` — CD content is data, never code.
25
25
  * **Evaluation**: the CD binding table (`data/binding-table-1.yml`) binds
26
- the working core (nums1, arith1, relation1, logic1) to operations;
27
- `Openmath.evaluate(xml, variables:)` walks the tree under the exactness
28
- discipline — integers and rationals stay exact, floats contaminate to the
29
- limited class, unbound symbols refuse naming the symbol.
26
+ the working families — nums1, arith1, relation1, logic1, integer1,
27
+ rounding1, set1/list1, interval1, linalg1/linalg2/linalg3 — to exact
28
+ operations; `Openmath.evaluate(xml, variables:)` walks the tree under the
29
+ exactness discipline — integers and rationals stay exact, floats
30
+ contaminate to the limited class, unbound symbols refuse naming the
31
+ symbol. `fns1/lambda` binds: `OMBIND` evaluates to a closure captured
32
+ lexically, applied through an enclosing `OMA` with typed arity refusals;
33
+ `map`/`suchthat` ride the lambda layer; attributed variables bind by
34
+ their wrapped name; `OMATTR` evaluates its attributed object,
35
+ attributions riding along as data; `OMR` references resolve within the
36
+ document scope with cycle detection; shape contradictions refuse with
37
+ the DimensionMismatch name. calculus1 stays symbolic — outside the
38
+ evaluated surface, refused typed.
39
+
40
+ * **Foreign objects**: markup inside OMFOREIGN (the schema's notOM content)
41
+ is captured verbatim at parse time (`notom_value`) and re-emitted at its
42
+ recorded positions on serialization — MathML, SVG, any well-formed
43
+ fragment round-trips byte-identically.
44
+
45
+ * **Canonical serialization**: `#to_canonical_xml` and `#canonical_sha256`
46
+ on every element give one deterministic form of an object — invariant
47
+ under prefix choice, attribute order and insignificant whitespace —
48
+ with `Openmath.canonical_equal?` as the explicit equality operation.
49
+
50
+ * **Content MathML v4**: `Openmath::ContentMathML.parse`/`generate`
51
+ ride the same content models (the plurimath#35 re-parenting) —
52
+ csymbol ↔ symbol, apply ↔ application, lambda/bvar ↔ the binding
53
+ containers — with the MathML 4 operator table transforming to the
54
+ strict form, exact cn constructions (rational, based integers,
55
+ e-notation), and typed refusals for everything outside the semantic
56
+ core.
57
+ * **Binary encoding**: `Openmath::Binary.encode`/`decode` speak the
58
+ standard's compact tagged format — both framings, streaming packets,
59
+ internal and external references, the shared-object optimization backed
60
+ by OMR, and typed refusals for every malformed byte sequence. Every
61
+ corpus object round-trips at a binary fixed point.
62
+
63
+ * **The PM register**: the `pmquant` CD family (`data/pmquant.ocd`, schema-
64
+ validated) carries PM 1002's quantity/uncertainty constructors — `ustd`,
65
+ `uexp`, `ucov` — as OpenMath data with its own signature file; quantities
66
+ combine under JCGM 101's first-order propagation, and
67
+ `Openmath.evaluate_stochastic` runs deterministic Monte-Carlo evaluation
68
+ under a declared generator and seed (same seed, same samples).
30
69
 
31
70
  Known limitations (tracked in the issues):
32
71
 
33
- * Non-OpenMath markup inside OMFOREIGN is not yet represented.
72
+ * OMFOREIGN fragments re-serialize pretty-printed by nokogiri rather than
73
+ in the surrounding document's indentation.
34
74
 
35
75
  == Usage
36
76
 
@@ -0,0 +1,76 @@
1
+ # frozen_string_literal: true
2
+
3
+ schema: openmath-binding-table/1
4
+ version: 4
5
+ description: >
6
+ The CD binding table: which content-dictionary symbols evaluate, and the
7
+ operation each binds to. Adding a binding is adding data here plus the
8
+ operation's implementation in Openmath::Evaluation::Operations; the
9
+ evaluator never dispatches on anything this table does not bind.
10
+ bindings:
11
+ # nums1 — the number constructions
12
+ - { cd: nums1, name: integer, operation: identity }
13
+ - { cd: nums1, name: rational, operation: rational }
14
+ - { cd: nums1, name: based_integer, operation: based_integer }
15
+ # arith1 — the arithmetic core
16
+ - { cd: arith1, name: plus, operation: plus }
17
+ - { cd: arith1, name: times, operation: times }
18
+ - { cd: arith1, name: minus, operation: minus }
19
+ - { cd: arith1, name: unary_minus, operation: unary_minus }
20
+ - { cd: arith1, name: divided_by, operation: divided_by }
21
+ - { cd: arith1, name: power, operation: power }
22
+ - { cd: arith1, name: root, operation: root }
23
+ - { cd: arith1, name: sum, operation: sum }
24
+ - { cd: arith1, name: product, operation: product }
25
+ - { cd: arith1, name: abs, operation: abs }
26
+ - { cd: arith1, name: max, operation: max }
27
+ - { cd: arith1, name: min, operation: min }
28
+ # relation1 — the comparisons
29
+ - { cd: relation1, name: eq, operation: eq }
30
+ - { cd: relation1, name: neq, operation: neq }
31
+ - { cd: relation1, name: gt, operation: gt }
32
+ - { cd: relation1, name: lt, operation: lt }
33
+ - { cd: relation1, name: geq, operation: geq }
34
+ - { cd: relation1, name: leq, operation: leq }
35
+ - { cd: relation1, name: approx, operation: approx }
36
+ # logic1 — the connectives
37
+ - { cd: logic1, name: and, operation: and }
38
+ - { cd: logic1, name: or, operation: or }
39
+ - { cd: logic1, name: xor, operation: xor }
40
+ - { cd: logic1, name: not, operation: not }
41
+ - { cd: logic1, name: implies, operation: implies }
42
+ # integer1 / rounding1 — exact integer semantics
43
+ - { cd: integer1, name: factorial, operation: factorial }
44
+ - { cd: integer1, name: quotient, operation: quotient }
45
+ - { cd: integer1, name: remainder, operation: remainder }
46
+ - { cd: rounding1, name: floor, operation: floor }
47
+ - { cd: rounding1, name: ceiling, operation: ceiling }
48
+ - { cd: rounding1, name: round, operation: round }
49
+ # set1 / list1 — exact collections; suchthat/map ride the lambda layer
50
+ - { cd: list1, name: list, operation: list }
51
+ - { cd: set1, name: set, operation: set }
52
+ - { cd: set1, name: in, operation: in }
53
+ - { cd: set1, name: size, operation: size }
54
+ - { cd: list1, name: map, operation: map }
55
+ - { cd: set1, name: suchthat, operation: suchthat }
56
+ # interval1 — exact domains
57
+ - { cd: interval1, name: interval, operation: interval }
58
+ - { cd: interval1, name: interval_oo, operation: interval_oo }
59
+ - { cd: interval1, name: interval_oc, operation: interval_oc }
60
+ - { cd: interval1, name: interval_co, operation: interval_co }
61
+ # linalg — exact matrices over rationals
62
+ - { cd: linalg2, name: matrix, operation: matrix }
63
+ - { cd: linalg2, name: matrixrow, operation: matrixrow }
64
+ - { cd: linalg1, name: transpose, operation: transpose }
65
+ - { cd: linalg3, name: determinant, operation: determinant }
66
+ - { cd: linalg1, name: vector_product, operation: vector_product }
67
+ # pmquant — the PM 1002 quantity/uncertainty constructors
68
+ - { cd: pmquant, name: ustd, operation: ustd }
69
+ - { cd: pmquant, name: uexp, operation: uexp }
70
+ - { cd: pmquant, name: ucov, operation: ucov }
71
+ - { cd: pmquant, name: value, operation: value }
72
+ # pmquant — the PM 1002 quantity/uncertainty constructors
73
+ - { cd: pmquant, name: ustd, operation: ustd }
74
+ - { cd: pmquant, name: uexp, operation: uexp }
75
+ - { cd: pmquant, name: ucov, operation: ucov }
76
+ - { cd: pmquant, name: value, operation: value }
data/data/pmquant.ocd ADDED
@@ -0,0 +1,89 @@
1
+ <CD xmlns="http://www.openmath.org/OpenMathCD">
2
+ <CDName>pmquant</CDName>
3
+ <CDBase>http://www.plurimath.org/cd</CDBase>
4
+ <CDDate>2026-11-16</CDDate>
5
+ <CDStatus>experimental</CDStatus>
6
+ <CDUses>
7
+ <CDName>sts</CDName>
8
+ </CDUses>
9
+ <CDVersion>1</CDVersion>
10
+ <CDRevision>0</CDRevision>
11
+ <Description>
12
+ The PM quantity and uncertainty constructors: the measurement-uncertainty
13
+ categories of PM 1002 (the standard, expanded and coverage-interval
14
+ categories of JCGM 100/101) as OpenMath symbols. The category is part of
15
+ the constructed value's identity; converting between categories is a
16
+ computation (PM 1004), never a rendering act. This CD is the Plurimath PM
17
+ register's own content dictionary; it is experimental and loads beside
18
+ the official collection.
19
+ </Description>
20
+ <CDDefinition>
21
+ <Name>ustd</Name>
22
+ <Role>application</Role>
23
+ <Description>
24
+ The standard uncertainty category (JCGM 100 7.2.1, PM 1002 clause 6):
25
+ ustd(v, m) reports the result v with its standard uncertainty m. It
26
+ carries value and magnitude; it carries no coverage factor, no
27
+ coverage probability and no endpoints.
28
+ </Description>
29
+ <CMP>
30
+ The constructed quantity keeps the category, the reported value and
31
+ the magnitude exactly as given: exact operands stay exact. A magnitude
32
+ must be non-negative and finite; a negative magnitude refuses.
33
+ </CMP>
34
+ <Example>ustd(10.3, 0.2)</Example>
35
+ </CDDefinition>
36
+ <CDDefinition>
37
+ <Name>uexp</Name>
38
+ <Role>application</Role>
39
+ <Description>
40
+ The expanded uncertainty category (JCGM 100 6.2.1 and 7.2.3, PM 1002
41
+ clause 6): uexp(v, m, k) reports the result v with expanded-uncertainty
42
+ magnitude m and coverage factor k, optionally with the coverage
43
+ probability p that was used to choose k (uexp(v, m, k, p)). The
44
+ magnitude here is the expanded uncertainty itself, not a standard
45
+ uncertainty.
46
+ </Description>
47
+ <CMP>
48
+ The coverage factor is a positive unsigned number: 0, 0.5 and negative
49
+ factors do not describe coverage factors and refuse. The coverage
50
+ probability, when present, lies strictly between 0 and 1; both bounds
51
+ are exact comparisons, not float comparisons.
52
+ </CMP>
53
+ <Example>uexp(10.3, 0.5, 2, 0.95)</Example>
54
+ </CDDefinition>
55
+ <CDDefinition>
56
+ <Name>ucov</Name>
57
+ <Role>application</Role>
58
+ <Description>
59
+ The coverage interval category (JCGM 101 5.3 and 5.5, PM 1002 clause
60
+ 6): ucov(v, l, u) reports the result v with the interval [l, u];
61
+ ucov(v, l, u, p) carries the coverage probability p; ucov(v, l, u, p,
62
+ kind) carries the interval kind, the string "shortest" or "symmetric"
63
+ (the probabilistically-symmetric kind; AsciiMath spells it symmetric
64
+ because the dash would read as minus). The kind defaults to symmetric.
65
+ </Description>
66
+ <CMP>
67
+ The lower endpoint must not exceed the upper one. The coverage
68
+ probability, when present, lies strictly between 0 and 1. The two
69
+ kinds differ semantically - the shortest interval of a distribution
70
+ need not be its probabilistically symmetric one - and the constructed
71
+ value carries the one kind it was given.
72
+ </CMP>
73
+ <Example>ucov(10.3, 9.9, 10.7, 0.95, shortest)</Example>
74
+ </CDDefinition>
75
+ <CDDefinition>
76
+ <Name>value</Name>
77
+ <Role>application</Role>
78
+ <Description>
79
+ The reported value of a quantity: value(q) extracts the reported value
80
+ v of the uncertain quantity q without touching its uncertainty.
81
+ </Description>
82
+ <CMP>
83
+ Applying value to a plain numeric quantity is the identity; applying
84
+ it to an uncertain quantity gives the reported value with the exact
85
+ class preserved.
86
+ </CMP>
87
+ <Example>value(ustd(10.3, 0.2))</Example>
88
+ </CDDefinition>
89
+ </CD>
data/data/pmquant.sts ADDED
@@ -0,0 +1,60 @@
1
+ <CDSignatures type="sts" cd="pmquant" xmlns="http://www.openmath.org/OpenMathCDS">
2
+ <CDSComment>
3
+ The STS signatures for the pmquant CD. Quantities are real-valued
4
+ reports; the constructed quantity's own type rides the Quantity carrier
5
+ variable. The optional arguments of uexp and ucov ride sts/nary tails,
6
+ so the signatures pin the required arguments and leave the optional
7
+ ones to the CD's CMP prose.
8
+ </CDSComment>
9
+ <CDSReviewDate>2027-11-16</CDSReviewDate>
10
+ <CDSStatus>experimental</CDSStatus>
11
+ <Signature name="ustd">
12
+ <OMOBJ xmlns="http://www.openmath.org/OpenMath">
13
+ <OMA>
14
+ <OMS cd="sts" name="mapsto"/>
15
+ <OMS cd="setname1" name="R"/>
16
+ <OMS cd="setname1" name="R"/>
17
+ <OMV name="Quantity"/>
18
+ </OMA>
19
+ </OMOBJ>
20
+ </Signature>
21
+ <Signature name="uexp">
22
+ <OMOBJ xmlns="http://www.openmath.org/OpenMath">
23
+ <OMA>
24
+ <OMS cd="sts" name="mapsto"/>
25
+ <OMS cd="setname1" name="R"/>
26
+ <OMS cd="setname1" name="R"/>
27
+ <OMS cd="setname1" name="R"/>
28
+ <OMA>
29
+ <OMS cd="sts" name="nary"/>
30
+ <OMS cd="setname1" name="R"/>
31
+ </OMA>
32
+ <OMV name="Quantity"/>
33
+ </OMA>
34
+ </OMOBJ>
35
+ </Signature>
36
+ <Signature name="ucov">
37
+ <OMOBJ xmlns="http://www.openmath.org/OpenMath">
38
+ <OMA>
39
+ <OMS cd="sts" name="mapsto"/>
40
+ <OMS cd="setname1" name="R"/>
41
+ <OMS cd="setname1" name="R"/>
42
+ <OMS cd="setname1" name="R"/>
43
+ <OMA>
44
+ <OMS cd="sts" name="nary"/>
45
+ <OMS cd="setname1" name="R"/>
46
+ </OMA>
47
+ <OMV name="Quantity"/>
48
+ </OMA>
49
+ </OMOBJ>
50
+ </Signature>
51
+ <Signature name="value">
52
+ <OMOBJ xmlns="http://www.openmath.org/OpenMath">
53
+ <OMA>
54
+ <OMS cd="sts" name="mapsto"/>
55
+ <OMV name="Quantity"/>
56
+ <OMS cd="setname1" name="R"/>
57
+ </OMA>
58
+ </OMOBJ>
59
+ </Signature>
60
+ </CDSignatures>
@@ -0,0 +1 @@
1
+ {"bindings":[{"arity":[1,1],"cd":"arith1","name":"abs","operation":"abs"},{"arity":[2,2],"cd":"arith1","name":"divided_by","operation":"divided_by"},{"arity":[1,null],"cd":"arith1","name":"max","operation":"max"},{"arity":[1,null],"cd":"arith1","name":"min","operation":"min"},{"arity":[2,2],"cd":"arith1","name":"minus","operation":"minus"},{"arity":[1,null],"cd":"arith1","name":"plus","operation":"plus"},{"arity":[2,2],"cd":"arith1","name":"power","operation":"power"},{"arity":[2,2],"cd":"arith1","name":"product","operation":"product"},{"arity":[2,2],"cd":"arith1","name":"root","operation":"root"},{"arity":[2,2],"cd":"arith1","name":"sum","operation":"sum"},{"arity":[1,null],"cd":"arith1","name":"times","operation":"times"},{"arity":[1,1],"cd":"arith1","name":"unary_minus","operation":"unary_minus"},{"arity":[1,1],"cd":"integer1","name":"factorial","operation":"factorial"},{"arity":[2,2],"cd":"integer1","name":"quotient","operation":"quotient"},{"arity":[2,2],"cd":"integer1","name":"remainder","operation":"remainder"},{"arity":[2,2],"cd":"interval1","name":"interval","operation":"interval"},{"arity":[2,2],"cd":"interval1","name":"interval_co","operation":"interval_co"},{"arity":[2,2],"cd":"interval1","name":"interval_oc","operation":"interval_oc"},{"arity":[2,2],"cd":"interval1","name":"interval_oo","operation":"interval_oo"},{"arity":[1,1],"cd":"linalg1","name":"transpose","operation":"transpose"},{"arity":[2,2],"cd":"linalg1","name":"vector_product","operation":"vector_product"},{"arity":[1,null],"cd":"linalg2","name":"matrix","operation":"matrix"},{"arity":[0,null],"cd":"linalg2","name":"matrixrow","operation":"matrixrow"},{"arity":[1,1],"cd":"linalg3","name":"determinant","operation":"determinant"},{"arity":[0,null],"cd":"list1","name":"list","operation":"list"},{"arity":[2,2],"cd":"list1","name":"map","operation":"map"},{"arity":[1,null],"cd":"logic1","name":"and","operation":"and"},{"arity":[2,2],"cd":"logic1","name":"implies","operation":"implies"},{"arity":[1,1],"cd":"logic1","name":"not","operation":"not"},{"arity":[1,null],"cd":"logic1","name":"or","operation":"or"},{"arity":[2,null],"cd":"logic1","name":"xor","operation":"xor"},{"arity":[2,2],"cd":"nums1","name":"based_integer","operation":"based_integer"},{"arity":[1,1],"cd":"nums1","name":"integer","operation":"identity"},{"arity":[2,2],"cd":"nums1","name":"rational","operation":"rational"},{"arity":[3,5],"cd":"pmquant","name":"ucov","operation":"ucov"},{"arity":[3,5],"cd":"pmquant","name":"ucov","operation":"ucov"},{"arity":[3,4],"cd":"pmquant","name":"uexp","operation":"uexp"},{"arity":[3,4],"cd":"pmquant","name":"uexp","operation":"uexp"},{"arity":[2,2],"cd":"pmquant","name":"ustd","operation":"ustd"},{"arity":[2,2],"cd":"pmquant","name":"ustd","operation":"ustd"},{"arity":[1,1],"cd":"pmquant","name":"value","operation":"value"},{"arity":[1,1],"cd":"pmquant","name":"value","operation":"value"},{"arity":[2,2],"cd":"relation1","name":"approx","operation":"approx"},{"arity":[2,null],"cd":"relation1","name":"eq","operation":"eq"},{"arity":[2,null],"cd":"relation1","name":"geq","operation":"geq"},{"arity":[2,null],"cd":"relation1","name":"gt","operation":"gt"},{"arity":[2,null],"cd":"relation1","name":"leq","operation":"leq"},{"arity":[2,null],"cd":"relation1","name":"lt","operation":"lt"},{"arity":[2,2],"cd":"relation1","name":"neq","operation":"neq"},{"arity":[1,1],"cd":"rounding1","name":"ceiling","operation":"ceiling"},{"arity":[1,1],"cd":"rounding1","name":"floor","operation":"floor"},{"arity":[1,1],"cd":"rounding1","name":"round","operation":"round"},{"arity":[2,2],"cd":"set1","name":"in","operation":"in"},{"arity":[0,null],"cd":"set1","name":"set","operation":"set"},{"arity":[1,1],"cd":"set1","name":"size","operation":"size"},{"arity":[2,2],"cd":"set1","name":"suchthat","operation":"suchthat"}],"generator":"openmath-ruby 0.1.1","schema":"openmath-portable-bindings/1","table_checksum":"3f9c4df3303c5fe403f3a27e9e770f1842e99c5222a72e619c63b6f883b2e221","vectors":[{"expected":{"value":42},"id":"nums1-integer-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"nums1\" name=\"integer\"/><OMI>42</OMI></OMA></OMOBJ>"},{"expected":{"value":"1/3"},"id":"nums1-rational-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"nums1\" name=\"rational\"/><OMI>3</OMI><OMI>9</OMI></OMA></OMOBJ>"},{"expected":{"value":431},"id":"nums1-based-integer-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"nums1\" name=\"based_integer\"/><OMI>16</OMI><OMSTR>1af</OMSTR></OMA></OMOBJ>"},{"id":"nums1-based-integer-2","refusal":{"error":"OperandTypeError"},"request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"nums1\" name=\"based_integer\"/><OMI>1</OMI><OMSTR>1</OMSTR></OMA></OMOBJ>"},{"expected":{"value":2},"id":"arith1-plus-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"arith1\" name=\"plus\"/><OMI>1</OMI><OMI>1</OMI></OMA></OMOBJ>"},{"expected":{"value":6},"id":"arith1-times-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"arith1\" name=\"times\"/><OMI>2</OMI><OMI>3</OMI></OMA></OMOBJ>"},{"expected":{"value":-2},"id":"arith1-minus-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"arith1\" name=\"minus\"/><OMI>7</OMI><OMI>9</OMI></OMA></OMOBJ>"},{"expected":{"value":-5},"id":"arith1-unary-minus-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"arith1\" name=\"unary_minus\"/><OMI>5</OMI></OMA></OMOBJ>"},{"expected":{"value":"1/4"},"id":"arith1-divided-by-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"arith1\" name=\"divided_by\"/><OMI>1</OMI><OMI>4</OMI></OMA></OMOBJ>"},{"id":"arith1-divided-by-2","refusal":{"error":"ZeroDivisionError"},"request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"arith1\" name=\"divided_by\"/><OMI>1</OMI><OMI>0</OMI></OMA></OMOBJ>"},{"expected":{"value":1024},"id":"arith1-power-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"arith1\" name=\"power\"/><OMI>2</OMI><OMI>10</OMI></OMA></OMOBJ>"},{"expected":{"value":"1/4"},"id":"arith1-power-2","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"arith1\" name=\"power\"/><OMI>2</OMI><OMI>-2</OMI></OMA></OMOBJ>"},{"expected":{"value":2},"id":"arith1-root-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"arith1\" name=\"root\"/><OMI>4</OMI><OMI>2</OMI></OMA></OMOBJ>"},{"expected":{"value":"1.4142135623730951"},"id":"arith1-root-2","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"arith1\" name=\"root\"/><OMI>2</OMI><OMI>2</OMI></OMA></OMOBJ>"},{"expected":{"value":3},"id":"arith1-abs-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"arith1\" name=\"abs\"/><OMI>-3</OMI></OMA></OMOBJ>"},{"expected":{"value":3},"id":"arith1-max-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"arith1\" name=\"max\"/><OMI>3</OMI><OMI>1</OMI><OMI>2</OMI></OMA></OMOBJ>"},{"expected":{"value":1},"id":"arith1-min-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"arith1\" name=\"min\"/><OMI>3</OMI><OMI>1</OMI><OMI>2</OMI></OMA></OMOBJ>"},{"expected":{"value":"5/1"},"id":"arith1-sum-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"arith1\" name=\"sum\"/><OMA><OMS cd=\"interval1\" name=\"interval\"/><OMI>1</OMI><OMI>4</OMI></OMA><OMBIND><OMS cd=\"fns1\" name=\"lambda\"/><OMBVAR><OMV name=\"x\"/></OMBVAR><OMA><OMS cd=\"arith1\" name=\"divided_by\"/><OMV name=\"x\"/><OMI>2</OMI></OMA></OMBIND></OMA></OMOBJ>"},{"expected":{"value":384},"id":"arith1-product-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"arith1\" name=\"product\"/><OMA><OMS cd=\"interval1\" name=\"interval\"/><OMI>1</OMI><OMI>4</OMI></OMA><OMBIND><OMS cd=\"fns1\" name=\"lambda\"/><OMBVAR><OMV name=\"x\"/></OMBVAR><OMA><OMS cd=\"arith1\" name=\"times\"/><OMV name=\"x\"/><OMI>2</OMI></OMA></OMBIND></OMA></OMOBJ>"},{"expected":{"value":true},"id":"relation1-eq-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"relation1\" name=\"eq\"/><OMI>1</OMI><OMI>1</OMI></OMA></OMOBJ>"},{"expected":{"value":false},"id":"relation1-neq-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"relation1\" name=\"neq\"/><OMI>1</OMI><OMI>1</OMI></OMA></OMOBJ>"},{"expected":{"value":true},"id":"relation1-lt-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"relation1\" name=\"lt\"/><OMI>1</OMI><OMI>2</OMI><OMI>3</OMI></OMA></OMOBJ>"},{"expected":{"value":false},"id":"relation1-geq-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"relation1\" name=\"geq\"/><OMI>1</OMI><OMI>2</OMI></OMA></OMOBJ>"},{"expected":{"value":false},"id":"relation1-approx-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"relation1\" name=\"approx\"/><OMI>1</OMI><OMI>2</OMI></OMA></OMOBJ>"},{"expected":{"value":false},"id":"logic1-and-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"logic1\" name=\"and\"/><OMV name=\"a\"/><OMV name=\"b\"/></OMA></OMOBJ>","variables":{"a":true,"b":false}},{"expected":{"value":true},"id":"logic1-implies-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"logic1\" name=\"implies\"/><OMV name=\"a\"/><OMV name=\"b\"/></OMA></OMOBJ>","variables":{"a":false,"b":false}},{"expected":{"value":120},"id":"integer1-factorial-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"integer1\" name=\"factorial\"/><OMI>5</OMI></OMA></OMOBJ>"},{"expected":{"value":3},"id":"integer1-quotient-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"integer1\" name=\"quotient\"/><OMI>7</OMI><OMI>2</OMI></OMA></OMOBJ>"},{"expected":{"value":1},"id":"integer1-remainder-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"integer1\" name=\"remainder\"/><OMI>7</OMI><OMI>2</OMI></OMA></OMOBJ>"},{"expected":{"value":3},"id":"rounding1-floor-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"rounding1\" name=\"floor\"/><OMA><OMS cd=\"nums1\" name=\"rational\"/><OMI>7</OMI><OMI>2</OMI></OMA></OMA></OMOBJ>"},{"expected":{"value":4},"id":"rounding1-ceiling-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"rounding1\" name=\"ceiling\"/><OMA><OMS cd=\"nums1\" name=\"rational\"/><OMI>7</OMI><OMI>2</OMI></OMA></OMA></OMOBJ>"},{"expected":{"value":"[1, 2, 3]"},"id":"list1-list-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"list1\" name=\"list\"/><OMI>1</OMI><OMI>2</OMI><OMI>3</OMI></OMA></OMOBJ>"},{"expected":{"value":"[1, 2]"},"id":"set1-set-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"set1\" name=\"set\"/><OMI>1</OMI><OMI>2</OMI><OMI>1</OMI></OMA></OMOBJ>"},{"expected":{"value":true},"id":"set1-in-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"set1\" name=\"in\"/><OMI>2</OMI><OMA><OMS cd=\"list1\" name=\"list\"/><OMI>1</OMI><OMI>2</OMI></OMA></OMA></OMOBJ>"},{"expected":{"value":3},"id":"set1-size-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"set1\" name=\"size\"/><OMA><OMS cd=\"list1\" name=\"list\"/><OMI>1</OMI><OMI>2</OMI><OMI>3</OMI></OMA></OMA></OMOBJ>"},{"expected":{"value":true},"id":"interval1-in-oc-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"set1\" name=\"in\"/><OMI>3</OMI><OMA><OMS cd=\"interval1\" name=\"interval_oc\"/><OMI>1</OMI><OMI>3</OMI></OMA></OMA></OMOBJ>"},{"expected":{"value":false},"id":"interval1-in-oc-2","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"set1\" name=\"in\"/><OMI>1</OMI><OMA><OMS cd=\"interval1\" name=\"interval_oc\"/><OMI>1</OMI><OMI>3</OMI></OMA></OMA></OMOBJ>"},{"expected":{"value":-2},"id":"linalg3-determinant-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"linalg3\" name=\"determinant\"/><OMA><OMS cd=\"linalg2\" name=\"matrix\"/><OMA><OMS cd=\"linalg2\" name=\"matrixrow\"/><OMI>1</OMI><OMI>2</OMI></OMA><OMA><OMS cd=\"linalg2\" name=\"matrixrow\"/><OMI>3</OMI><OMI>4</OMI></OMA></OMA></OMA></OMOBJ>"},{"expected":{"value":"[0, 0, 1]"},"id":"linalg1-vector-product-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"linalg1\" name=\"vector_product\"/><OMA><OMS cd=\"linalg2\" name=\"matrixrow\"/><OMI>1</OMI><OMI>0</OMI><OMI>0</OMI></OMA><OMA><OMS cd=\"linalg2\" name=\"matrixrow\"/><OMI>0</OMI><OMI>1</OMI><OMI>0</OMI></OMA></OMA></OMOBJ>"},{"id":"linalg1-vector-product-2","refusal":{"error":"DimensionMismatchError"},"request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"linalg1\" name=\"vector_product\"/><OMA><OMS cd=\"linalg2\" name=\"matrixrow\"/><OMI>1</OMI><OMI>0</OMI><OMI>0</OMI></OMA><OMA><OMS cd=\"linalg2\" name=\"matrixrow\"/><OMI>0</OMI><OMI>0</OMI><OMI>0</OMI><OMI>1</OMI></OMA></OMA></OMOBJ>"},{"expected":{"value":3},"id":"fns1-lambda-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMBIND><OMS cd=\"fns1\" name=\"lambda\"/><OMBVAR><OMV name=\"x\"/></OMBVAR><OMA><OMS cd=\"arith1\" name=\"plus\"/><OMV name=\"x\"/><OMI>1</OMI></OMA></OMBIND><OMI>2</OMI></OMA></OMOBJ>"},{"id":"lambda-arity-1","refusal":{"error":"ArityError"},"request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMBIND><OMS cd=\"fns1\" name=\"lambda\"/><OMBVAR><OMV name=\"x\"/></OMBVAR><OMA><OMS cd=\"arith1\" name=\"plus\"/><OMV name=\"x\"/><OMV name=\"y\"/></OMA></OMBIND><OMI>2</OMI><OMI>3</OMI></OMA></OMOBJ>"},{"expected":{"value":12},"id":"omr-resolution-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"arith1\" name=\"plus\"/><OMI id=\"t\">6</OMI><OMR href=\"#t\"/></OMA></OMOBJ>"},{"id":"omr-cycle-1","refusal":{"error":"RecursionError"},"request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA id=\"me\"><OMR href=\"#me\"/></OMA></OMOBJ>"},{"id":"refusal-unbound-1","refusal":{"error":"UnboundSymbolError"},"request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"mycd\" name=\"f\"/><OMI>1</OMI></OMA></OMOBJ>"},{"id":"refusal-arity-1","refusal":{"error":"ArityError"},"request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"arith1\" name=\"divided_by\"/><OMI>1</OMI></OMA></OMOBJ>"},{"id":"refusal-domain-1","refusal":{"error":"OperandTypeError"},"request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"arith1\" name=\"plus\"/><OMSTR>x</OMSTR></OMA></OMOBJ>"},{"expected":{"class":"Openmath::Evaluation::Uncertain","fields":{"category":"standard","value":"10.3"}},"id":"pmquant-ustd-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"pmquant\" name=\"ustd\"/><OMF dec=\"10.3\"/><OMF dec=\"0.2\"/></OMA></OMOBJ>"},{"expected":{"value":"10.3"},"id":"pmquant-value-1","request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"pmquant\" name=\"value\"/><OMA><OMS cd=\"pmquant\" name=\"ustd\"/><OMF dec=\"10.3\"/><OMF dec=\"0.2\"/></OMA></OMA></OMOBJ>"},{"id":"pmquant-factor-1","refusal":{"error":"OperandTypeError"},"request":"<OMOBJ xmlns=\"http://www.openmath.org/OpenMath\"><OMA><OMS cd=\"pmquant\" name=\"uexp\"/><OMF dec=\"1\"/><OMF dec=\"1\"/><OMF dec=\"0\"/></OMA></OMOBJ>"}]}
@@ -0,0 +1,70 @@
1
+ # The replay ledger: deterministic evaluation vectors for the portable
2
+ # bindings artifact. Each row carries the request verbatim and the
3
+ # expected value (or the typed refusal's error class). The rs/wasm lanes
4
+ # replay these rows against the same table; adding a binding adds rows
5
+ # here and to the binding table together.
6
+ ---
7
+ schema: openmath-replay-ledger/1
8
+ version: 1
9
+ vectors:
10
+ # nums1
11
+ - { id: nums1-integer-1, request: '<OMOBJ xmlns="http://www.openmath.org/OpenMath"><OMA><OMS cd="nums1" name="integer"/><OMI>42</OMI></OMA></OMOBJ>', expected: { value: 42 } }
12
+ - { id: nums1-rational-1, request: '<OMOBJ xmlns="http://www.openmath.org/OpenMath"><OMA><OMS cd="nums1" name="rational"/><OMI>3</OMI><OMI>9</OMI></OMA></OMOBJ>', expected: { value: "1/3" } }
13
+ - { id: nums1-based-integer-1, request: '<OMOBJ xmlns="http://www.openmath.org/OpenMath"><OMA><OMS cd="nums1" name="based_integer"/><OMI>16</OMI><OMSTR>1af</OMSTR></OMA></OMOBJ>', expected: { value: 431 } }
14
+ - { id: nums1-based-integer-2, request: '<OMOBJ xmlns="http://www.openmath.org/OpenMath"><OMA><OMS cd="nums1" name="based_integer"/><OMI>1</OMI><OMSTR>1</OMSTR></OMA></OMOBJ>', refusal: { error: "OperandTypeError" } }
15
+ # arith1
16
+ - { id: arith1-plus-1, request: '<OMOBJ xmlns="http://www.openmath.org/OpenMath"><OMA><OMS cd="arith1" name="plus"/><OMI>1</OMI><OMI>1</OMI></OMA></OMOBJ>', expected: { value: 2 } }
17
+ - { id: arith1-times-1, request: '<OMOBJ xmlns="http://www.openmath.org/OpenMath"><OMA><OMS cd="arith1" name="times"/><OMI>2</OMI><OMI>3</OMI></OMA></OMOBJ>', expected: { value: 6 } }
18
+ - { id: arith1-minus-1, request: '<OMOBJ xmlns="http://www.openmath.org/OpenMath"><OMA><OMS cd="arith1" name="minus"/><OMI>7</OMI><OMI>9</OMI></OMA></OMOBJ>', expected: { value: -2 } }
19
+ - { id: arith1-unary-minus-1, request: '<OMOBJ xmlns="http://www.openmath.org/OpenMath"><OMA><OMS cd="arith1" name="unary_minus"/><OMI>5</OMI></OMA></OMOBJ>', expected: { value: -5 } }
20
+ - { id: arith1-divided-by-1, request: '<OMOBJ xmlns="http://www.openmath.org/OpenMath"><OMA><OMS cd="arith1" name="divided_by"/><OMI>1</OMI><OMI>4</OMI></OMA></OMOBJ>', expected: { value: "1/4" } }
21
+ - { id: arith1-divided-by-2, request: '<OMOBJ xmlns="http://www.openmath.org/OpenMath"><OMA><OMS cd="arith1" name="divided_by"/><OMI>1</OMI><OMI>0</OMI></OMA></OMOBJ>', refusal: { error: "ZeroDivisionError" } }
22
+ - { id: arith1-power-1, request: '<OMOBJ xmlns="http://www.openmath.org/OpenMath"><OMA><OMS cd="arith1" name="power"/><OMI>2</OMI><OMI>10</OMI></OMA></OMOBJ>', expected: { value: 1024 } }
23
+ - { id: arith1-power-2, request: '<OMOBJ xmlns="http://www.openmath.org/OpenMath"><OMA><OMS cd="arith1" name="power"/><OMI>2</OMI><OMI>-2</OMI></OMA></OMOBJ>', expected: { value: "1/4" } }
24
+ - { id: arith1-root-1, request: '<OMOBJ xmlns="http://www.openmath.org/OpenMath"><OMA><OMS cd="arith1" name="root"/><OMI>4</OMI><OMI>2</OMI></OMA></OMOBJ>', expected: { value: 2 } }
25
+ - { id: arith1-root-2, request: '<OMOBJ xmlns="http://www.openmath.org/OpenMath"><OMA><OMS cd="arith1" name="root"/><OMI>2</OMI><OMI>2</OMI></OMA></OMOBJ>', expected: { value: "1.4142135623730951" } }
26
+ - { id: arith1-abs-1, request: '<OMOBJ xmlns="http://www.openmath.org/OpenMath"><OMA><OMS cd="arith1" name="abs"/><OMI>-3</OMI></OMA></OMOBJ>', expected: { value: 3 } }
27
+ - { id: arith1-max-1, request: '<OMOBJ xmlns="http://www.openmath.org/OpenMath"><OMA><OMS cd="arith1" name="max"/><OMI>3</OMI><OMI>1</OMI><OMI>2</OMI></OMA></OMOBJ>', expected: { value: 3 } }
28
+ - { id: arith1-min-1, request: '<OMOBJ xmlns="http://www.openmath.org/OpenMath"><OMA><OMS cd="arith1" name="min"/><OMI>3</OMI><OMI>1</OMI><OMI>2</OMI></OMA></OMOBJ>', expected: { value: 1 } }
29
+ - { id: arith1-sum-1, request: '<OMOBJ xmlns="http://www.openmath.org/OpenMath"><OMA><OMS cd="arith1" name="sum"/><OMA><OMS cd="interval1" name="interval"/><OMI>1</OMI><OMI>4</OMI></OMA><OMBIND><OMS cd="fns1" name="lambda"/><OMBVAR><OMV name="x"/></OMBVAR><OMA><OMS cd="arith1" name="divided_by"/><OMV name="x"/><OMI>2</OMI></OMA></OMBIND></OMA></OMOBJ>', expected: { value: "5/1" } }
30
+ - { id: arith1-product-1, request: '<OMOBJ xmlns="http://www.openmath.org/OpenMath"><OMA><OMS cd="arith1" name="product"/><OMA><OMS cd="interval1" name="interval"/><OMI>1</OMI><OMI>4</OMI></OMA><OMBIND><OMS cd="fns1" name="lambda"/><OMBVAR><OMV name="x"/></OMBVAR><OMA><OMS cd="arith1" name="times"/><OMV name="x"/><OMI>2</OMI></OMA></OMBIND></OMA></OMOBJ>', expected: { value: 384 } }
31
+ # relation1
32
+ - { id: relation1-eq-1, request: '<OMOBJ xmlns="http://www.openmath.org/OpenMath"><OMA><OMS cd="relation1" name="eq"/><OMI>1</OMI><OMI>1</OMI></OMA></OMOBJ>', expected: { value: true } }
33
+ - { id: relation1-neq-1, request: '<OMOBJ xmlns="http://www.openmath.org/OpenMath"><OMA><OMS cd="relation1" name="neq"/><OMI>1</OMI><OMI>1</OMI></OMA></OMOBJ>', expected: { value: false } }
34
+ - { id: relation1-lt-1, request: '<OMOBJ xmlns="http://www.openmath.org/OpenMath"><OMA><OMS cd="relation1" name="lt"/><OMI>1</OMI><OMI>2</OMI><OMI>3</OMI></OMA></OMOBJ>', expected: { value: true } }
35
+ - { id: relation1-geq-1, request: '<OMOBJ xmlns="http://www.openmath.org/OpenMath"><OMA><OMS cd="relation1" name="geq"/><OMI>1</OMI><OMI>2</OMI></OMA></OMOBJ>', expected: { value: false } }
36
+ - { id: relation1-approx-1, request: '<OMOBJ xmlns="http://www.openmath.org/OpenMath"><OMA><OMS cd="relation1" name="approx"/><OMI>1</OMI><OMI>2</OMI></OMA></OMOBJ>', expected: { value: false } }
37
+ # logic1
38
+ - { id: logic1-and-1, request: '<OMOBJ xmlns="http://www.openmath.org/OpenMath"><OMA><OMS cd="logic1" name="and"/><OMV name="a"/><OMV name="b"/></OMA></OMOBJ>', variables: { a: true, b: false }, expected: { value: false } }
39
+ - { id: logic1-implies-1, request: '<OMOBJ xmlns="http://www.openmath.org/OpenMath"><OMA><OMS cd="logic1" name="implies"/><OMV name="a"/><OMV name="b"/></OMA></OMOBJ>', variables: { a: false, b: false }, expected: { value: true } }
40
+ # integer1 / rounding1
41
+ - { id: integer1-factorial-1, request: '<OMOBJ xmlns="http://www.openmath.org/OpenMath"><OMA><OMS cd="integer1" name="factorial"/><OMI>5</OMI></OMA></OMOBJ>', expected: { value: 120 } }
42
+ - { id: integer1-quotient-1, request: '<OMOBJ xmlns="http://www.openmath.org/OpenMath"><OMA><OMS cd="integer1" name="quotient"/><OMI>7</OMI><OMI>2</OMI></OMA></OMOBJ>', expected: { value: 3 } }
43
+ - { id: integer1-remainder-1, request: '<OMOBJ xmlns="http://www.openmath.org/OpenMath"><OMA><OMS cd="integer1" name="remainder"/><OMI>7</OMI><OMI>2</OMI></OMA></OMOBJ>', expected: { value: 1 } }
44
+ - { id: rounding1-floor-1, request: '<OMOBJ xmlns="http://www.openmath.org/OpenMath"><OMA><OMS cd="rounding1" name="floor"/><OMA><OMS cd="nums1" name="rational"/><OMI>7</OMI><OMI>2</OMI></OMA></OMA></OMOBJ>', expected: { value: 3 } }
45
+ - { id: rounding1-ceiling-1, request: '<OMOBJ xmlns="http://www.openmath.org/OpenMath"><OMA><OMS cd="rounding1" name="ceiling"/><OMA><OMS cd="nums1" name="rational"/><OMI>7</OMI><OMI>2</OMI></OMA></OMA></OMOBJ>', expected: { value: 4 } }
46
+ # set1 / list1
47
+ - { id: list1-list-1, request: '<OMOBJ xmlns="http://www.openmath.org/OpenMath"><OMA><OMS cd="list1" name="list"/><OMI>1</OMI><OMI>2</OMI><OMI>3</OMI></OMA></OMOBJ>', expected: { value: "[1, 2, 3]" } }
48
+ - { id: set1-set-1, request: '<OMOBJ xmlns="http://www.openmath.org/OpenMath"><OMA><OMS cd="set1" name="set"/><OMI>1</OMI><OMI>2</OMI><OMI>1</OMI></OMA></OMOBJ>', expected: { value: "[1, 2]" } }
49
+ - { id: set1-in-1, request: '<OMOBJ xmlns="http://www.openmath.org/OpenMath"><OMA><OMS cd="set1" name="in"/><OMI>2</OMI><OMA><OMS cd="list1" name="list"/><OMI>1</OMI><OMI>2</OMI></OMA></OMA></OMOBJ>', expected: { value: true } }
50
+ - { id: set1-size-1, request: '<OMOBJ xmlns="http://www.openmath.org/OpenMath"><OMA><OMS cd="set1" name="size"/><OMA><OMS cd="list1" name="list"/><OMI>1</OMI><OMI>2</OMI><OMI>3</OMI></OMA></OMA></OMOBJ>', expected: { value: 3 } }
51
+ # interval1
52
+ - { id: interval1-in-oc-1, request: '<OMOBJ xmlns="http://www.openmath.org/OpenMath"><OMA><OMS cd="set1" name="in"/><OMI>3</OMI><OMA><OMS cd="interval1" name="interval_oc"/><OMI>1</OMI><OMI>3</OMI></OMA></OMA></OMOBJ>', expected: { value: true } }
53
+ - { id: interval1-in-oc-2, request: '<OMOBJ xmlns="http://www.openmath.org/OpenMath"><OMA><OMS cd="set1" name="in"/><OMI>1</OMI><OMA><OMS cd="interval1" name="interval_oc"/><OMI>1</OMI><OMI>3</OMI></OMA></OMA></OMOBJ>', expected: { value: false } }
54
+ # linalg
55
+ - { id: linalg3-determinant-1, request: '<OMOBJ xmlns="http://www.openmath.org/OpenMath"><OMA><OMS cd="linalg3" name="determinant"/><OMA><OMS cd="linalg2" name="matrix"/><OMA><OMS cd="linalg2" name="matrixrow"/><OMI>1</OMI><OMI>2</OMI></OMA><OMA><OMS cd="linalg2" name="matrixrow"/><OMI>3</OMI><OMI>4</OMI></OMA></OMA></OMA></OMOBJ>', expected: { value: -2 } }
56
+ - { id: linalg1-vector-product-1, request: '<OMOBJ xmlns="http://www.openmath.org/OpenMath"><OMA><OMS cd="linalg1" name="vector_product"/><OMA><OMS cd="linalg2" name="matrixrow"/><OMI>1</OMI><OMI>0</OMI><OMI>0</OMI></OMA><OMA><OMS cd="linalg2" name="matrixrow"/><OMI>0</OMI><OMI>1</OMI><OMI>0</OMI></OMA></OMA></OMOBJ>', expected: { value: "[0, 0, 1]" } }
57
+ - { id: linalg1-vector-product-2, request: '<OMOBJ xmlns="http://www.openmath.org/OpenMath"><OMA><OMS cd="linalg1" name="vector_product"/><OMA><OMS cd="linalg2" name="matrixrow"/><OMI>1</OMI><OMI>0</OMI><OMI>0</OMI></OMA><OMA><OMS cd="linalg2" name="matrixrow"/><OMI>0</OMI><OMI>0</OMI><OMI>0</OMI><OMI>1</OMI></OMA></OMA></OMOBJ>', refusal: { error: "DimensionMismatchError" } }
58
+ # lambda and references
59
+ - { id: fns1-lambda-1, request: '<OMOBJ xmlns="http://www.openmath.org/OpenMath"><OMA><OMBIND><OMS cd="fns1" name="lambda"/><OMBVAR><OMV name="x"/></OMBVAR><OMA><OMS cd="arith1" name="plus"/><OMV name="x"/><OMI>1</OMI></OMA></OMBIND><OMI>2</OMI></OMA></OMOBJ>', expected: { value: 3 } }
60
+ - { id: lambda-arity-1, request: '<OMOBJ xmlns="http://www.openmath.org/OpenMath"><OMA><OMBIND><OMS cd="fns1" name="lambda"/><OMBVAR><OMV name="x"/></OMBVAR><OMA><OMS cd="arith1" name="plus"/><OMV name="x"/><OMV name="y"/></OMA></OMBIND><OMI>2</OMI><OMI>3</OMI></OMA></OMOBJ>', refusal: { error: "ArityError" } }
61
+ - { id: omr-resolution-1, request: '<OMOBJ xmlns="http://www.openmath.org/OpenMath"><OMA><OMS cd="arith1" name="plus"/><OMI id="t">6</OMI><OMR href="#t"/></OMA></OMOBJ>', expected: { value: 12 } }
62
+ - { id: omr-cycle-1, request: '<OMOBJ xmlns="http://www.openmath.org/OpenMath"><OMA id="me"><OMR href="#me"/></OMA></OMOBJ>', refusal: { error: "RecursionError" } }
63
+ # strict refusals
64
+ - { id: refusal-unbound-1, request: '<OMOBJ xmlns="http://www.openmath.org/OpenMath"><OMA><OMS cd="mycd" name="f"/><OMI>1</OMI></OMA></OMOBJ>', refusal: { error: "UnboundSymbolError" } }
65
+ - { id: refusal-arity-1, request: '<OMOBJ xmlns="http://www.openmath.org/OpenMath"><OMA><OMS cd="arith1" name="divided_by"/><OMI>1</OMI></OMA></OMOBJ>', refusal: { error: "ArityError" } }
66
+ - { id: refusal-domain-1, request: '<OMOBJ xmlns="http://www.openmath.org/OpenMath"><OMA><OMS cd="arith1" name="plus"/><OMSTR>x</OMSTR></OMA></OMOBJ>', refusal: { error: "OperandTypeError" } }
67
+ # pmquant
68
+ - { id: pmquant-ustd-1, request: '<OMOBJ xmlns="http://www.openmath.org/OpenMath"><OMA><OMS cd="pmquant" name="ustd"/><OMF dec="10.3"/><OMF dec="0.2"/></OMA></OMOBJ>', expected: { class: "Openmath::Evaluation::Uncertain", fields: { value: "10.3", category: "standard" } } }
69
+ - { id: pmquant-value-1, request: '<OMOBJ xmlns="http://www.openmath.org/OpenMath"><OMA><OMS cd="pmquant" name="value"/><OMA><OMS cd="pmquant" name="ustd"/><OMF dec="10.3"/><OMF dec="0.2"/></OMA></OMA></OMOBJ>', expected: { value: "10.3" } }
70
+ - { id: pmquant-factor-1, request: '<OMOBJ xmlns="http://www.openmath.org/OpenMath"><OMA><OMS cd="pmquant" name="uexp"/><OMF dec="1"/><OMF dec="1"/><OMF dec="0"/></OMA></OMOBJ>', refusal: { error: "OperandTypeError" } }
@@ -3,22 +3,36 @@
3
3
  module Openmath
4
4
  module Base
5
5
  # A foreign object: <OMFOREIGN encoding="...">...</OMFOREIGN>
6
- # (schema: compound attributes, optional encoding, then OpenMath children
7
- # and foreign markup. This release models the OpenMath children and the
8
- # encoding; non-OpenMath markup inside is not yet represented — see the
9
- # roadmap issue.)
6
+ # (schema: compound attributes, optional encoding, then OpenMath
7
+ # children and foreign markup). Foreign markup (any element outside
8
+ # the OpenMath namespace) is captured verbatim by
9
+ # Openmath::Foreign.capture at parse time into +notom_value+ and
10
+ # re-emitted by the serialization override below. The interleaving
11
+ # position of foreign fragments relative to OpenMath children is
12
+ # normalized to OpenMath-children-first on re-serialization; the
13
+ # fragments themselves round-trip byte-identically.
10
14
  module Omforeign
11
15
  def self.included(klass)
12
16
  klass.class_eval do
13
17
  include Openmath::Base::Compound
14
18
 
15
19
  attribute :foreign_encoding, :string
20
+ attribute :notom_value, :string, collection: true
21
+ attribute :notom_positions, :integer, collection: true
16
22
 
17
23
  xml do
18
24
  element "OMFOREIGN"
19
25
  ordered
20
26
  map_attribute "encoding", to: :foreign_encoding
21
27
  end
28
+
29
+ def to_xml(**options, &block)
30
+ result = super(**options, &block)
31
+ fragments = Array(notom_value)
32
+ return result if fragments.empty?
33
+
34
+ Openmath::Foreign.inject(result, fragments)
35
+ end
22
36
  end
23
37
  end
24
38
  end
@@ -17,6 +17,13 @@ module Openmath
17
17
  ordered
18
18
  map_attribute "version", to: :version
19
19
  end
20
+
21
+ def to_xml(**options, &block)
22
+ result = super(**options, &block)
23
+ return result unless Openmath::Foreign.contained?(self)
24
+
25
+ Openmath::Foreign.inject_tree(self, result)
26
+ end
20
27
  end
21
28
  end
22
29
  end