sets by jason, help page

Basics

What is this tool?
Why does this tool exist?
Who made it?

Help using

How do I use it?
What can it do?
What notations can it recognize?

Troubleshooting

The line ... contains unrecognized symbols
The line ... cannot be parsed
[thing] is an Error: type error
[thing] is an Error: DNE error
Page blank and unresponsive

How it works

What technologies does it use?
Written in pure JavaScript? Are you serious?
What exactly is it doing?

What's is this tool?

This tool is an automatic set theory calculator. It understands the natural language of set theory, interprets it, and performs set-theoretical calculations.

Why does this tool exist?

The set theory calculator is designed for exploratory student use in a learning environment, to enhance learning.

Who made it?

Jason Howald, math professor at SUNY Potsdam and computer programmer, wrote this tool primarily in the summer of 2007, with the intention to use it in the course Set Theory and Logic.

Help using

How do I use it?

You may wish to go back to the main page and view the examples first. In a nutshell, you write expressions, such as Let x = {1,2,3} and the machine reads it, interprets its meaning, and learns any variables you define. The computer reports back all symbols you have defined. For this reason all lines should define symbols.

What can it do?

The machine knows about sets ({{},{1,2,3},{1,2}}), vectors ((1,2,7)), functions (f(x)), numbers (42), statements (C subset D), and abstracts ({"apple","orange"}). It can do all basic set theoretical operations, such as union, intersection, set difference, power set, cardinality, etc. It does basic arithmetic when needed, and understands y+7*x^3. It understands about functions, their domain and range, evaluation, and notation for definition by formula: Let f:A to B via f(x) = x^2+1.

What notations can it recognize?

Troubleshooting

The line ... contains unrecognized symbols

This is a "nonsense symbol error." Technically speaking, the tokenizer failed to recognize something you typed as a set theoretical symbol. Probably you used the wrong symbols to represent something, such as [1,2,3,4] instead of (1,2,3,4), f[S] instead of f(s), & instead of and. If you can't find the problem, copy what you typed and email jason.

The line ... cannot be parsed

This is a "bad grammar" error, or "syntax error". It means that the parser could not recognize your entry as a grammatically sensible combination of symbols. This could be caused by the use of a synonym for the right symbol instead of the right symbol: elementof instead of in, subsetof instead of subset, by instead of via in a function definition, there exists instead of exists, etc. It could also be caused by poor arithmetic or "optimistic" grammar: a+-b, a+b**4, or even x<y<z (try (x<y) and (y<z)). Negatives currently generate this error: Instead of -3, try 0-3. Sorry.

[thing] is an Error: type error

You tried to act on things in a way that they can't be acted on. For example, you intersected two numbers, evaluated S(4), where S is not a function, divided two sets, etc.

[thing] is an Error: DNE

You divided by zero, evaluated a function at an element not in its domain, took the fifth coordinate of a 3D vector, or some other such disaster.

Page blank and unresponsive

This can be caused by an actual internal program error, uncovered by some peculiar user input. Obviously, it's supposed to never happen. If it does happen, jason would appreciate knowing the input that caused it.

How it works

What technologies does it use?

Obviously html and css, since the project is a webpage. But these are very minimal. The entire codebase is written in Javascript.

Written in pure Javascript? Are you serious?

Lots of people criticize Javascript, and I'm among them: It's interpreted, quirky, has odd syntax, uses peculiar object inheritance, and can't do regular expressions very well. I chose it for one reason only: Availability. Everybody runs a browser, so everybody has a Javascript interpreter already up and running. In my opinion, DHMTL/Javascript/AJAX/css programming has become what Java was supposed to become. Also, writing a smooth interface in javascript is a snap, and that has its appeal.

What exactly is it doing?

Each line of user code is processed separately in order. There is a "grammar" object which converts the user input to symbols, then passes it to the parser. The parser is given (by the grammar) a long list of "rules", such as how to interpret a symbol combination "[symbol][left paren][anything][rightparen]" as functional evaluation. These rules encompass the full expressivity of the language of set theory. The parser begins a long bottom-up search process to express substrings of the symbol string as resulting from the applications of various rules. From the parser's perspective, the grammatical rules are variable, handed to it at runtime. So this search was the hardest part to code. The result of the search is (supposed to be) a parse tree for the entire expression, which can then be evaluated. Evaluation is recursive and defined simultaneously with the grammar. (Each rule has an evaluation method.) The values of the expressions are vectors, sets, functions, abstracts, etc., and so of course there is a whole subpackage to define all those gadgets and specify their behavior. Finally an interface package takes over and makes the objects display in a pretty way. Any assertion that "let"s a variable causes an update to a symbol table, which of course affects the evaluation of future expressions.