The GF Mathematical Grammar Library

Olga Caprotti
Jordi Saludes

OpenMath workshop 2012, Bremen, July 2012

How it started?

The Grammatical Framework: GF

GF logo

GF logo

The Mathematics Grammar Library

The Mathematics Grammar Library

mgl structure

mgl structure

Other upper layers

Operations

Simple drills.

Commands

Queries/Answers to/from a CAS.

WordProblems

Modeling and solving simple word problems.

Some examples

    abs : ValNum -> ValNum ;            -- the absolute value of z
    times : [ValNum] -> ValNum ;        -- the product of x, y and z
    unary_minus : ValNum -> ValNum ;    -- minus x
  Compute  :  (k: Kind) -> Value k -> Command ;          
  Assign   :   (k: Kind) -> Variable k -> Value k -> Command ; 
  Assert   : Prop -> Command ;
  Approximate  : ValNum -> Command ; 
  BeginBlock  : String -> Command ;
  EndBlock    : String -> Command ; 

Abstract/Concrete types

A simple example

    abs : ValNum -> ValNum
    abs : NP -> NP

Concrete differences

  value_N : N       = mkN "value"  ;
  absolute_A : A    = mkA "absolute"  ;                       -- In LexiconEng
  abs_value_CN : CN = mkCN absolute_A value_N ;              -- In LexiconX
  
  mkNP the_Art (mkCN abs_value_CN (mkAdv possess_Prep obj)) ; -- In Arith1I
  1. In English: Combine the adjective "absolute" with the noun "value" to get a common noun (CN)
  1. Combine this with the argument (NP) using the "of" preposition. It gives a CN;
  1. Combine this with a determiner ("the") to give an NP.

In German:

  absolute_A : A    = mkA "absolut"  ;
  value_N : N       = mkN "Wert" "Werte" masculine  ;         -- In LexiconGer
  abs_value_CN : CN = mkCN absolute_A value_N ;              -- In LexiconX
  
  mkNP the_Art (mkCN abs_value_CN (mkAdv possess_Prep obj)) ; -- In Arith1I

Associative operators

    plus : [ValNum] -> ValNum

    plus : ListNP -> NP
DefGenCN sum_CN (mkNP and_Conj terms)
  1. ListNP is basically a list of NP which knows if there is 2 or more elements in it:
    • "the sum of x and y": BaseValNum x y
    • "the sum of x, y and z": ConsValNum x (BaseValNum y z)
  1. We combine ListNP with the "and" conjunction to get a new NP
  1. As in the previous example: combine with "sum", etc.

The case of functions

MathFunc = Kind + Variable + NP

Named function
"the cosine of 3"
Function variable
"f at 3"
General case
"the derivative of the sine at 3"
Lambda abstraction
"x to the cosine of x where x is 3"

The importance of transfers

"Compute the integral of the function mapping x to the square of x from minus infinity to infinity."

Compute Num (fromNum (
  defint_interval (lambda x (power2 (Var2Num x))) nums1_minus_infinity nums1_infinity))

Compute Num (fromNum (
  defint_interval (lambda x (power2 (Var2Num x))) (unary_minus nums1_infinity) nums1_infinity))

Transfers

Concluding remarks