Skip to content

Commit 7a9714d

Browse files
committed
set containment with equality
1 parent 795d826 commit 7a9714d

17 files changed

+1052
-9980
lines changed

build/math-expressions.js

+4-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/math-expressions_umd.js

+4-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/converters/ast-to-latex.js

+15-1
Original file line numberDiff line numberDiff line change
@@ -116,15 +116,27 @@ const operators = {
116116
"subset": function (operands) {
117117
return operands[0] + " \\subset " + operands[1];
118118
},
119+
"subseteq": function (operands) {
120+
return operands[0] + " \\subseteq " + operands[1];
121+
},
119122
"notsubset": function (operands) {
120123
return operands[0] + " \\not\\subset " + operands[1];
121124
},
125+
"notsubseteq": function (operands) {
126+
return operands[0] + " \\not\\subseteq " + operands[1];
127+
},
122128
"superset": function (operands) {
123129
return operands[0] + " \\supset " + operands[1];
124130
},
131+
"superseteq": function (operands) {
132+
return operands[0] + " \\supseteq " + operands[1];
133+
},
125134
"notsuperset": function (operands) {
126135
return operands[0] + " \\not\\supset " + operands[1];
127136
},
137+
"notsuperseteq": function (operands) {
138+
return operands[0] + " \\not\\supseteq " + operands[1];
139+
},
128140
"union": function (operands) {
129141
return operands.join(' \\cup ');
130142
},
@@ -271,7 +283,9 @@ class astToLatex {
271283
(operator === 'in') || (operator === 'notin') ||
272284
(operator === 'ni') || (operator === 'notni') ||
273285
(operator === 'subset') || (operator === 'notsubset') ||
274-
(operator === 'superset') || (operator === 'notsuperset')) {
286+
(operator === 'subseteq') || (operator === 'notsubseteq') ||
287+
(operator === 'superset') || (operator === 'notsuperset') ||
288+
(operator === 'superseteq') || (operator === 'notsuperseteq')) {
275289
return operators[operator](operands.map(function (v, i) {
276290
return this.expression(v);
277291
}.bind(this)));

lib/converters/ast-to-text.js

+11-1
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,13 @@ const unicode_operators = {
5555
"ni": function (operands) { return operands[0] + " ∋ " + operands[1]; },
5656
"notni": function (operands) { return operands[0] + " ∌ " + operands[1]; },
5757
"subset": function (operands) { return operands[0] + " ⊂ " + operands[1]; },
58+
"subseteq": function (operands) { return operands[0] + " ⊆ " + operands[1]; },
5859
"notsubset": function (operands) { return operands[0] + " ⊄ " + operands[1]; },
60+
"notsubseteq": function (operands) { return operands[0] + " ⊈ " + operands[1]; },
5961
"superset": function (operands) { return operands[0] + " ⊃ " + operands[1]; },
62+
"superseteq": function (operands) { return operands[0] + " ⊇ " + operands[1]; },
6063
"notsuperset": function (operands) { return operands[0] + " ⊅ " + operands[1]; },
64+
"notsuperseteq": function (operands) { return operands[0] + " ⊉ " + operands[1]; },
6165
"union": function (operands) { return operands.join(' ∪ '); },
6266
"intersect": function (operands) { return operands.join(' ∩ '); },
6367
"perp": function (operands) { return operands.join(' ⟂ '); },
@@ -111,9 +115,13 @@ const nonunicode_operators = {
111115
"ni": function (operands) { return operands[0] + " containselement " + operands[1]; },
112116
"notni": function (operands) { return operands[0] + " notcontainselement " + operands[1]; },
113117
"subset": function (operands) { return operands[0] + " subset " + operands[1]; },
118+
"subseteq": function (operands) { return operands[0] + " subseteq " + operands[1]; },
114119
"notsubset": function (operands) { return operands[0] + " notsubset " + operands[1]; },
120+
"notsubseteq": function (operands) { return operands[0] + " notsubseteq " + operands[1]; },
115121
"superset": function (operands) { return operands[0] + " superset " + operands[1]; },
122+
"superseteq": function (operands) { return operands[0] + " superseteq " + operands[1]; },
116123
"notsuperset": function (operands) { return operands[0] + " notsuperset " + operands[1]; },
124+
"notsuperseteq": function (operands) { return operands[0] + " notsuperseteq " + operands[1]; },
117125
"union": function (operands) { return operands.join(' union '); },
118126
"intersect": function (operands) { return operands.join(' intersect '); },
119127
"perp": function (operands) { return operands.join(' perp '); },
@@ -213,7 +221,9 @@ class astToText {
213221
|| (operator === 'in') || (operator === 'notin')
214222
|| (operator === 'ni') || (operator === 'notni')
215223
|| (operator === 'subset') || (operator === 'notsubset')
216-
|| (operator === 'superset') || (operator === 'notsuperset')) {
224+
|| (operator === 'subseteq') || (operator === 'notsubseteq')
225+
|| (operator === 'superset') || (operator === 'notsuperset')
226+
|| (operator === 'superseteq') || (operator === 'notsuperseteq')) {
217227
return this.operators[operator](operands.map(function (v, i) {
218228
return this.expression(v);
219229
}.bind(this)));

lib/converters/latex-to-ast.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -306,12 +306,16 @@ const base_latex_rules = [
306306
['\\\\not\\s*\\\\ni(?![a-zA-Z])', 'NOTNI'],
307307

308308
['\\\\subset(?![a-zA-Z])', 'SUBSET'],
309+
['\\\\subseteq(?![a-zA-Z])', 'SUBSETEQ'],
309310

310311
['\\\\not\\s*\\\\subset(?![a-zA-Z])', 'NOTSUBSET'],
312+
['\\\\not\\s*\\\\subseteq(?![a-zA-Z])', 'NOTSUBSETEQ'],
311313

312314
['\\\\supset(?![a-zA-Z])', 'SUPERSET'],
315+
['\\\\supseteq(?![a-zA-Z])', 'SUPERSETEQ'],
313316

314317
['\\\\not\\s*\\\\supset(?![a-zA-Z])', 'NOTSUPERSET'],
318+
['\\\\not\\s*\\\\supseteq(?![a-zA-Z])', 'NOTSUPERSETEQ'],
315319

316320
['\\\\cup(?![a-zA-Z])', 'UNION'],
317321

@@ -595,7 +599,9 @@ class latexToAst {
595599
|| (this.token.token_type === 'IN') || (this.token.token_type === 'NOTIN')
596600
|| (this.token.token_type === 'NI') || (this.token.token_type === 'NOTNI')
597601
|| (this.token.token_type === 'SUBSET') || (this.token.token_type === 'NOTSUBSET')
598-
|| (this.token.token_type === 'SUPERSET') || (this.token.token_type === 'NOTSUPERSET')) {
602+
|| (this.token.token_type === 'SUBSETEQ') || (this.token.token_type === 'NOTSUBSETEQ')
603+
|| (this.token.token_type === 'SUPERSET') || (this.token.token_type === 'NOTSUPERSET')
604+
|| (this.token.token_type === 'SUPERSETEQ') || (this.token.token_type === 'NOTSUPERSETEQ')) {
599605

600606
let operation = this.token.token_type.toLowerCase();
601607

lib/converters/text-to-ast.js

+39-25
Original file line numberDiff line numberDiff line change
@@ -245,11 +245,11 @@ const base_text_rules = [
245245
['\u03C9', 'VARMULTICHAR', 'omega'], // 'ω'
246246

247247

248-
['oo\\b', 'INFINITY'],
249-
['OO\\b', 'INFINITY'],
250-
['infty\\b', 'INFINITY'],
251-
['infinity\\b', 'INFINITY'],
252-
['Infinity\\b', 'INFINITY'],
248+
['oo(?![a-zA-Z0-9])', 'INFINITY'],
249+
['OO(?![a-zA-Z0-9])', 'INFINITY'],
250+
['infty(?![a-zA-Z0-9])', 'INFINITY'],
251+
['infinity(?![a-zA-Z0-9])', 'INFINITY'],
252+
['Infinity(?![a-zA-Z0-9])', 'INFINITY'],
253253
['\u221E', 'INFINITY'], // '∞'
254254

255255
['\u212F', 'VAR', 'e'], // 'ℯ'
@@ -273,14 +273,14 @@ const base_text_rules = [
273273
['\u2218', 'VARMULTICHAR', 'circ'], // '∘'
274274
['\u22C6', 'VARMULTICHAR', 'star'], // '⋆'
275275

276-
['and\\b', 'AND'],
276+
['and(?![a-zA-Z0-9])', 'AND'],
277277
['\\&\\&?', 'AND'],
278278
['\u2227', 'AND'], // '∧'
279279

280-
['or\\b', 'OR'],
280+
['or(?![a-zA-Z0-9])', 'OR'],
281281
['\u2228', 'OR'], // '∨'
282282

283-
['not\\b', 'NOT'],
283+
['not(?![a-zA-Z0-9])', 'NOT'],
284284
['\u00ac', 'NOT'], // '¬'
285285

286286
['=', '='],
@@ -295,46 +295,58 @@ const base_text_rules = [
295295
['<', '<'],
296296
['>', '>'],
297297

298-
['elementof\\b', 'IN'],
298+
['elementof(?![a-zA-Z0-9])', 'IN'],
299299
['\u2208', 'IN'], // '∈'
300300

301-
['notelementof\\b', 'NOTIN'],
302-
['\u2209', 'NOTIN'], //'∉'
301+
['notelementof(?![a-zA-Z0-9])', 'NOTIN'],
302+
['\u2209', 'NOTIN'], // '∉'
303303

304-
['containselement\\b', 'NI'],
304+
['containselement(?![a-zA-Z0-9])', 'NI'],
305305
['\u220B', 'NI'], // '∋'
306306

307-
['notcontainselement\\b', 'NOTNI'],
307+
['notcontainselement(?![a-zA-Z0-9])', 'NOTNI'],
308308
['\u220C', 'NOTNI'], // '∌'
309309

310-
['subset\\b', 'SUBSET'],
310+
['subset(?![a-zA-Z0-9])', 'SUBSET'],
311311
['\u2282', 'SUBSET'], // '⊂'
312312

313-
['notsubset\\b', 'NOTSUBSET'],
313+
['subseteq(?![a-zA-Z0-9])', 'SUBSETEQ'],
314+
['\u2286', 'SUBSETEQ'], // '⊆'
315+
316+
['notsubset(?![a-zA-Z0-9])', 'NOTSUBSET'],
314317
['\u2284', 'NOTSUBSET'], // '⊄'
315318

316-
['superset\\b', 'SUPERSET'],
319+
['notsubseteq(?![a-zA-Z0-9])', 'NOTSUBSETEQ'],
320+
['\u2288', 'NOTSUBSETEQ'], // '⊈'
321+
322+
['superset(?![a-zA-Z0-9])', 'SUPERSET'],
317323
['\u2283', 'SUPERSET'], // '⊃'
318324

319-
['notsuperset\\b', 'NOTSUPERSET'],
320-
['\u2285', 'NOTSUPERSET'], //'⊅'
325+
['superseteq(?![a-zA-Z0-9])', 'SUPERSETEQ'],
326+
['\u2287', 'SUPERSETEQ'], // '⊇'
327+
328+
['notsuperset(?![a-zA-Z0-9])', 'NOTSUPERSET'],
329+
['\u2285', 'NOTSUPERSET'], // '⊅'
330+
331+
['notsuperseteq(?![a-zA-Z0-9])', 'NOTSUPERSETEQ'],
332+
['\u2289', 'NOTSUPERSETEQ'], // '⊉'
321333

322-
['union\\b', 'UNION'],
334+
['union(?![a-zA-Z0-9])', 'UNION'],
323335
['\u222A', 'UNION'], // '∪'
324336

325-
['intersect\\b', 'INTERSECT'],
337+
['intersect(?![a-zA-Z0-9])', 'INTERSECT'],
326338
['\u2229', 'INTERSECT'], //'∩'
327339

328-
['perp\\b', 'PERP'],
340+
['perp(?![a-zA-Z0-9])', 'PERP'],
329341
['\u27c2', 'PERP'], // '⟂'
330342

331-
['parallel\\b', 'PARALLEL'],
343+
['parallel(?![a-zA-Z0-9])', 'PARALLEL'],
332344
['\u2225', 'PARALLEL'], // '∥'
333345

334-
['angle\\b', 'ANGLE'],
346+
['angle(?![a-zA-Z0-9])', 'ANGLE'],
335347
['\u2220', 'ANGLE'], // '∠'
336348

337-
['int(?![a-zA-Z])', 'INT'],
349+
['int(?![a-zA-Z0-9])', 'INT'],
338350
['\u222b', 'INT'], // '∫'
339351

340352
['!', '!'],
@@ -588,7 +600,9 @@ class textToAst {
588600
(this.token.token_type === 'IN') || (this.token.token_type === 'NOTIN') ||
589601
(this.token.token_type === 'NI') || (this.token.token_type === 'NOTNI') ||
590602
(this.token.token_type === 'SUBSET') || (this.token.token_type === 'NOTSUBSET') ||
591-
(this.token.token_type === 'SUPERSET') || (this.token.token_type === 'NOTSUPERSET')) {
603+
(this.token.token_type === 'SUBSETEQ') || (this.token.token_type === 'NOTSUBSETEQ') ||
604+
(this.token.token_type === 'SUPERSET') || (this.token.token_type === 'NOTSUPERSET') ||
605+
(this.token.token_type === 'SUPERSETEQ') || (this.token.token_type === 'NOTSUPERSETEQ')) {
592606

593607
let operation = this.token.token_type.toLowerCase();
594608

lib/trees/default_order.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,8 @@ function default_order(expr_or_tree, params) {
410410

411411
}
412412
else if (operator === 'ni' || operator === 'notni'
413-
|| operator === 'superset' || operator === 'notsuperset') {
413+
|| operator === 'superset' || operator === 'notsuperset'
414+
|| operator === 'superseteq' || operator === 'notsuperseteq') {
414415
// turn all containment operators to have larger set at right
415416

416417
operands = operands.reverse();
@@ -420,8 +421,12 @@ function default_order(expr_or_tree, params) {
420421
operator = 'notin';
421422
else if (operator === 'superset')
422423
operator = 'subset';
423-
else
424+
else if (operator === 'notsuperset')
424425
operator = 'notsubset';
426+
else if (operator === 'superseteq')
427+
operator = 'subseteq';
428+
else if (operator === 'notsuperseteq')
429+
operator = 'notsubseteq';
425430
}
426431
else if (operator === '-') {
427432
// when negating a product with a numerical first factor

0 commit comments

Comments
 (0)