Blockly for mathematics & first-order logic

897 views
Skip to first unread message

Anthony Morphett

unread,
Oct 28, 2015, 12:57:29 PM10/28/15
to blo...@googlegroups.com
Hi Blockly people,

I've been toying a little with using Blockly for constructing mathematical expressions in first-order logic.  Quantifiers and logical connectives are new for many undergraduate maths students when they encounter them in their 1st or 2nd year subjects, and students make all sorts of syntactical errors when they use them in their work.  I'm hoping to use Blockly with undergraduate maths students to support their use of mathematical notation and help them internalise the syntax.  I've been playing around with some mathematics blocks and proof-of-concept online activities.  You can try them for youself at:

https://awmorp.github.io/math-blockly/

These are still at an early stage, they need a lot more polishing and I haven't used them with students yet. Nevertheless, any feedback or ideas are welcome.

Some technical aspects that might be of interest:
  • Types are indicated using shaped connectors instead of the puzzle piece: round for Number, angled for Boolean, {-shaped for Set.
  • There's a Latex code generator to produce Latex code from blocks. This can then be rendered using MathJax. See the builder example.  The Latex code generator required some minor modifications to the Blockly core- namely, language-specific parentheses and line ends.
  • It uses HendrikD's type indicator, modified to support shaped connectors.
  • Variables are typed: Number, Set or Boolean. Dropdowns show only variables of the correct type.

I also have one Blockly bug to report: the startScale zoom option does not work properly with a toolbox.  The toolbox blocks initially appear zoomed, but when you drag a block from the toolbox to the workspace the new block is unzoomed, as are any initial blocks loaded with domToWorkspace.  Zooming with the buttons or mousewheel fixes this. You can see this in the bottom two examples at https://awmorp.github.io/math-blockly/html/logic-exercise.html

Best regards,
Anthony

--
Anthony Morphett
awm...@gmail.com
http://morphett.info
Melbourne, Australia

Erik Pasternak

unread,
Oct 28, 2015, 8:17:05 PM10/28/15
to Blockly
Cool idea. You might want to consider also generating an English sentence along with the mathematical expression (like "There exists an 'm' in the set of integers such that...").

One other nit, do you need some way of specifying assumptions about the variables the logic is describing? The is prime example describes the requirements for 'p' being prime but doesn't specify that 'p' must be an integer.

Anthony Morphett

unread,
Oct 30, 2015, 4:05:25 AM10/30/15
to blo...@googlegroups.com
Thanks for the comments Eric, both sensible suggestions.

Anthony


--
You received this message because you are subscribed to the Google Groups "Blockly" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blockly+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Neil Fraser

unread,
Oct 31, 2015, 4:45:09 AM10/31/15
to blo...@googlegroups.com
On 28 October 2015 at 05:57, Anthony Morphett <awm...@gmail.com> wrote:
I also have one Blockly bug to report: the startScale zoom option does not work properly with a toolbox.  The toolbox blocks initially appear zoomed, but when you drag a block from the toolbox to the workspace the new block is unzoomed, as are any initial blocks loaded with domToWorkspace.  Zooming with the buttons or mousewheel fixes this. You can see this in the bottom two examples at https://awmorp.github.io/math-blockly/html/logic-exercise.html

Indeed, I can see a lot of zooming issues in your examples.  For instance, dragging scaled blocks will drag with a multiple of the mouse movement.  However, I can't recreate this using stock Blockly (the playground).  Did you have a bad merge somewhere?

--

Anthony Morphett

unread,
Nov 1, 2015, 5:05:09 AM11/1/15
to blo...@googlegroups.com
Hi Neil,

Thanks for investigating.  I can reproduce it with the latest stock Blockly, see attached example.  Interestingly it doesn't occur for me in the playground either when I change startScale in playground.html

Anthony


--
zoom-bug.html
blockly-zoom-bug-screenshot.png

Romualdo Grillo

unread,
Jan 27, 2020, 1:15:26 PM1/27/20
to Blockly

Anthony, your “Math Blocks”work is great. 

I think today, with the new rendering engine, it can become much more compelling.

I have been experimenting with various math notation and I  also built some prototypes.

My proposal: Why don't we use the new rendering so that blocks seamlessly disappear and the notation magically becomes classic?


 


Math blockly

Blokly visualization

Standard visualization


Gradually changing from standard notation to Block notation




Romualdo
Math and Physics teacher from Italy

Reply all
Reply to author
Forward
0 new messages