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

MapThenSumSet and several theorems for it. #99

Merged
merged 2 commits into from
Feb 21, 2024

Conversation

kape1395
Copy link
Contributor

I introduced MapThenSumSet operator. It was useful for me to define decreasing sequences to prove termination.
Then, I proved several theorems about it. The theorems are not general enough to port them to the Fold operator, but maybe that's still useful.

I have checked the proofs with TLAPS from PR tlaplus/tlapm#93.
The SANY parser says there is an error, but the TLAPS says OK on line 328 in modules/FiniteSetsExt_theorems_proofs.tla. I made a smaller case showing the same error. Documented it in tlaplus/tlapm#119.

@lemmy
Copy link
Member

lemmy commented Feb 10, 2024

LGTM - Anticipating more MapThen... operators, I would perhaps move MapThenSumSet after ReduceSet.

It probably makes sense to add TLAPS to our CI now that we start adding theorems.

@lemmy lemmy added the enhancement New feature or request label Feb 10, 2024
@muenchnerkindl
Copy link
Contributor

Thanks a lot for these theorems. In order to avoid the SANY / TLAPS issue, should we EXTEND Folds for the time being (I presume the other LOCAL INSTANCEs don't cause problems)?

@lemmy
Copy link
Member

lemmy commented Feb 11, 2024

+1 for changing to EXTENDS Folds for the time being, given that Folds has a single, very verbose operator definition (MapThenFoldSet). Please include a comment in the EXTENDS section as a reminder or explanation for our future selves.

@kape1395
Copy link
Contributor Author

It appears that it is not enough to use EXTENDS instead of LOCAL INSTANCE for Folds only. I have to add Functions as well, probably because it has LOCAL INSTANCE of Folds inside.

If I keep LOCAL INSTANCE for Functions, then the proof fails like this:

failed isabelle[auto; time-limit: 30]:
    (false)
failed smt[time-limit: 5]:
    (Trying to Boolify a non Boolean operator.)
failed zenon[time-limit: 10]:
    (timeout)

ASSUME NEW CONSTANT S,
       IsFiniteSet(S) ,
       NEW CONSTANT op(_),
       \A s \in S : op(s) \in Nat ,
       (CHOOSE F :
          F
          = [s \in SUBSET S |->
               IF s = {}
                 THEN 0
                 ELSE op(CHOOSE e \in s : TRUE)
                      + F[s \ {CHOOSE e \in s : TRUE}]])
       = [s \in SUBSET S |->
            Cardinality(UNION {NatAsSet(n, op(n)) : n \in s})] 
PROVE  (CHOOSE iter :
          iter
          = [s \in SUBSET S |->
               IF s = {}
                 THEN 0
                 ELSE op(CHOOSE x \in s : TRUE)
                      + iter[s \ {CHOOSE x \in s : TRUE}]])[S]
       = Cardinality(UNION {NatAsSet(n, op(n)) : n \in S})

Interestingly, the obligation looks identical if I keep the Functions module as a local instance (fails) or extend from it (passes).

@kape1395
Copy link
Contributor Author

It probably makes sense to add TLAPS to our CI now that we start adding theorems.

Maybe it would be better first to set up the rolling updates for TLAPS before integrating it here.
I think at least tlaplus/tlapm#109 and tlaplus/tlapm#96 should be merged for that.

@kape1395
Copy link
Contributor Author

Is it OK to merge, or should it wait for TLAPM changes? I guess that will take a long time, because the existing branches should be merged before adding more changes.

@muenchnerkindl
Copy link
Contributor

I support merging.

@lemmy lemmy merged commit d75f00d into tlaplus:master Feb 21, 2024
1 check passed
@lemmy
Copy link
Member

lemmy commented Feb 21, 2024

     [java] "FiniteSetsExtTests"
     [java] Error: Assumption line 97, col 8 to line 99, col 55 of module FiniteSetsExtTests is false.
     [java] Finished in 08s at (2024-02-21 16:51:29)

lemmy pushed a commit that referenced this pull request Feb 21, 2024
FiniteSetsExt!MapThenSumSet including and support TLAPS theorems.

[Feature]

Signed-off-by: Karolis Petrauskas <[email protected]>
@lemmy
Copy link
Member

lemmy commented Feb 21, 2024

     [java] "FiniteSetsExtTests"
     [java] Error: Assumption line 97, col 8 to line 99, col 55 of module FiniteSetsExtTests is false.
     [java] Finished in 08s at (2024-02-21 16:51:29)

Taken care of by adjusting the line numbers in FiniteSetsExtTests.tla.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

Successfully merging this pull request may close these issues.

3 participants