Skip to content

Simplify kvar solutions in fqout files#741

Merged
facundominguez merged 3 commits into
developfrom
fd/simplify-fqout
Mar 10, 2025
Merged

Simplify kvar solutions in fqout files#741
facundominguez merged 3 commits into
developfrom
fd/simplify-fqout

Conversation

@facundominguez

Copy link
Copy Markdown
Collaborator

This PR eliminates much of the bindings in the kvar solutions in fqout files.
Many bindings are inconsequential because they are existential variables that appear only once in one of the sides of an equality, and are never related again to another term.

Before this change:

k_##1604 := exists [lq_karg$Test.extendSubst##k_##1604 : func(0 , [func(0 , [int;
                                                                              @(1330)]);
                                                                    int;
                                                                    @(1330);
                                                                    int;
                                                                    @(1330)]);
                     lq_karg$lq_anf$##7205759403792797858##d16G##k_##1604 : bool;
                     lq_karg$j##aXR##k_##1604 : int;
                     lq_karg$ds_d15x##k_##1604 : Test.Exp;
                     lq_karg$VV##1603##k_##1604 : Test.Exp;
                     lq_karg$Test.freshVar##k_##1604 : func(0 , [(Set_Set int); int]);
                     lq_karg$lq_anf$##7205759403792797857##d16F##k_##1604 : bool;
                     lq_karg$scope##aXJ##k_##1604 : (Set_Set int);
                     lq_karg$Test.substitute##k_##1604 : func(0 , [(Set_Set int);
                                                                   func(0 , [int; Test.Exp]);
                                                                   Test.Exp;
                                                                   Test.Exp]);
                     lq_karg$f##aXK##k_##1604 : func(0 , [int; Test.Exp]);
                     lq_karg$i##aXO##k_##1604 : int;
                     lq_karg$lq_anf$##7205759403792797854##d16C##k_##1604 : Test.Exp;
                     lq_karg$lq_anf$##7205759403792797861##d16J##k_##1604 : Test.Exp;
                     lq_karg$lq_anf$##7205759403792797860##d16I##k_##1604 : (Set_Set int);
                     lq_karg$e##aXP##k_##1604 : Test.Exp;
                     lq_tmp$x##1598 : int;
                     VV##F##4 : Test.Exp]
               . lq_karg$Test.extendSubst##k_##1604 == Test.extendSubst
                 && lq_karg$Test.freshVar##k_##1604 == Test.freshVar
                 && lq_karg$Test.substitute##k_##1604 == Test.substitute
                 && lq_karg$VV##1603##k_##1604 == VV##F##4
                 && lq_karg$ds_d15x##k_##1604 == ds_d15x
                 && lq_karg$e##aXP##k_##1604 == e##aXP
                 && lq_karg$f##aXK##k_##1604 == f##aXK
                 && lq_karg$i##aXO##k_##1604 == i##aXO
                 && lq_karg$j##aXR##k_##1604 == j##aXR
                 && lq_karg$lq_anf$##7205759403792797854##d16C##k_##1604 == lq_anf$##7205759403792797854##d16C
                 && lq_karg$lq_anf$##7205759403792797857##d16F##k_##1604 == lq_anf$##7205759403792797857##d16F
                 && lq_karg$lq_anf$##7205759403792797858##d16G##k_##1604 == lq_anf$##7205759403792797858##d16G
                 && lq_karg$lq_anf$##7205759403792797861##d16J##k_##1604 == lq_anf$##7205759403792797861##d16J
                 && cast_as_int lq_karg$lq_anf$##7205759403792797860##d16I##k_##1604 == cast_as_int lq_anf$##7205759403792797860##d16I
                 && cast_as_int lq_karg$scope##aXJ##k_##1604 == cast_as_int scope##aXJ
                 && arr_const_s true == arr_map_imp (Test.freeVars VV##F##4) scope##aXJ
             || exists [lq_karg$Test.extendSubst##k_##1604 : func(0 , [func(0 , [int;
                                                                                 @(1337)]);
                                                                       int;
                                                                       @(1337);
                                                                       int;
                                                                       @(1337)]);
                        lq_karg$lq_anf$##7205759403792797858##d16G##k_##1604 : bool;
                        lq_karg$j##aXR##k_##1604 : int;
                        lq_karg$ds_d15x##k_##1604 : Test.Exp;
                        lq_karg$VV##1603##k_##1604 : Test.Exp;
                        lq_karg$Test.freshVar##k_##1604 : func(0 , [(Set_Set int); int]);
                        lq_karg$lq_anf$##7205759403792797857##d16F##k_##1604 : bool;
                        lq_karg$scope##aXJ##k_##1604 : (Set_Set int);
                        lq_karg$Test.substitute##k_##1604 : func(0 , [(Set_Set int);
                                                                      func(0 , [int; Test.Exp]);
                                                                      Test.Exp;
                                                                      Test.Exp]);
                        lq_karg$f##aXK##k_##1604 : func(0 , [int; Test.Exp]);
                        lq_karg$i##aXO##k_##1604 : int;
                        lq_karg$lq_anf$##7205759403792797854##d16C##k_##1604 : Test.Exp;
                        lq_karg$lq_anf$##7205759403792797861##d16J##k_##1604 : Test.Exp;
                        lq_karg$lq_anf$##7205759403792797860##d16I##k_##1604 : (Set_Set int);
                        lq_karg$e##aXP##k_##1604 : Test.Exp;
                        VV##F##3 : Test.Exp]
                  . lq_karg$Test.extendSubst##k_##1604 == Test.extendSubst
                    && lq_karg$Test.freshVar##k_##1604 == Test.freshVar
                    && lq_karg$Test.substitute##k_##1604 == Test.substitute
                    && lq_karg$VV##1603##k_##1604 == VV##F##3
                    && lq_karg$ds_d15x##k_##1604 == ds_d15x
                    && lq_karg$e##aXP##k_##1604 == e##aXP
                    && lq_karg$f##aXK##k_##1604 == f##aXK
                    && lq_karg$i##aXO##k_##1604 == i##aXO
                    && lq_karg$j##aXR##k_##1604 == j##aXR
                    && lq_karg$lq_anf$##7205759403792797854##d16C##k_##1604 == lq_anf$##7205759403792797854##d16C
                    && lq_karg$lq_anf$##7205759403792797857##d16F##k_##1604 == lq_anf$##7205759403792797857##d16F
                    && lq_karg$lq_anf$##7205759403792797858##d16G##k_##1604 == lq_anf$##7205759403792797858##d16G
                    && lq_karg$lq_anf$##7205759403792797861##d16J##k_##1604 == lq_anf$##7205759403792797861##d16J
                    && VV##F##3 == lq_anf$##7205759403792797861##d16J
                    && VV##F##3 == Test.Var j##aXR
                    && Test.freeVars VV##F##3 == arr_store_s (arr_const_s false) j##aXR true
                    && cast_as_int lq_karg$lq_anf$##7205759403792797860##d16I##k_##1604 == cast_as_int lq_anf$##7205759403792797860##d16I
                    && cast_as_int lq_karg$scope##aXJ##k_##1604 == cast_as_int scope##aXJ

After this change:

$k_##1604 := exists [VV##F##4 : Test.Exp]
               . arr_const_s true == arr_map_imp (Test.freeVars VV##F##4) scope##aXJ
             || exists [VV##F##3 : Test.Exp]
                  . VV##F##3 == lq_anf$##7205759403792797861##d16J
                    && VV##F##3 == Test.Var j##aXR
                    && Test.freeVars VV##F##3 == arr_store_s (arr_const_s false) j##aXR true

@facundominguez

Copy link
Copy Markdown
Collaborator Author

@ranjitjhala, should I try this simplification elsewhere in the pipeline?

It is only used for pretty printing at the moment, and it relies much on list traversals.

@ranjitjhala

ranjitjhala commented Mar 9, 2025 via email

Copy link
Copy Markdown
Member

@facundominguez

facundominguez commented Mar 9, 2025

Copy link
Copy Markdown
Collaborator Author

Sure!

Sorry to be so vague :) Do you have any advice about where to insert it?

@facundominguez

Copy link
Copy Markdown
Collaborator Author

Here are the benchmarks. I don't regard the changes as significant, but let me know if you have any comments.

top
bot

@ranjitjhala

ranjitjhala commented Mar 10, 2025 via email

Copy link
Copy Markdown
Member

@facundominguez

Copy link
Copy Markdown
Collaborator Author

If you mean this sanitize, it returns an SInfo. Does it have KVar solutions to simplify anywhere inside?

@ranjitjhala

ranjitjhala commented Mar 10, 2025 via email

Copy link
Copy Markdown
Member

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