What is DML?

DML is a programming language that has been custom designed for teaching discrete math. It offers several operators and constructs unavailable in typical languages, such as quantification and boolean formula satisfaction checking. While DML's syntax for these new constructs closely matches the notation used in discrete math texts, it aims for syntactic consistency with existing languages (specifically, Python) for the concepts that are already included in these languages. Here are some examples of DML formulas:

The DML language is described in a separate document. This document is only about its installation and use.

Installation

Although students tend to work on several platforms, including MacOS, Windows and Linux, DML runs only on Ubuntu Linux. In order to allow it to be run across all these platforms, DML has been packaged into a Docker container. Docker packages the DML system together with the underlying Linux environment into a self-contained application that you can download and run.

Before using DML, you need to install the DML container. This consists of a few steps.

  1. Create a folder for DML code: Create a folder named dmlhome in your home directory. This is the only folder on your computer that will be shared with the DML container. It provides the sole means for moving files between your laptop and the DML container. Some of the features of DML will not work without this shared folder, so don't skip this step. For more information on how to use this folder to move files between the container and your laptop, see below.
  2. Install Docker: Docker is the application that can "play" docker images. It may already be installed on your system. You can check this by opening a terminal and running the following command:
    docker --version
    Copy

    If you get an error message saying that docker was not found, follow the instructions below to install the Docker engine:
    The Docker installation takes up around 500 MB of disk space.

  3. Download and setup the DML container: The technical term for what you will download is a docker image. DML's docker image is about 400 MBs in size. Roughly 90% of this size comes from having to package the Linux environment, and the rest from the DML system implementation. (DML has been implemented in the C++ programming language, but this should have no impact on your use.) Run the following command on a terminal to check if docker is up and running:
    docker stats
    Copy

    If you get an error message, look at the bottom of this page for solutions. Otherwise, proceed to download DML:
    docker pull miscsb/dml:latest
    Copy

    Next, you need to set up the container so that it is ready for running. You do this with the following command:

    Pay attention to the presence of spaces in these commands. In some instances, there is a space following the two dashes, and in other instances, there isn't. If you mix these up, you will get an error. (You can avoid all this by cut/pasting these commands instead of retyping them.)


  4. Updating the DML container:

    At this point, DML is set up, and you can proceed to the next section to run it. But you should return to this download step periodically in order to ensure that you have the latest version of DML. For this update, run these commands:

    docker stop dml; docker rm dml; docker pull miscsb/dml:latest
    Copy

    Note that if you already have the latest version, docker pull will immediately tell you this, and you won't have to wait for a download. However, if you already went through the first two steps, you will still need to rerun the create command. If you mistakenly run the create command twice without removing the old container, you will get an error. (If you get this error, you can simply proceed to the next step to run DML.)

Running DML

The following command runs the container you just made and connects the terminal to that container.

docker start -i dml
Copy

You will see a prompt that looks like ubuntu@container:~$, where container is a random-looking string of characters. From here, you can run either run DML directly using the command dml, or use a more user-friendly DML shell using the command dmlsh. We recommend dmlsh because it provides helpful editing capabilities, including the ability to When you start DML shell, you will see the following message:

To exit DML, enter "quit" or press Ctrl+D. To exit the container, press Ctrl+D again.

Running DML commands

You can press Tab for a full list of available commands. For additional help on DML, see its documentation. Here, we focus on checking that everything is OK. For this purpose, you can try cut/pasting the examples from the top of this page. Here is how such a session should look like:

dml>  {x for x in 0..100 if x % 2 = 0}
    {0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38,
 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78,
 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100}
    ________________________________________________________________________

dml> valid (x->y) || (y->z) || (z->x)
    true
    ________________________________________________________________________

dml> { x for x in 2..1000 if forall (y in 2..(x-1)) x % y != 0 }
    {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71,
 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157,
 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241,
 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347,
 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439,
 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547,
 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643,
 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751,
 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859,
 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977,
 983, 991, 997}
    ________________________________________________________________________

dml> 

Importing files into the container

DML will access a directory on your system named dmlhome in your home directory. To access the home directory, follow the appropriate instructions for your platform: Note that none of the files on your host platform, with the exception of files in this dmlhome folder, are available to your container. Thus, any sharing of files between the DML container and the host must be explicit: you must explicit action to bring files into or out of the DML container. Note that file syncing is two-way: changes made on the host platform to dmlhome folder are all visible in the /home/ubuntu folder within the container. Similarly, changes made within the container to the folder /home/ubuntu are reflected in the files on the host folder dmlhome. To get a list of files available in the container, you can use the following command:
ubuntu@container:~$ ls
(your list of files appear here...)

Some issues you might into:

  1. docker: Error response from daemon: Conflict. The container name is already in use: This is because you have run docker run ... twice. If you see this error, you can remove the container with the following command:
    docker rm dml
    Copy

    and retry the command.

  2. docker: Cannot connect to the Docker daemon. Is the docker daemon running?: You have to run Docker: Depending on your system setup, you may have to run the docker daemon with admin privileges, e.g., by prefixing the command with sudo on Linux.