Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 31: Added SPOT 2.X wrapper #82

Merged
merged 25 commits into from
Mar 8, 2022

Conversation

cjbanks
Copy link

@cjbanks cjbanks commented Jan 17, 2022

#31

Hi, I've managed to create the wrapper for SPOT 2.X in order to enhance compatibility with Texada. Could you take a look and let me know if you have any questions/comments? I also ran ./texadatest with the following output:

[----------] Global test environment tear-down
[==========] 63 tests from 13 test suites ran. (6218 ms total)
[ PASSED ] 61 tests.
[ FAILED ] 2 tests, listed below:
[ FAILED ] AtomicPropositionSubbingClonerTest.SimpleTest
[ FAILED ] AtomicPropositionSubbingClonerTest.SimpleConstantEventTest

2 FAILED TESTS
YOU HAVE 2 DISABLED TESTS

If you have any suggestions on how to pass these last two tests that would be very helpful. Thanks!

Mapping files have updated the previous class/function calls
to reside in texada namespace instead of spot since these calls
may be defunct in SPOT 2.X
Cannot use SPOT namespace with current object calls so we use the
texada namespace and use the mappings created for Texada
@cjbanks cjbanks changed the title Issue 31: Added SPOT 2.X wrapper Issue 31: Added SPOT 2.X wrapper #31 Jan 17, 2022
@cjbanks cjbanks changed the title Issue 31: Added SPOT 2.X wrapper #31 Issue 31: Added SPOT 2.X wrapper Jan 17, 2022
@cjbanks cjbanks marked this pull request as ready for review January 17, 2022 21:29
@carolemieux
Copy link
Contributor

Wow, thank you so much for the contribution! Let me have a look at the changes and in particular the failing tests --- I should be able to get to this sometime next week.

@@ -980,6 +980,8 @@ map<int, statistic> prefix_tree_checker::not_map(map<int, statistic> map) {
*/
void prefix_tree_checker::add_satisfying_values(map<int, statistic>& returned_vals,
bool to_satisfy, map<int, statistic>& map_to_return, set<int>& to_check) {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can remove this extra whitespace.

@@ -336,9 +338,9 @@ int main(int ac, char* av[]) {
outFile << ", ";
print_json(outFile, *it, opts_map.count("print-stats"));
} else {
const spot::ltl::formula * valid_form = texada::instantiate(
const ltl::formula * valid_form = texada::instantiate(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're using namespace texada, why do we need texada::instantiate rather than just instantiate?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is true, we can use just instantiate.

@@ -68,15 +67,15 @@ TEST(ConstInstantsPoolTest,UsableByLinearChecker) {
ASSERT_EQ(l_valid_instants.at(0).first.at("a"), "a");
ASSERT_EQ(l_valid_instants.at(0).first.at("c"), "c");

f->destroy();
//f->destroy();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is f->destroy removed in this test?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SPOT 2.X does not use the destroy function externally like this anymore, a lot of the destruction of formula classes is done internally. In this test, the instantiated_prop_type used in 'valid_instants_on_traces' instantiated the formula by recusing on the formula. In this case, when creating the visitor this is just returning the pointer to the formula so when destroy is called in the function it is also destroying the original formula.

@@ -9,8 +9,7 @@
#include "../src/main/opts.h"
#include "../src/checkers/statistic.h"
#include <gtest/gtest.h>
#include <ltlvisit/tostring.hh>
#include <ltlparse/public.hh>
#include "../src/instantiation-tools/texadatospotmapping.h"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this import necessary? It doesn't look like this is used anywhere.

@carolemieux
Copy link
Contributor

(left a few minor comments above, hoping to tackle the core of the review tomorrow)

@carolemieux
Copy link
Contributor

Thanks again for the contribution :). I looked at the overall changes. The PR works great overall, I got everything running against the latest version of SPOT! Two main things remain:

  • The failing test case is due to the use of the str_spin_ltl function (https://spot.lrde.epita.fr/doxygen/group__tl__io.html), which prints formulas in SPIN format rather than in SPOT's native format (so [] instead of G, <> instead of F, and V instead of R, I believe). I did try some of the other print functions, but found none that print in SPOT's native format. For backwards compatibility, it would be better to find a printing function that prints in SPOT's native format, or write one custom.
  • The PR includes some code copied directly from SPOT, which poses a bit of a licensing issue, since SPOT is GPL 3.0 (requires all projects that integrate code from SPOT/include SPOT as a linked library to be GPL 3.0) as well, essentially preventing commercial use of Texada. Some of these code similarities are probably inevitable (e.g. the visitor pattern), but there is other copied code that I think brings in unneccessary complexity into the code base (e.g., the texadatospotformula includes some elements of SPOT formulas which I don't think Texada needs?)

This leaves us with 2 options:

  1. We iterate on this PR to fix the tests remove the copied code from SPOT.
  2. We integrate your changes into a SPOT 2.X support branch. We can change the test cases to show the new print behavior there. Later contributors can help us strip the copied SPOT code to integrate the support into main. Like this anyone who doesn't want a GPL 3.0 license/SPOT 2.X support can still use the main branch.

What do you think?

If 2., I will open a new SPOT 2.X support branch, and you can create a PR that targets that branch. I can help fix some of the formatting issues there.

@cjbanks
Copy link
Author

cjbanks commented Feb 4, 2022

I am happy with option 2 both for myself and users who do not plan to use Texada for commercial use. I think it is good to think about for future contributions.

If it were possible to iterate on the wrapper by moving the copied code to make an independent library and then have Texada depend on it seperately would this address the licencing issue? This would effectively have Texada depend on both SPOT and this "SPOT adjacent" library. I am not sure how easy it is to do though..

@carolemieux carolemieux changed the base branch from master to spot-2.x February 17, 2022 20:52
@carolemieux
Copy link
Contributor

carolemieux commented Feb 17, 2022

Sorry I'm being so slow on this!

So, I just made a new spot-2.x support branch. I think a few changes are needed before merging there:

  1. update the tests so they pass
  2. move all the formula stuff to a formula subdir in the source rather than in instantiation-tools
  3. update the README.md and LICENSE doc accordingly.

I've done most of 2. and just need to check that everything builds, but if I'm taking too long just ping me here. After all that is done merge and close the PR, and I'll update the main README.md to point to this branch.

I don't think we should make another independent library that Texada depends on at this point. First I want to see how much of the copied code can be removed. I think we might be able to get rid of most of it:

  • for example, texada::formula right now supports all the operators that SPOT supports, but the texada checker does not really support those (bunop, for instance). So we could restructure texada::formula accordingly
  • we can also get rid of all the properties in texada::formula that are copied over from spot but we don't need (i.e. the ltl_prop stuff on line 67 of texadatospotformula.h, and all the comparison operators for formulas; do we need that lying around? On a quick check I don't think texada uses these)
  • I'm also not sure how much of the refformula stuff we need---really the clean thing would be to upgrade to smart pointers, (or just pass all the formula arguments as references?) and this should remove the need for reference counting at all.
  • Ideally from a software engineering perspective I'd like to decouple the spot formula from the texada formula, so that texada::formula doesn't carry around its own spot formula. It seems like the main place where we really need the spot formula is in the call to negative_normal_form, and the parsing/printing? Perhaps we would take a performance hit by not carrying around the spot formula, but I am not sure.

I think other than that, the primary borrowings from spot are the visitor pattern --- like the postfix visitor and clone visitor, correct? Code similarity is I think inevitable for such a standard pattern, and I think we should be able to simplify things to not need both the clone visitor and postfix visitor --- at that point the code will probably be fresh enough to not have these duplications issues. Is there anything else major I'm missing?

If you want to tackle some of these things, we can iterate on it (and I'll make the thoughts I outlined above more precise), but I figure we might as well incorporate your contribution now so that other users can take advantage of it. The refformula/ memory management stuff in particular seems like it could get hairy. What do you think?

@carolemieux carolemieux merged commit 37a7356 into ModelInference:spot-2.x Mar 8, 2022
@carolemieux
Copy link
Contributor

Merged, thanks again for all the hard work adding this support :)

@cjbanks
Copy link
Author

cjbanks commented Mar 9, 2022

Thank you for the quick responses! Sorry I've been so behind on catching up to these messages..I'm glad the additions I made were useful. If I have time in a month or so I'd be happy to put a little more effort into addressing the main branch licencing issues. Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants