Not logged in. · Lost password · Register

jfschaefer
Member for 2 months
29 posts
Subject: Assignment 3 (GLF Intro)
Dear all,

I've created the third homework assignment. You can find it at https://kwarc.info/teaching/LBS/assignment.pdf.
This requires that you set up GLF in some form. I'll try to provide all the instructions you need in this post.
As always: If you have any technical difficulties, feel free to ask here. We can also try to resolve problems on Wednesday.

Prerequisites

  • I assume you have a recent version of Python installed (I think version 3.6 or newer should work)
  • It would be good if you have git installed (that is essentially a requirement for MMT anyway)

You need to have MMT installed. Instructions are here: https://uniformal.github.io//doc/setup/
However, we need some feature that have not been released yet. So instead, you should try to use the following file: https://kwarc.info/teaching/LBS/resources/mmt.jar
If you have installed MMT already, it should suffice to replace the file at MMT/deploy and run java -jar mmt.jar :setup.

You need to clone the LBS repository into the right place.
The easy way: run java -jar mmt.jar lmh install Teaching/lbs1920

If that doesn't work: Follow the instructions in footnote 1.

Option 1: Use Jupyter Notebooks
You need to install the GLF Jupyter kernel for this. Since it still under development, you can't just install it from pip.

Step 1:
Clone the GLF Kernel repository and pick the right branch:
git clone https://github.com/kaiamann/glf_kernel
git checkout -b lbs

Step 2:
In the file glf_kernel/MMTInterface.py change the value of MMT_LOCATION to point to the MMT folder that was created during the installation.
That folder should contain among other things a deploy folder.

Step 3:
Install the kernel (which should also install Jupyter). Run the following commands from the cloned repository:
sudo python3 -m pip install .
python3 -m glf_kernel.install

Now you should be able to start the notebooks with jupyter notebook.

Option 2: Don't use Jupyter
In this case you can edit the GF files in any editor you want (but keep them in the place they are!) and test them with the normal GF command line.
Similarly, you can edit the assignment3.mmt file with jedit/IntelliJ.

In order to connect the two, you can use the attached Python script.
Before running the script, you will have to adjust the values of LOCATION_MMT_JAR, GF_BIN and GF_CONCRETE_FILE.
The remaining variables should already be set to the right values.

Running the script will import the GF grammars into MMT. So when you are done with the GF part, you should run it once so that MMT can properly typecheck your semantics construction view.
When you are done with everything, you can run the script to enter sentence and check the result.



Good luck and see you on Wednesday, :)
Frederik


Footnote 1: Cloning the LBS repository manually

When you installed MMT, a folder called "MMT-Content" or maybe "MathHub" or maybe something else was created. It should contain a folder "MMT" with subfolders like "examples" or "urtheories".
In this "MMT-Content" folder you should create a new folder called "Teaching".
And into this "teaching" folder you should clone the repository https://gl.mathhub.info/Teaching/lbs1920.
Afterwards you should have a folder "MMT-Content/Teaching/lbs1920". The exact spelling of "Teaching/lbs1920" is important!
The author has attached one file to this post:
SimpleGlf.py | Save   4.2 kBytes, downloaded 11 times
jfschaefer
Member for 2 months
29 posts
One more comment for Windows users (from Max):
For using Jupyter on Windows, apparently this issue is relevant: https://stackoverflow.com/questions/58422817/jupyter-noteb…

And one more think (especially when using the Linux subsystem):
The GLF kernel requires at least Python version 3.6, otherwise you will get errors when running python3 -m glf_kernel.install
Today we had issues, because the Ubuntu subsystem apparently had nothing newer than 3.5.

Best,
Frederik
algocrack
Member since Oct 2015
15 posts
Hi,

Just want to add: For those using Jupyter Notebook to do the assignment (probably in the future semesters), you might also need to set the variable **self.archive**

i set mine to self.archive = 'MMT/urtheories/' before it worked.

Cheers.
algocrack
Member since Oct 2015
15 posts
Subject: I get this error on my terminal when running the Assignment 3 notebook. But it seems to be unrelated to the problem I had.
hello,

generally when running Jupyter Notebooks, the [*] on the left of the cell indicates that the operation is still running.
But sometimes, for GF, the [*] can be shown even when the cell is completely executed. And so, the error below was shown when the cell was executed and I thought it was related to the never ending [*]. But I just realized that the cell was done executing anyway.

Bottom line is (FYI) if there is a cell for GF showing the [*] on the left, maybe and just maybe the cell is already done running.
Don't wait like I did for it to "terminate" because it probably already has.

Cheers.

[IPKernelApp] ERROR | Exception in message handler:
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/ipykernel/kernelbase.py", line 268, in dispatch_shell
    yield gen.maybe_future(handler(stream, idents, msg))
  File "/usr/local/lib/python3.7/site-packages/tornado/gen.py", line 735, in run
    value = future.result()
  File "/usr/local/lib/python3.7/site-packages/tornado/gen.py", line 209, in wrapper
    yielded = next(result)
  File "/usr/local/lib/python3.7/site-packages/ipykernel/kernelbase.py", line 541, in execute_request
    user_expressions, allow_stdin,
  File "/Users/zzpp/PycharmProjects/glf_kernel/glf_kernel/kernel.py", line 112, in do_execute
    messages = self.GFRepl.handle_input(code)
  File "/Users/zzpp/PycharmProjects/glf_kernel/glf_kernel/GLFRepl.py", line 103, in handle_input
    message=self.handle_grammar(code, parse_dict['name'])))
  File "/Users/zzpp/PycharmProjects/glf_kernel/glf_kernel/GLFRepl.py", line 273, in handle_grammar
    build_result = self.mmtInterface.build_file(file_name) # build the Grammar with the GlfBuild extension
  File "/Users/zzpp/PycharmProjects/glf_kernel/glf_kernel/MMTInterface.py", line 145, in build_file
    return resp.json()
  File "/usr/local/lib/python3.7/site-packages/requests/models.py", line 897, in json
    return complexjson.loads(self.text, **kwargs)
  File "/usr/local/Cellar/python/3.7.4_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/__init__.py", line 348, in loads
    return _default_decoder.decode(s)
  File "/usr/local/Cellar/python/3.7.4_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/local/Cellar/python/3.7.4_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
This post was edited on 2019-12-06, 22:57 by algocrack.
leonopulos
Member since Jan 2017
6 posts
Hey,

I just realized thaz I posted this question in the wrong thread initially.

The construct and show commands don't seem to be working for me. I simply get a "command not found" error.
I installed via the official installation guide and am using GLF through jupyter notebooks. Any idea on throubleshooting?
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters:
Go to forum
Datenschutz | Kontakt
Powered by the Unclassified NewsBoard software, 20150713-dev, © 2003-2011 by Yves Goergen