Hi all,
I am developing a web-based proof assistant and would like to share current results. The proof assistant is written in ReScript programming language and React UI library. It runs completely in the browser. It uses the same approach for building proofs as mmj2 (but at the moment it doesn’t have all the features mmj2 has). I recorded a video (without verbal explanations) similar to one of the mmj2 tutorial videos in order to demonstrate its features. Any feedback is appreciated.
The demo video (if it is not opening, try to download; and sorry for low quality of the video):
https://drive.google.com/file/d/1JCDffUXkb_J-TiA07aNwK9SBKyaukaA3/view?usp=share_link
The proof assistant:
https://igorocky.github.io/mm-proof-assistant/demo/v1/index.html
The source code is stored in two repositories. And there is mess with it. I started writing it inside of another project, put some logic into a second repo. Because of that it is not easy to run it locally. But I am going to improve this soon.
The source code:
https://github.com/Igorocky/learn-js-react-app/tree/master/src/metamath
https://github.com/Igorocky/js-common-functions/tree/master/src/main
Best regards,
Igor
I am developing a web-based proof assistant and would like to share current results. The proof assistant is written in ReScript programming language and React UI library. It runs completely in the browser. It uses the same approach for building proofs as mmj2 (but at the moment it doesn’t have all the features mmj2 has). I recorded a video (without verbal explanations) similar to one of the mmj2 tutorial videos in order to demonstrate its features. Any feedback is appreciated.
--
You received this message because you are subscribed to the Google Groups "Metamath" group.
To unsubscribe from this group and stop receiving emails from it, send an email to metamath+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/metamath/8c4a0c96-7815-497d-aca0-a1d4ae321eb9n%40googlegroups.com.
Thanks Antony and David for your feedback!
"Who's it targeted at?"
At the moment I don’t have any particular long term plans for this project. I started it just out of curiosity, Metamath seemed very simple and I wanted to try to automate proofs. When I realized that I cannot achieve desired level of automation, I started watching what existing solutions can do. I liked how mmj2 works because it is also seemed simple but very practical. So I decided to check if I can do something similar. When I was able to repeat the proof from the mmj2 tutorial I wrote this post. Now I am planning to work on two more major features - proving in bottom-up direction and proof explorer, some small UI improvements and writing more tests (the code is tough, I already found few bugs). When I complete these goals, probably, I will use this assistant to learn to create Metamath proofs myself. Editing code in a dedicated code editor is much more comfortable but it is difficult to implement, so I didn’t even choose between what kind of UI to implement. Simple HTML UI was the only option for me.
"it might be good to provide a README.md (and a repository with a sensible name)"
I moved the code to a new repository and provided a README file with instructions. Please let me know if there are any issues with running the project locally.
The new repo - https://github.com/expln/metamath-proof-assistant
This project depends on @expln/utils npm module. This is my project too ( https://github.com/expln/rescript-utils ) But this is not a usual library. This is just a set of useful functions which I collected in one place to reuse across my other projects. And version N+1 may be absolutely not compatible with version N :)
"I'd like to see some reusable packages make their way into the npm repository so that this isn't such a huge mountain to climb."
That’s a good idea. As for now I think it makes sense for me to implement remaining features and when the code (underlying data structures) become more stable, I will be able to create some API and publish it as an npm package. I also feel like I need to warn regarding the algorithm I use for unification. I read in the mmj2 documentation that mmj2 first creates syntax trees of expressions and then compares them to find possible substitutions (please correct me if I am wrong). As I understand this approach guaranties quick response for any expressions. But what I implemented is comparing two arrays of integers with some performance improvements (counting parentheses is one of them). And there is no guarantee that this algorithm will work fast for any expressions. So it may turn out that using my future library is not such a good decision :)
"I notice that you don't have a license included - please add one!"
I added MIT license. Thanks for pointing out to this!
Best regards,
Igor
Best regards,
Igor
Best regards,
Igor
Hi Igor and all,
This looks very promising!
What I implemented is comparing two arrays of integers with some performance improvements (counting parentheses is one of them). And there is no guarantee that this algorithm will work fast for any expressions.I think this is exactly the way the Metamath C program is working, including using parentheses for performance improvement.
The resulting speed seems to be good enough!
Overall I was not active in Metamath during the second half of 2022, for personal reasons. I hope I can be a more active member of the community in the coming months!
Anyway I've been reading what's going on and I see many initiatives going on around tooling; I think this is exactly what we need!
Best Regards, and all my wishes for 2023 to all Metamath
enthusiasts!
_
Thierry
--
You received this message because you are subscribed to the Google Groups "Metamath" group.
To unsubscribe from this group and stop receiving emails from it, send an email to metamath+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/metamath/9aac3fc2-ea01-4bce-afab-7f08aa99be8en%40googlegroups.com.
>>> I think this is exactly the way the Metamath C program is working, including using parentheses for performance improvement.
Thank you Thierry. It is difficult for me to understand from the code if it works the same way, but I see it also intensively uses arrays.
>>> I've added an entry that links to your new tool from our list of "other tools" for Metamath
Thank you David!
>>> I suggest adding tooltips to every icon
It is already implemented. The software I used to record the video didn’t capture tooltips. But they are present on all icons and other ui elements (like texts and text fields to show what hot keys may be used). If it is not working in your browser, could you please write what browser you use and its version?
>>> Currently it uses "class1" etc. as a working variable, but these are easily confused with specific names. I suggest using mmj2's convention that &C1 is a working variable. Those are easier to distinguish, and it'd look more like mmj2 as well.
Yes, I am going to implement this.
>>> mmj2 does have mechanisms to prove specific patterns, but those are written in JavaScript and might be easily to copy over to a tool already written in JavaScript.
My tool is actually written in ReScript (which gets compiled to JavaScript). But anyway I don’t think I could easily copy-paste the code even if the tool was written in JavaScript, because most probably we use different data structures and different algorithms. However, the idea of mechanisms to prove specific patterns is interesting to me. I had an idea to add numerous tactics to automate common proof steps, but I need to gain more experience in creating proofs to understand what common patterns exist. And if there are already some mechanisms, I would like to take a look. Could you send a link to the code in mmj2 sources, or documentation, or just write what is the core idea (whatever is easier)?
>>> mmj2's ability to check definitions is awesome, but probably not critical for a proof assistant.
I’ll remember that there is such area like definitions check and will return to it when I am done with the most important features. However, if you have on hand some links with description of what this is, then could you please send it as well, I will take a look.
>>> I hope you'll be willing to continue work on it, it looks promising.
Thank you!
Best regards,
Igor
Hi Igor,
Ok, let me give you here some quick and random feedback:
Your examples works, but in many cases I do not manage to replace
metavariables. For example in "spcgv", when I want to replace
"setvar1" by e.g. "x", or in "brab2a" when I want to replace
"class1" by anything.
Every time I get a message "No substitution can be extracted from
the provided expressions." How can I deal with that?
It's possible to edit a step's formula using ALT-left click, why
not a simple click? (that's why I naturally tried first, then I
saw the tooltip...)
If when creating a new step I change my mind, it seems there is no way out of actually creating the step and then deleting it. I end up writing some dummy, and then deleting the step. It would be nice if e.g. just ESC would get you out of the step edition mode.
When "Justification cannot be determined automatically", it would
be nice to find out what fails: was an unification found, but
distinct variables conditions were missing, or was a unification
found, but no matching for (such and such) hypothesis, etc...
Of course more automation would be nice...
Hi Thierry,
>>> It's possible to edit a step's formula using ALT-left click, why not a simple click? (that's why I naturally tried first, then I saw the tooltip...)
I reserved a simple click for future - I am planning to implement a feature when a simple click on any symbol will highlight the smallest syntax subtree the symbol is included into. I hope this feature will simplify exploring long statements and also it should make it easier to copy subexpressions.
>>> If when creating a new step I change my mind, it seems there is no way out of actually creating the step and then deleting it. I end up writing some dummy, and then deleting the step. It would be nice if e.g. just ESC would get you out of the step edition mode.
That’s right, currently a user is forced to type at least one dummy symbol in that situation. I was trying to implement the editor in the most simple way for me for not to spent a lot of time on ui development when some core features are not ready. Unfortunately, this simple use case is not so simple to fix. But I will definitely fix it in the future.
>>> When "Justification cannot be determined automatically", it would be nice to find out what fails: was an unification found, but distinct variables conditions were missing, or was a unification found, but no matching for (such and such) hypothesis, etc…
Yeah, I also though about that. Unfortunately I don’t see any simple fix for this at the moment. Moreover the unification algorithm is still under development and I am actively modifying it now when developing bottom-up proofs. But for sure I will try to improve this in the future. BTW, what is current behavior of mmj2 in a similar situation?
Thanks Thierry for your feedback!
And next follows the most difficult part of my response (at least for me) :)
>>> Your examples works, but in many cases I do not manage to replace metavariables. For example in "spcgv", when I want to replace "setvar1" by e.g. "x", or in "brab2a" when I want to replace "class1" by anything.
If I am getting you correctly, you started with an empty page, read all the set.mm, added “spcgv” by searching it by label. As a result you’ve got the state as follows:
Variables:
var1 setvar setvar1
var2 class class2
var3 wff wff3
var4 wff wff4
var5 class class5
Disjoints:
setvar1,wff4,class2
stmt1-spcgv.11: |- ( setvar1 = class2 -> ( wff3 <-> wff4 ) )
stmt1:|- ( class2 e. class5 -> ( A. setvar1 wff3 -> wff4 ) )
Then you tried to replace setvar1 with x and you’ve got “No substitution can be extracted from the provided expressions.”
In that case it behaves exactly as I programmed it, though I am not sure if this is correct as for a proof assistant. And I need your and others experienced metamath developers help to verify this. This case doesn’t work because of disjoints. The Metamath book explains how to check disjoints when we are verifying a proof, but I have not found any explanation of how to check disjoints in a proof assistant (or maybe I have not read till that place in the book or skipped it unintentionally :) ) So I came up with the following rules myself. When you provide “Replace what” = [some sequence of active symbols] and “Replace with” = [another sequence of active symbols], the program searches for all possible substitutions by means of which we can get from [some sequence of active symbols] to [another sequence of active symbols]. In your example there is only one possible substitution setvar1 -> [x]. Then the program adds all other active variables to this substitution replacing them by themselves. So as a result we have such substitution:
setvar1 -> [x]
x -> [x]
ph -> [ph]
class2 -> [class2]
… and so on for all other variables defined in set.mm and all the work variables.
I introduced this by analogy of applying substitutions during proof verification, when we have to apply a substitution simultaneously for all the variables in the assertion used in the proof step.
Next the program checks disjoints for this substitution. setvar1 results in [x] (an expression consisting of only one symbol) and class2 results in [class2] (also an expression consisting of only one symbol). Then similarly to the checks in proofs:
“the two expressions must have no variables in common”: [x] and [class2] have no common variables - this is passed.
“each possible pair of variables, one from each expression, must exist in an active $d statement …”, i.e. x and class2 must be in a disjoin group - this fails. So the entire substitution is considered invalid and the programs shows “No substitution can be extracted from the provided expressions.”
This is possible to fix by adding a disjoint “x,wff4,class2”, so you’ll end up with two disjoints:
Disjoints:
setvar1,wff4,class2
x,wff4,class2
Then the replacement should work.
Please let me know if this is what is expected from a proof assistant. If this is correct behavior, then I will consider adding some messages to the ui explaining why no substitution can be found or even adding missing disjoints automatically.
Best regards,
Igor
Hi Igor,
Thanks for all answers, and especially the change for the single click!
I understand very well not everything is simple, and you have to move on step by step.
Concerning the substitution function: thanks to your explanations, I could make it work in cases which previously blocked!
I think here I would make a difference between the UI substitution function, which is here to help the user, and the substitutions checked when applying theorems.
The later requires to follow distinct variables requirement, and it's very nice that your proof assistants follows with that along the way (that is a weak point of MMJ2 in my opinion, as it seems to only worry about disjoint variables after the whole proof is complete, and sometimes miss some).
However It looks like for the former, in the example we use, an additional burden is placed on the user to manually add new DV for UI substitutions. Actually, I think ideally the UI would instead help the user and automatically turn the DV restriction from "setvar1,wff4,class2" into "x,wff4,class2". Indeed the first one disappears (since setvar1 gets replaced), and the second one is the same DV where "setvar1" has been substituted by "x".
Of course it's not just simple substitutions, if a more complex substitution is done, the UI would have to all all variables to the new DV restrictions... so it's probably easier said than done - but that would be another great feature.
Keep it up!
_
Thierry
Hi Thierry,
And next follows the most difficult part of my response (at least for me) :)
To view this discussion on the web visit https://groups.google.com/d/msgid/metamath/e4e7deb6-06e7-41a3-88a4-a2adcdf1293en%40googlegroups.com.
Ok, one more quick remark (now that I know how to use substitutions!):
Currently, the tool blocks if two steps are the same. One has to
manually remove the step, and update any justification using that
step.
MMJ2 automatically merged them, IIRC. It would be very nice to
have the same mechanism (automatically updating corresponding
justifications too, of course!)
To view this discussion on the web visit https://groups.google.com/d/msgid/metamath/2961bd35-1f93-8cce-feb2-760ace5ae4db%40gmx.net.
>One broad suggestion: Could you give it a short & less generic name,
>since there are other Metamath proof assistants?
That’s done! The new name is metamath-lamp “Lite Assistant for Metamath Proofs”.
I renamed the repository accordingly:
https://github.com/expln/metamath-lamp
I guess I need to create a pull request to make corresponding changes on https://us.metamath.org/other.html ? I will try after sending this email.
> You might want to include, on the screen or an "about" option, a link to the
> GitHub repo for the code (so people can review/contribute). I understand that is currently:
> https://github.com/expln/metamath-proof-assistant (MIT license).
Good point. I will add such a link. Yes, MIT license, but the new URL is https://github.com/expln/metamath-lamp
> But I think trying to answer "why can't I automate this in general" is best delayed for a long time.
I thought on this, and finally concluded that this is not even a “nice to have” but this is “must have” feature. The reasoning is as follows. Users will ask me “why this doesn’t unify” or “why this cannot be proved automatically”. Currently the only solution is to reproduce the case locally and debug. But this is too hard because I debug by small steps and I don’t see a bigger picture. Thus I conclude that I need some kind of log of main events to understand faster what’s going on. So I feel like I cannot delay development of this feature.
> You could easily combine 2 & 3. Just create a first tactic called "auto" or similar that tries to apply a few simple rules to automatically prove a few simple/common cases.
I don’t have enough experience to figure out what are the common cases. I need to spend some time practicing in creating proofs first. And this is related to the tutorial topic (please see my response on tutorial topic below).
> mmj2 has a few simple heuristics that it applies automatically its default configuration.
> You could make them either fully automatic or the basis for an "auto" tactic. Code here
>(I think Mario wrote more or all of this):
>> https://github.com/digama0/mmj2/blob/master/mmj2jar/macros/transformations.js
Thanks for the reference. I will check and return back to you and Mario with questions when I will be closer to writing heuristics.
> Even a few small automations could make a big improvement in usability.
If anyone sees such small automations please let me know. I have experience in writing code which manipulates metamath statements, but this adds almost nothing to my ability to create actual proofs, so such kind of small improvements are not visible to me at the moment.
> > b) highlighting syntax subtrees by clicking them
> To simplify replacing them, I guess?
Yes, but not only. This should also make easier to copy subexpressions. Currently unexperienced users like me have to count parentheses which is too tedious.
> I would instead prefer an optional simple column, to the left of the statement proved, showing JUSTIFICATION_NAME LIST_OF_REFERRED_STATEMENTS (similar to how mmj2 works now).
That’s doable. I will add this to my todo list and implement in some time.
> You might want to walk through the mmj2 tutorial to see what ideas are
> worth stealing. I recorded it on Youtube here:
> https://www.youtube.com/watch?v=87mnU1ckbI0
> The text is here:
> https://github.com/digama0/mmj2/tree/master/mmj2jar/PATutorial
Yeah, I watched it few times and will watch one more time with pleasure. Moreover, I have now more understanding of the processes under the hood, so I am able to catch more details. (When I watched it for the first time few years ago it was like magic to me :) )
> Once you're further along, I'd be happy to work with you to create a tutorial
> if you'd like. I'd probably want to build on the same examples from the mmj2 tutorial.
Of course! This is a great opportunity for me to get more experience in creating proofs and simultaneously help other metamath newcomers to get acquainted with it. If you can provide those mmp files from us.metamath.org, and additionally some json file which will work as a table of content for the tutorial, then I will parse them and represent in my app. Such an interactive tutorial could be a good starting point for beginners. So, once you think my app is ready to become a tutorial for Metamath we may start a separate email thread and discuss details of implementation of such tutorial. Currently I think the tool requires more testing, because I implemented some algorithms by intuition and I have not analyzed everything with mathematical rigor.
> Nevermind, I see you can already rename statements
In the previous versions it was not “true” renaming. Justifications were not updated. But in the v6 renaming of statements updates justifications.
> below I tell what I've come up with, in yamma.
Thanks, Glauco, for the ideas. I checked your test cases and I see similar validations may be implemented in metamath-lamp too.
> 'Working Var unification error: the working var &W2 should be replaced with the following subformula, containing itself ( &W2 -> ph )'
Could you please explain why a working var cannot be replaced by a subformula containing itself? It is possible in mm-lamp and I don’t see any reason why it should not be possible.
> Hope this can give you some ideas.
Definitely! Thank you, Glauco!
I implemented few new features and moved my tool to a new URL - https://expln.github.io/lamp/latest/index.html
1) Exit edit mode on ESC, save changes on Enter on all text fields in the editor. (To start a new line in a multiline text editor press Shift+Enter, this is not mentioned on tooltips, but I will add it in the next versions )
2) Shorter names for statements and “true” renaming of statements when justifications are also updated with the new statement label.
3) In substitution dialog, now it is possible to see hints why some substitutions are invalid.
4) A new parameter in bottom-up proofs - “Derive from root statements”. It was present in v5 and it was always “true”. But it significantly decreases performance and I expect it to be not necessary in many cases. So I added it to the bottom-up dialog and set its default value to false. Users will be able to decide if they want to use it or not. I understand that I have to provide here more details on how bottom-up exactly works in mm-lamp and in particular what the new parameter does. But unfortunately I don’t have time right now. I will write this a bit later.
The demo video below demonstrates #3 feature and the use case when #4 feature could be useful.
https://drive.google.com/file/d/1nIigII46Z8l1xk9VRWlPT9_N-VcNTh2R/view?usp=sharing
Current latest version is https://expln.github.io/lamp/v6/index.html
-
Igor
Hi all,
I have implemented a few new features in the version 9 of mm-lamp https://expln.github.io/lamp/v9/index.html :
Reading the set.mm file from us.metamath.org.
Possibility to share editor state via URL and JSON.
Possibility to add a description with basic formatting.
Showing a proof table for the proof being exported.
Here is a short demo (without sound) https://drive.google.com/file/d/1sM19TfF-7nRfhnnsKA_i_1I0H18mUyX5/view
A few comments on the new features:
Reading the set.mm file from us.metamath.org. This is configurable, other URLs may be added on the settings tab. When an editor state is exported, if all the loaded mm files are loaded from the Web then they will be automatically reloaded when this state gets imported. For each URL a user is asked if they want to load data from that URL. The user has the possibility to mark some URLs as “trusted” then data will be loaded from such URLs without asking. This is also configurable on the settings tab.
Possibility to share editor state via URL and JSON. Such URLs contain a Base64 encoded editor state. It may be decoded with many online Base64 decoders if for some reason a URL is not opened by mm-lamp but it is needed to see its content. GitHub IO limits URL length so that only about 5K characters in the editor state may be shared via URLs without problems. Exporting/Importing to/from json doesn’t have this limitation.
Possibility to add a description with basic formatting. Initially I planned to use some existing advanced component which is capable of rendering markdown. But then I realized that I don’t control what is injected into the page which makes XSS attacks possible. So I ended up implementing my own markup language which produces simple html without the risk of XSS attacks (at least I think so, if anyone finds such a possibility, please let me know). As a downside, formatting is very basic. But I can add new formatting features if needed.
And one more note. The previous version of /latest/index.html page truncated a query string when redirecting to the actual latest version page. That made redirection with the editor state in the URL impossible. I updated that page (added a programmatic redirection). But a browser may cache the old version. So, if opening a URL with an encoded editor state doesn’t load that state, probably clearing of the cache will help.
This is the link from the demo - proof
-
Igor
mm-lamp v10 is released with few new features:
Autocompletion for parentheses - when you type an opening parenthesis followed by a space then the closing parenthesis is added automatically and the cursor is placed in between those parentheses.
Syntax validation and “syntax aware” selection.
Graphical visualization of justifications.
The below demo almost repeats the proof from the v1 demo but using the new features this time:
https://drive.google.com/file/d/1IwdHLpQreZ_1CJFZJmptRJc2unO8aNh4/view?usp=sharing
Best regards,
Igor
--
You received this message because you are subscribed to the Google Groups "Metamath" group.
To unsubscribe from this group and stop receiving emails from it, send an email to metamath+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/metamath/4c913c14-d74b-4457-a6af-f6fd5dcc5e13n%40googlegroups.com.