├── docs
├── .nojekyll
├── _config.yml
├── modules.rst
├── _static
│ ├── sign.png
│ ├── coherence.png
│ └── interval.jpg
├── html
│ ├── objects.inv
│ ├── _static
│ │ ├── up.png
│ │ ├── down.png
│ │ ├── file.png
│ │ ├── minus.png
│ │ ├── plus.png
│ │ ├── sign.png
│ │ ├── comment.png
│ │ ├── coherence.png
│ │ ├── interval.jpg
│ │ ├── up-pressed.png
│ │ ├── ajax-loader.gif
│ │ ├── down-pressed.png
│ │ ├── comment-bright.png
│ │ ├── comment-close.png
│ │ └── fonts
│ │ │ ├── Lato-Bold.ttf
│ │ │ ├── Lato-Regular.ttf
│ │ │ ├── Inconsolata-Bold.ttf
│ │ │ ├── RobotoSlab-Bold.ttf
│ │ │ ├── Inconsolata-Regular.ttf
│ │ │ ├── RobotoSlab-Regular.ttf
│ │ │ ├── fontawesome-webfont.eot
│ │ │ ├── fontawesome-webfont.ttf
│ │ │ └── fontawesome-webfont.woff
│ ├── _images
│ │ ├── sign.png
│ │ └── interval.jpg
│ ├── _sources
│ │ ├── modules.rst.txt
│ │ ├── lyra.frontend.rst.txt
│ │ ├── lyra.engine.usage.rst.txt
│ │ ├── lyra.engine.string.rst.txt
│ │ ├── lyra.engine.liveness.rst.txt
│ │ ├── lyra.engine.assumption.rst.txt
│ │ ├── lyra.abstract_domains.string.rst.txt
│ │ ├── lyra.abstract_domains.liveness.rst.txt
│ │ ├── lyra.rst.txt
│ │ ├── lyra.engine.numerical.rst.txt
│ │ ├── index.rst.txt
│ │ ├── lyra.abstract_domains.usage.rst.txt
│ │ ├── lyra.abstract_domains.numerical.rst.txt
│ │ ├── lyra.semantics.rst.txt
│ │ ├── lyra.core.rst.txt
│ │ ├── lyra.engine.rst.txt
│ │ ├── lyra.abstract_domains.assumption.rst.txt
│ │ └── lyra.abstract_domains.rst.txt
│ └── .buildinfo
├── index.html
├── apidoc.sh
├── lyra.frontend.rst
├── lyra.engine.usage.rst
├── lyra.engine.string.rst
├── lyra.engine.liveness.rst
├── lyra.engine.assumption.rst
├── lyra.abstract_domains.string.rst
├── lyra.abstract_domains.liveness.rst
├── lyra.rst
├── lyra.engine.numerical.rst
├── index.rst
├── lyra.abstract_domains.usage.rst
├── lyra.abstract_domains.numerical.rst
├── lyra.semantics.rst
├── Makefile
├── lyra.core.rst
├── lyra.engine.rst
├── lyra.abstract_domains.assumption.rst
└── lyra.abstract_domains.rst
├── src
├── __init__.py
├── lyra
│ ├── __init__.py
│ ├── core
│ │ ├── __init__.py
│ │ └── utils.py
│ ├── engine
│ │ ├── __init__.py
│ │ ├── usage
│ │ │ ├── __init__.py
│ │ │ ├── dataframe_usage_analysis.py
│ │ │ └── usage_analysis.py
│ │ ├── assumption
│ │ │ └── __init__.py
│ │ ├── container
│ │ │ ├── __init__.py
│ │ │ └── fulara
│ │ │ │ └── __init__.py
│ │ ├── liveness
│ │ │ ├── __init__.py
│ │ │ └── liveness_analysis.py
│ │ ├── numerical
│ │ │ ├── __init__.py
│ │ │ ├── sign_analysis.py
│ │ │ ├── octagon_analysis.py
│ │ │ └── polyhedra_analysis.py
│ │ └── string
│ │ │ ├── __init__.py
│ │ │ ├── character_analysis.py
│ │ │ └── stringset_analysis.py
│ ├── tests
│ │ ├── __init__.py
│ │ ├── container
│ │ │ ├── __init__.py
│ │ │ ├── dict_simple_example.py
│ │ │ ├── dict_example.py
│ │ │ ├── dict_if_example.py
│ │ │ ├── BRCA_example.py
│ │ │ └── dict_descr_example.py
│ │ ├── esop2018.py
│ │ ├── usage
│ │ │ ├── three_dict_example.py
│ │ │ └── running_example.py
│ │ └── code_jam
│ │ │ └── pancake_flipper
│ │ │ ├── pancakes_mofhu.py
│ │ │ ├── pancakes_gahou.py
│ │ │ ├── pancakes_jsphkn.py
│ │ │ ├── pancakes_billjeff.py
│ │ │ └── pancakes_real.py
│ ├── frontend
│ │ └── __init__.py
│ ├── semantics
│ │ └── __init__.py
│ ├── unittests
│ │ ├── __init__.py
│ │ ├── ranking
│ │ │ └── __init__.py
│ │ ├── usage
│ │ │ ├── __init__.py
│ │ │ ├── fulara
│ │ │ │ └── __init__.py
│ │ │ ├── dataframes
│ │ │ │ ├── __init__.py
│ │ │ │ ├── index.py
│ │ │ │ ├── handcraft_example_1.py
│ │ │ │ ├── handcraft_example_4.py
│ │ │ │ ├── drop_before_use.py
│ │ │ │ ├── handcraft_example_5.py
│ │ │ │ ├── handcraft_example_if.py
│ │ │ │ ├── handcraft_example_5b.py
│ │ │ │ ├── handcraft_example_7.py
│ │ │ │ ├── handcraft_example_3.py
│ │ │ │ ├── handcraft_example_2.py
│ │ │ │ ├── handcraft_example_6.py
│ │ │ │ ├── call.py
│ │ │ │ └── loc.py
│ │ │ ├── var.py
│ │ │ ├── demo0.py
│ │ │ ├── demo1.py
│ │ │ ├── demo2a.py
│ │ │ ├── demo2b.py
│ │ │ ├── bug.py
│ │ │ ├── demo2c.py
│ │ │ ├── boolvar.py
│ │ │ ├── if.py
│ │ │ ├── unused.py
│ │ │ ├── if2.py
│ │ │ ├── tricky.py
│ │ │ ├── while.py
│ │ │ ├── list.py
│ │ │ ├── list_while.py
│ │ │ ├── demo3.py
│ │ │ ├── while_break.py
│ │ │ ├── missing_update.py
│ │ │ ├── if_nested.py
│ │ │ ├── list2.py
│ │ │ ├── simple.py
│ │ │ ├── dict_simple_example.py
│ │ │ └── dict_varkey_example.py
│ │ ├── assumption
│ │ │ ├── __init__.py
│ │ │ ├── type
│ │ │ │ ├── __init__.py
│ │ │ │ ├── cast.py
│ │ │ │ └── add.py
│ │ │ ├── type+range
│ │ │ │ ├── __init__.py
│ │ │ │ ├── filter.py
│ │ │ │ ├── loop.py
│ │ │ │ ├── boolean.py
│ │ │ │ ├── five.py
│ │ │ │ ├── branch.py
│ │ │ │ ├── dependencies.py
│ │ │ │ ├── length.py
│ │ │ │ ├── nested.py
│ │ │ │ ├── hamm.py
│ │ │ │ ├── repeat.py
│ │ │ │ ├── paths.py
│ │ │ │ ├── lost.py
│ │ │ │ ├── merge.py
│ │ │ │ └── 123.py
│ │ │ ├── type+alphabet
│ │ │ │ ├── __init__.py
│ │ │ │ ├── assume1.py
│ │ │ │ ├── assume2.py
│ │ │ │ ├── must.py
│ │ │ │ ├── basic.py
│ │ │ │ ├── concatenation.py
│ │ │ │ ├── mix.py
│ │ │ │ ├── merge.py
│ │ │ │ └── substitution.py
│ │ │ ├── type+quantity
│ │ │ │ ├── __init__.py
│ │ │ │ ├── zero.py
│ │ │ │ ├── division.py
│ │ │ │ ├── cars.py
│ │ │ │ └── convert.py
│ │ │ ├── type+range+alphabet
│ │ │ │ ├── __init__.py
│ │ │ │ ├── noinfo.py
│ │ │ │ ├── mix.py
│ │ │ │ ├── cars.py
│ │ │ │ ├── convert.py
│ │ │ │ └── dna.py
│ │ │ ├── quantity+range+wordset
│ │ │ │ ├── __init__.py
│ │ │ │ └── gpa.py
│ │ │ ├── type+sign+interval+stringset
│ │ │ │ ├── __init__.py
│ │ │ │ ├── stringlist.py
│ │ │ │ ├── abcd.py
│ │ │ │ └── grade2gpa.py
│ │ │ └── type+wordset
│ │ │ │ ├── assume1.py
│ │ │ │ ├── assume2.py
│ │ │ │ ├── must.py
│ │ │ │ ├── basic.py
│ │ │ │ ├── substitution.py
│ │ │ │ └── convert.py
│ │ ├── container
│ │ │ ├── __init__.py
│ │ │ └── fulara
│ │ │ │ ├── __init__.py
│ │ │ │ └── interval
│ │ │ │ └── __init__.py
│ │ ├── liveness
│ │ │ ├── __init__.py
│ │ │ └── dict_simple_example.py
│ │ ├── numerical
│ │ │ ├── __init__.py
│ │ │ ├── box
│ │ │ │ └── __init__.py
│ │ │ ├── octagon
│ │ │ │ ├── __init__.py
│ │ │ │ ├── interval_assignment_fallback.py
│ │ │ │ ├── not_equal.py
│ │ │ │ ├── interval_assume_fallback.py
│ │ │ │ ├── dead_branch.py
│ │ │ │ ├── straight.py
│ │ │ │ ├── while.py
│ │ │ │ ├── implicit_bound.py
│ │ │ │ └── if_nested.py
│ │ │ ├── sign
│ │ │ │ ├── __init__.py
│ │ │ │ ├── forward
│ │ │ │ │ ├── __init__.py
│ │ │ │ │ ├── while.py
│ │ │ │ │ ├── filter.py
│ │ │ │ │ ├── conditional.py
│ │ │ │ │ ├── assignments.py
│ │ │ │ │ ├── booleans.py
│ │ │ │ │ └── lists.py
│ │ │ │ └── backward
│ │ │ │ │ ├── __init__.py
│ │ │ │ │ ├── zero.py
│ │ │ │ │ └── assignment.py
│ │ │ ├── interval
│ │ │ │ ├── __init__.py
│ │ │ │ ├── backward
│ │ │ │ │ ├── __init__.py
│ │ │ │ │ ├── indexing3
│ │ │ │ │ │ ├── __init__.py
│ │ │ │ │ │ ├── subscriptions2a.py
│ │ │ │ │ │ ├── subscriptions2b.py
│ │ │ │ │ │ ├── subscriptions0.py
│ │ │ │ │ │ ├── subscriptions1c.py
│ │ │ │ │ │ ├── subscriptions1f.py
│ │ │ │ │ │ ├── subscriptions1h.py
│ │ │ │ │ │ ├── list2.py
│ │ │ │ │ │ ├── list0.py
│ │ │ │ │ │ ├── dictionary0.py
│ │ │ │ │ │ ├── subscriptions1b.py
│ │ │ │ │ │ ├── dictionary2.py
│ │ │ │ │ │ ├── list1.py
│ │ │ │ │ │ ├── subscriptions1g.py
│ │ │ │ │ │ ├── subscriptions1e.py
│ │ │ │ │ │ ├── subscriptions1a.py
│ │ │ │ │ │ ├── dictionary1.py
│ │ │ │ │ │ └── subscriptions1d.py
│ │ │ │ │ ├── summarization
│ │ │ │ │ │ ├── __init__.py
│ │ │ │ │ │ ├── subscriptions2a.py
│ │ │ │ │ │ ├── subscriptions2b.py
│ │ │ │ │ │ ├── subscriptions0.py
│ │ │ │ │ │ ├── subscriptions1c.py
│ │ │ │ │ │ ├── subscriptions1f.py
│ │ │ │ │ │ ├── subscriptions1h.py
│ │ │ │ │ │ ├── list0.py
│ │ │ │ │ │ ├── list2.py
│ │ │ │ │ │ ├── dictionary0.py
│ │ │ │ │ │ ├── subscriptions1b.py
│ │ │ │ │ │ ├── dictionary2.py
│ │ │ │ │ │ ├── list1.py
│ │ │ │ │ │ ├── subscriptions1g.py
│ │ │ │ │ │ ├── subscriptions1e.py
│ │ │ │ │ │ ├── subscriptions1a.py
│ │ │ │ │ │ ├── dictionary1.py
│ │ │ │ │ │ └── subscriptions1d.py
│ │ │ │ │ ├── unfeasible.py
│ │ │ │ │ ├── assignment.py
│ │ │ │ │ ├── call.py
│ │ │ │ │ └── double.py
│ │ │ │ └── forward
│ │ │ │ │ ├── __init__.py
│ │ │ │ │ ├── indexing3
│ │ │ │ │ ├── __init__.py
│ │ │ │ │ ├── subscriptions9.py
│ │ │ │ │ ├── subscriptions8.py
│ │ │ │ │ ├── subscriptionsA.py
│ │ │ │ │ ├── subscriptionsB.py
│ │ │ │ │ ├── empty.py
│ │ │ │ │ ├── five.py
│ │ │ │ │ ├── list_of_range1.py
│ │ │ │ │ ├── dictionary8c.py
│ │ │ │ │ ├── three.py
│ │ │ │ │ ├── list_of_range2.py
│ │ │ │ │ ├── set_to_list.py
│ │ │ │ │ ├── split1.py
│ │ │ │ │ ├── creation1.py
│ │ │ │ │ ├── creation2.py
│ │ │ │ │ ├── subscriptions5.py
│ │ │ │ │ ├── dictionary0.py
│ │ │ │ │ ├── dictionary9.py
│ │ │ │ │ ├── subscriptions2.py
│ │ │ │ │ ├── subscriptions3.py
│ │ │ │ │ ├── adding.py
│ │ │ │ │ ├── counting1.py
│ │ │ │ │ ├── lengths.py
│ │ │ │ │ ├── newline.py
│ │ │ │ │ ├── counting2.py
│ │ │ │ │ ├── weak2.py
│ │ │ │ │ ├── dictionary8b.py
│ │ │ │ │ ├── dictionary2.py
│ │ │ │ │ ├── inL7.py
│ │ │ │ │ ├── subscriptionsD.py
│ │ │ │ │ ├── weak1.py
│ │ │ │ │ ├── inL8.py
│ │ │ │ │ ├── weak4.py
│ │ │ │ │ ├── dictionary5.py
│ │ │ │ │ ├── symbolic.py
│ │ │ │ │ ├── dictionary3.py
│ │ │ │ │ ├── inL1.py
│ │ │ │ │ ├── inL2.py
│ │ │ │ │ ├── weak3.py
│ │ │ │ │ ├── subscriptionsE.py
│ │ │ │ │ ├── subscriptionsF.py
│ │ │ │ │ ├── subscriptions6.py
│ │ │ │ │ ├── inL9.py
│ │ │ │ │ ├── subscriptionsG.py
│ │ │ │ │ ├── keyval.py
│ │ │ │ │ ├── inL3.py
│ │ │ │ │ ├── inL4.py
│ │ │ │ │ ├── dictionary8a.py
│ │ │ │ │ ├── subscriptions7.py
│ │ │ │ │ ├── subscriptions1.py
│ │ │ │ │ ├── filterX.py
│ │ │ │ │ ├── inL6.py
│ │ │ │ │ ├── inL5.py
│ │ │ │ │ ├── dictionary4.py
│ │ │ │ │ ├── dictionary7.py
│ │ │ │ │ ├── subscriptions4.py
│ │ │ │ │ ├── length.py
│ │ │ │ │ ├── subscriptionsC.py
│ │ │ │ │ ├── nested1.py
│ │ │ │ │ ├── dictionary1.py
│ │ │ │ │ ├── nested3.py
│ │ │ │ │ ├── same.py
│ │ │ │ │ └── concat.py
│ │ │ │ │ ├── summarization
│ │ │ │ │ ├── __init__.py
│ │ │ │ │ ├── subscriptions9.py
│ │ │ │ │ ├── subscriptions8.py
│ │ │ │ │ ├── subscriptionsA.py
│ │ │ │ │ ├── subscriptionsB.py
│ │ │ │ │ ├── five.py
│ │ │ │ │ ├── list_of_range1.py
│ │ │ │ │ ├── empty.py
│ │ │ │ │ ├── three.py
│ │ │ │ │ ├── dictionary8c.py
│ │ │ │ │ ├── list_of_range2.py
│ │ │ │ │ ├── set_to_list.py
│ │ │ │ │ ├── adding.py
│ │ │ │ │ ├── subscriptions5.py
│ │ │ │ │ ├── counting1.py
│ │ │ │ │ ├── dictionary9.py
│ │ │ │ │ ├── subscriptions3.py
│ │ │ │ │ ├── creation1.py
│ │ │ │ │ ├── dictionary0.py
│ │ │ │ │ ├── newline.py
│ │ │ │ │ ├── split1.py
│ │ │ │ │ ├── creation2.py
│ │ │ │ │ ├── counting2.py
│ │ │ │ │ ├── inL8.py
│ │ │ │ │ ├── weak2.py
│ │ │ │ │ ├── lengths.py
│ │ │ │ │ ├── subscriptionsD.py
│ │ │ │ │ ├── weak1.py
│ │ │ │ │ ├── dictionary2.py
│ │ │ │ │ ├── dictionary8b.py
│ │ │ │ │ ├── inL7.py
│ │ │ │ │ ├── weak4.py
│ │ │ │ │ ├── weak3.py
│ │ │ │ │ ├── dictionary3.py
│ │ │ │ │ ├── dictionary5.py
│ │ │ │ │ ├── subscriptionsE.py
│ │ │ │ │ ├── subscriptions6.py
│ │ │ │ │ ├── inL2.py
│ │ │ │ │ ├── inL1.py
│ │ │ │ │ ├── subscriptionsF.py
│ │ │ │ │ ├── symbolic.py
│ │ │ │ │ ├── subscriptions2.py
│ │ │ │ │ ├── inL3.py
│ │ │ │ │ ├── inL4.py
│ │ │ │ │ ├── subscriptionsG.py
│ │ │ │ │ ├── inL9.py
│ │ │ │ │ ├── keyval.py
│ │ │ │ │ ├── subscriptions7.py
│ │ │ │ │ ├── dictionary8a.py
│ │ │ │ │ ├── filterX.py
│ │ │ │ │ ├── subscriptions1.py
│ │ │ │ │ ├── copy.py
│ │ │ │ │ ├── dictionary4.py
│ │ │ │ │ ├── inL6.py
│ │ │ │ │ ├── subscriptions4.py
│ │ │ │ │ ├── inL5.py
│ │ │ │ │ ├── dictionary7.py
│ │ │ │ │ ├── length.py
│ │ │ │ │ ├── subscriptionsC.py
│ │ │ │ │ ├── nested1.py
│ │ │ │ │ ├── nested3.py
│ │ │ │ │ ├── dictionary1.py
│ │ │ │ │ ├── concat.py
│ │ │ │ │ └── same.py
│ │ │ │ │ ├── sets.py
│ │ │ │ │ ├── double2.py
│ │ │ │ │ ├── inR8.py
│ │ │ │ │ ├── inR9.py
│ │ │ │ │ ├── double1.py
│ │ │ │ │ ├── inR7.py
│ │ │ │ │ ├── composition.py
│ │ │ │ │ ├── outside.py
│ │ │ │ │ ├── ifexpression.py
│ │ │ │ │ ├── inR2.py
│ │ │ │ │ ├── inR1.py
│ │ │ │ │ ├── inR3.py
│ │ │ │ │ ├── inR4.py
│ │ │ │ │ ├── inR5.py
│ │ │ │ │ ├── inR6.py
│ │ │ │ │ ├── conditional2.py
│ │ │ │ │ ├── while.py
│ │ │ │ │ ├── issue69.py
│ │ │ │ │ ├── max2.py
│ │ │ │ │ ├── filter.py
│ │ │ │ │ ├── max1.py
│ │ │ │ │ ├── demo2a.py
│ │ │ │ │ ├── break.py
│ │ │ │ │ ├── conditional1.py
│ │ │ │ │ ├── assignments.py
│ │ │ │ │ └── boolvar.py
│ │ │ └── polyhedra
│ │ │ │ ├── __init__.py
│ │ │ │ ├── forward
│ │ │ │ ├── __init__.py
│ │ │ │ ├── filter.py
│ │ │ │ ├── filterX.py
│ │ │ │ └── popl2014.py
│ │ │ │ └── backward
│ │ │ │ └── __init__.py
│ │ └── liveness_tests.py
│ ├── abstract_domains
│ │ ├── __init__.py
│ │ ├── usage
│ │ │ └── __init__.py
│ │ ├── assumption
│ │ │ └── __init__.py
│ │ ├── container
│ │ │ ├── __init__.py
│ │ │ └── fulara
│ │ │ │ ├── __init__.py
│ │ │ │ └── value_wrapper.py
│ │ ├── liveness
│ │ │ └── __init__.py
│ │ ├── numerical
│ │ │ ├── __init__.py
│ │ │ ├── polyhedra_domain.py
│ │ │ └── octagon_domain.py
│ │ ├── ranking
│ │ │ └── __init__.py
│ │ └── string
│ │ │ └── __init__.py
│ ├── visualization
│ │ └── __init__.py
│ └── main.py
└── setup.cfg
├── icon.png
├── lyra.png
├── requirements.txt
├── setup.py
└── .travis.yml
/docs/.nojekyll:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/lyra/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/lyra/core/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/lyra/engine/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/lyra/tests/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/lyra/engine/usage/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/lyra/frontend/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/lyra/semantics/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/lyra/unittests/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/lyra/abstract_domains/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/lyra/engine/assumption/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/lyra/engine/container/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/lyra/engine/liveness/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/lyra/engine/numerical/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/lyra/engine/string/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/lyra/tests/container/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/lyra/unittests/ranking/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/lyra/unittests/usage/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/lyra/visualization/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/docs/_config.yml:
--------------------------------------------------------------------------------
1 | theme: jekyll-theme-cayman
--------------------------------------------------------------------------------
/src/lyra/abstract_domains/usage/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/lyra/unittests/assumption/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/lyra/unittests/container/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/lyra/unittests/liveness/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/lyra/unittests/usage/fulara/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/lyra/abstract_domains/assumption/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/lyra/abstract_domains/container/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/lyra/abstract_domains/liveness/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/lyra/abstract_domains/numerical/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/lyra/abstract_domains/ranking/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/lyra/abstract_domains/string/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/lyra/engine/container/fulara/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/lyra/unittests/assumption/type/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/lyra/unittests/container/fulara/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/box/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/octagon/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/sign/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/lyra/unittests/usage/dataframes/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/lyra/unittests/assumption/type+range/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/polyhedra/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/sign/forward/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/lyra/abstract_domains/container/fulara/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/lyra/unittests/assumption/type+alphabet/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/lyra/unittests/assumption/type+quantity/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/lyra/unittests/container/fulara/interval/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/backward/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/polyhedra/forward/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/sign/backward/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/lyra/unittests/assumption/type+range+alphabet/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/polyhedra/backward/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/lyra/unittests/assumption/quantity+range+wordset/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/backward/indexing3/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/indexing3/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/caterinaurban/Lyra/HEAD/icon.png
--------------------------------------------------------------------------------
/lyra.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/caterinaurban/Lyra/HEAD/lyra.png
--------------------------------------------------------------------------------
/src/lyra/unittests/assumption/type+sign+interval+stringset/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/backward/summarization/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/summarization/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/lyra/unittests/usage/var.py:
--------------------------------------------------------------------------------
1 |
2 | x: int = 2
3 | y: int = 4
4 | z: int = 1
5 |
--------------------------------------------------------------------------------
/docs/modules.rst:
--------------------------------------------------------------------------------
1 | lyra
2 | ====
3 |
4 | .. toctree::
5 | :maxdepth: 4
6 |
7 | lyra
8 |
--------------------------------------------------------------------------------
/docs/_static/sign.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/caterinaurban/Lyra/HEAD/docs/_static/sign.png
--------------------------------------------------------------------------------
/docs/html/objects.inv:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/caterinaurban/Lyra/HEAD/docs/html/objects.inv
--------------------------------------------------------------------------------
/src/lyra/unittests/usage/demo0.py:
--------------------------------------------------------------------------------
1 |
2 | x: int = int(input())
3 | # STATE: x -> U
4 | print(x)
5 |
--------------------------------------------------------------------------------
/docs/html/_static/up.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/caterinaurban/Lyra/HEAD/docs/html/_static/up.png
--------------------------------------------------------------------------------
/docs/_static/coherence.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/caterinaurban/Lyra/HEAD/docs/_static/coherence.png
--------------------------------------------------------------------------------
/docs/_static/interval.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/caterinaurban/Lyra/HEAD/docs/_static/interval.jpg
--------------------------------------------------------------------------------
/docs/html/_images/sign.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/caterinaurban/Lyra/HEAD/docs/html/_images/sign.png
--------------------------------------------------------------------------------
/docs/html/_static/down.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/caterinaurban/Lyra/HEAD/docs/html/_static/down.png
--------------------------------------------------------------------------------
/docs/html/_static/file.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/caterinaurban/Lyra/HEAD/docs/html/_static/file.png
--------------------------------------------------------------------------------
/docs/html/_static/minus.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/caterinaurban/Lyra/HEAD/docs/html/_static/minus.png
--------------------------------------------------------------------------------
/docs/html/_static/plus.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/caterinaurban/Lyra/HEAD/docs/html/_static/plus.png
--------------------------------------------------------------------------------
/docs/html/_static/sign.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/caterinaurban/Lyra/HEAD/docs/html/_static/sign.png
--------------------------------------------------------------------------------
/docs/html/_sources/modules.rst.txt:
--------------------------------------------------------------------------------
1 | lyra
2 | ====
3 |
4 | .. toctree::
5 | :maxdepth: 4
6 |
7 | lyra
8 |
--------------------------------------------------------------------------------
/docs/html/_static/comment.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/caterinaurban/Lyra/HEAD/docs/html/_static/comment.png
--------------------------------------------------------------------------------
/requirements.txt:
--------------------------------------------------------------------------------
1 | apronpy
2 | graphviz==0.7.1
3 | pycodestyle
4 | Sphinx==1.6.2
5 | sphinx-rtd-theme==0.1.9
6 |
--------------------------------------------------------------------------------
/docs/html/_images/interval.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/caterinaurban/Lyra/HEAD/docs/html/_images/interval.jpg
--------------------------------------------------------------------------------
/docs/html/_static/coherence.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/caterinaurban/Lyra/HEAD/docs/html/_static/coherence.png
--------------------------------------------------------------------------------
/docs/html/_static/interval.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/caterinaurban/Lyra/HEAD/docs/html/_static/interval.jpg
--------------------------------------------------------------------------------
/docs/html/_static/up-pressed.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/caterinaurban/Lyra/HEAD/docs/html/_static/up-pressed.png
--------------------------------------------------------------------------------
/docs/html/_static/ajax-loader.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/caterinaurban/Lyra/HEAD/docs/html/_static/ajax-loader.gif
--------------------------------------------------------------------------------
/docs/html/_static/down-pressed.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/caterinaurban/Lyra/HEAD/docs/html/_static/down-pressed.png
--------------------------------------------------------------------------------
/src/lyra/unittests/usage/demo1.py:
--------------------------------------------------------------------------------
1 |
2 | x: int = int(input())
3 | # STATE: a -> W; x -> U
4 | a: int = x
5 | print(a)
6 |
--------------------------------------------------------------------------------
/docs/html/_static/comment-bright.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/caterinaurban/Lyra/HEAD/docs/html/_static/comment-bright.png
--------------------------------------------------------------------------------
/docs/html/_static/comment-close.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/caterinaurban/Lyra/HEAD/docs/html/_static/comment-close.png
--------------------------------------------------------------------------------
/docs/html/_static/fonts/Lato-Bold.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/caterinaurban/Lyra/HEAD/docs/html/_static/fonts/Lato-Bold.ttf
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/indexing3/subscriptions9.py:
--------------------------------------------------------------------------------
1 |
2 | x: int = {1: 1, 2: 2, 3: 3}[9]
3 | # FINAL: x -> ⊥
4 |
--------------------------------------------------------------------------------
/docs/html/_static/fonts/Lato-Regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/caterinaurban/Lyra/HEAD/docs/html/_static/fonts/Lato-Regular.ttf
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/summarization/subscriptions9.py:
--------------------------------------------------------------------------------
1 |
2 | x: int = {1: 1, 2: 2, 3: 3}[9]
3 | # FINAL: x -> ⊥
4 |
--------------------------------------------------------------------------------
/docs/html/_static/fonts/Inconsolata-Bold.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/caterinaurban/Lyra/HEAD/docs/html/_static/fonts/Inconsolata-Bold.ttf
--------------------------------------------------------------------------------
/docs/html/_static/fonts/RobotoSlab-Bold.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/caterinaurban/Lyra/HEAD/docs/html/_static/fonts/RobotoSlab-Bold.ttf
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/sign/backward/zero.py:
--------------------------------------------------------------------------------
1 |
2 | a: int = int(input())
3 | # STATE: a -> ≠0
4 | if a == 0:
5 | raise ValueError
6 |
--------------------------------------------------------------------------------
/docs/html/_static/fonts/Inconsolata-Regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/caterinaurban/Lyra/HEAD/docs/html/_static/fonts/Inconsolata-Regular.ttf
--------------------------------------------------------------------------------
/docs/html/_static/fonts/RobotoSlab-Regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/caterinaurban/Lyra/HEAD/docs/html/_static/fonts/RobotoSlab-Regular.ttf
--------------------------------------------------------------------------------
/docs/html/_static/fonts/fontawesome-webfont.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/caterinaurban/Lyra/HEAD/docs/html/_static/fonts/fontawesome-webfont.eot
--------------------------------------------------------------------------------
/docs/html/_static/fonts/fontawesome-webfont.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/caterinaurban/Lyra/HEAD/docs/html/_static/fonts/fontawesome-webfont.ttf
--------------------------------------------------------------------------------
/src/lyra/unittests/assumption/type/cast.py:
--------------------------------------------------------------------------------
1 |
2 | x: str = input()
3 | # STATE: len(x) -> [0, inf]; x -> Integer; y -> Float
4 | y: float = int(x)
5 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/indexing3/subscriptions8.py:
--------------------------------------------------------------------------------
1 |
2 | x: int = {'a': 1, 'b': 2, 'c': 3}['c']
3 | # FINAL: x -> [3, 3]
4 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/indexing3/subscriptionsA.py:
--------------------------------------------------------------------------------
1 |
2 | x: int = [1, 2, 3][3]
3 | y: int = 0
4 | #RESULT: x -> ⊥ y -> ⊥
5 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/indexing3/subscriptionsB.py:
--------------------------------------------------------------------------------
1 |
2 | z: int = {0: [0], 1: [1], 2: [2]}[2][0]
3 | # FINAL: z -> [2, 2]
4 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/sets.py:
--------------------------------------------------------------------------------
1 |
2 | S: Set[Tuple[int, int]] = {(1, 2), (2, 1)}
3 | # FINAL: S -> [1, 2]; len(S) -> [2, 2]
4 |
--------------------------------------------------------------------------------
/docs/html/_static/fonts/fontawesome-webfont.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/caterinaurban/Lyra/HEAD/docs/html/_static/fonts/fontawesome-webfont.woff
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/summarization/subscriptions8.py:
--------------------------------------------------------------------------------
1 |
2 | x: int = {'a': 1, 'b': 2, 'c': 3}['c']
3 | # FINAL: x -> [1, 3]
4 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/summarization/subscriptionsA.py:
--------------------------------------------------------------------------------
1 |
2 | x: int = [1, 2, 3][3]
3 | y: int = 0
4 | #RESULT: x -> ⊥ y -> ⊥
5 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/summarization/subscriptionsB.py:
--------------------------------------------------------------------------------
1 |
2 | z: int = {0: [0], 1: [1], 2: [2]}[2][0]
3 | # FINAL: z -> [0, 2]
4 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/double2.py:
--------------------------------------------------------------------------------
1 |
2 | def f(x: int) -> int:
3 | return x + 1
4 |
5 | z: int = f(f(10))
6 | # FINAL: z -> [12, 12]
--------------------------------------------------------------------------------
/src/lyra/unittests/usage/demo2a.py:
--------------------------------------------------------------------------------
1 |
2 | x: int = int(input())
3 | a: int = 0
4 | # STATE: a -> U; x -> U
5 | if 3 > x:
6 | a: int = x
7 | print(a)
8 |
--------------------------------------------------------------------------------
/src/lyra/unittests/usage/demo2b.py:
--------------------------------------------------------------------------------
1 |
2 | x: int = int(input())
3 | a: int = 0
4 | # STATE: a -> U; x -> U
5 | if 3 > x:
6 | a: int = 10
7 | print(a)
8 |
--------------------------------------------------------------------------------
/src/setup.cfg:
--------------------------------------------------------------------------------
1 | [pycodestyle]
2 | exclude = lyra/tests/, lyra/unittests/
3 | ignore = W605
4 | max_line_length = 99
5 | show_source = True
6 | count = True
7 |
--------------------------------------------------------------------------------
/docs/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/summarization/five.py:
--------------------------------------------------------------------------------
1 |
2 | five: List[int] = [1, 2, 3, 4, 5]
3 | # FINAL: five -> [1, 5]; len(five) -> [5, 5]
4 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/summarization/list_of_range1.py:
--------------------------------------------------------------------------------
1 |
2 | L: List[int] = list(range(10))
3 | # STATE: L -> [0, 9]; len(L) -> [10, 10]
4 |
--------------------------------------------------------------------------------
/src/lyra/unittests/assumption/type+quantity/zero.py:
--------------------------------------------------------------------------------
1 |
2 | # INITIAL: 3:(Integer, ≠0)
3 | a: int = int(input())
4 | if a == 0:
5 | raise ValueError
6 | # FINAL: ε
7 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/inR8.py:
--------------------------------------------------------------------------------
1 |
2 | x: int = -9
3 | # STATE: x -> [-9, -9]
4 | for x in range(3):
5 | print(x)
6 | # FINAL: x -> [-9, 2]
7 |
--------------------------------------------------------------------------------
/src/lyra/unittests/usage/bug.py:
--------------------------------------------------------------------------------
1 |
2 | x: int = int(input())
3 | a: int = 0
4 | # STATE: a -> U; foo -> N; x -> N
5 | if 3 > x:
6 | foo: int = 10
7 | print(a)
8 |
--------------------------------------------------------------------------------
/src/lyra/unittests/usage/demo2c.py:
--------------------------------------------------------------------------------
1 |
2 | x: int = int(input())
3 | a: int = 0
4 | # STATE: a -> U; foo -> N; x -> N
5 | if 3 > x:
6 | foo: int = 10
7 | print(a)
8 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/backward/unfeasible.py:
--------------------------------------------------------------------------------
1 |
2 | # STATE: x -> ⊥
3 | x: int = 9
4 | # STATE: x -> [1, 5]
5 | if x < 1 or 5 < x:
6 | raise ValueError
7 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/indexing3/empty.py:
--------------------------------------------------------------------------------
1 |
2 | L: List[int] = list()
3 | b: bool = bool(L)
4 | # FINAL: L -> _@⊥; b -> [0, 0]; len(L) -> [0, 0]
5 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/summarization/empty.py:
--------------------------------------------------------------------------------
1 |
2 | L: List[int] = list()
3 | b: bool = bool(L)
4 | # FINAL: L -> ⊥; b -> [0, 0]; len(L) -> [0, 0]
5 |
--------------------------------------------------------------------------------
/src/lyra/unittests/assumption/type+wordset/assume1.py:
--------------------------------------------------------------------------------
1 |
2 | # INITIAL: 3:(String, {'#', '.'})
3 | sep: str = input()
4 | if sep != '.' and sep != '#':
5 | raise ValueError
6 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/summarization/three.py:
--------------------------------------------------------------------------------
1 |
2 | three: List[List[int]] = [[1], [1, 2], [1, 2, 3]]
3 | # FINAL: len(three) -> [3, 3]; three -> [1, 3]
4 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/octagon/interval_assignment_fallback.py:
--------------------------------------------------------------------------------
1 | x = 3
2 | a = x * 2
3 | # STATE: 6.0≤a≤6.0, 3≤x≤3, x+a≤9.0, x-a≤-3.0, -x+a≤3.0, -x-a≤-9.0
4 | print(a)
5 |
--------------------------------------------------------------------------------
/src/lyra/unittests/usage/boolvar.py:
--------------------------------------------------------------------------------
1 |
2 | b: bool = bool(input())
3 | q: bool = bool(input())
4 | # STATE: b -> U; q -> U; z -> W
5 | z: int = 1 if b and q else 0
6 | print(z)
7 |
--------------------------------------------------------------------------------
/src/lyra/unittests/assumption/type+range+alphabet/noinfo.py:
--------------------------------------------------------------------------------
1 |
2 | # INITIAL: 3:(String, [-inf, inf], (∅, Σ))
3 | a: str = input()
4 | if int(a[0]) != 3:
5 | raise ValueError
6 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/inR9.py:
--------------------------------------------------------------------------------
1 |
2 | x: int = -9
3 | # STATE: x -> [-9, -9]
4 | for x in range(int(input())):
5 | print(x)
6 | # FINAL: x -> [-9, inf]
7 |
--------------------------------------------------------------------------------
/src/lyra/unittests/assumption/type+alphabet/assume1.py:
--------------------------------------------------------------------------------
1 |
2 | # INITIAL: 3:(String, (∅, {'#', '.'}))
3 | sep: str = input()
4 | if sep != '.' and sep != '#':
5 | raise ValueError
6 |
--------------------------------------------------------------------------------
/src/lyra/unittests/assumption/type+range/filter.py:
--------------------------------------------------------------------------------
1 |
2 | # INITIAL: 3:(Integer, [-inf, 9])
3 | T: int = int(input())
4 |
5 | if 0 < T:
6 | if 9 < T:
7 | raise ValueError
8 |
--------------------------------------------------------------------------------
/src/lyra/unittests/assumption/type+range/loop.py:
--------------------------------------------------------------------------------
1 |
2 | # INITIAL: 3:(Integer, [-inf, inf]), ★
3 | T: int = int(input())
4 | while T < 10:
5 | a: str = input()
6 | T: int = T + 1
7 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/double1.py:
--------------------------------------------------------------------------------
1 |
2 | def f(x: int) -> int:
3 | return x - 1
4 |
5 | a: int = 2
6 | c: int = f(f(a))
7 | # FINAL: a -> [2, 2]; c -> [0, 0]
8 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/indexing3/five.py:
--------------------------------------------------------------------------------
1 |
2 | five: List[int] = [1, 2, 3, 4, 5]
3 | # FINAL: five -> 0@[1, 1], 1@[2, 2], 2@[3, 3], _@[4, 5]; len(five) -> [5, 5]
4 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/indexing3/list_of_range1.py:
--------------------------------------------------------------------------------
1 |
2 | L: List[int] = list(range(10))
3 | # FINAL: L -> 0@[0, 0], 1@[1, 1], 2@[2, 2], _@[3, 9]; len(L) -> [10, 10]
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/octagon/not_equal.py:
--------------------------------------------------------------------------------
1 | x = int(input())
2 |
3 | # make positive
4 | if x < 0 and x != 0:
5 | x = -x
6 |
7 | # RESULT: 1≤x
8 |
9 | print(x)
10 |
--------------------------------------------------------------------------------
/src/lyra/unittests/assumption/type+range/boolean.py:
--------------------------------------------------------------------------------
1 |
2 | # INITIAL: 3:(Boolean, [0, 1]), ★
3 | b: bool = bool(input())
4 | # STATE: ★
5 | if b:
6 | a: int = int(input())
7 | # FINAL: ε
8 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/inR7.py:
--------------------------------------------------------------------------------
1 |
2 | x: int = -9
3 | # STATE: x -> [-9, -9]
4 | for x in range(0):
5 | # STATE: x -> ⊥
6 | print(x)
7 | # FINAL: x -> [-9, -9]
8 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/indexing3/dictionary8c.py:
--------------------------------------------------------------------------------
1 |
2 | x: int = int(input())
3 | z: int = {3: {0: 0}, 4: {0: 1}, 5: {0: 2}}[5][0]
4 | # FINAL: x -> [-inf, inf]; z -> [0, 2]
5 |
--------------------------------------------------------------------------------
/src/lyra/unittests/assumption/type+wordset/assume2.py:
--------------------------------------------------------------------------------
1 |
2 | # INITIAL: 3:(String, {'#', '.'})
3 | sep: str = input()
4 | if sep == '.' or sep == '#':
5 | pass
6 | else:
7 | raise ValueError
8 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/indexing3/three.py:
--------------------------------------------------------------------------------
1 |
2 | three: List[List[int]] = [[1], [1, 2], [1, 2, 3]]
3 | # FINAL: len(three) -> [3, 3]; three -> 0@[1, 1], 1@[1, 2], 2@[1, 3], _@⊥
4 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/summarization/dictionary8c.py:
--------------------------------------------------------------------------------
1 |
2 | x: int = int(input())
3 | z: int = {3: {0: 0}, 4: {0: 1}, 5: {0: 2}}[5][0]
4 | # FINAL: x -> [-inf, inf]; z -> [0, 2]
5 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/sign/backward/assignment.py:
--------------------------------------------------------------------------------
1 |
2 | a: int = int(input())
3 | # STATE: a -> >0
4 | a -= 1
5 | # STATE: a -> ≥0
6 | if a < 0:
7 | # STATE: a -> ⊥
8 | raise ValueError
9 |
--------------------------------------------------------------------------------
/docs/apidoc.sh:
--------------------------------------------------------------------------------
1 | sphinx-apidoc -f -P -E -M -o . ../src/lyra ../setup.py ../src/lyra/abstract_domains/container ../src/lyra/engine/container ../src/lyra/visualization ../src/lyra/tests ../src/lyra/unittests
2 |
--------------------------------------------------------------------------------
/src/lyra/unittests/assumption/type+alphabet/assume2.py:
--------------------------------------------------------------------------------
1 |
2 | # INITIAL: 3:(String, (∅, {'#', '.'}))
3 | sep: str = input()
4 | if sep == '.' or sep == '#':
5 | pass
6 | else:
7 | raise ValueError
8 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/indexing3/list_of_range2.py:
--------------------------------------------------------------------------------
1 |
2 | T: int = int(input())
3 | L: List[int] = list(range(T))
4 | # FINAL: L -> _@[0, inf]; T -> [-inf, inf]; len(L) -> [0, inf]
5 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/indexing3/set_to_list.py:
--------------------------------------------------------------------------------
1 |
2 | S: Set[int] = {1, 2, 3}
3 | M: List[int] = list(S)
4 | # FINAL: M -> _@[1, 3]; S -> [1, 3]; len(M) -> [3, 3]; len(S) -> [3, 3]
5 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/summarization/list_of_range2.py:
--------------------------------------------------------------------------------
1 |
2 | T: int = int(input())
3 | L: List[int] = list(range(T))
4 | # FINAL: L -> [0, inf]; T -> [-inf, inf]; len(L) -> [0, inf]
5 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/summarization/set_to_list.py:
--------------------------------------------------------------------------------
1 |
2 | S: Set[int] = {1, 2, 3}
3 | M: List[int] = list(S)
4 | #STATE: M -> [1, 3]; S -> [1, 3]; len(M) -> [3, 3]; len(S) -> [3, 3]
5 |
--------------------------------------------------------------------------------
/src/lyra/tests/container/dict_simple_example.py:
--------------------------------------------------------------------------------
1 |
2 | value: int = input()
3 |
4 | example: Dict[str, int] = {"a": 0, "b": 1, "c": 2}
5 | example["a"]: int = value
6 | i: int = example["a"]
7 |
8 | print(i)
9 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/composition.py:
--------------------------------------------------------------------------------
1 |
2 | def f(x: int) -> int:
3 | return x + 1
4 |
5 | def g(x: int) -> int:
6 | return x - 1
7 |
8 | z: int = g(f(10))
9 | # FINAL: z -> [10, 10]
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/outside.py:
--------------------------------------------------------------------------------
1 |
2 | def f(x: int) -> int:
3 | return x + b
4 |
5 | a: int = 3
6 | b: int = 4
7 | c: int = f(a)
8 | # FINAL: a -> [3, 3]; b -> [4, 4]; c -> [7, 7]
9 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/octagon/interval_assume_fallback.py:
--------------------------------------------------------------------------------
1 | x = int(input())
2 | a = 0
3 | b = 3
4 |
5 | if a + b + x > 0:
6 | a = x
7 |
8 | if a * x > 0:
9 | a = x
10 |
11 | print(a)
12 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/summarization/adding.py:
--------------------------------------------------------------------------------
1 |
2 | D: Dict[Tuple[int, int], int] = {(1, 2): 3, (2, 1): 3}
3 | # FINAL: D -> [1, 3]; keys(D) -> [1, 2]; len(D) -> [2, 2]; values(D) -> [3, 3]
4 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/sign/forward/while.py:
--------------------------------------------------------------------------------
1 | # INITIAL: a -> ⊤
2 | a: int = 10
3 | # STATE: a -> >0
4 | while a > 0:
5 | # STATE: a -> >0
6 | a = a - 1
7 | # STATE: a -> ⊤
8 | # FINAL: a -> ≤0
9 |
--------------------------------------------------------------------------------
/src/lyra/unittests/assumption/type+quantity/division.py:
--------------------------------------------------------------------------------
1 |
2 | # INITIAL: 3:(Integer, ⊤), 5:(Integer, ≠0)
3 | a: int = int(input())
4 | # STATE: 5:(Integer, ≠0)
5 | b: int = int(input())
6 | c: int = a / b
7 | # FINAL: ε
8 |
--------------------------------------------------------------------------------
/src/lyra/unittests/assumption/type+wordset/must.py:
--------------------------------------------------------------------------------
1 |
2 | # INITIAL: 3:(String, {'abc', 'bcd', 'ccc'})
3 | a: str = input()
4 | if a == 'abc' or a == 'bcd' or a == 'ccc':
5 | pass
6 | else:
7 | raise ValueError
8 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/backward/assignment.py:
--------------------------------------------------------------------------------
1 |
2 | a: int = int(input())
3 | # STATE: a -> [-inf, 10]
4 | a -= 1
5 | # STATE: a -> [-inf, 9]
6 | if a > 9:
7 | # STATE: a -> ⊥
8 | raise ValueError
9 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/ifexpression.py:
--------------------------------------------------------------------------------
1 |
2 | a: int = -9
3 | b: bool = bool(input())
4 | c: int = 9
5 | x: int = a if b else c
6 | # FINAL: a -> [-9, -9]; b -> [0, 1]; c -> [9, 9]; x -> [-9, 9]
7 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/summarization/subscriptions5.py:
--------------------------------------------------------------------------------
1 |
2 | A: List[List[int]] = [[1], [1, 2]]
3 | B: List[int] = A[0]
4 | # FINAL: A -> [1, 2]; B -> [1, 2]; len(A) -> [2, 2]; len(B) -> [0, inf]
5 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/inR2.py:
--------------------------------------------------------------------------------
1 |
2 | x: int = 2
3 | # STATE: x -> [2, 2]
4 | if x in range(0):
5 | # STATE: x -> ⊥
6 | print(x)
7 | else:
8 | raise ValueError
9 | # FINAL: x -> ⊥
10 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/summarization/counting1.py:
--------------------------------------------------------------------------------
1 |
2 | D: Dict[int, List[int]] = {1: [1], 2: [1, 2], 3: [1, 2, 3]}
3 | # FINAL: D -> [1, 3]; keys(D) -> [1, 3]; len(D) -> [3, 3]; values(D) -> [1, 3]
4 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/summarization/dictionary9.py:
--------------------------------------------------------------------------------
1 |
2 | D: Dict[int, Dict[int, int]] = {0: {3 : 4}, 2: {10: 9}}
3 | # FINAL: D -> [0, 10]; keys(D) -> [0, 2]; len(D) -> [2, 2]; values(D) -> [3, 10]
4 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/summarization/subscriptions3.py:
--------------------------------------------------------------------------------
1 |
2 | done: List[bool] = [False, False, False]
3 | x: int = 3 if done[0] else -3
4 | # FINAL: done -> [0, 0]; len(done) -> [3, 3]; x -> [-3, -3]
5 |
--------------------------------------------------------------------------------
/src/lyra/unittests/usage/if.py:
--------------------------------------------------------------------------------
1 |
2 | x: int = int(input())
3 | y: int = int(input())
4 | # STATE: x -> U; y -> U; z -> W
5 | z: int = 1
6 | if y > x:
7 | z: int = y
8 | else:
9 | z: int = y * y
10 | print(z)
11 |
--------------------------------------------------------------------------------
/src/lyra/unittests/usage/unused.py:
--------------------------------------------------------------------------------
1 |
2 | x: bool = bool(input())
3 | y: bool = bool(input())
4 | # STATE: t -> N; x -> N; y -> U
5 | if x:
6 | t: bool = True
7 | else:
8 | t: bool = True
9 |
10 | print(y)
11 |
--------------------------------------------------------------------------------
/src/lyra/tests/container/dict_example.py:
--------------------------------------------------------------------------------
1 |
2 | value: int = input()
3 |
4 | example: Dict[str, int] = {"a": 0, "b": 1, "c": 2}
5 | key: str = "b"
6 | example[key]: int = value
7 | i: int = example["a"]
8 |
9 | print(i)
10 |
--------------------------------------------------------------------------------
/src/lyra/unittests/assumption/type+alphabet/must.py:
--------------------------------------------------------------------------------
1 |
2 | # INITIAL: 3:(String, ({'c'}, {'a', 'b', 'c', 'd'}))
3 | a: str = input()
4 | if a == 'abc' or a == 'bcd' or a == 'ccc':
5 | pass
6 | else:
7 | raise ValueError
8 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/inR1.py:
--------------------------------------------------------------------------------
1 |
2 | x: int = -9
3 | # STATE: x -> [-9, -9]
4 | if x in range(0):
5 | # STATE: x -> ⊥
6 | print(x)
7 | else:
8 | raise ValueError
9 | # FINAL: x -> ⊥
10 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/inR3.py:
--------------------------------------------------------------------------------
1 |
2 | x: int = -9
3 | # STATE: x -> [-9, -9]
4 | if x in range(3):
5 | # STATE: x -> ⊥
6 | print(x)
7 | else:
8 | raise ValueError
9 | # FINAL: x -> ⊥
10 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/indexing3/split1.py:
--------------------------------------------------------------------------------
1 |
2 | inp: str = input()
3 | stp: str = inp.rstrip().split()[0]
4 | # FINAL: inp -> _@[-inf, inf]; len(inp) -> [1, inf]; len(stp) -> [0, inf]; stp -> _@[-inf, inf]
5 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/summarization/creation1.py:
--------------------------------------------------------------------------------
1 |
2 | L: List[int] = list()
3 | for i in range(int(input())):
4 | L = L + [int(input())]
5 | # FINAL: L -> [-inf, inf]; i -> [-inf, inf]; len(L) -> [0, inf]
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/summarization/dictionary0.py:
--------------------------------------------------------------------------------
1 |
2 | D: Dict[int, int] = {1: 1, 2: 2}
3 | y: int = D[2]
4 | # FINAL: D -> [1, 2]; keys(D) -> [1, 2]; len(D) -> [2, 2]; values(D) -> [1, 2]; y -> [1, 2]
5 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/summarization/newline.py:
--------------------------------------------------------------------------------
1 |
2 | def newline(table: str) -> str:
3 | return table + '\n'
4 |
5 | result: str = newline('ABC')
6 | # FINAL: len(result) -> [4, 4]; result -> [-inf, inf]
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/summarization/split1.py:
--------------------------------------------------------------------------------
1 |
2 | inp: str = input()
3 | stp: str = inp.rstrip().split()[0]
4 | # FINAL: inp -> [-inf, inf]; len(inp) -> [1, inf]; len(stp) -> [0, inf]; stp -> [-inf, inf]
5 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/octagon/dead_branch.py:
--------------------------------------------------------------------------------
1 | x = int(input())
2 | a = 0
3 |
4 | a = a - 1
5 |
6 | if a > 0:
7 | a = x
8 | # STATE: ⊥
9 | else:
10 | x = a
11 |
12 | a = 2
13 |
14 | print(a - x)
15 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/octagon/straight.py:
--------------------------------------------------------------------------------
1 | x = int(input())
2 | y = int(input())
3 | a = x - 1
4 | b = a
5 |
6 | b += 10
7 |
8 | # STATE: b-a≤10, -b+a≤-10, x-a≤1, -x+a≤-1, x-b≤-9, -x+b≤9
9 |
10 | print(a - x)
11 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/octagon/while.py:
--------------------------------------------------------------------------------
1 | n = int(input())
2 | x = int(input())
3 | i = 0
4 |
5 | while i < n:
6 | x = i * 2 # BUG: should be x = x / 2
7 | i = i + 1
8 | else:
9 | x = -1
10 | print(x)
11 |
--------------------------------------------------------------------------------
/src/lyra/unittests/assumption/type+wordset/basic.py:
--------------------------------------------------------------------------------
1 |
2 | # INITIAL: 3:(String, {'abc', 'bcd'})
3 | a: str = input()
4 | if a == 'abc':
5 | print(a)
6 | elif a == 'bcd':
7 | print(a)
8 | else:
9 | raise ValueError
10 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/inR4.py:
--------------------------------------------------------------------------------
1 |
2 | x: int = 2
3 | # STATE: x -> [2, 2]
4 | if x in range(3):
5 | # STATE: x -> [2, 2]
6 | print(x)
7 | else:
8 | raise ValueError
9 | # FINAL: x -> [2, 2]
10 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/indexing3/creation1.py:
--------------------------------------------------------------------------------
1 |
2 | L: List[int] = list()
3 | for i in range(int(input())):
4 | L = L + [int(input())]
5 | # FINAL: L -> _@[-inf, inf]; i -> [-inf, inf]; len(L) -> [0, inf]
6 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/indexing3/creation2.py:
--------------------------------------------------------------------------------
1 |
2 | L: List[int] = list()
3 | for i in range(int(input())):
4 | L.append(int(input()))
5 | # FINAL: L -> _@[-inf, inf]; i -> [-inf, inf]; len(L) -> [0, inf]
6 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/indexing3/subscriptions5.py:
--------------------------------------------------------------------------------
1 |
2 | A: List[List[int]] = [[1], [1, 2]]
3 | B: List[int] = A[0]
4 | # FINAL: A -> 0@[1, 1], 1@[1, 2], _@⊥; B -> _@[1, 1]; len(A) -> [2, 2]; len(B) -> [0, inf]
5 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/summarization/creation2.py:
--------------------------------------------------------------------------------
1 |
2 | L: List[int] = list()
3 | for i in range(int(input())):
4 | L.append(int(input()))
5 | # FINAL: L -> [-inf, inf]; i -> [-inf, inf]; len(L) -> [0, inf]
6 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/inR5.py:
--------------------------------------------------------------------------------
1 |
2 | x: int = -9
3 | # STATE: x -> [-9, -9]
4 | if x in range(int(input())):
5 | # STATE: x -> ⊥
6 | print(x)
7 | else:
8 | raise ValueError
9 | # FINAL: x -> ⊥
10 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/indexing3/dictionary0.py:
--------------------------------------------------------------------------------
1 |
2 | D: Dict[int, int] = {1: 1, 2: 2}
3 | y: int = D[2]
4 | # FINAL: D -> 1@[1, 1], 2@[2, 2], _@⊥; keys(D) -> [1, 2]; len(D) -> [2, 2]; values(D) -> [1, 2]; y -> [2, 2]
5 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/indexing3/dictionary9.py:
--------------------------------------------------------------------------------
1 |
2 | D: Dict[int, Dict[int, int]] = {0: {3 : 4}, 2: {10: 9}}
3 | # FINAL: D -> 0@[3, 4], 2@[9, 10], _@⊥; keys(D) -> [0, 2]; len(D) -> [2, 2]; values(D) -> _@[3, 10]
4 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/summarization/counting2.py:
--------------------------------------------------------------------------------
1 |
2 | D: Dict[str, List[int]] = {'a': [1], 'b': [1, 2], 'c': [1, 2, 3]}
3 | # FINAL: D -> [-inf, inf]; keys(D) -> [-inf, inf]; len(D) -> [3, 3]; values(D) -> [1, 3]
4 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/inR6.py:
--------------------------------------------------------------------------------
1 |
2 | x: int = 2
3 | # STATE: x -> [2, 2]
4 | if x in range(int(input())):
5 | # STATE: x -> [2, 2]
6 | print(x)
7 | else:
8 | raise ValueError
9 | # FINAL: x -> [2, 2]
10 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/indexing3/subscriptions2.py:
--------------------------------------------------------------------------------
1 |
2 | done: List[bool] = [False, False, False]
3 | x: int = 3 if done[0] else -3
4 | # FINA: done -> 0@[0, 0], 1@[0, 0], 2@[0, 0], _@⊥; len(done) -> [3, 3]; x -> [-3, -3]
5 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/indexing3/subscriptions3.py:
--------------------------------------------------------------------------------
1 |
2 | done: List[bool] = [False, False, False]
3 | x: int = 3 if done[0] else -3
4 | # FINAL: done -> 0@[0, 0], 1@[0, 0], 2@[0, 0], _@⊥; len(done) -> [3, 3]; x -> [-3, -3]
5 |
--------------------------------------------------------------------------------
/src/lyra/unittests/assumption/type+range/five.py:
--------------------------------------------------------------------------------
1 |
2 | # INITIAL: 3:(String, [-inf, inf]), 5 * 5:(String, [-inf, inf]), 7:(String, [-inf, inf])
3 | x: str = input()
4 | for i in range(5):
5 | y: str = input()
6 | print(y)
7 | z: str = input()
8 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/backward/indexing3/subscriptions2a.py:
--------------------------------------------------------------------------------
1 |
2 | x: int = int(input())
3 | # STATE: x -> [2, 2]; z -> [-inf, inf]
4 | z: int = [0, 1, 2][x]
5 | # STATE: x -> [-inf, inf]; z -> [2, 2]
6 | if z != 2:
7 | raise ValueError
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/indexing3/adding.py:
--------------------------------------------------------------------------------
1 |
2 | D: Dict[Tuple[int, int], int] = {(1, 2): 3, (2, 1): 3}
3 | # FINAL: D -> (1, 2)@[3, 3], (2, 1)@[3, 3], _@⊥; keys(D) -> 0@[1, 2], 1@[1, 2], _@⊥; len(D) -> [2, 2]; values(D) -> [3, 3]
4 |
--------------------------------------------------------------------------------
/src/lyra/unittests/assumption/type+alphabet/basic.py:
--------------------------------------------------------------------------------
1 |
2 | # INITIAL: 3:(String, ({'b', 'c'}, {'a', 'b', 'c', 'd'}))
3 | a: str = input()
4 | if a == 'abc':
5 | print(a)
6 | elif a == 'bcd':
7 | print(a)
8 | else:
9 | raise ValueError
10 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/backward/indexing3/subscriptions2b.py:
--------------------------------------------------------------------------------
1 |
2 | x: int = int(input())
3 | # STATE: x -> [2, 2]; z -> [-inf, inf]
4 | z: int = {0: 0, 1: 1, 2: 2}[x]
5 | # STATE: x -> [-inf, inf]; z -> [2, 2]
6 | if z != 2:
7 | raise ValueError
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/backward/summarization/subscriptions2a.py:
--------------------------------------------------------------------------------
1 |
2 | x: int = int(input())
3 | # STATE: x -> [-inf, inf]; z -> [-inf, inf]
4 | z: int = [0, 1, 2][x]
5 | # STATE: x -> [-inf, inf]; z -> [2, 2]
6 | if z != 2:
7 | raise ValueError
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/indexing3/counting1.py:
--------------------------------------------------------------------------------
1 |
2 | D: Dict[int, List[int]] = {1: [1], 2: [1, 2], 3: [1, 2, 3]}
3 | # FINAL: D -> 1@[1, 1], 2@[1, 2], 3@[1, 3], _@⊥; keys(D) -> [1, 3]; len(D) -> [3, 3]; values(D) -> 0@[1, 1], _@[2, 3]
4 |
--------------------------------------------------------------------------------
/docs/html/.buildinfo:
--------------------------------------------------------------------------------
1 | # Sphinx build info version 1
2 | # This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
3 | config: f8628857fb807ea3dac642250539e4bd
4 | tags: 645f666f9bcd5a90fca523b33c5a78b7
5 |
--------------------------------------------------------------------------------
/src/lyra/tests/container/dict_if_example.py:
--------------------------------------------------------------------------------
1 |
2 | key: str = input()
3 | example: Dict[str, int] = {"a": 0, "b": 1, "c": 2}
4 | thresh: int = 1
5 | if example[key] > thresh:
6 | ret: bool = True
7 | else:
8 | ret: bool = False
9 |
10 | print(ret)
11 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/backward/indexing3/subscriptions0.py:
--------------------------------------------------------------------------------
1 |
2 | x: int = int(input())
3 | # STATE: x -> [2, 2]; z -> [-inf, inf]
4 | z: int = {0: 0, 1: 1, 2: x}[2]
5 | # STATE: x -> [-inf, inf]; z -> [2, 2]
6 | if z != 2:
7 | raise ValueError
8 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/summarization/inL8.py:
--------------------------------------------------------------------------------
1 |
2 | L: List[int] = [0, 1, 2]
3 | x: int = -9
4 | # STATE: L -> [0, 2]; len(L) -> [3, 3]; x -> [-9, -9]
5 | for x in L:
6 | print(x)
7 | # FINAL: L -> [0, 2]; len(L) -> [3, 3]; x -> [-9, 2]
8 |
--------------------------------------------------------------------------------
/src/lyra/unittests/usage/dataframes/index.py:
--------------------------------------------------------------------------------
1 | import pandas as pd
2 |
3 | df: pd.DataFrame = pd.read_csv("...")
4 | a: int = input()
5 |
6 |
7 | df.index = a
8 | print(df.index)
9 | df.index = 1
10 | df.head()
11 | df.index = 1
12 | df["A"] = 1
13 |
14 |
--------------------------------------------------------------------------------
/src/lyra/unittests/usage/if2.py:
--------------------------------------------------------------------------------
1 |
2 | # INITIAL: x -> N; y -> W; z -> W
3 | x: int = int(input())
4 | y: int = int(input())
5 | z: int = int(input())
6 | # STATE: x -> N; y -> U; z -> U
7 | if 1 < y < 3 or y < 5 and True:
8 | z: int = y
9 | print(z)
10 |
--------------------------------------------------------------------------------
/src/lyra/unittests/usage/tricky.py:
--------------------------------------------------------------------------------
1 |
2 | x: bool = bool(input())
3 | # STATE: x -> U; y -> W
4 | y: bool = bool(input())
5 | if x:
6 | x: bool = x and y
7 | y: bool = False
8 | if x:
9 | x: bool = x and y
10 | y: bool = False
11 | print(y)
12 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/backward/indexing3/subscriptions1c.py:
--------------------------------------------------------------------------------
1 |
2 | x: int = int(input())
3 | # STATE: x -> [-inf, inf]; z -> [-inf, inf]
4 | z: int = [[0], [1], [x]][2][0]
5 | # STATE: x -> [-inf, inf]; z -> [2, 2]
6 | if z != 2:
7 | raise ValueError
8 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/backward/summarization/subscriptions2b.py:
--------------------------------------------------------------------------------
1 |
2 | x: int = int(input())
3 | # STATE: x -> [-inf, inf]; z -> [-inf, inf]
4 | z: int = {0: 0, 1: 1, 2: 2}[x]
5 | # STATE: x -> [-inf, inf]; z -> [2, 2]
6 | if z != 2:
7 | raise ValueError
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/conditional2.py:
--------------------------------------------------------------------------------
1 |
2 | # INITIAL: a -> [-inf, inf]; b -> [-inf, inf]
3 | a: int = int(input())
4 | # STATE: a -> [-inf, inf]; b -> [-inf, inf]
5 | b: int = 1 if 1 <= a <= 9 else 2
6 | # FINAL: a -> [-inf, inf]; b -> [1, 2]
7 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/indexing3/lengths.py:
--------------------------------------------------------------------------------
1 |
2 | w: int = len([1, 2, 3, 4, 5])
3 | x: int = len({1, 2, 3})
4 | y: int = len(('a', 3))
5 | z: int = len({'a': 1, 'b': 2, 'c': 3, 'd': 4})
6 | # FINAL: w -> [5, 5]; x -> [3, 3]; y -> [2, 2]; z -> [4, 4]
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/summarization/weak2.py:
--------------------------------------------------------------------------------
1 |
2 | D: Dict[int, int] = {1: 1, 2: 2, 3: 3, 4: 4}
3 | x: int = int(input())
4 | D[x] = 5
5 | # FINAL: D -> [-inf, inf]; keys(D) -> [-inf, inf]; len(D) -> [4, 5]; values(D) -> [1, 5]; x -> [-inf, inf]
6 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/backward/indexing3/subscriptions1f.py:
--------------------------------------------------------------------------------
1 |
2 | x: int = int(input())
3 | # STATE: x -> [2, 2]; z -> [-inf, inf]
4 | z: int = {0: [0], 1: [1], 2: [x]}[2][0]
5 | # STATE: x -> [-inf, inf]; z -> [2, 2]
6 | if z != 2:
7 | raise ValueError
8 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/backward/summarization/subscriptions0.py:
--------------------------------------------------------------------------------
1 |
2 | x: int = int(input())
3 | # STATE: x -> [-inf, inf]; z -> [-inf, inf]
4 | z: int = {0: 0, 1: 1, 2: x}[2]
5 | # STATE: x -> [-inf, inf]; z -> [2, 2]
6 | if z != 2:
7 | raise ValueError
8 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/backward/summarization/subscriptions1c.py:
--------------------------------------------------------------------------------
1 |
2 | x: int = int(input())
3 | # STATE: x -> [-inf, inf]; z -> [-inf, inf]
4 | z: int = [[0], [1], [x]][2][0]
5 | # STATE: x -> [-inf, inf]; z -> [2, 2]
6 | if z != 2:
7 | raise ValueError
8 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/indexing3/newline.py:
--------------------------------------------------------------------------------
1 |
2 | def newline(table: str) -> str:
3 | return table + '\n'
4 |
5 | result: str = newline('ABC')
6 | # FINAL: len(result) -> [4, 4]; result -> 0@[-inf, inf], 1@[-inf, inf], 2@[-inf, inf], _@[-inf, inf]
7 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/summarization/lengths.py:
--------------------------------------------------------------------------------
1 |
2 | w: int = len([1, 2, 3, 4, 5])
3 | x: int = len({1, 2, 3})
4 | y: int = len(('a', 3))
5 | z: int = len({'a': 1, 'b': 2, 'c': 3, 'd': 4})
6 | # FINAL: w -> [5, 5]; x -> [3, 3]; y -> [2, 2]; z -> [4, 4]
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/indexing3/counting2.py:
--------------------------------------------------------------------------------
1 |
2 | D: Dict[str, List[int]] = {'a': [1], 'b': [1, 2], 'c': [1, 2, 3]}
3 | # FINAL: D -> "a"@[1, 1], "b"@[1, 2], "c"@[1, 3], _@⊥; keys(D) -> 0@[-inf, inf], _@⊥; len(D) -> [3, 3]; values(D) -> 0@[1, 1], _@[2, 3]
4 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/summarization/subscriptionsD.py:
--------------------------------------------------------------------------------
1 |
2 | L: List[Dict[int, int]] = [{0: 1}, {2: 3}, {4: 5}]
3 | r: Dict[int, int] = L[1]
4 | # FINAL: L -> [0, 5]; keys(r) -> [0, 5]; len(L) -> [3, 3]; len(r) -> [0, inf]; r -> [0, 5]; values(r) -> [0, 5]
5 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/summarization/weak1.py:
--------------------------------------------------------------------------------
1 |
2 | D: Dict[int, int] = {1: 1, 2: 2, 3: 3, 4: 4}
3 | x: int = int(input())
4 | y: int = D[x]
5 | # FINAL: D -> [1, 4]; keys(D) -> [1, 4]; len(D) -> [4, 4]; values(D) -> [1, 4]; x -> [-inf, inf]; y -> [1, 4]
6 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/while.py:
--------------------------------------------------------------------------------
1 |
2 | # INITIAL: x -> [-inf, inf]
3 | x: int = 0
4 | # STATE: x -> [0, 0]
5 | while x < 9: # LOOP: x -> [0, inf]
6 | # STATE: x -> [0, 8]
7 | x += 1
8 | # STATE: x -> [1, 9]
9 | # FINAL: x -> [9, inf]
10 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/backward/indexing3/subscriptions1h.py:
--------------------------------------------------------------------------------
1 |
2 | x: int = int(input())
3 | # STATE: x -> [2, 2]; z -> [-inf, inf]
4 | z: int = {3: {0: 0}, 4: {0: 1}, 5: {0: x}}[5][0]
5 | # STATE: x -> [-inf, inf]; z -> [2, 2]
6 | if z != 2:
7 | raise ValueError
8 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/backward/summarization/subscriptions1f.py:
--------------------------------------------------------------------------------
1 |
2 | x: int = int(input())
3 | # STATE: x -> [-inf, inf]; z -> [-inf, inf]
4 | z: int = {0: [0], 1: [1], 2: [x]}[2][0]
5 | # STATE: x -> [-inf, inf]; z -> [2, 2]
6 | if z != 2:
7 | raise ValueError
8 |
--------------------------------------------------------------------------------
/src/lyra/unittests/usage/while.py:
--------------------------------------------------------------------------------
1 |
2 | n: int = int(input())
3 | x: int = int(input())
4 | i: int = 0
5 | # STATE: i -> N; n -> N; x -> W
6 | while i < n:
7 | x: int = i / 2 # BUG: should be x = x / 2
8 | i: int = i + 1
9 | else:
10 | x: int = -1
11 | print(x)
12 |
--------------------------------------------------------------------------------
/src/lyra/unittests/assumption/type+sign+interval+stringset/stringlist.py:
--------------------------------------------------------------------------------
1 |
2 | row: List[str] = list()
3 | for i in range(3): # LOOP: i -> Integer ⋅ ⊤ ⋅ [-inf, inf] ⋅ ⊤; len(row) -> [0, inf] ⋅ [0, inf] ⋅ [0, inf] ⋅ [0, inf]; row -> String ⋅ ⊤ ⋅ [-inf, inf] ⋅ {'A'}
4 | row.append('A')
5 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/backward/summarization/subscriptions1h.py:
--------------------------------------------------------------------------------
1 |
2 | x: int = int(input())
3 | # STATE: x -> [-inf, inf]; z -> [-inf, inf]
4 | z: int = {3: {0: 0}, 4: {0: 1}, 5: {0: x}}[5][0]
5 | # STATE: x -> [-inf, inf]; z -> [2, 2]
6 | if z != 2:
7 | raise ValueError
8 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/indexing3/weak2.py:
--------------------------------------------------------------------------------
1 |
2 | D: Dict[int, int] = {1: 1, 2: 2, 3: 3, 4: 4}
3 | x: int = int(input())
4 | D[x] = 5
5 | # FINAL: D -> 1@[1, 5], 2@[2, 5], 3@[3, 5], _@[4, 5]; keys(D) -> [-inf, inf]; len(D) -> [4, 5]; values(D) -> [1, 5]; x -> [-inf, inf]
6 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/backward/call.py:
--------------------------------------------------------------------------------
1 |
2 | def f(x: int) -> int:
3 | return x - 1
4 |
5 | a: int = int(input())
6 | # STATE: a -> [1, inf]; c -> [-inf, inf]
7 | c: int = f(a)
8 | # STATE: a -> [-inf, inf]; c -> [0, inf]
9 |
10 | if c < 0:
11 | raise ValueError
12 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/indexing3/dictionary8b.py:
--------------------------------------------------------------------------------
1 |
2 | x: int = int(input())
3 | d: Dict[int, int] = {3: {0: 0}, 4: {0: 1}, 5: {0: 2}}[5]
4 | z: int = d[0]
5 | # FINAL: d -> 0@[0, 2], _@⊥; keys(d) -> [0, 0]; len(d) -> [1, 1]; values(d) -> [0, 2]; x -> [-inf, inf]; z -> [0, 2]
6 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/summarization/dictionary2.py:
--------------------------------------------------------------------------------
1 |
2 | d0: Dict[int, int] = {0 : 0}
3 | d1: Dict[int, Dict[int, int]] = dict()
4 | # FINAL: d0 -> [0, 0]; d1 -> ⊥; keys(d0) -> [0, 0]; keys(d1) -> ⊥; len(d0) -> [1, 1]; len(d1) -> [0, 0]; values(d0) -> [0, 0]; values(d1) -> ⊥
5 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/summarization/dictionary8b.py:
--------------------------------------------------------------------------------
1 |
2 | x: int = int(input())
3 | d: Dict[int, int] = {3: {0: 0}, 4: {0: 1}, 5: {0: 2}}[5]
4 | z: int = d[0]
5 | # FINAL: d -> [0, 2]; keys(d) -> [0, 2]; len(d) -> [1, inf]; values(d) -> [0, 2]; x -> [-inf, inf]; z -> [0, 2]
6 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/summarization/inL7.py:
--------------------------------------------------------------------------------
1 |
2 | L: List[int] = list()
3 | x: int = -9
4 | # STATE: L -> ⊥; len(L) -> [0, 0]; x -> [-9, -9]
5 | for x in L:
6 | # STATE: L -> ⊥; len(L) -> [0, 0]; x -> ⊥
7 | print(x)
8 | # FINAL: L -> ⊥; len(L) -> [0, 0]; x -> [-9, -9]
9 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/summarization/weak4.py:
--------------------------------------------------------------------------------
1 |
2 | D: Dict[int, int] = {1: 1, 2: 2, 3: 3, 4: 4}
3 | x: int = int(input())
4 | if x < 3:
5 | raise ValueError
6 | D[x] = 5
7 | # FINAL: D -> [1, inf]; keys(D) -> [1, inf]; len(D) -> [4, 5]; values(D) -> [1, 5]; x -> [3, inf]
8 |
--------------------------------------------------------------------------------
/src/lyra/unittests/assumption/type+range/branch.py:
--------------------------------------------------------------------------------
1 |
2 | # INITIAL: 3:(Integer, [-inf, inf]), 5:(String, [-inf, inf]), 9:(String, [-inf, inf])
3 | T: int = int(input())
4 | if T < 10:
5 | a: str = input()
6 | T: int = T + 1
7 | else:
8 | b: int = int(input())
9 | c: str = input()
10 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/backward/double.py:
--------------------------------------------------------------------------------
1 |
2 | def f(x: int) -> int:
3 | return x - 1
4 |
5 | a: int = int(input())
6 | # STATE: a -> [2, inf]; c -> [-inf, inf]
7 | c: int = f(f(a))
8 | # STATE: a -> [-inf, inf]; c -> [0, inf]
9 |
10 | if c < 0:
11 | raise ValueError
12 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/backward/summarization/list0.py:
--------------------------------------------------------------------------------
1 |
2 | L: List[int] = list()
3 | for i in range(int(input())):
4 | L.append(int(input()))
5 | # STATE: L -> [-inf, inf]; i -> [-inf, inf]; len(L) -> [3, inf]; x -> [-inf, inf]
6 | x: int = L[2]
7 | if x < 0:
8 | raise ValueError
9 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/backward/summarization/list2.py:
--------------------------------------------------------------------------------
1 |
2 | y: int = int(input())
3 | # STATE: len(x) -> [0, inf]; x -> [-inf, inf]; y -> [-inf, inf]
4 | x: List[int] = [y, 1, 2]
5 | # STATE: len(x) -> [1, inf]; x -> [-inf, inf]; y -> [-inf, inf]
6 | if x[0] != 0:
7 | raise ValueError
8 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/indexing3/dictionary2.py:
--------------------------------------------------------------------------------
1 |
2 | d0: Dict[int, int] = {0 : 0}
3 | d1: Dict[int, Dict[int, int]] = dict()
4 | # FINAL: d0 -> 0@[0, 0], _@⊥; d1 -> _@⊥; keys(d0) -> [0, 0]; keys(d1) -> ⊥; len(d0) -> [1, 1]; len(d1) -> [0, 0]; values(d0) -> [0, 0]; values(d1) -> ⊥
5 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/indexing3/inL7.py:
--------------------------------------------------------------------------------
1 |
2 | L: List[int] = list()
3 | x: int = -9
4 | # STATE: L -> _@⊥; len(L) -> [0, 0]; x -> [-9, -9]
5 | for x in L:
6 | # STATE: L -> _@⊥; len(L) -> [0, 0]; x -> ⊥
7 | print(x)
8 | # FINAL: L -> _@⊥; len(L) -> [0, 0]; x -> [-9, -9]
9 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/indexing3/subscriptionsD.py:
--------------------------------------------------------------------------------
1 |
2 | L: List[Dict[int, int]] = [{0: 1}, {2: 3}, {4: 5}]
3 | r: Dict[int, int] = L[1]
4 | # FINAL: L -> 0@[0, 1], 1@[2, 3], 2@[4, 5], _@⊥; keys(r) -> [2, 3]; len(L) -> [3, 3]; len(r) -> [0, inf]; r -> _@[2, 3]; values(r) -> [2, 3]
5 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/indexing3/weak1.py:
--------------------------------------------------------------------------------
1 |
2 | D: Dict[int, int] = {1: 1, 2: 2, 3: 3, 4: 4}
3 | x: int = int(input())
4 | y: int = D[x]
5 | # FINAL: D -> 1@[1, 1], 2@[2, 2], 3@[3, 3], _@[4, 4]; keys(D) -> [1, 4]; len(D) -> [4, 4]; values(D) -> [1, 4]; x -> [-inf, inf]; y -> [1, 4]
6 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/backward/indexing3/list2.py:
--------------------------------------------------------------------------------
1 |
2 | y: int = int(input())
3 | # STATE: len(x) -> [0, inf]; x -> _@[-inf, inf]; y -> [0, 0]
4 | x: List[int] = [y, 1, 2]
5 | # STATE: len(x) -> [1, inf]; x -> 0@[0, 0], _@[-inf, inf]; y -> [-inf, inf]
6 | if x[0] != 0:
7 | raise ValueError
8 |
--------------------------------------------------------------------------------
/src/lyra/unittests/assumption/type+range/dependencies.py:
--------------------------------------------------------------------------------
1 |
2 | # INITIAL: 2 * [6:(Float, [-inf, inf]), ★]
3 | b: float = 0
4 | for i in range(2):
5 | if b > 0:
6 | a: int = int(input())
7 | if a < b:
8 | raise ValueError
9 | b: float = float(input())
10 | # FINAL: ε
11 |
--------------------------------------------------------------------------------
/src/lyra/unittests/assumption/type+sign+interval+stringset/abcd.py:
--------------------------------------------------------------------------------
1 |
2 | abc: str = 'ABC'
3 | abcd: str = abc + 'D'
4 | # FINAL: abc -> String ⋅ ⊤ ⋅ [-inf, inf] ⋅ {'ABC'}; abcd -> String ⋅ ⊤ ⋅ [-inf, inf] ⋅ {'ABCD'}; len(abc) -> [0, inf] ⋅ [3, 3] ⋅ [3, 3] ⋅ [3, 3]; len(abcd) -> [0, inf] ⋅ [4, 4] ⋅ [4, 4] ⋅ [4, 4]
5 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/backward/indexing3/list0.py:
--------------------------------------------------------------------------------
1 |
2 | L: List[int] = list()
3 | for i in range(int(input())):
4 | L.append(int(input()))
5 | # STATE: L -> 2@[0, inf], _@[-inf, inf]; i -> [-inf, inf]; len(L) -> [3, inf]; x -> [-inf, inf]
6 | x: int = L[2]
7 | if x < 0:
8 | raise ValueError
9 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/indexing3/inL8.py:
--------------------------------------------------------------------------------
1 |
2 | L: List[int] = [0, 1, 2]
3 | x: int = -9
4 | # STATE: L -> 0@[0, 0], 1@[1, 1], 2@[2, 2], _@⊥; len(L) -> [3, 3]; x -> [-9, -9]
5 | for x in L:
6 | print(x)
7 | # FINAL: L -> 0@[0, 0], 1@[1, 1], 2@[2, 2], _@⊥; len(L) -> [3, 3]; x -> [-9, 2]
8 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/summarization/weak3.py:
--------------------------------------------------------------------------------
1 |
2 | D: Dict[int, int] = {1: 1, 2: 2, 3: 3, 4: 4}
3 | x: int = int(input())
4 | if x < 3:
5 | raise ValueError
6 | y: int = D[x]
7 | # FINAL: D -> [1, 4]; keys(D) -> [1, 4]; len(D) -> [4, 4]; values(D) -> [1, 4]; x -> [3, inf]; y -> [1, 4]
8 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/octagon/implicit_bound.py:
--------------------------------------------------------------------------------
1 | x = int(input())
2 | a = 0
3 |
4 | if x < 3:
5 | a = x # this implicitly upper bounds a, since x < 3 when assignment happens
6 |
7 | pass # without this, comment is interpreted to be inside if :(
8 |
9 | # STATE: a≤2, -x+a≤0
10 |
11 | print(a)
12 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/indexing3/weak4.py:
--------------------------------------------------------------------------------
1 |
2 | D: Dict[int, int] = {1: 1, 2: 2, 3: 3, 4: 4}
3 | x: int = int(input())
4 | if x < 3:
5 | raise ValueError
6 | D[x] = 5
7 | # FINAL: D -> 1@[1, 1], 2@[2, 2], 3@[3, 5], _@[4, 5]; keys(D) -> [1, inf]; len(D) -> [4, 5]; values(D) -> [1, 5]; x -> [3, inf]
8 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/summarization/dictionary3.py:
--------------------------------------------------------------------------------
1 |
2 | d0: Dict[int, int] = {0 : -1}
3 | d1: Dict[int, Dict[int, int]] = {1: d0}
4 | # FINAL: d0 -> [-1, 0]; d1 -> [-1, 1]; keys(d0) -> [0, 0]; keys(d1) -> [1, 1]; len(d0) -> [1, 1]; len(d1) -> [1, 1]; values(d0) -> [-1, -1]; values(d1) -> [-1, 0]
5 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/summarization/dictionary5.py:
--------------------------------------------------------------------------------
1 |
2 | d0: Dict[int, int] = {0 : 1}
3 | d1: Dict[int, int] = dict()
4 | d1[d0[0]] = 2
5 | # FINAL: d0 -> [0, 1]; d1 -> [1, 2]; keys(d0) -> [0, 0]; keys(d1) -> [1, 1]; len(d0) -> [1, 1]; len(d1) -> [1, 1]; values(d0) -> [1, 1]; values(d1) -> [2, 2]
6 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/summarization/subscriptionsE.py:
--------------------------------------------------------------------------------
1 |
2 | D: Dict[int, Dict[int, int]] = {0: {1: 3}, 1: {1: 4}}
3 | r: Dict[int, int] = D[1]
4 | # FINAL: D -> [0, 4]; keys(D) -> [0, 1]; keys(r) -> [1, 4]; len(D) -> [2, 2]; len(r) -> [0, inf]; r -> [1, 4]; values(D) -> [1, 4]; values(r) -> [1, 4]
5 |
--------------------------------------------------------------------------------
/src/lyra/unittests/assumption/type+range/length.py:
--------------------------------------------------------------------------------
1 |
2 | # INITIAL: len([0, 0, 0]) * 5:(Integer, [0, inf])
3 | l: List[int] = [0, 0, 0]
4 | for i in range(len(l)): # LOOP: len(l) * 5:(Integer, [0, inf])
5 | v: int = int(input())
6 | if v < 0:
7 | raise ValueError
8 | l[i]: int = v
9 | # FINAL: ε
10 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/issue69.py:
--------------------------------------------------------------------------------
1 |
2 | # INITIAL: a -> [-inf, inf]
3 | a: bool = False
4 | # STATE: a -> [0, 0]
5 | if a:
6 | # STATE: a -> ⊥
7 | a = a
8 | # STATE: a -> ⊥
9 | else:
10 | # STATE: a -> [0, 0]
11 | a = a
12 | # STATE: a -> [0, 0]
13 | # FINAL: a -> [0, 0]
14 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/summarization/subscriptions6.py:
--------------------------------------------------------------------------------
1 |
2 | A: Dict[int, List[int]] = {1: [1], 2: [1, 2]}
3 | B: List[int] = A[1]
4 | C: List[int] = A[2]
5 | # FINAL: A -> [1, 2]; B -> [1, 2]; C -> [1, 2]; keys(A) -> [1, 2]; len(A) -> [2, 2]; len(B) -> [0, inf]; len(C) -> [0, inf]; values(A) -> [1, 2]
6 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/indexing3/dictionary5.py:
--------------------------------------------------------------------------------
1 |
2 | d0: Dict[int, int] = {0 : 1}
3 | d1: Dict[int, int] = dict()
4 | d1[d0[0]] = 2
5 | # FINAL: d0 -> 0@[1, 1], _@⊥; d1 -> 1@[2, 2], _@⊥; keys(d0) -> [0, 0]; keys(d1) -> [1, 1]; len(d0) -> [1, 1]; len(d1) -> [1, 1]; values(d0) -> [1, 1]; values(d1) -> [2, 2]
6 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/indexing3/symbolic.py:
--------------------------------------------------------------------------------
1 |
2 | x: int = int(input())
3 | y: int = int(input())
4 | z: int = int(input())
5 | d: Dict[int, int] = {x: 1, y: 2, z: 3}
6 | # FINAL: d -> _@[1, 3]; keys(d) -> [-inf, inf]; len(d) -> [3, 3]; values(d) -> [1, 3]; x -> [-inf, inf]; y -> [-inf, inf]; z -> [-inf, inf]
7 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/summarization/inL2.py:
--------------------------------------------------------------------------------
1 |
2 | L: List[int] = list()
3 | x: int = 2
4 | # STATE: L -> ⊥; len(L) -> [0, 0]; x -> [2, 2]
5 | if x in L:
6 | # STATE: L -> ⊥; len(L) -> [0, 0]; x -> ⊥
7 | print(x)
8 | else:
9 | raise ValueError
10 | # FINAL: L -> ⊥; len(L) -> [0, 0]; x -> ⊥
11 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/indexing3/dictionary3.py:
--------------------------------------------------------------------------------
1 |
2 | d0: Dict[int, int] = {0 : -1}
3 | d1: Dict[int, Dict[int, int]] = {1: d0}
4 | # FINAL: d0 -> 0@[-1, -1], _@⊥; d1 -> 1@[-1, 0], _@⊥; keys(d0) -> [0, 0]; keys(d1) -> [1, 1]; len(d0) -> [1, 1]; len(d1) -> [1, 1]; values(d0) -> [-1, -1]; values(d1) -> 0@[-1, -1], _@⊥
5 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/indexing3/inL1.py:
--------------------------------------------------------------------------------
1 |
2 | L: List[int] = list()
3 | x: int = -9
4 | # STATE: L -> _@⊥; len(L) -> [0, 0]; x -> [-9, -9]
5 | if x in L:
6 | # STATE: L -> _@⊥; len(L) -> [0, 0]; x -> ⊥
7 | print(x)
8 | else:
9 | raise ValueError
10 | # FINAL: L -> _@⊥; len(L) -> [0, 0]; x -> ⊥
11 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/indexing3/inL2.py:
--------------------------------------------------------------------------------
1 |
2 | L: List[int] = list()
3 | x: int = 2
4 | # STATE: L -> _@⊥; len(L) -> [0, 0]; x -> [2, 2]
5 | if x in L:
6 | # STATE: L -> _@⊥; len(L) -> [0, 0]; x -> ⊥
7 | print(x)
8 | else:
9 | raise ValueError
10 | # FINAL: L -> _@⊥; len(L) -> [0, 0]; x -> ⊥
11 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/summarization/inL1.py:
--------------------------------------------------------------------------------
1 |
2 | L: List[int] = list()
3 | x: int = -9
4 | # STATE: L -> ⊥; len(L) -> [0, 0]; x -> [-9, -9]
5 | if x in L:
6 | # STATE: L -> ⊥; len(L) -> [0, 0]; x -> ⊥
7 | print(x)
8 | else:
9 | raise ValueError
10 | # FINAL: L -> ⊥; len(L) -> [0, 0]; x -> ⊥
11 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/summarization/subscriptionsF.py:
--------------------------------------------------------------------------------
1 |
2 | D: Dict[int, Dict[int, List[int]]] = {0: {1: [3]}, 1: {1: [4]}}
3 | r: Dict[int, List[int]] = D[1]
4 | # FINAL: D -> [0, 4]; keys(D) -> [0, 1]; keys(r) -> [1, 4]; len(D) -> [2, 2]; len(r) -> [0, inf]; r -> [1, 4]; values(D) -> [1, 4]; values(r) -> [1, 4]
5 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/indexing3/weak3.py:
--------------------------------------------------------------------------------
1 |
2 | D: Dict[int, int] = {1: 1, 2: 2, 3: 3, 4: 4}
3 | x: int = int(input())
4 | if x < 3:
5 | raise ValueError
6 | y: int = D[x]
7 | # FINAL: D -> 1@[1, 1], 2@[2, 2], 3@[3, 3], _@[4, 4]; keys(D) -> [1, 4]; len(D) -> [4, 4]; values(D) -> [1, 4]; x -> [3, inf]; y -> [3, 4]
8 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/summarization/symbolic.py:
--------------------------------------------------------------------------------
1 |
2 | x: int = int(input())
3 | y: int = int(input())
4 | z: int = int(input())
5 | d: Dict[int, int] = {x: 1, y: 2, z: 3}
6 | # FINAL: d -> [-inf, inf]; keys(d) -> [-inf, inf]; len(d) -> [3, 3]; values(d) -> [1, 3]; x -> [-inf, inf]; y -> [-inf, inf]; z -> [-inf, inf]
7 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/indexing3/subscriptionsE.py:
--------------------------------------------------------------------------------
1 |
2 | D: Dict[int, Dict[int, int]] = {0: {1: 3}, 1: {1: 4}}
3 | r: Dict[int, int] = D[1]
4 | # FINAL: D -> 0@[1, 3], 1@[1, 4], _@⊥; keys(D) -> [0, 1]; keys(r) -> [1, 1]; len(D) -> [2, 2]; len(r) -> [1, 1]; r -> 1@[3, 4], _@⊥; values(D) -> 1@[3, 4], _@⊥; values(r) -> [1, 4]
5 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/summarization/subscriptions2.py:
--------------------------------------------------------------------------------
1 | x5: List[List[str]] = [["a", "b", "c"], ["d", "e", "f"]]
2 | # STATE: i -> [-inf, inf]; j -> [-inf, inf]; len(x5) -> [2, 2]; x5 -> [-inf, inf]
3 | for i in range(3):
4 | for j in range(2):
5 | if (x5[i][j] == '?' and (i < j)):
6 | x5[j][i]: str = ''
7 |
--------------------------------------------------------------------------------
/src/lyra/unittests/usage/dataframes/handcraft_example_1.py:
--------------------------------------------------------------------------------
1 | import pandas as pd
2 |
3 | # INITIAL: df -> {_ -> W}
4 | df: pd.DataFrame = pd.read_csv("...")
5 |
6 | # STATE: df -> {id -> N, t -> U, _ -> N}
7 | df.drop(['id'], axis=1, inplace=True)
8 |
9 | # STATE: df -> {t -> U, _ -> N}
10 | df["t"].head()
11 |
12 | # FINAL: df -> {_ -> N}
13 |
--------------------------------------------------------------------------------
/src/lyra/unittests/assumption/type+range/nested.py:
--------------------------------------------------------------------------------
1 |
2 | # INITIAL: 3:(String, [-inf, inf]), 10 * [6:(String, [-inf, inf]), 20 * 8:(String, [-inf, inf])]
3 | a: str = input()
4 | # STATE: 10 * [6:(String, [-inf, inf]), 20 * 8:(String, [-inf, inf])]
5 | for i in range(10):
6 | b: str = input()
7 | for j in range(20):
8 | c: str = input()
9 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/summarization/inL3.py:
--------------------------------------------------------------------------------
1 |
2 | L: List[int] = [0, 1, 2]
3 | x: int = -9
4 | # STATE: L -> [0, 2]; len(L) -> [3, 3]; x -> [-9, -9]
5 | if x in L:
6 | # STATE: L -> [0, 2]; len(L) -> [3, 3]; x -> ⊥
7 | print(x)
8 | else:
9 | raise ValueError
10 | # FINAL: L -> [0, 2]; len(L) -> [3, 3]; x -> ⊥
11 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/indexing3/subscriptionsF.py:
--------------------------------------------------------------------------------
1 |
2 | D: Dict[int, Dict[int, List[int]]] = {0: {1: [3]}, 1: {1: [4]}}
3 | r: Dict[int, List[int]] = D[1]
4 | # FINAL: D -> 0@[1, 3], 1@[1, 4], _@⊥; keys(D) -> [0, 1]; keys(r) -> [1, 1]; len(D) -> [2, 2]; len(r) -> [1, 1]; r -> 1@[3, 4], _@⊥; values(D) -> 1@[3, 4], _@⊥; values(r) -> [3, 4]
5 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/summarization/inL4.py:
--------------------------------------------------------------------------------
1 |
2 | L: List[int] = [0, 1, 2]
3 | x: int = 2
4 | # STATE: L -> [0, 2]; len(L) -> [3, 3]; x -> [2, 2]
5 | if x in L:
6 | # STATE: L -> [0, 2]; len(L) -> [3, 3]; x -> [2, 2]
7 | print(x)
8 | else:
9 | raise ValueError
10 | # FINAL: L -> [0, 2]; len(L) -> [3, 3]; x -> [2, 2]
11 |
--------------------------------------------------------------------------------
/src/lyra/unittests/usage/list.py:
--------------------------------------------------------------------------------
1 |
2 | x: int = int(input())
3 | y: int = int(input())
4 | # list1 -> (O@0:4), s -> O; x -> U; y -> N
5 | list1: List[int] = [1, x, 2, 3, 5, 8, y]
6 | s: int = 0
7 |
8 | s: int = s + list1[2]
9 | s: int = s + list1[1]
10 | s: int = s + list1[4]
11 | s: int = s + list1[3]
12 | s: int = s + list1[0]
13 |
14 | print(s)
15 |
--------------------------------------------------------------------------------
/docs/lyra.frontend.rst:
--------------------------------------------------------------------------------
1 | lyra\.frontend package
2 | ======================
3 |
4 | .. automodule:: lyra.frontend
5 | :members:
6 | :undoc-members:
7 | :show-inheritance:
8 |
9 | Submodules
10 | ----------
11 |
12 | .. automodule:: lyra.frontend.cfg_generator
13 | :members:
14 | :undoc-members:
15 | :show-inheritance:
16 |
17 |
18 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/indexing3/subscriptions6.py:
--------------------------------------------------------------------------------
1 |
2 | A: Dict[int, List[int]] = {1: [1], 2: [1, 2]}
3 | B: List[int] = A[1]
4 | C: List[int] = A[2]
5 | # FINAL: A -> 1@[1, 1], 2@[1, 2], _@⊥; B -> 0@[1, 1], _@⊥; C -> 0@[1, 1], _@[2, 2]; keys(A) -> [1, 2]; len(A) -> [2, 2]; len(B) -> [0, inf]; len(C) -> [0, inf]; values(A) -> 0@[1, 1], _@[2, 2]
6 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/sign/forward/filter.py:
--------------------------------------------------------------------------------
1 |
2 | x: int = int(input())
3 | y: int = int(input())
4 | z: int = int(input())
5 | if x < 0 or x > 10 or y < 2 or y > 10 or z < 3 or z > 5:
6 | raise ValueError
7 | print("")
8 | # STATE: x -> ≥0; y -> >0; z -> >0
9 | if z - x - y >= 0:
10 | # STATE: x -> ≥0; y -> >0; z -> >0
11 | print("Ok!")
12 |
--------------------------------------------------------------------------------
/src/lyra/unittests/usage/list_while.py:
--------------------------------------------------------------------------------
1 |
2 | x: int = int(input())
3 | y: int = int(input())
4 |
5 | list1: List[int] = [x, 2, 3, 5, 8, y]
6 |
7 | s: int = 0
8 |
9 | i: int = 0
10 | l: int = len(list1)
11 | l: int = l - 1
12 |
13 | while i <= l:
14 | i: int = i + 1
15 | s: int = s + list1[i] # bug: list1[0] is not summed up
16 |
17 | print(s)
18 |
--------------------------------------------------------------------------------
/src/lyra/unittests/assumption/type+alphabet/concatenation.py:
--------------------------------------------------------------------------------
1 |
2 | # INITIAL: 3:(String, (∅, {'a', 'b', 'c', 'd'})), 5:(String, (∅, {'a', 'b', 'c', 'd'}))
3 | b: str = input()
4 | # STATE: 5:(String, (∅, {'a', 'b', 'c', 'd'}))
5 | c: str = input()
6 | a: str = b + c
7 | if a == 'abc' or a == 'bcd' or a == 'ccc':
8 | pass
9 | else:
10 | raise ValueError
11 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/max2.py:
--------------------------------------------------------------------------------
1 |
2 | def max(x: int, y: int) -> int:
3 | if x > y:
4 | return x
5 | else:
6 | return y
7 |
8 | a: int = 10
9 | b: int = 20
10 | c: int = max(a, b)
11 | x: int = 0
12 | for i in range(c):
13 | x += 1
14 | # STATE: a -> [10, 10]; b -> [20, 20]; c -> [20, 20]; i -> [0, 19]; x -> [1, inf]
15 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/summarization/subscriptionsG.py:
--------------------------------------------------------------------------------
1 |
2 | D: Dict[int, Dict[Tuple[int, int], List[int]]] = {0: {(1, 2): [3]}, 1: {(1, 2): [4]}}
3 | r: Dict[Tuple[int, int], List[int]] = D[1]
4 | # FINAL: D -> [0, 4]; keys(D) -> [0, 1]; keys(r) -> [1, 4]; len(D) -> [2, 2]; len(r) -> [0, inf]; r -> [1, 4]; values(D) -> [1, 4]; values(r) -> [1, 4]
5 |
--------------------------------------------------------------------------------
/src/lyra/tests/container/BRCA_example.py:
--------------------------------------------------------------------------------
1 | col_indices: Dict[str, int] = input()
2 | items: List[str] = input()
3 |
4 | bx_ids: Dict[str,str] = {} # or other type
5 | key: str = ""
6 | # items[col_indices.values()] -> U
7 | for key in col_indices.keys():
8 | # items[col_indices[key]]-> U
9 | bx_ids[key]: str = items[col_indices[key]]
10 | print(bx_ids)
11 |
--------------------------------------------------------------------------------
/src/lyra/unittests/assumption/type+range/hamm.py:
--------------------------------------------------------------------------------
1 |
2 | # INITIAL: 3:(String, [-inf, inf]), 4:(String, [-inf, inf])
3 | seq1: str = input()
4 | seq2: str = input()
5 | hamm: int = 0
6 |
7 | if len(seq1) != len(seq2):
8 | raise ValueError
9 |
10 | for i in range(len(seq1)):
11 | if seq1[i] != seq2[i]:
12 | hamm: int = hamm + 1
13 |
14 | print(hamm)
15 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/sign/forward/conditional.py:
--------------------------------------------------------------------------------
1 | # INITIAL: a -> ⊤; b -> ⊤
2 | a: int = int(input())
3 | # STATE: a -> ⊤; b -> ⊤
4 | if 1 <= a <= 9:
5 | # STATE: a -> >0; b -> ⊤
6 | b: int = 0
7 | # STATE: a -> >0; b -> =0
8 | else:
9 | # STATE: a -> ⊤; b -> ⊤
10 | b: int = 2
11 | # STATE: a -> ⊤; b -> >0
12 | # FINAL: a -> ⊤; b -> ≥0
13 |
--------------------------------------------------------------------------------
/src/lyra/unittests/usage/demo3.py:
--------------------------------------------------------------------------------
1 |
2 | x: int = int(input())
3 | y: int = int(input())
4 | # STATE: a -> W; b -> N; x -> U; y -> N
5 | if 3 > x: # x decision
6 | # inside nested if only b is modified!
7 | if 2 > y: # y decision
8 | b: int = 10
9 | else:
10 | b: int = 20
11 | a: int = 10
12 | else:
13 | a: int = 20
14 | print(a)
15 |
--------------------------------------------------------------------------------
/docs/html/_sources/lyra.frontend.rst.txt:
--------------------------------------------------------------------------------
1 | lyra\.frontend package
2 | ======================
3 |
4 | .. automodule:: lyra.frontend
5 | :members:
6 | :undoc-members:
7 | :show-inheritance:
8 |
9 | Submodules
10 | ----------
11 |
12 | .. automodule:: lyra.frontend.cfg_generator
13 | :members:
14 | :undoc-members:
15 | :show-inheritance:
16 |
17 |
18 |
--------------------------------------------------------------------------------
/docs/lyra.engine.usage.rst:
--------------------------------------------------------------------------------
1 | lyra\.engine\.usage package
2 | ===========================
3 |
4 | .. automodule:: lyra.engine.usage
5 | :members:
6 | :undoc-members:
7 | :show-inheritance:
8 |
9 | Submodules
10 | ----------
11 |
12 | .. automodule:: lyra.engine.usage.usage_analysis
13 | :members:
14 | :undoc-members:
15 | :show-inheritance:
16 |
17 |
18 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/indexing3/inL9.py:
--------------------------------------------------------------------------------
1 |
2 | L: List[int] = list()
3 | for i in range(int(input())):
4 | L.append(int(input()))
5 | x: int = -9
6 | # STATE: L -> _@[-inf, inf]; i -> [-inf, inf]; len(L) -> [0, inf]; x -> [-9, -9]
7 | for x in L:
8 | print(x)
9 | # FINAL: L -> _@[-inf, inf]; i -> [-inf, inf]; len(L) -> [0, inf]; x -> [-inf, inf]
10 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/summarization/inL9.py:
--------------------------------------------------------------------------------
1 |
2 | L: List[int] = list()
3 | for i in range(int(input())):
4 | L.append(int(input()))
5 | x: int = -9
6 | # STATE: L -> [-inf, inf]; i -> [-inf, inf]; len(L) -> [0, inf]; x -> [-9, -9]
7 | for x in L:
8 | print(x)
9 | # FINAL: L -> [-inf, inf]; i -> [-inf, inf]; len(L) -> [0, inf]; x -> [-inf, inf]
10 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/summarization/keyval.py:
--------------------------------------------------------------------------------
1 |
2 | D: Dict[str, Dict[int, int]] = {'a': {1: 0}, 'b': {1: 1}, 'c': {1: 2}, 'd': {1: 3}}
3 | k: Set[str] = D.keys()
4 | z: Set[Dict[int, int]] = D.values()
5 | # FINAL: D -> [-inf, inf]; k -> [-inf, inf]; keys(D) -> [-inf, inf]; len(D) -> [4, 4]; len(k) -> [0, inf]; len(z) -> [0, inf]; values(D) -> [0, 3]; z -> [0, 3]
6 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/summarization/subscriptions7.py:
--------------------------------------------------------------------------------
1 |
2 | x: List[List[int]] = [[0], [0, 1], [0, 1, 2], [0, 1, 2, 3]]
3 | # STATE: len(x) -> [4, 4]; x -> [0, 3]; y -> [-inf, inf]; z -> [-inf, inf]
4 | y: int = x[3][3]
5 | # STATE: len(x) -> [4, 4]; x -> [0, 3]; y -> [0, 3]; z -> [-inf, inf]
6 | z: int = x[9][0]
7 | # FINAL: len(x) -> ⊥; x -> ⊥; y -> ⊥; z -> ⊥
8 |
--------------------------------------------------------------------------------
/src/lyra/unittests/assumption/type+range/repeat.py:
--------------------------------------------------------------------------------
1 |
2 | # INITIAL: 3:(Integer, [-inf, inf]), 3:(Integer, [-inf, inf]), 3.1 + 3.2 * 5:(Float, [-inf, 3.0]), 10:(String, [-inf, inf])
3 | x: int = int(input()) + int(input())
4 | for i in range(x):
5 | y: float = float(input())
6 | if y <= 3.0:
7 | print(y)
8 | else:
9 | raise ValueError
10 | z: str = input()
11 |
--------------------------------------------------------------------------------
/src/lyra/unittests/assumption/type+sign+interval+stringset/grade2gpa.py:
--------------------------------------------------------------------------------
1 |
2 | grade2gpa: Dict[str, float] = { 'A': 4.0, 'B': 3.0, 'C': 2.0, 'D': 1.0, 'F': 0.0 }
3 | # FINAL: grade2gpa -> String ⋅ ⊤ ⋅ [-inf, inf] ⋅ ⊤; keys(grade2gpa) -> String ⋅ ⊤ ⋅ [-inf, inf] ⋅ {'A', 'B', 'C', 'D', 'F'}; len(grade2gpa) -> [0, inf] ⋅ [5, 5] ⋅ [5, 5] ⋅ [5, 5]; values(grade2gpa) -> Float ⋅ ≥0 ⋅ [0.0, 4.0] ⋅ ⊤
4 |
--------------------------------------------------------------------------------
/docs/lyra.engine.string.rst:
--------------------------------------------------------------------------------
1 | lyra\.engine\.string package
2 | ============================
3 |
4 | .. automodule:: lyra.engine.string
5 | :members:
6 | :undoc-members:
7 | :show-inheritance:
8 |
9 | Submodules
10 | ----------
11 |
12 | .. automodule:: lyra.engine.string.character_analysis
13 | :members:
14 | :undoc-members:
15 | :show-inheritance:
16 |
17 |
18 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/filter.py:
--------------------------------------------------------------------------------
1 |
2 | x: int = int(input())
3 | y: int = int(input())
4 | z: int = int(input())
5 | if x < 0 or x > 10 or y < 2 or y > 10 or z < 3 or z > 5:
6 | raise ValueError
7 | print("")
8 | # STATE: x -> [0, 10]; y -> [2, 10]; z -> [3, 5]
9 | if z - x - y >= 0:
10 | # STATE: x -> [0, 3]; y -> [2, 5]; z -> [3, 5]
11 | print("Ok!")
12 |
--------------------------------------------------------------------------------
/docs/html/_sources/lyra.engine.usage.rst.txt:
--------------------------------------------------------------------------------
1 | lyra\.engine\.usage package
2 | ===========================
3 |
4 | .. automodule:: lyra.engine.usage
5 | :members:
6 | :undoc-members:
7 | :show-inheritance:
8 |
9 | Submodules
10 | ----------
11 |
12 | .. automodule:: lyra.engine.usage.usage_analysis
13 | :members:
14 | :undoc-members:
15 | :show-inheritance:
16 |
17 |
18 |
--------------------------------------------------------------------------------
/docs/lyra.engine.liveness.rst:
--------------------------------------------------------------------------------
1 | lyra\.engine\.liveness package
2 | ==============================
3 |
4 | .. automodule:: lyra.engine.liveness
5 | :members:
6 | :undoc-members:
7 | :show-inheritance:
8 |
9 | Submodules
10 | ----------
11 |
12 | .. automodule:: lyra.engine.liveness.liveness_analysis
13 | :members:
14 | :undoc-members:
15 | :show-inheritance:
16 |
17 |
18 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/backward/summarization/dictionary0.py:
--------------------------------------------------------------------------------
1 |
2 | D: Dict[int, int] = {0: 0, 1: 1, 2: 2}
3 | # STATE: D -> [-inf, inf]; keys(D) -> [-inf, inf]; len(D) -> [1, inf]; values(D) -> [-inf, inf]; x -> [-inf, inf]
4 | x: int = D[2]
5 | # STATE: D -> [-inf, inf]; keys(D) -> [-inf, inf]; len(D) -> [0, inf]; values(D) -> [-inf, inf]; x -> [0, inf]
6 | if x < 0:
7 | raise ValueError
8 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/indexing3/subscriptionsG.py:
--------------------------------------------------------------------------------
1 |
2 | D: Dict[int, Dict[Tuple[int, int], List[int]]] = {0: {(1, 2): [3]}, 1: {(1, 2): [4]}}
3 | r: Dict[Tuple[int, int], List[int]] = D[1]
4 | # FINAL: D -> 0@[1, 3], 1@[1, 4], _@⊥; keys(D) -> [0, 1]; keys(r) -> _@[1, 2]; len(D) -> [2, 2]; len(r) -> [1, 1]; r -> (1, 2)@[3, 4], _@⊥; values(D) -> (1, 2)@[3, 4], _@⊥; values(r) -> [3, 4]
5 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/summarization/dictionary8a.py:
--------------------------------------------------------------------------------
1 |
2 | x: int = int(input())
3 | D: Dict[int, Dict[int, int]] = {3: {0: 0}, 4: {0: 1}, 5: {0: 2}}
4 | d: Dict[int, int] = D[5]
5 | z: int = d[0]
6 | # FINAL: D -> [0, 5]; d -> [0, 2]; keys(D) -> [3, 5]; keys(d) -> [0, 2]; len(D) -> [3, 3]; len(d) -> [1, inf]; values(D) -> [0, 2]; values(d) -> [0, 2]; x -> [-inf, inf]; z -> [0, 2]
7 |
--------------------------------------------------------------------------------
/src/lyra/unittests/assumption/type+range/paths.py:
--------------------------------------------------------------------------------
1 |
2 | # INITIAL: 3:(Integer, [-inf, inf]), 3.1 * 8:(Integer, [-inf, inf])
3 | N: int = int(input())
4 | neg: int = 0
5 | pos: int = 0
6 | # STATE: N * 8:(Integer, [-inf, inf])
7 | for i in range(N):
8 | num: int = int(input())
9 | if num < 0:
10 | neg: int = neg + 1
11 | elif num > 0:
12 | post: int = pos + 1
13 | # FINAL: ε
14 |
--------------------------------------------------------------------------------
/docs/html/_sources/lyra.engine.string.rst.txt:
--------------------------------------------------------------------------------
1 | lyra\.engine\.string package
2 | ============================
3 |
4 | .. automodule:: lyra.engine.string
5 | :members:
6 | :undoc-members:
7 | :show-inheritance:
8 |
9 | Submodules
10 | ----------
11 |
12 | .. automodule:: lyra.engine.string.character_analysis
13 | :members:
14 | :undoc-members:
15 | :show-inheritance:
16 |
17 |
18 |
--------------------------------------------------------------------------------
/docs/lyra.engine.assumption.rst:
--------------------------------------------------------------------------------
1 | lyra\.engine\.assumption package
2 | ================================
3 |
4 | .. automodule:: lyra.engine.assumption
5 | :members:
6 | :undoc-members:
7 | :show-inheritance:
8 |
9 | Submodules
10 | ----------
11 |
12 | .. automodule:: lyra.engine.assumption.assumption_analysis
13 | :members:
14 | :undoc-members:
15 | :show-inheritance:
16 |
17 |
18 |
--------------------------------------------------------------------------------
/src/lyra/unittests/usage/dataframes/handcraft_example_4.py:
--------------------------------------------------------------------------------
1 | import pandas as pd
2 |
3 | # INITIAL: df -> {_ -> W}; sub -> {_ -> W}
4 | df: pd.DataFrame = pd.read_csv("...")
5 |
6 | # STATE: df -> {A -> U, B -> U, C -> U, _ -> N}; sub -> {_ -> W}
7 | sub: pd.DataFrame = df[["A", "B", "C"]]
8 |
9 | # STATE: df -> {_ -> N}; sub -> {_ -> U}
10 | sub.head()
11 |
12 | # FINAL: df -> {_ -> N}; sub -> {_ -> N}
13 |
--------------------------------------------------------------------------------
/docs/html/_sources/lyra.engine.liveness.rst.txt:
--------------------------------------------------------------------------------
1 | lyra\.engine\.liveness package
2 | ==============================
3 |
4 | .. automodule:: lyra.engine.liveness
5 | :members:
6 | :undoc-members:
7 | :show-inheritance:
8 |
9 | Submodules
10 | ----------
11 |
12 | .. automodule:: lyra.engine.liveness.liveness_analysis
13 | :members:
14 | :undoc-members:
15 | :show-inheritance:
16 |
17 |
18 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/backward/indexing3/dictionary0.py:
--------------------------------------------------------------------------------
1 |
2 | D: Dict[int, int] = {0: 0, 1: 1, 2: 2}
3 | # STATE: D -> 2@[0, inf], _@[-inf, inf]; keys(D) -> [-inf, inf]; len(D) -> [1, inf]; values(D) -> [-inf, inf]; x -> [-inf, inf]
4 | x: int = D[2]
5 | # STATE: D -> _@[-inf, inf]; keys(D) -> [-inf, inf]; len(D) -> [0, inf]; values(D) -> [-inf, inf]; x -> [0, inf]
6 | if x < 0:
7 | raise ValueError
8 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/indexing3/keyval.py:
--------------------------------------------------------------------------------
1 |
2 | D: Dict[str, Dict[int, int]] = {'a': {1: 0}, 'b': {1: 1}, 'c': {1: 2}, 'd': {1: 3}}
3 | k: Set[str] = D.keys()
4 | z: Set[Dict[int, int]] = D.values()
5 | # FINAL: D -> "a"@[0, 1], "b"@[1, 1], "c"@[1, 2], _@[1, 3]; k -> [-inf, inf]; keys(D) -> 0@[-inf, inf], _@⊥; len(D) -> [4, 4]; len(k) -> [1, 1]; len(z) -> [1, 1]; values(D) -> 1@[0, 3], _@⊥; z -> [0, 3]
6 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/sign/forward/assignments.py:
--------------------------------------------------------------------------------
1 | # INITIAL: a -> ⊤; b -> ⊤; c -> ⊤; x -> ⊤
2 | a: int = -2
3 | # STATE: a -> <0; b -> ⊤; c -> ⊤; x -> ⊤
4 | b: int = 0
5 | # STATE: a -> <0; b -> =0; c -> ⊤; x -> ⊤
6 | c: int = 2
7 | # STATE: a -> <0; b -> =0; c -> >0; x -> ⊤
8 | x: int = a + b
9 | # STATE: a -> <0; b -> =0; c -> >0; x -> <0
10 | x = 2 * c + 1
11 | # FINAL: a -> <0; b -> =0; c -> >0; x -> >0
12 |
--------------------------------------------------------------------------------
/src/lyra/unittests/assumption/type+range/lost.py:
--------------------------------------------------------------------------------
1 |
2 | # INITIAL: 3:(Integer, [-inf, inf]), 7:(Integer, [-inf, inf]), ★
3 | x: str = input()
4 | y: float = int(x)
5 | if y < 10:
6 | if 0 < x:
7 | w: int = int(input())
8 | else:
9 | t: int = int(input())
10 | g: int = int(input())
11 | else:
12 | if 0 < x:
13 | w: int = int(input())
14 | else:
15 | t: int = int(input())
16 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/max1.py:
--------------------------------------------------------------------------------
1 |
2 | def max(x: int, y: int) -> int:
3 | if x > y:
4 | return x
5 | else:
6 | return y
7 |
8 | def min(x: int, y: int) -> int:
9 | if x < y:
10 | return x
11 | else:
12 | return y
13 |
14 | a: int = 10
15 | b: int = 20
16 | c: int = max(a, b) if a > 0 and b > 0 else min(a, b)
17 | # FINAL: a -> [10, 10]; b -> [20, 20]; c -> [20, 20]
18 |
--------------------------------------------------------------------------------
/src/lyra/unittests/usage/while_break.py:
--------------------------------------------------------------------------------
1 |
2 | n: int = int(input())
3 | x: int = int(input())
4 | i: int = 0
5 | while i < n:
6 | x: int = x / 2
7 | if x < 1:
8 | if i > 3:
9 | x: int = 0
10 | break
11 | continue
12 | else:
13 | x: int = 1
14 | print(x)
15 | i: int = i + 1
16 | else:
17 | x: int = 3
18 |
19 | while i < n:
20 | break
21 | print(n)
22 |
--------------------------------------------------------------------------------
/docs/html/_sources/lyra.engine.assumption.rst.txt:
--------------------------------------------------------------------------------
1 | lyra\.engine\.assumption package
2 | ================================
3 |
4 | .. automodule:: lyra.engine.assumption
5 | :members:
6 | :undoc-members:
7 | :show-inheritance:
8 |
9 | Submodules
10 | ----------
11 |
12 | .. automodule:: lyra.engine.assumption.assumption_analysis
13 | :members:
14 | :undoc-members:
15 | :show-inheritance:
16 |
17 |
18 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/indexing3/inL3.py:
--------------------------------------------------------------------------------
1 |
2 | L: List[int] = [0, 1, 2]
3 | x: int = -9
4 | # STATE: L -> 0@[0, 0], 1@[1, 1], 2@[2, 2], _@⊥; len(L) -> [3, 3]; x -> [-9, -9]
5 | if x in L:
6 | # STATE: L -> 0@[0, 0], 1@[1, 1], 2@[2, 2], _@⊥; len(L) -> [3, 3]; x -> ⊥
7 | print(x)
8 | else:
9 | raise ValueError
10 | # FINAL: L -> 0@[0, 0], 1@[1, 1], 2@[2, 2], _@⊥; len(L) -> [3, 3]; x -> ⊥
11 |
12 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/indexing3/inL4.py:
--------------------------------------------------------------------------------
1 |
2 | L: List[int] = [0, 1, 2]
3 | x: int = 2
4 | # STATE: L -> 0@[0, 0], 1@[1, 1], 2@[2, 2], _@⊥; len(L) -> [3, 3]; x -> [2, 2]
5 | if x in L:
6 | # STATE: L -> 0@[0, 0], 1@[1, 1], 2@[2, 2], _@⊥; len(L) -> [3, 3]; x -> [2, 2]
7 | print(x)
8 | else:
9 | raise ValueError
10 | # FINAL: L -> 0@[0, 0], 1@[1, 1], 2@[2, 2], _@⊥; len(L) -> [3, 3]; x -> [2, 2]
11 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/summarization/filterX.py:
--------------------------------------------------------------------------------
1 |
2 | X: List[int] = [0, 5, 10]
3 | y: int = int(input())
4 | z: int = int(input())
5 | if y < 2 or y > 10 or z < 3 or z > 5:
6 | raise ValueError
7 | print("")
8 | # STATE: X -> [0, 10]; len(X) -> [3, 3]; y -> [2, 10]; z -> [3, 5]
9 | if z - X[1] - y >= 0:
10 | # STATE: X -> [0, 10]; len(X) -> [3, 3]; y -> [2, 5]; z -> [3, 5]
11 | print("Ok!")
12 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/indexing3/dictionary8a.py:
--------------------------------------------------------------------------------
1 |
2 | x: int = int(input())
3 | D: Dict[int, Dict[int, int]] = {3: {0: 0}, 4: {0: 1}, 5: {0: 2}}
4 | d: Dict[int, int] = D[5]
5 | z: int = d[0]
6 | # FINAL: D -> 3@[0, 0], 4@[0, 1], 5@[0, 2], _@⊥; d -> 0@[0, 2], _@⊥; keys(D) -> [3, 5]; keys(d) -> [0, 0]; len(D) -> [3, 3]; len(d) -> [1, 1]; values(D) -> 0@[0, 2], _@⊥; values(d) -> [0, 2]; x -> [-inf, inf]; z -> [0, 2]
7 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/summarization/subscriptions1.py:
--------------------------------------------------------------------------------
1 |
2 | b1: bool = bool(input())
3 | if b1:
4 | y1: int = 1
5 | else:
6 | y1: int = 3
7 |
8 | x4: List[List[int]] = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
9 | # STATE: b1 -> [0, 1]; len(x4) -> [3, 3]; x4 -> [1, 9]; y1 -> [1, 3]
10 | if x4[y1][y1-1] == 100:
11 | # STATE: b1 -> [0, 1]; len(x4) -> [3, 3]; x4 -> [1, 9]; y1 -> [1, 3]
12 | print(100)
13 |
--------------------------------------------------------------------------------
/docs/lyra.abstract_domains.string.rst:
--------------------------------------------------------------------------------
1 | lyra\.abstract\_domains\.string package
2 | =======================================
3 |
4 | .. automodule:: lyra.abstract_domains.string
5 | :members:
6 | :undoc-members:
7 | :show-inheritance:
8 |
9 | Submodules
10 | ----------
11 |
12 | .. automodule:: lyra.abstract_domains.string.character_domain
13 | :members:
14 | :undoc-members:
15 | :show-inheritance:
16 |
17 |
18 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/indexing3/subscriptions7.py:
--------------------------------------------------------------------------------
1 |
2 | x: List[List[int]] = [[0], [0, 1], [0, 1, 2], [0, 1, 2, 3]]
3 | # STATE: len(x) -> [4, 4]; x -> 0@[0, 0], 1@[0, 1], 2@[0, 2], _@[0, 3]; y -> [-inf, inf]; z -> [-inf, inf]
4 | y: int = x[3][3]
5 | # STATE: len(x) -> [4, 4]; x -> 0@[0, 0], 1@[0, 1], 2@[0, 2], _@[0, 3]; y -> [0, 3]; z -> [-inf, inf]
6 | z: int = x[9][0]
7 | # FINAL: len(x) -> ⊥; x -> ⊥; y -> ⊥; z -> ⊥
8 |
--------------------------------------------------------------------------------
/docs/lyra.abstract_domains.liveness.rst:
--------------------------------------------------------------------------------
1 | lyra\.abstract\_domains\.liveness package
2 | =========================================
3 |
4 | .. automodule:: lyra.abstract_domains.liveness
5 | :members:
6 | :undoc-members:
7 | :show-inheritance:
8 |
9 | Submodules
10 | ----------
11 |
12 | .. automodule:: lyra.abstract_domains.liveness.liveness_domain
13 | :members:
14 | :undoc-members:
15 | :show-inheritance:
16 |
17 |
18 |
--------------------------------------------------------------------------------
/src/lyra/core/utils.py:
--------------------------------------------------------------------------------
1 |
2 | def copy_docstring(fromfunc):
3 | """Decorator to copy the docstring of ``fromfunc``.
4 |
5 | It appends an existing docstring to it.
6 | """
7 | def _decorator(func):
8 | sourcedoc = fromfunc.__doc__
9 | if func.__doc__:
10 | func.__doc__ = sourcedoc + func.__doc__
11 | else:
12 | func.__doc__ = sourcedoc
13 | return func
14 | return _decorator
15 |
--------------------------------------------------------------------------------
/src/lyra/tests/esop2018.py:
--------------------------------------------------------------------------------
1 |
2 | english: bool = bool(input())
3 | math: bool = bool(input())
4 | science: bool = bool(input())
5 | bonus: bool = bool(input())
6 | passing: bool = True
7 | if not english:
8 | english: bool = False # error: *english* should be *passing*
9 | if not math:
10 | passing: bool = False or bonus
11 | if not math:
12 | passing: bool = False or bonus # error: *math* should be *science*
13 | print(passing)
14 |
--------------------------------------------------------------------------------
/docs/html/_sources/lyra.abstract_domains.string.rst.txt:
--------------------------------------------------------------------------------
1 | lyra\.abstract\_domains\.string package
2 | =======================================
3 |
4 | .. automodule:: lyra.abstract_domains.string
5 | :members:
6 | :undoc-members:
7 | :show-inheritance:
8 |
9 | Submodules
10 | ----------
11 |
12 | .. automodule:: lyra.abstract_domains.string.character_domain
13 | :members:
14 | :undoc-members:
15 | :show-inheritance:
16 |
17 |
18 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/summarization/copy.py:
--------------------------------------------------------------------------------
1 | def copy(original: List[List[str]]) -> List[List[str]]:
2 | new_list: List[List[str]] = list()
3 | for line in original:
4 | new_list.append(line[:])
5 | print(new_list)
6 | return new_list
7 |
8 |
9 | R: int = int(input())
10 | matrix: List[List[str]] = []
11 | for row in range(R):
12 | matrix.append(list(input()))
13 | result: List[List[str]] = copy(matrix)
14 |
--------------------------------------------------------------------------------
/docs/html/_sources/lyra.abstract_domains.liveness.rst.txt:
--------------------------------------------------------------------------------
1 | lyra\.abstract\_domains\.liveness package
2 | =========================================
3 |
4 | .. automodule:: lyra.abstract_domains.liveness
5 | :members:
6 | :undoc-members:
7 | :show-inheritance:
8 |
9 | Submodules
10 | ----------
11 |
12 | .. automodule:: lyra.abstract_domains.liveness.liveness_domain
13 | :members:
14 | :undoc-members:
15 | :show-inheritance:
16 |
17 |
18 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/backward/summarization/subscriptions1b.py:
--------------------------------------------------------------------------------
1 |
2 | x: int = int(input())
3 | # STATE: L -> [-inf, inf]; len(L) -> [0, inf]; x -> [-inf, inf]; z -> [-inf, inf]
4 | L: List[List[int]] = [[0], [1], [x]]
5 | # STATE: L -> [-inf, inf]; len(L) -> [3, inf]; x -> [-inf, inf]; z -> [-inf, inf]
6 | z: int = L[2][0]
7 | # STATE: L -> [-inf, inf]; len(L) -> [0, inf]; x -> [-inf, inf]; z -> [2, 2]
8 | if z != 2:
9 | raise ValueError
10 |
--------------------------------------------------------------------------------
/src/lyra/unittests/assumption/type+alphabet/mix.py:
--------------------------------------------------------------------------------
1 |
2 | # INITIAL: 3:(Integer, (∅, Σ)), 3.1 * [6:(Float, (∅, Σ)), 7:(String, ({'a', 'b', 'd'}, {'a', 'b', 'd'}))]
3 | T:int = int(input())
4 | # STATE: T * [6:(Float, (∅, Σ)), 7:(String, ({'a', 'b', 'd'}, {'a', 'b', 'd'}))]
5 | for i in range(T):
6 | x: float = float(input())
7 | y: str = input()
8 | if x > 10 and y == 'abd':
9 | pass
10 | else:
11 | raise ValueError
12 | # FINAL: ε
13 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/demo2a.py:
--------------------------------------------------------------------------------
1 |
2 | # INITIAL: a -> [-inf, inf]; x -> [-inf, inf]
3 | x: int = int(input())
4 | # STATE: a -> [-inf, inf]; x -> [-inf, inf]
5 | a: int = 0
6 | # STATE: a -> [0, 0]; x -> [-inf, inf]
7 | if 3 > x:
8 | # STATE: a -> [0, 0]; x -> [-inf, 2]
9 | a = x
10 | # STATE: a -> [-inf, 2]; x -> [-inf, 2]
11 | # STATE: a -> [-inf, 2]; x -> [-inf, inf]
12 | print(a)
13 | # FINAL: a -> [-inf, 2]; x -> [-inf, inf]
14 |
--------------------------------------------------------------------------------
/src/lyra/unittests/usage/dataframes/drop_before_use.py:
--------------------------------------------------------------------------------
1 | import pandas as pd
2 |
3 | x: pd.DataFrame = pd.read_csv("data.csv")
4 | y: pd.DataFrame = pd.read_csv("data.csv")
5 |
6 | # STATE: x -> {A -> N, _ -> U}; y -> {B -> N, _ -> N}
7 | x.drop(["A"])
8 | # WARNING: Warning: column B of y dropped before use!
9 | y.drop(["B"])
10 |
11 | # STATE: x -> {_ -> U}; y -> {B -> U, _ -> N}
12 | x.head()
13 | y["B"].head()
14 |
15 | # FINAL: x -> {_ -> N}; y -> {_ -> N}
16 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/summarization/dictionary4.py:
--------------------------------------------------------------------------------
1 |
2 | d0: Dict[int, int] = {0 : -1}
3 | d1: Dict[int, Dict[int, int]] = dict()
4 | # STATE: d0 -> [-1, 0]; d1 -> ⊥; keys(d0) -> [0, 0]; keys(d1) -> ⊥; len(d0) -> [1, 1]; len(d1) -> [0, 0]; values(d0) -> [-1, -1]; values(d1) -> ⊥
5 | d1[1] = d0
6 | # FINAL: d0 -> [-1, 0]; d1 -> [-1, 1]; keys(d0) -> [0, 0]; keys(d1) -> [1, 1]; len(d0) -> [1, 1]; len(d1) -> [1, 1]; values(d0) -> [-1, -1]; values(d1) -> [-1, 0]
7 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/backward/indexing3/subscriptions1b.py:
--------------------------------------------------------------------------------
1 |
2 | x: int = int(input())
3 | # STATE: L -> _@[-inf, inf]; len(L) -> [0, inf]; x -> [-inf, inf]; z -> [-inf, inf]
4 | L: List[List[int]] = [[0], [1], [x]]
5 | # STATE: L -> 2@[-inf, inf], _@[-inf, inf]; len(L) -> [3, inf]; x -> [-inf, inf]; z -> [-inf, inf]
6 | z: int = L[2][0]
7 | # STATE: L -> _@[-inf, inf]; len(L) -> [0, inf]; x -> [-inf, inf]; z -> [2, 2]
8 | if z != 2:
9 | raise ValueError
10 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/indexing3/subscriptions1.py:
--------------------------------------------------------------------------------
1 |
2 | b1: bool = bool(input())
3 | if b1:
4 | y1: int = 1
5 | else:
6 | y1: int = 3
7 |
8 | x4: List[List[int]] = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
9 | # STATE: b1 -> [0, 1]; len(x4) -> [3, 3]; x4 -> 0@[1, 3], 1@[4, 6], 2@[7, 9], _@⊥; y1 -> [1, 3]
10 | if x4[y1][y1-1] == 100:
11 | # STATE: b1 -> [0, 1]; len(x4) -> [3, 3]; x4 -> 0@[1, 3], 1@[4, 6], 2@[7, 9], _@⊥; y1 -> ⊥
12 | print(100)
13 |
--------------------------------------------------------------------------------
/src/lyra/unittests/assumption/type+range/merge.py:
--------------------------------------------------------------------------------
1 |
2 | # INITIAL: 3:(Integer, [-inf, inf]), 5:(Integer, [-inf, 5]), 6:(Integer, [3, inf])
3 | z: int = int(input())
4 | if z <= 3:
5 | x: int = int(input())
6 | y: int = int(input())
7 | if x <= 3 <= y:
8 | pass
9 | else:
10 | raise ValueError
11 | else:
12 | y: int = int(input())
13 | x: int = int(input())
14 | if y <= 5 <= x:
15 | pass
16 | else:
17 | raise ValueError
18 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/break.py:
--------------------------------------------------------------------------------
1 |
2 | for x in range(10):
3 | # STATE: x -> [0, 9]
4 | if x > 7:
5 | # STATE: x -> [8, 9]
6 | x: int = x + 2
7 | # STATE: x -> [10, 11]
8 | else:
9 | # STATE: x -> [0, 7]
10 | x: int = x + 1
11 | # STATE: x -> [1, 8]
12 | if x == 8:
13 | # STATE: x -> [8, 8]
14 | break
15 | # STATE: x -> [1, 7]
16 | # STATE: x -> [1, 11]
17 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/indexing3/filterX.py:
--------------------------------------------------------------------------------
1 |
2 | X: List[int] = [0, 5, 10]
3 | y: int = int(input())
4 | z: int = int(input())
5 | if y < 2 or y > 10 or z < 3 or z > 5:
6 | raise ValueError
7 | print("")
8 | # STATE: X -> 0@[0, 0], 1@[5, 5], 2@[10, 10], _@⊥; len(X) -> [3, 3]; y -> [2, 10]; z -> [3, 5]
9 | if X[1] - y - z >= 0:
10 | # STATE: X -> 0@[0, 0], 1@[5, 5], 2@[10, 10], _@⊥; len(X) -> [3, 3]; y -> [2, 2]; z -> [3, 3]
11 | print("OK!")
12 |
--------------------------------------------------------------------------------
/docs/lyra.rst:
--------------------------------------------------------------------------------
1 | lyra package
2 | ============
3 |
4 | .. automodule:: lyra
5 | :members:
6 | :undoc-members:
7 | :show-inheritance:
8 |
9 | Subpackages
10 | -----------
11 |
12 | .. toctree::
13 |
14 | lyra.abstract_domains
15 | lyra.core
16 | lyra.engine
17 | lyra.frontend
18 | lyra.semantics
19 |
20 | Submodules
21 | ----------
22 |
23 | .. automodule:: lyra.main
24 | :members:
25 | :undoc-members:
26 | :show-inheritance:
27 |
28 |
29 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/conditional1.py:
--------------------------------------------------------------------------------
1 |
2 | # INITIAL: a -> [-inf, inf]; b -> [-inf, inf]
3 | a: int = int(input())
4 | # STATE: a -> [-inf, inf]; b -> [-inf, inf]
5 | if 1 <= a <= 9:
6 | # STATE: a -> [1, 9]; b -> [-inf, inf]
7 | b: int = 1
8 | # STATE: a -> [1, 9]; b -> [1, 1]
9 | else:
10 | # STATE: a -> [-inf, inf]; b -> [-inf, inf]
11 | b: int = 2
12 | # STATE: a -> [-inf, inf]; b -> [2, 2]
13 | # FINAL: a -> [-inf, inf]; b -> [1, 2]
14 |
--------------------------------------------------------------------------------
/src/lyra/unittests/usage/missing_update.py:
--------------------------------------------------------------------------------
1 |
2 | x1: int = int(input()) # x1 unused
3 | x2: int = int(input())
4 | x3: int = int(input())
5 | # STATE: asc -> W; temp -> W; x1 -> N; x2 -> U; x3 -> U
6 | asc: bool = True
7 | if x1 <= x2:
8 | temp: bool = False
9 | else:
10 | temp: bool = True
11 |
12 | # BUG, missing update on asc
13 |
14 | if x2 <= x3:
15 | temp: bool = False
16 | else:
17 | temp: bool = True
18 |
19 | asc: bool = asc and temp
20 |
21 | print(asc)
22 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/backward/summarization/dictionary2.py:
--------------------------------------------------------------------------------
1 |
2 | Y: int = int(input())
3 | Z: int = int(input())
4 | # STATE: Y -> [-inf, inf]; Z -> [-inf, inf]; keys(x) -> [-inf, inf]; len(x) -> [0, inf]; values(x) -> [-inf, inf]; x -> [-inf, inf]
5 | x: Dict[str, int] = {'a': Y, 'b': Z}
6 | # STATE: Y -> [-inf, inf]; Z -> [-inf, inf]; keys(x) -> [-inf, inf]; len(x) -> [1, inf]; values(x) -> [-inf, inf]; x -> [-inf, inf]
7 | if x['b'] != 0 or x['a'] < 0:
8 | raise ValueError
9 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/indexing3/inL6.py:
--------------------------------------------------------------------------------
1 |
2 | L: List[int] = list()
3 | for i in range(int(input())):
4 | L.append(int(input()))
5 | x: int = 2
6 | # STATE: L -> _@[-inf, inf]; i -> [-inf, inf]; len(L) -> [0, inf]; x -> [2, 2]
7 | if x in L:
8 | # STATE: L -> _@[-inf, inf]; i -> [-inf, inf]; len(L) -> [0, inf]; x -> [2, 2]
9 | print(x)
10 | else:
11 | raise ValueError
12 | # FINAL: L -> _@[-inf, inf]; i -> [-inf, inf]; len(L) -> [0, inf]; x -> [2, 2]
13 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/summarization/inL6.py:
--------------------------------------------------------------------------------
1 |
2 | L: List[int] = list()
3 | for i in range(int(input())):
4 | L.append(int(input()))
5 | x: int = 2
6 | # STATE: L -> [-inf, inf]; i -> [-inf, inf]; len(L) -> [0, inf]; x -> [2, 2]
7 | if x in L:
8 | # STATE: L -> [-inf, inf]; i -> [-inf, inf]; len(L) -> [0, inf]; x -> [2, 2]
9 | print(x)
10 | else:
11 | raise ValueError
12 | # FINAL: L -> [-inf, inf]; i -> [-inf, inf]; len(L) -> [0, inf]; x -> [2, 2]
13 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/summarization/subscriptions4.py:
--------------------------------------------------------------------------------
1 |
2 | D: Dict[int, List[int]] = {1: [2], 2: [3, 4]}
3 | L: List[List[int]] = [[], [2], [3, 4]]
4 | # STATE: D -> [1, 4]; L -> [2, 4]; keys(D) -> [1, 2]; len(D) -> [2, 2]; len(L) -> [3, 3]; values(D) -> [2, 4]; y -> [-inf, inf]; z -> [-inf, inf]
5 | y: int = D[2][1]
6 | z: int = L[2][1]
7 | # STATE: D -> [1, 4]; L -> [2, 4]; keys(D) -> [1, 2]; len(D) -> [2, 2]; len(L) -> [3, 3]; values(D) -> [2, 4]; y -> [2, 4]; z -> [2, 4]
8 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/polyhedra/forward/filter.py:
--------------------------------------------------------------------------------
1 |
2 | x: int = int(input())
3 | y: int = int(input())
4 | z: int = int(input())
5 | if x < 0 or x > 10 or y < 2 or y > 10 or z < 3 or z > 5:
6 | raise ValueError
7 | print("")
8 | # STATE: -1·x + 10 >= 0 ∧ -1·y + 10 >= 0 ∧ -1·z + 5 >= 0 ∧ 1·z - 3 >= 0 ∧ 1·y - 2 >= 0 ∧ 1·x + 0 >= 0
9 | if z - x - y >= 0:
10 | # STATE: -1·x - 1·y + 1·z + 0 >= 0 ∧ -1·z + 5 >= 0 ∧ 1·z - 3 >= 0 ∧ 1·y - 2 >= 0 ∧ 1·x + 0 >= 0
11 | print("Ok!")
12 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/polyhedra/forward/filterX.py:
--------------------------------------------------------------------------------
1 |
2 | X: List[int] = [0, 5, 10]
3 | y: int = int(input())
4 | z: int = int(input())
5 | if y < 2 or y > 10 or z < 3 or z > 5:
6 | raise ValueError
7 | print("")
8 | # STATE: -1·X + 10 >= 0 ∧ -1·y + 10 >= 0 ∧ -1·z + 5 >= 0 ∧ 1·z - 3 >= 0 ∧ 1·y - 2 >= 0 ∧ 1·X + 0 >= 0
9 | if z - X[1] - y >= 0:
10 | # STATE: -1·X + 10 >= 0 ∧ -1·y + 1·z + 0 >= 0 ∧ -1·z + 5 >= 0 ∧ 1·z - 3 >= 0 ∧ 1·y - 2 >= 0 ∧ 1·X + 0 >= 0
11 | print("Ok!")
12 |
--------------------------------------------------------------------------------
/src/lyra/unittests/usage/dataframes/handcraft_example_5.py:
--------------------------------------------------------------------------------
1 | import pandas as pd
2 |
3 | # INITIAL: df -> {_ -> W}; sub -> {_ -> W}
4 | df: pd.DataFrame = pd.read_csv("...")
5 |
6 | # STATE: df -> {A -> U, B -> W, C -> U, _ -> N}; sub -> {_ -> W}
7 | sub: pd.DataFrame = df[["A", "B", "C"]]
8 |
9 | # STATE: df -> {_ -> N}; sub -> {B -> W, _ -> U}
10 | sub["B"] = 1
11 |
12 | # STATE: df -> {_ -> N}; sub -> {_ -> U}
13 | sub.head()
14 |
15 | # FINAL: df -> {_ -> N}; sub -> {_ -> N}
16 |
17 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/summarization/inL5.py:
--------------------------------------------------------------------------------
1 |
2 | L: List[int] = list()
3 | for i in range(int(input())):
4 | L.append(int(input()))
5 | x: int = -9
6 | # STATE: L -> [-inf, inf]; i -> [-inf, inf]; len(L) -> [0, inf]; x -> [-9, -9]
7 | if x in L:
8 | # STATE: L -> [-inf, inf]; i -> [-inf, inf]; len(L) -> [0, inf]; x -> [-9, -9]
9 | print(x)
10 | else:
11 | raise ValueError
12 | # FINAL: L -> [-inf, inf]; i -> [-inf, inf]; len(L) -> [0, inf]; x -> [-9, -9]
13 |
--------------------------------------------------------------------------------
/src/lyra/unittests/assumption/type/add.py:
--------------------------------------------------------------------------------
1 |
2 | x1: str = input()
3 | x2: str = input()
4 | # STATE: len(x) -> [0, inf]; len(x1) -> [0, inf]; len(x2) -> [0, inf]; x -> String; x1 -> Integer; x2 -> Integer; y -> Float
5 | x: str = x1 + x2
6 | # STATE: len(x) -> [0, inf]; len(x1) -> [0, inf]; len(x2) -> [0, inf]; x -> Integer; x1 -> String; x2 -> String; y -> Float
7 | y: float = int(x)
8 | # FINAL: len(x) -> [0, inf]; len(x1) -> [0, inf]; len(x2) -> [0, inf]; x -> String; x1 -> String; x2 -> String; y -> Float
9 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/indexing3/inL5.py:
--------------------------------------------------------------------------------
1 |
2 | L: List[int] = list()
3 | for i in range(int(input())):
4 | L.append(int(input()))
5 | x: int = -9
6 | # STATE: L -> _@[-inf, inf]; i -> [-inf, inf]; len(L) -> [0, inf]; x -> [-9, -9]
7 | if x in L:
8 | # STATE: L -> _@[-inf, inf]; i -> [-inf, inf]; len(L) -> [0, inf]; x -> [-9, -9]
9 | print(x)
10 | else:
11 | raise ValueError
12 | # FINAL: L -> _@[-inf, inf]; i -> [-inf, inf]; len(L) -> [0, inf]; x -> [-9, -9]
13 |
--------------------------------------------------------------------------------
/src/lyra/unittests/usage/dataframes/handcraft_example_if.py:
--------------------------------------------------------------------------------
1 | import pandas as pd
2 |
3 | df: pd.DataFrame = pd.read_csv("...")
4 |
5 | b: bool = input()
6 | # STATE: b -> U; df -> {x -> W, y -> U, _ -> N}; df2 -> {_ -> N}
7 |
8 | if b:
9 | df["x"] = 1
10 | else:
11 | df2 : pd.DataFrame = df.drop("y")
12 |
13 | # STATE: b -> N; df -> {x -> U, y -> U, _ -> N}; df2 -> {_ -> N}
14 | df["y"].head()
15 | df["x"].head()
16 | # df.head()
17 |
18 | # FINAL: b -> N; df -> {_ -> N}; df2 -> {_ -> N}
19 |
--------------------------------------------------------------------------------
/docs/html/_sources/lyra.rst.txt:
--------------------------------------------------------------------------------
1 | lyra package
2 | ============
3 |
4 | .. automodule:: lyra
5 | :members:
6 | :undoc-members:
7 | :show-inheritance:
8 |
9 | Subpackages
10 | -----------
11 |
12 | .. toctree::
13 |
14 | lyra.abstract_domains
15 | lyra.core
16 | lyra.engine
17 | lyra.frontend
18 | lyra.semantics
19 |
20 | Submodules
21 | ----------
22 |
23 | .. automodule:: lyra.main
24 | :members:
25 | :undoc-members:
26 | :show-inheritance:
27 |
28 |
29 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/indexing3/dictionary4.py:
--------------------------------------------------------------------------------
1 |
2 | d0: Dict[int, int] = {0 : -1}
3 | d1: Dict[int, Dict[int, int]] = dict()
4 | # STATE: d0 -> 0@[-1, -1], _@⊥; d1 -> _@⊥; keys(d0) -> [0, 0]; keys(d1) -> ⊥; len(d0) -> [1, 1]; len(d1) -> [0, 0]; values(d0) -> [-1, -1]; values(d1) -> ⊥
5 | d1[1] = d0
6 | # FINAL: d0 -> 0@[-1, -1], _@⊥; d1 -> 1@[-1, 0], _@⊥; keys(d0) -> [0, 0]; keys(d1) -> [1, 1]; len(d0) -> [1, 1]; len(d1) -> [1, 1]; values(d0) -> [-1, -1]; values(d1) -> 0@[-1, -1], _@⊥
7 |
8 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/backward/indexing3/dictionary2.py:
--------------------------------------------------------------------------------
1 |
2 | Y: int = int(input())
3 | Z: int = int(input())
4 | # STATE: Y -> [0, inf]; Z -> [0, 0]; keys(x) -> _@[-inf, inf]; len(x) -> [0, inf]; values(x) -> [-inf, inf]; x -> _@[-inf, inf]
5 | x: Dict[str, int] = {'a': Y, 'b': Z}
6 | # STATE: Y -> [-inf, inf]; Z -> [-inf, inf]; keys(x) -> _@[-inf, inf]; len(x) -> [1, inf]; values(x) -> [-inf, inf]; x -> "a"@[0, inf], "b"@[0, 0], _@[-inf, inf]
7 | if x['b'] != 0 or x['a'] < 0:
8 | raise ValueError
9 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/octagon/if_nested.py:
--------------------------------------------------------------------------------
1 | x = int(input())
2 | y = int(input())
3 | if 3 > x: # x decision
4 | # inside nested if only b is modified!
5 | if 2 > y: # y decision
6 | b = 10
7 | else:
8 | b = 20
9 | a = 10
10 | else:
11 | # inside nested if only b is modified!
12 | if 2 > y: # y decision
13 | b = 10
14 | else:
15 | b = 20
16 | a = 20
17 |
18 | # STATE: 10≤a≤20, 10≤b≤20, b+a≤40, b-a≤10, -b+a≤10, -b-a≤-20
19 | print(a)
20 |
--------------------------------------------------------------------------------
/src/lyra/unittests/assumption/type+range/123.py:
--------------------------------------------------------------------------------
1 |
2 | # INITIAL: 3:(Integer, [-inf, inf]), 3.1 * 9:(Integer, [1, 3])
3 | N: int = int(input())
4 | one: int = 0
5 | two: int = 0
6 | three: int = 0
7 | # STATE: N * 9:(Integer, [1, 3])
8 | for i in range(N):
9 | num: int = int(input())
10 | if num == 1:
11 | one: int = one + 1
12 | elif num == 2:
13 | two: int = two + 1
14 | elif num == 3:
15 | three: int = three + 1
16 | else:
17 | raise ValueError
18 | # FINAL: ε
19 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/summarization/dictionary7.py:
--------------------------------------------------------------------------------
1 |
2 | d1: Dict[int, Dict[int, int]] = dict()
3 | # STATE: d1 -> ⊥; keys(d1) -> ⊥; len(d1) -> [0, 0]; values(d1) -> ⊥
4 | d1[1] = {0: -1}
5 | # STATE: d1 -> [-1, 1]; keys(d1) -> [1, 1]; len(d1) -> [1, 1]; values(d1) -> [-1, 0]
6 | d1[1][0] = -9
7 | # STATE: d1 -> [-9, 1]; keys(d1) -> [1, 1]; len(d1) -> [1, 1]; values(d1) -> [-9, 0]
8 | d1[1][23] = -9
9 | # FINAL: d1 -> [-9, 23]; keys(d1) -> [1, 1]; len(d1) -> [1, 1]; values(d1) -> [-9, 23]
10 |
--------------------------------------------------------------------------------
/src/lyra/unittests/usage/if_nested.py:
--------------------------------------------------------------------------------
1 |
2 | x: int = int(input())
3 | y: int = int(input())
4 | # STATE: a -> W; b -> N; x -> U; y -> N
5 | if 3 > x: # x decision
6 | # inside nested if only b is modified!
7 | if 2 > y: # y decision
8 | b: int = 10
9 | else:
10 | b: int = 20
11 | a: int = 10
12 | else:
13 | # inside nested if only b is modified!
14 | if 2 > y: # y decision
15 | b: int = 10
16 | else:
17 | b: int = 20
18 | a: int = 20
19 | print(a)
20 |
--------------------------------------------------------------------------------
/src/lyra/unittests/usage/dataframes/handcraft_example_5b.py:
--------------------------------------------------------------------------------
1 | import pandas as pd
2 |
3 | # INITIAL: df -> {_ -> W}; sub -> {_ -> W}
4 | df: pd.DataFrame = pd.read_csv("...")
5 |
6 | # STATE: df -> {A -> U, B -> W, X -> U, Y -> U, _ -> N}; sub -> {_ -> W}
7 | sub: pd.DataFrame = df[["A", "B", "Y"]]
8 |
9 | # STATE: df -> {X -> U, Y -> U, _ -> N}; sub -> {B -> W, _ -> U}
10 | sub["B"] = df["X"] + df["Y"]
11 |
12 | # STATE: df -> {_ -> N}; sub -> {_ -> U}
13 | sub.head()
14 |
15 | # FINAL: df -> {_ -> N}; sub -> {_ -> N}
16 |
--------------------------------------------------------------------------------
/src/lyra/unittests/assumption/type+range+alphabet/mix.py:
--------------------------------------------------------------------------------
1 |
2 | # INITIAL: 3:(Integer, [-inf, inf], (∅, Σ)), 3.1 * [6:(Float, [11, inf], (∅, Σ)), 7:(String, [-inf, inf], ({'a', 'b', 'd'}, {'a', 'b', 'd'}))]
3 | T:int = int(input())
4 | # STATE: T * [6:(Float, [11, inf], (∅, Σ)), 7:(String, [-inf, inf], ({'a', 'b', 'd'}, {'a', 'b', 'd'}))]
5 | for i in range(T):
6 | x: float = float(input())
7 | y: str = input()
8 | if x > 10 and y == 'abd':
9 | pass
10 | else:
11 | raise ValueError
12 | # FINAL: ε
13 |
--------------------------------------------------------------------------------
/docs/lyra.engine.numerical.rst:
--------------------------------------------------------------------------------
1 | lyra\.engine\.numerical package
2 | ===============================
3 |
4 | .. automodule:: lyra.engine.numerical
5 | :members:
6 | :undoc-members:
7 | :show-inheritance:
8 |
9 | Submodules
10 | ----------
11 |
12 | .. automodule:: lyra.engine.numerical.interval_analysis
13 | :members:
14 | :undoc-members:
15 | :show-inheritance:
16 |
17 | .. automodule:: lyra.engine.numerical.sign_analysis
18 | :members:
19 | :undoc-members:
20 | :show-inheritance:
21 |
22 |
23 |
--------------------------------------------------------------------------------
/docs/index.rst:
--------------------------------------------------------------------------------
1 | .. Lyra documentation master file, created by
2 | sphinx-quickstart on Fri Jun 9 12:29:25 2017.
3 | You can adapt this file completely to your liking, but it should at least
4 | contain the root `toctree` directive.
5 |
6 | Welcome to Lyra's documentation!
7 | ================================
8 |
9 | .. toctree::
10 | :maxdepth: 2
11 | :caption: Contents:
12 |
13 | modules
14 |
15 | Indices and Tables
16 | ==================
17 |
18 | * :ref:`genindex`
19 | * :ref:`modindex`
20 | * :ref:`search`
21 |
--------------------------------------------------------------------------------
/docs/html/_sources/lyra.engine.numerical.rst.txt:
--------------------------------------------------------------------------------
1 | lyra\.engine\.numerical package
2 | ===============================
3 |
4 | .. automodule:: lyra.engine.numerical
5 | :members:
6 | :undoc-members:
7 | :show-inheritance:
8 |
9 | Submodules
10 | ----------
11 |
12 | .. automodule:: lyra.engine.numerical.interval_analysis
13 | :members:
14 | :undoc-members:
15 | :show-inheritance:
16 |
17 | .. automodule:: lyra.engine.numerical.sign_analysis
18 | :members:
19 | :undoc-members:
20 | :show-inheritance:
21 |
22 |
23 |
--------------------------------------------------------------------------------
/docs/html/_sources/index.rst.txt:
--------------------------------------------------------------------------------
1 | .. Lyra documentation master file, created by
2 | sphinx-quickstart on Fri Jun 9 12:29:25 2017.
3 | You can adapt this file completely to your liking, but it should at least
4 | contain the root `toctree` directive.
5 |
6 | Welcome to Lyra's documentation!
7 | ================================
8 |
9 | .. toctree::
10 | :maxdepth: 2
11 | :caption: Contents:
12 |
13 | modules
14 |
15 | Indices and Tables
16 | ==================
17 |
18 | * :ref:`genindex`
19 | * :ref:`modindex`
20 | * :ref:`search`
21 |
--------------------------------------------------------------------------------
/src/lyra/unittests/assumption/quantity+range+wordset/gpa.py:
--------------------------------------------------------------------------------
1 |
2 | grade2gpa: Dict[str, float] = { 'A': 4.0, 'B': 3.0, 'C': 2.0, 'D': 1.0, 'F': 0.0 }
3 | students: int = int(input())
4 | # STATE: students * [6:(⊤, [-inf, inf], ⊤), 7:(≠0, [-inf, inf], ⊤), 7.1 * 10:(⊤, [-inf, inf], ⊤)]
5 | for _ in range(students):
6 | name: str = input()
7 | grades: int = int(input())
8 | gpa: float = 0.0
9 | for _ in range(grades):
10 | grade: str = input()
11 | gpa += grade2gpa[grade]
12 | result: float = gpa / grades
13 | print(result)
14 |
--------------------------------------------------------------------------------
/docs/lyra.abstract_domains.usage.rst:
--------------------------------------------------------------------------------
1 | lyra\.abstract\_domains\.usage package
2 | ======================================
3 |
4 | .. automodule:: lyra.abstract_domains.usage
5 | :members:
6 | :undoc-members:
7 | :show-inheritance:
8 |
9 | Submodules
10 | ----------
11 |
12 | .. automodule:: lyra.abstract_domains.usage.usage_domain
13 | :members:
14 | :undoc-members:
15 | :show-inheritance:
16 |
17 | .. automodule:: lyra.abstract_domains.usage.usage_lattice
18 | :members:
19 | :undoc-members:
20 | :show-inheritance:
21 |
22 |
23 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/indexing3/dictionary7.py:
--------------------------------------------------------------------------------
1 |
2 | d1: Dict[int, Dict[int, int]] = dict()
3 | # STATE: d1 -> _@⊥; keys(d1) -> ⊥; len(d1) -> [0, 0]; values(d1) -> ⊥
4 | d1[1] = {0: -1}
5 | # STATE: d1 -> 1@[-1, 0], _@⊥; keys(d1) -> [1, 1]; len(d1) -> [1, 1]; values(d1) -> 0@[-1, -1], _@⊥
6 | d1[1][0] = -9
7 | # STATE: d1 -> 1@[-9, 0], _@⊥; keys(d1) -> [1, 1]; len(d1) -> [1, 1]; values(d1) -> 0@[-9, -1], _@⊥
8 | d1[1][23] = -9
9 | # FINAL: d1 -> 1@[-9, 23], _@⊥; keys(d1) -> [1, 1]; len(d1) -> [1, 1]; values(d1) -> 0@[-9, -1], _@[-9, -9]
10 |
--------------------------------------------------------------------------------
/src/lyra/unittests/usage/list2.py:
--------------------------------------------------------------------------------
1 |
2 | b: bool = bool(input())
3 | x: int = int(input())
4 | y: int = int(input())
5 | # RESULT: b -> U; list1 -> (O@0:4); list2 -> (O@0:2); s -> O; x -> U; y -> N
6 | list1: List[int] = [1, x, 2, 3, 5, 8, y]
7 | s: int = 0
8 | if b:
9 | # some random accesses to list
10 | list2: List[int] = list1
11 | s: int = s + list2[2]
12 | s: int = s + list2[1]
13 | else:
14 | # some different random accesses to list
15 | s: int = s + list1[4]
16 | s: int = s + list1[3]
17 | s: int = s + list1[0]
18 | print(s)
19 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/backward/summarization/list1.py:
--------------------------------------------------------------------------------
1 |
2 | example: List[int] = list()
3 | for i in range(3):
4 | example.append(i)
5 | value: int = int(input())
6 | # STATE: example -> [-inf, inf]; i -> [-inf, inf]; len(example) -> [3, inf]; value -> [-inf, inf]
7 | example[2]: int = value
8 | # STATE: example -> [-inf, inf]; i -> [-inf, inf]; len(example) -> [3, inf]; value -> [-inf, inf]
9 | i: int = example[2]
10 | # STATE: example -> [-inf, inf]; i -> [3, 3]; len(example) -> [0, inf]; value -> [-inf, inf]
11 | if i != 3:
12 | raise ValueError
13 |
--------------------------------------------------------------------------------
/src/lyra/unittests/usage/dataframes/handcraft_example_7.py:
--------------------------------------------------------------------------------
1 | import pandas as pd
2 |
3 | # INITIAL: df -> {_ -> W}
4 | df: pd.DataFrame = pd.read_csv("train.csv")
5 |
6 | # STATE: df -> {f -> U, id -> U, _ -> U}
7 | df.head()
8 |
9 | # STATE: df -> {f -> U, id -> N, norm_f -> W, _ -> N}
10 | df.drop(['id'], axis=1, inplace=True)
11 |
12 | # STATE: df -> {f -> U, norm_f -> W, _ -> N}
13 | df["norm_f"] = (df["f"] - df["f"].min()) / (df["f"].min() - df["f"].max())
14 |
15 | # STATE: df -> {norm_f -> U, _ -> N}
16 | df["norm_f"].head()
17 |
18 | # FINAL: df -> {_ -> N}
19 |
--------------------------------------------------------------------------------
/src/lyra/tests/usage/three_dict_example.py:
--------------------------------------------------------------------------------
1 |
2 | i: int = int(input())
3 | v: int = 8
4 |
5 | dict_in: Dict[int,int] = {}
6 | dict_out: Dict[int,int] = {}
7 | dict_own: Dict[int,int] = {3: 6}
8 |
9 | for key in range(v+1):
10 | value: int = int(input())
11 | if -3 <= value <= 3:
12 | dict_in[key]: int = value
13 |
14 | dict_own[v]: int = -1
15 | if 2 <= i <= 5:
16 | dict_own[i]: int = 0
17 |
18 | for k in dict_own.keys():
19 | dict_out[k]: int = dict_in[k] + dict_own[k]
20 |
21 | for k, v in dict_out.items():
22 | if k >= 3:
23 | print(v)
24 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/backward/indexing3/list1.py:
--------------------------------------------------------------------------------
1 |
2 | example: List[int] = list()
3 | for i in range(3):
4 | example.append(i)
5 | value: int = int(input())
6 | # STATE: example -> _@[-inf, inf]; i -> [-inf, inf]; len(example) -> [3, inf]; value -> [3, 3]
7 | example[2]: int = value
8 | # STATE: example -> 2@[3, 3], _@[-inf, inf]; i -> [-inf, inf]; len(example) -> [3, inf]; value -> [-inf, inf]
9 | i: int = example[2]
10 | # STATE: example -> _@[-inf, inf]; i -> [3, 3]; len(example) -> [0, inf]; value -> [-inf, inf]
11 | if i != 3:
12 | raise ValueError
13 |
--------------------------------------------------------------------------------
/docs/html/_sources/lyra.abstract_domains.usage.rst.txt:
--------------------------------------------------------------------------------
1 | lyra\.abstract\_domains\.usage package
2 | ======================================
3 |
4 | .. automodule:: lyra.abstract_domains.usage
5 | :members:
6 | :undoc-members:
7 | :show-inheritance:
8 |
9 | Submodules
10 | ----------
11 |
12 | .. automodule:: lyra.abstract_domains.usage.usage_domain
13 | :members:
14 | :undoc-members:
15 | :show-inheritance:
16 |
17 | .. automodule:: lyra.abstract_domains.usage.usage_lattice
18 | :members:
19 | :undoc-members:
20 | :show-inheritance:
21 |
22 |
23 |
--------------------------------------------------------------------------------
/src/lyra/unittests/assumption/type+wordset/substitution.py:
--------------------------------------------------------------------------------
1 |
2 | # INITIAL: 3:(String, {'abc'}), 5:(String, {'abc'}), 7:(String, {''})
3 | a: str = input()
4 | # STATE: 5:(String, {'abc'}), 7:(String, {''})
5 | b: str = input()
6 | # STATE: 7:(String, {''})
7 | c: str = input()
8 | # STATE: ε
9 | if a == b + c:
10 | pass
11 | else:
12 | raise ValueError
13 | if a == 'abc':
14 | pass
15 | else:
16 | raise ValueError
17 | if c == '':
18 | pass
19 | else:
20 | raise ValueError
21 | if b == 'abc':
22 | pass
23 | else:
24 | raise ValueError
25 | # FINAL: ε
26 |
--------------------------------------------------------------------------------
/docs/lyra.abstract_domains.numerical.rst:
--------------------------------------------------------------------------------
1 | lyra\.abstract\_domains\.numerical package
2 | ==========================================
3 |
4 | .. automodule:: lyra.abstract_domains.numerical
5 | :members:
6 | :undoc-members:
7 | :show-inheritance:
8 |
9 | Submodules
10 | ----------
11 |
12 | .. automodule:: lyra.abstract_domains.numerical.interval_domain
13 | :members:
14 | :undoc-members:
15 | :show-inheritance:
16 |
17 | .. automodule:: lyra.abstract_domains.numerical.sign_domain
18 | :members:
19 | :undoc-members:
20 | :show-inheritance:
21 |
22 |
23 |
--------------------------------------------------------------------------------
/src/lyra/unittests/assumption/type+alphabet/merge.py:
--------------------------------------------------------------------------------
1 |
2 | # INITIAL: 3:(Integer, (∅, Σ)), 3.1 * [6:(Integer, (∅, Σ)), 8:(String, (∅, Σ))]
3 | T: int = int(input())
4 | # STATE: T * [6:(Integer, (∅, Σ)), 8:(String, (∅, Σ))]
5 | for i in range(T):
6 | z: int = int(input())
7 | if z > 0:
8 | x: int = int(input())
9 | if x == 10:
10 | pass
11 | else:
12 | raise ValueError
13 | else:
14 | y: str = input()
15 | if y == 'abc':
16 | pass
17 | else:
18 | raise ValueError
19 | # FINAL: ε
20 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/indexing3/subscriptions4.py:
--------------------------------------------------------------------------------
1 |
2 | D: Dict[int, List[int]] = {1: [2], 2: [3, 4]}
3 | L: List[List[int]] = [[], [2], [3, 4]]
4 | # STATE: D -> 1@[2, 2], 2@[3, 4], _@⊥; L -> 0@⊥, 1@[2, 2], 2@[3, 4], _@⊥; keys(D) -> [1, 2]; len(D) -> [2, 2]; len(L) -> [3, 3]; values(D) -> 0@[2, 3], _@[4, 4]; y -> [-inf, inf]; z -> [-inf, inf]
5 | y: int = D[2][1]
6 | z: int = L[2][1]
7 | # FINAL: D -> 1@[2, 2], 2@[3, 4], _@⊥; L -> 0@⊥, 1@[2, 2], 2@[3, 4], _@⊥; keys(D) -> [1, 2]; len(D) -> [2, 2]; len(L) -> [3, 3]; values(D) -> 0@[2, 3], _@[4, 4]; y -> [4, 4]; z -> [3, 4]
8 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/summarization/length.py:
--------------------------------------------------------------------------------
1 |
2 | # INITIAL: i -> [-inf, inf]; len(x) -> [0, inf]; len(y) -> [0, inf]; x -> [-inf, inf]; y -> [-inf, inf]
3 | x: List[str] = input().split()
4 | y: List[int] = list()
5 | # STATE: i -> [-inf, inf]; len(x) -> [0, inf]; len(y) -> [0, 0]; x -> [-inf, inf]; y -> ⊥
6 | for i in range(len(x)): # LOOP: i -> [-inf, inf]; len(x) -> [0, inf]; len(y) -> [0, inf]; x -> [-inf, inf]; y -> [-inf, inf]
7 | y.append(int(x[i]))
8 | # FINAL: i -> [-inf, inf]; len(x) -> [0, inf]; len(y) -> [0, inf]; x -> [-inf, inf]; y -> [-inf, inf]
9 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/summarization/subscriptionsC.py:
--------------------------------------------------------------------------------
1 |
2 | s: str = 'abcd'
3 | z: str = s[0]
4 |
5 | L: List[Set[int]] = [{0}, {1, 2}, {3}]
6 | x: Set[int] = L[1]
7 |
8 | D: Dict[int, Dict[int, int]] = {0: {3: 4}, 1: {5 : 6}, 2: {7: 8, 9: 10}}
9 | d: Dict[int, int] = D[2]
10 | # FINAL: D -> [0, 10]; L -> [0, 3]; d -> [3, 10]; keys(D) -> [0, 2]; keys(d) -> [3, 10]; len(D) -> [3, 3]; len(L) -> [3, 3]; len(d) -> [0, inf]; len(s) -> [4, 4]; len(x) -> [0, inf]; len(z) -> [1, 1]; s -> [-inf, inf]; values(D) -> [3, 10]; values(d) -> [3, 10]; x -> [0, 3]; z -> [-inf, inf]
11 |
--------------------------------------------------------------------------------
/docs/lyra.semantics.rst:
--------------------------------------------------------------------------------
1 | lyra\.semantics package
2 | =======================
3 |
4 | .. automodule:: lyra.semantics
5 | :members:
6 | :undoc-members:
7 | :show-inheritance:
8 |
9 | Submodules
10 | ----------
11 |
12 | .. automodule:: lyra.semantics.backward
13 | :members:
14 | :undoc-members:
15 | :show-inheritance:
16 |
17 | .. automodule:: lyra.semantics.forward
18 | :members:
19 | :undoc-members:
20 | :show-inheritance:
21 |
22 | .. automodule:: lyra.semantics.semantics
23 | :members:
24 | :undoc-members:
25 | :show-inheritance:
26 |
27 |
28 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/indexing3/length.py:
--------------------------------------------------------------------------------
1 |
2 | # INITIAL: i -> [-inf, inf]; len(x) -> [0, inf]; len(y) -> [0, inf]; x -> _@[-inf, inf]; y -> _@[-inf, inf]
3 | x: List[str] = input().split()
4 | y: List[int] = list()
5 | # STATE: i -> [-inf, inf]; len(x) -> [0, inf]; len(y) -> [0, 0]; x -> _@[-inf, inf]; y -> _@⊥
6 | for i in range(len(x)): # LOOP: i -> [-inf, inf]; len(x) -> [0, inf]; len(y) -> [0, inf]; x -> _@[-inf, inf]; y -> _@[-inf, inf]
7 | y.append(int(x[i]))
8 | # FINAL: i -> [-inf, inf]; len(x) -> [0, inf]; len(y) -> [0, inf]; x -> _@[-inf, inf]; y -> _@[-inf, inf]
9 |
--------------------------------------------------------------------------------
/docs/html/_sources/lyra.abstract_domains.numerical.rst.txt:
--------------------------------------------------------------------------------
1 | lyra\.abstract\_domains\.numerical package
2 | ==========================================
3 |
4 | .. automodule:: lyra.abstract_domains.numerical
5 | :members:
6 | :undoc-members:
7 | :show-inheritance:
8 |
9 | Submodules
10 | ----------
11 |
12 | .. automodule:: lyra.abstract_domains.numerical.interval_domain
13 | :members:
14 | :undoc-members:
15 | :show-inheritance:
16 |
17 | .. automodule:: lyra.abstract_domains.numerical.sign_domain
18 | :members:
19 | :undoc-members:
20 | :show-inheritance:
21 |
22 |
23 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/backward/summarization/subscriptions1g.py:
--------------------------------------------------------------------------------
1 |
2 | x: int = int(input())
3 | # STATE: d -> [-inf, inf]; keys(d) -> [-inf, inf]; len(d) -> [0, inf]; values(d) -> [-inf, inf]; x -> [-inf, inf]; z -> [-inf, inf]
4 | d: Dict[int, int] = {3: {0: 0}, 4: {0: 1}, 5: {0: x}}[5]
5 | # STATE: d -> [-inf, inf]; keys(d) -> [-inf, inf]; len(d) -> [1, inf]; values(d) -> [-inf, inf]; x -> [-inf, inf]; z -> [-inf, inf]
6 | z: int = d[0]
7 | # STATE: d -> [-inf, inf]; keys(d) -> [-inf, inf]; len(d) -> [0, inf]; values(d) -> [-inf, inf]; x -> [-inf, inf]; z -> [2, 2]
8 | if z != 2:
9 | raise ValueError
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/summarization/nested1.py:
--------------------------------------------------------------------------------
1 |
2 | L1: List[int] = [1, 1]
3 | L2: List[List[int]] = [[1], [1, 1, 1]]
4 | L3: List[Dict[int, int]] = [{1: 1}, {}]
5 | L4: List[List[List[int]]] = [[[1], [1, 1]], [[1, 1], [1, 1, 1]]]
6 | # STATE: L1 -> [1, 1]; L2 -> [1, 1]; L3 -> [1, 1]; L4 -> [1, 1]; len(L1) -> [2, 2]; len(L2) -> [2, 2]; len(L3) -> [2, 2]; len(L4) -> [2, 2]
7 | L1[1] = 2
8 | L2[1][2] = 2
9 | L3[1][2] = 2
10 | L4[0][1][2] = 2
11 | # FINAL: L1 -> [1, 2]; L2 -> [1, 2]; L3 -> [1, 2]; L4 -> [1, 2]; len(L1) -> [2, 2]; len(L2) -> [2, 2]; len(L3) -> [2, 2]; len(L4) -> [2, 2]
12 |
--------------------------------------------------------------------------------
/docs/html/_sources/lyra.semantics.rst.txt:
--------------------------------------------------------------------------------
1 | lyra\.semantics package
2 | =======================
3 |
4 | .. automodule:: lyra.semantics
5 | :members:
6 | :undoc-members:
7 | :show-inheritance:
8 |
9 | Submodules
10 | ----------
11 |
12 | .. automodule:: lyra.semantics.backward
13 | :members:
14 | :undoc-members:
15 | :show-inheritance:
16 |
17 | .. automodule:: lyra.semantics.forward
18 | :members:
19 | :undoc-members:
20 | :show-inheritance:
21 |
22 | .. automodule:: lyra.semantics.semantics
23 | :members:
24 | :undoc-members:
25 | :show-inheritance:
26 |
27 |
28 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/assignments.py:
--------------------------------------------------------------------------------
1 |
2 | # INITIAL: a -> [-inf, inf]; x -> [-inf, inf]; y -> [-inf, inf]
3 | x: int = 3
4 | # STATE: a -> [-inf, inf]; x -> [3, 3]; y -> [-inf, inf]
5 | y: int = 5
6 | # STATE: a -> [-inf, inf]; x -> [3, 3]; y -> [5, 5]
7 | a: int = x + y
8 | # STATE: a -> [8, 8]; x -> [3, 3]; y -> [5, 5]
9 | if a > 0:
10 | # STATE: a -> [8, 8]; x -> [3, 3]; y -> [5, 5]
11 | a = 2 * a
12 | # STATE: a -> [16, 16]; x -> [3, 3]; y -> [5, 5]
13 | # STATE: a -> [16, 16]; x -> [3, 3]; y -> [5, 5]
14 | print(a)
15 | # FINAL: a -> [16, 16]; x -> [3, 3]; y -> [5, 5]
16 |
--------------------------------------------------------------------------------
/src/lyra/unittests/usage/dataframes/handcraft_example_3.py:
--------------------------------------------------------------------------------
1 | import pandas as pd
2 |
3 | # INITIAL: df -> {_ -> W}
4 | df: pd.DataFrame = pd.read_csv("data.csv")
5 |
6 | # STATE: df -> {Column -> N, First -> U, Second -> U, Some -> N, Third -> U, _ -> N}
7 | df[["Second", "Third"]].info()
8 |
9 | # STATE: df -> {Column -> N, First -> U, Some -> N, _ -> N}
10 | df["First"].info()
11 |
12 | # STATE: df -> {Column -> N, First -> N, Some -> N, _ -> N}
13 | df.drop("First", axis=1)
14 |
15 | # STATE: df -> {Column -> N, Some -> N, _ -> N}
16 | df.drop(["Some", "Column"], axis=1)
17 |
18 | # FINAL: df -> {_ -> N}
19 |
--------------------------------------------------------------------------------
/src/lyra/engine/usage/dataframe_usage_analysis.py:
--------------------------------------------------------------------------------
1 | from lyra.abstract_domains.usage.dataframe_usage_domain import DataFrameColumnUsageState
2 | from lyra.engine.backward import BackwardInterpreter
3 | from lyra.engine.runner import Runner
4 | from lyra.semantics.dataframe_usage_semantics import DataFrameColumnUsageSemantics
5 |
6 |
7 | class DataFrameColumnUsageAnalysis(Runner):
8 |
9 | def interpreter(self):
10 | return BackwardInterpreter(self.cfgs, self.fargs, DataFrameColumnUsageSemantics(), 3)
11 |
12 | def state(self): # initial state
13 | return DataFrameColumnUsageState(self.variables)
14 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/backward/summarization/subscriptions1e.py:
--------------------------------------------------------------------------------
1 |
2 | x: int = int(input())
3 | # STATE: D -> [-inf, inf]; keys(D) -> [-inf, inf]; len(D) -> [0, inf]; values(D) -> [-inf, inf]; x -> [-inf, inf]; z -> [-inf, inf]
4 | D: Dict[int, List[int]] = {0: [0], 1: [1], 2: [x]}
5 | # STATE: D -> [-inf, inf]; keys(D) -> [-inf, inf]; len(D) -> [1, inf]; values(D) -> [-inf, inf]; x -> [-inf, inf]; z -> [-inf, inf]
6 | z: int = D[2][0]
7 | # STATE: D -> [-inf, inf]; keys(D) -> [-inf, inf]; len(D) -> [0, inf]; values(D) -> [-inf, inf]; x -> [-inf, inf]; z -> [2, 2]
8 | if z != 2:
9 | raise ValueError
10 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/sign/forward/booleans.py:
--------------------------------------------------------------------------------
1 | # INITIAL: a -> ⊤; b -> ⊤; c -> ⊤
2 | a: bool = True
3 | # STATE: a -> >0; b -> ⊤; c -> ⊤
4 | b: bool = False
5 | # STATE: a -> >0; b -> =0; c -> ⊤
6 | c: bool = a and b
7 | # STATE: a -> >0; b -> =0; c -> =0
8 | c = a or b
9 | # STATE: a -> >0; b -> =0; c -> >0
10 | if a:
11 | # STATE: a -> >0; b -> =0; c -> >0
12 | c = False
13 | # STATE: a -> >0; b -> =0; c -> =0
14 | # STATE: a -> >0; b -> =0; c -> =0
15 | if not a:
16 | # STATE: a -> ⊥; b -> =0; c -> =0
17 | c = True
18 | # STATE: a -> ⊥; b -> =0; c -> =0
19 | # FINAL: a -> >0; b -> =0; c -> =0
20 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/backward/indexing3/subscriptions1g.py:
--------------------------------------------------------------------------------
1 |
2 | x: int = int(input())
3 | # STATE: d -> _@[-inf, inf]; keys(d) -> [-inf, inf]; len(d) -> [0, inf]; values(d) -> [-inf, inf]; x -> [2, 2]; z -> [-inf, inf]
4 | d: Dict[int, int] = {3: {0: 0}, 4: {0: 1}, 5: {0: x}}[5]
5 | # STATE: d -> 0@[2, 2], _@[-inf, inf]; keys(d) -> [-inf, inf]; len(d) -> [1, inf]; values(d) -> [-inf, inf]; x -> [-inf, inf]; z -> [-inf, inf]
6 | z: int = d[0]
7 | # STATE: d -> _@[-inf, inf]; keys(d) -> [-inf, inf]; len(d) -> [0, inf]; values(d) -> [-inf, inf]; x -> [-inf, inf]; z -> [2, 2]
8 | if z != 2:
9 | raise ValueError
10 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/sign/forward/lists.py:
--------------------------------------------------------------------------------
1 | # INITIAL: a -> ⊤; l1 -> ⊤; l2 -> ⊤; len(l1) -> [0, inf]; len(l2) -> [0, inf]
2 | l1: List[int] = [-1, 0]
3 | # STATE: a -> ⊤; l1 -> ≤0; l2 -> ⊤; len(l1) -> [2, 2]; len(l2) -> [0, inf]
4 | l2: List[int] = [0, 0]
5 | # STATE: a -> ⊤; l1 -> ≤0; l2 -> =0; len(l1) -> [2, 2]; len(l2) -> [2, 2]
6 | a: int = l1[0]
7 | # STATE: a -> ≤0; l1 -> ≤0; l2 -> =0; len(l1) -> [2, 2]; len(l2) -> [2, 2]
8 | l2[0]: int = 1
9 | # STATE: a -> ≤0; l1 -> ≤0; l2 -> ≥0; len(l1) -> [2, 2]; len(l2) -> [2, 2]
10 | l2[0]: int = a
11 | # FINAL: a -> ≤0; l1 -> ≤0; l2 -> ⊤; len(l1) -> [2, 2]; len(l2) -> [2, 2]
12 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/backward/indexing3/subscriptions1e.py:
--------------------------------------------------------------------------------
1 |
2 | x: int = int(input())
3 | # STATE: D -> _@[-inf, inf]; keys(D) -> [-inf, inf]; len(D) -> [0, inf]; values(D) -> _@[-inf, inf]; x -> [-inf, inf]; z -> [-inf, inf]
4 | D: Dict[int, List[int]] = {0: [0], 1: [1], 2: [x]}
5 | # STATE: D -> 2@[-inf, inf], _@[-inf, inf]; keys(D) -> [-inf, inf]; len(D) -> [1, inf]; values(D) -> _@[-inf, inf]; x -> [-inf, inf]; z -> [-inf, inf]
6 | z: int = D[2][0]
7 | # STATE: D -> _@[-inf, inf]; keys(D) -> [-inf, inf]; len(D) -> [0, inf]; values(D) -> _@[-inf, inf]; x -> [-inf, inf]; z -> [2, 2]
8 | if z != 2:
9 | raise ValueError
10 |
--------------------------------------------------------------------------------
/src/lyra/engine/usage/usage_analysis.py:
--------------------------------------------------------------------------------
1 | """
2 | Input Data Usage Analysis
3 | =========================
4 |
5 | :Author: Caterina Urban
6 | """
7 |
8 | from lyra.abstract_domains.usage.usage_domain import SimpleUsageState
9 | from lyra.engine.backward import BackwardInterpreter
10 | from lyra.engine.runner import Runner
11 | from lyra.semantics.backward import DefaultBackwardSemantics
12 |
13 |
14 | class SimpleUsageAnalysis(Runner):
15 |
16 | def interpreter(self):
17 | return BackwardInterpreter(self.cfgs, self.fargs, DefaultBackwardSemantics(), 3)
18 |
19 | def state(self): # initial state
20 | return SimpleUsageState(self.variables)
21 |
--------------------------------------------------------------------------------
/src/lyra/unittests/assumption/type+alphabet/substitution.py:
--------------------------------------------------------------------------------
1 |
2 | # INITIAL: 3:(String, ({'a', 'b', 'c'}, {'a', 'b', 'c'})), 5:(String, ({'a', 'b', 'c'}, {'a', 'b', 'c'})), 7:(String, (∅, ∅))
3 | a: str = input()
4 | # STATE: 5:(String, ({'a', 'b', 'c'}, {'a', 'b', 'c'})), 7:(String, (∅, ∅))
5 | b: str = input()
6 | # STATE: 7:(String, (∅, ∅))
7 | c: str = input()
8 | # STATE: ε
9 | if a == b + c:
10 | pass
11 | else:
12 | raise ValueError
13 | if a == 'abc':
14 | pass
15 | else:
16 | raise ValueError
17 | if c == '':
18 | pass
19 | else:
20 | raise ValueError
21 | if b == 'abc':
22 | pass
23 | else:
24 | raise ValueError
25 | # FINAL: ε
26 |
--------------------------------------------------------------------------------
/docs/Makefile:
--------------------------------------------------------------------------------
1 | # Minimal makefile for Sphinx documentation
2 | #
3 |
4 | # You can set these variables from the command line.
5 | SPHINXOPTS =
6 | SPHINXBUILD = python3.6 -msphinx
7 | SPHINXPROJ = Lyra
8 | SOURCEDIR = .
9 | BUILDDIR = .
10 |
11 | # Put it first so that "make" without argument is like "make help".
12 | help:
13 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14 |
15 | .PHONY: help Makefile
16 |
17 | # Catch-all target: route all unknown targets to Sphinx using the new
18 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19 | %: Makefile
20 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(cdBUILDDIR)" $(SPHINXOPTS) $(O)
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/indexing3/subscriptionsC.py:
--------------------------------------------------------------------------------
1 |
2 | s: str = 'abcd'
3 | z: str = s[0]
4 |
5 | L: List[Set[int]] = [{0}, {1, 2}, {3}]
6 | x: Set[int] = L[1]
7 |
8 | D: Dict[int, Dict[int, int]] = {0: {3: 4}, 1: {5 : 6}, 2: {7: 8, 9: 10}}
9 | d: Dict[int, int] = D[2]
10 | # FINAL: D -> 0@[3, 4], 1@[5, 6], 2@[7, 10], _@⊥; L -> 0@[0, 0], 1@[1, 2], 2@[3, 3], _@⊥; d -> _@[7, 10]; keys(D) -> [0, 2]; keys(d) -> [7, 10]; len(D) -> [3, 3]; len(L) -> [3, 3]; len(d) -> [0, inf]; len(s) -> [4, 4]; len(x) -> [0, inf]; len(z) -> [1, 1]; s -> 0@[-inf, inf], 1@[-inf, inf], 2@[-inf, inf], _@[-inf, inf]; values(D) -> _@[3, 10]; values(d) -> [7, 10]; x -> [1, 2]; z -> _@[-inf, inf]
11 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/polyhedra/forward/popl2014.py:
--------------------------------------------------------------------------------
1 |
2 | # INITIAL:
3 | x: float = float(input())
4 | # STATE:
5 | y: float = float(input())
6 | # STATE:
7 | if x < 1 or x > 3 or y < 0 or y > 2:
8 | raise ValueError
9 | # STATE: ⊥
10 | while y <= 3: # LOOP: -1·y + 4 >= 0 ∧ 1·y + 0 >= 0 ∧ 1·x - 1 >= 0 ∧ 2·x - 1·y + 0 >= 0 ∧ 4·x - 3·y + 3 >= 0
11 | # STATE: -1·y + 3 >= 0 ∧ 1·y + 0 >= 0 ∧ 1·x - 1 >= 0 ∧ 2·x - 1·y + 0 >= 0
12 | x = 1.5 * x
13 | # STATE: -1·y + 3 >= 0 ∧ 1·y + 0 >= 0 ∧ 2·x - 3 >= 0 ∧ 4·x - 3·y + 0 >= 0
14 | y = y + 1
15 | # STATE: -1·y + 4 >= 0 ∧ 1·y - 1 >= 0 ∧ 2·x - 3 >= 0 ∧ 4·x - 3·y + 3 >= 0
16 | # FINAL: -1·y + 4 >= 0 ∧ 1·y - 3 > 0 ∧ 4·x - 3·y + 3 >= 0
17 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/summarization/nested3.py:
--------------------------------------------------------------------------------
1 |
2 | D4: Dict[int, List[int]] = {1: [1, 1, 1], 2: [0, 0]}
3 | D5: Dict[int, List[List[int]]] = {1: [[1], [1, 1]], 2: [[0], [0, 0, 0]]}
4 | # STATE: D4 -> [0, 2]; D5 -> [0, 2]; keys(D4) -> [1, 2]; keys(D5) -> [1, 2]; len(D4) -> [2, 2]; len(D5) -> [2, 2]; values(D4) -> [0, 1]; values(D5) -> [0, 1]
5 | D4[1][0] = 2
6 | # STATE: D4 -> [0, 2]; D5 -> [0, 2]; keys(D4) -> [1, 2]; keys(D5) -> [1, 2]; len(D4) -> [2, 2]; len(D5) -> [2, 2]; values(D4) -> [0, 2]; values(D5) -> [0, 1]
7 | D5[1][1][0] = 2
8 | # STATE: D4 -> [0, 2]; D5 -> [0, 2]; keys(D4) -> [1, 2]; keys(D5) -> [1, 2]; len(D4) -> [2, 2]; len(D5) -> [2, 2]; values(D4) -> [0, 2]; values(D5) -> [0, 2]
9 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/backward/summarization/subscriptions1a.py:
--------------------------------------------------------------------------------
1 |
2 | x: int = int(input())
3 | # STATE: L -> [-inf, inf]; l -> [-inf, inf]; len(L) -> [0, inf]; len(l) -> [0, inf]; x -> [-inf, inf]; z -> [-inf, inf]
4 | L: List[List[int]] = [[0], [1], [x]]
5 | # STATE: L -> [-inf, inf]; l -> [-inf, inf]; len(L) -> [3, inf]; len(l) -> [0, inf]; x -> [-inf, inf]; z -> [-inf, inf]
6 | l: List[int] = L[2]
7 | # STATE: L -> [-inf, inf]; l -> [-inf, inf]; len(L) -> [0, inf]; len(l) -> [1, inf]; x -> [-inf, inf]; z -> [-inf, inf]
8 | z: int = l[0]
9 | # STATE: L -> [-inf, inf]; l -> [-inf, inf]; len(L) -> [0, inf]; len(l) -> [0, inf]; x -> [-inf, inf]; z -> [2, 2]
10 | if z != 2:
11 | raise ValueError
12 |
--------------------------------------------------------------------------------
/src/lyra/unittests/usage/dataframes/handcraft_example_2.py:
--------------------------------------------------------------------------------
1 | import pandas as pd
2 |
3 | # STATE: df -> {_ -> W}
4 | df: pd.DataFrame = pd.read_csv("...")
5 |
6 | # STATE: df -> {Latitude -> U, Longitude -> U, rot_15_x -> W, rot_30_x -> W, rot_45_x -> W, _ -> U}
7 | df['rot_15_x'] = 0.96 * df['Longitude'] + 0.25 * df['Latitude']
8 |
9 | # STATE: df -> {Latitude -> U, Longitude -> U, rot_30_x -> W, rot_45_x -> W, _ -> U}
10 | df['rot_30_x'] = 0.86 * df['Longitude'] + 0.49 * df['Latitude']
11 |
12 | # STATE: df -> {Latitude -> U, Longitude -> U, rot_45_x -> W, _ -> U}
13 | df['rot_45_x'] = 0.71 * df['Longitude'] + 0.71 * df['Latitude']
14 |
15 | # STATE: df -> {_ -> U}
16 | df.head()
17 |
18 | # FINAL: df -> {_ -> N}
19 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/indexing3/nested1.py:
--------------------------------------------------------------------------------
1 |
2 | L1: List[int] = [1, 1]
3 | L2: List[List[int]] = [[1], [1, 1, 1]]
4 | L3: List[Dict[int, int]] = [{1: 1}, {}]
5 | L4: List[List[List[int]]] = [[[1], [1, 1]], [[1, 1], [1, 1, 1]]]
6 | # STATE: L1 -> 0@[1, 1], 1@[1, 1], _@⊥; L2 -> 0@[1, 1], 1@[1, 1], _@⊥; L3 -> 0@[1, 1], 1@⊥, _@⊥; L4 -> 0@[1, 1], 1@[1, 1], _@⊥; len(L1) -> [2, 2]; len(L2) -> [2, 2]; len(L3) -> [2, 2]; len(L4) -> [2, 2]
7 | L1[1] = 2
8 | L2[1][2] = 2
9 | L3[1][2] = 2
10 | L4[0][1][2] = 2
11 | # FINAL: L1 -> 0@[1, 1], 1@[2, 2], _@⊥; L2 -> 0@[1, 1], 1@[1, 2], _@⊥; L3 -> 0@[1, 1], 1@[2, 2], _@⊥; L4 -> 0@[1, 2], 1@[1, 1], _@⊥; len(L1) -> [2, 2]; len(L2) -> [2, 2]; len(L3) -> [2, 2]; len(L4) -> [2, 2]
12 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/backward/indexing3/subscriptions1a.py:
--------------------------------------------------------------------------------
1 |
2 | x: int = int(input())
3 | # STATE: L -> _@[-inf, inf]; l -> _@[-inf, inf]; len(L) -> [0, inf]; len(l) -> [0, inf]; x -> [-inf, inf]; z -> [-inf, inf]
4 | L: List[List[int]] = [[0], [1], [x]]
5 | # STATE: L -> 2@[-inf, inf], _@[-inf, inf]; l -> _@[-inf, inf]; len(L) -> [3, inf]; len(l) -> [0, inf]; x -> [-inf, inf]; z -> [-inf, inf]
6 | l: List[int] = L[2]
7 | # STATE: L -> _@[-inf, inf]; l -> 0@[2, 2], _@[-inf, inf]; len(L) -> [0, inf]; len(l) -> [1, inf]; x -> [-inf, inf]; z -> [-inf, inf]
8 | z: int = l[0]
9 | # STATE: L -> _@[-inf, inf]; l -> _@[-inf, inf]; len(L) -> [0, inf]; len(l) -> [0, inf]; x -> [-inf, inf]; z -> [2, 2]
10 | if z != 2:
11 | raise ValueError
12 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/boolvar.py:
--------------------------------------------------------------------------------
1 |
2 | # INITIAL: b -> [-inf, inf]; q -> [-inf, inf]; z -> [-inf, inf]
3 | b: bool = bool(input())
4 | # STATE: b -> [0, 1]; q -> [-inf, inf]; z -> [-inf, inf]
5 | q: bool = bool(input())
6 | # STATE: b -> [0, 1]; q -> [0, 1]; z -> [-inf, inf]
7 | z: int = 1
8 | # STATE: b -> [0, 1]; q -> [0, 1]; z -> [1, 1]
9 | if b and q:
10 | # STATE: b -> [1, 1]; q -> [1, 1]; z -> [1, 1]
11 | z = 1
12 | # STATE: b -> [1, 1]; q -> [1, 1]; z -> [1, 1]
13 | else:
14 | # STATE: b -> [0, 1]; q -> [0, 1]; z -> [1, 1]
15 | z = 0
16 | # STATE: b -> [0, 1]; q -> [0, 1]; z -> [0, 0]
17 | # STATE: b -> [0, 1]; q -> [0, 1]; z -> [0, 1]
18 | print(z)
19 | # FINAL: b -> [0, 1]; q -> [0, 1]; z -> [0, 1]
20 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/backward/summarization/dictionary1.py:
--------------------------------------------------------------------------------
1 |
2 | example: Dict[str, int] = dict()
3 | for i in range(3):
4 | example[i] = i
5 | value: int = int(input())
6 | # STATE: example -> [-inf, inf]; i -> [-inf, inf]; keys(example) -> [-inf, inf]; len(example) -> [0, inf]; value -> [-inf, inf]; values(example) -> [-inf, inf]
7 | example[0]: int = value
8 | # STATE: example -> [-inf, inf]; i -> [-inf, inf]; keys(example) -> [-inf, inf]; len(example) -> [1, inf]; value -> [-inf, inf]; values(example) -> [-inf, inf]
9 | i: int = example[0]
10 | # STATE: example -> [-inf, inf]; i -> [3, 3]; keys(example) -> [-inf, inf]; len(example) -> [0, inf]; value -> [-inf, inf]; values(example) -> [-inf, inf]
11 | if i != 3:
12 | raise ValueError
13 |
--------------------------------------------------------------------------------
/src/lyra/unittests/usage/simple.py:
--------------------------------------------------------------------------------
1 |
2 | # INITIAL: bonus -> W; english -> N; math -> W; passing -> W; science -> N
3 | english: bool = bool(input())
4 | math: bool = bool(input())
5 | science: bool = bool(input())
6 | bonus: bool = bool(input())
7 | # STATE: bonus -> U; english -> N; math -> U; passing -> W; science -> N
8 | passing: bool = True
9 | # STATE: bonus -> U; english -> N; math -> U; passing -> U; science -> N
10 | if not english:
11 | english: bool = False # error: *english* should be *passing*
12 | if not math:
13 | passing: bool = False or bonus
14 | if not math:
15 | passing: bool = False or bonus # error: *math* should be *science*
16 | print(passing)
17 | # FINAL: bonus -> N; english -> N; math -> N; passing -> N; science -> N
18 |
--------------------------------------------------------------------------------
/setup.py:
--------------------------------------------------------------------------------
1 | from setuptools import setup, find_packages
2 |
3 | config = {
4 | 'name': 'Lyra',
5 | 'version': '0.1',
6 | 'author': 'Caterina Urban',
7 | 'author_email': 'caterina.urban@gmail.com',
8 | 'description': 'Static Program Analyzer for Python Data Science Applications',
9 | 'url': 'http://www.pm.inf.ethz.ch/research/lyra.html',
10 | 'license': 'MPL-2.0',
11 | 'packages': find_packages('src'),
12 | 'package_dir': {'': 'src'},
13 | 'entry_points': {
14 | 'console_scripts': [
15 | 'lyra = lyra.main:main',
16 | ]
17 | },
18 | 'install_requires': [
19 | 'graphviz==0.7.1',
20 | 'z3',
21 | ],
22 | 'scripts': [],
23 | }
24 |
25 | setup(**config)
26 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/backward/indexing3/dictionary1.py:
--------------------------------------------------------------------------------
1 |
2 | example: Dict[str, int] = dict()
3 | for i in range(3):
4 | example[i] = i
5 | value: int = int(input())
6 | # STATE: example -> _@[-inf, inf]; i -> [-inf, inf]; keys(example) -> _@[-inf, inf]; len(example) -> [0, inf]; value -> [3, 3]; values(example) -> [-inf, inf]
7 | example[0]: int = value
8 | # STATE: example -> 0@[3, 3], _@[-inf, inf]; i -> [-inf, inf]; keys(example) -> _@[-inf, inf]; len(example) -> [1, inf]; value -> [-inf, inf]; values(example) -> [-inf, inf]
9 | i: int = example[0]
10 | # STATE: example -> _@[-inf, inf]; i -> [3, 3]; keys(example) -> _@[-inf, inf]; len(example) -> [0, inf]; value -> [-inf, inf]; values(example) -> [-inf, inf]
11 | if i != 3:
12 | raise ValueError
13 |
--------------------------------------------------------------------------------
/docs/lyra.core.rst:
--------------------------------------------------------------------------------
1 | lyra\.core package
2 | ==================
3 |
4 | .. automodule:: lyra.core
5 | :members:
6 | :undoc-members:
7 | :show-inheritance:
8 |
9 | Submodules
10 | ----------
11 |
12 | .. automodule:: lyra.core.cfg
13 | :members:
14 | :undoc-members:
15 | :show-inheritance:
16 |
17 | .. automodule:: lyra.core.expressions
18 | :members:
19 | :undoc-members:
20 | :show-inheritance:
21 |
22 | .. automodule:: lyra.core.statements
23 | :members:
24 | :undoc-members:
25 | :show-inheritance:
26 |
27 | .. automodule:: lyra.core.types
28 | :members:
29 | :undoc-members:
30 | :show-inheritance:
31 |
32 | .. automodule:: lyra.core.utils
33 | :members:
34 | :undoc-members:
35 | :show-inheritance:
36 |
37 |
38 |
--------------------------------------------------------------------------------
/src/lyra/unittests/usage/dataframes/handcraft_example_6.py:
--------------------------------------------------------------------------------
1 | import pandas as pd
2 |
3 | # INITIAL: df -> {_ -> W}; norm_df -> {_ -> W}
4 | df: pd.DataFrame = pd.read_csv("...")
5 |
6 | # STATE: df -> {norm_x1 -> W, norm_x2 -> W, x1 -> U, x2 -> U, _ -> N}; norm_df -> {_ -> W}
7 | df["norm_x1"] = (df["x1"] - df["x1"].min()) / (df["x1"].max() - df["x1"].min())
8 |
9 | # STATE: df -> {norm_x1 -> U, norm_x2 -> W, x2 -> U, _ -> N}; norm_df -> {_ -> W}
10 | df["norm_x2"] = (df["x2"] - df["x2"].min()) / (df["x2"].max() - df["x2"].min())
11 |
12 | # STATE: df -> {norm_x1 -> U, norm_x2 -> U, _ -> N}; norm_df -> {_ -> W}
13 | norm_df: pd.DataFrame = df[["norm_x1", "norm_x2"]]
14 |
15 | # STATE: df -> {_ -> N}; norm_df -> {_ -> U}
16 | norm_df.head()
17 |
18 | # FINAL: df -> {_ -> N}; norm_df -> {_ -> N}
19 |
--------------------------------------------------------------------------------
/docs/html/_sources/lyra.core.rst.txt:
--------------------------------------------------------------------------------
1 | lyra\.core package
2 | ==================
3 |
4 | .. automodule:: lyra.core
5 | :members:
6 | :undoc-members:
7 | :show-inheritance:
8 |
9 | Submodules
10 | ----------
11 |
12 | .. automodule:: lyra.core.cfg
13 | :members:
14 | :undoc-members:
15 | :show-inheritance:
16 |
17 | .. automodule:: lyra.core.expressions
18 | :members:
19 | :undoc-members:
20 | :show-inheritance:
21 |
22 | .. automodule:: lyra.core.statements
23 | :members:
24 | :undoc-members:
25 | :show-inheritance:
26 |
27 | .. automodule:: lyra.core.types
28 | :members:
29 | :undoc-members:
30 | :show-inheritance:
31 |
32 | .. automodule:: lyra.core.utils
33 | :members:
34 | :undoc-members:
35 | :show-inheritance:
36 |
37 |
38 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/summarization/dictionary1.py:
--------------------------------------------------------------------------------
1 |
2 | value: int = 3
3 | # STATE: example -> [-inf, inf]; i -> [-inf, inf]; keys(example) -> [-inf, inf]; len(example) -> [0, inf]; value -> [3, 3]; values(example) -> [-inf, inf]
4 | example: Dict[str, int] = {'a': 0, 'b': 1, 'c': 2}
5 | # STATE: example -> [-inf, inf]; i -> [-inf, inf]; keys(example) -> [-inf, inf]; len(example) -> [3, 3]; value -> [3, 3]; values(example) -> [0, 2]
6 | example['a']: int = value
7 | # STATE: example -> [-inf, inf]; i -> [-inf, inf]; keys(example) -> [-inf, inf]; len(example) -> [3, 4]; value -> [3, 3]; values(example) -> [0, 3]
8 | i: int = example['a']
9 | # STATE: example -> [-inf, inf]; i -> [0, 3]; keys(example) -> [-inf, inf]; len(example) -> [3, 4]; value -> [3, 3]; values(example) -> [0, 3]
10 | print(i)
11 |
--------------------------------------------------------------------------------
/src/lyra/tests/container/dict_descr_example.py:
--------------------------------------------------------------------------------
1 |
2 | important: Set[str] = {"Albert Einstein" , "Alan Turing"}
3 | texts: Dict[str, str] = input() # {"" : ""}
4 |
5 | freqdict: Dict[str, int] = {} # defaultdict(int) err: int recognized as varId #initialized to 0
6 | a: str = "" #necessary?
7 | b: str = ""
8 | for a, b in texts.items():
9 | if a in important: #texts of important authors weighted twice
10 | weight: int = 2
11 | else:
12 | weight: int = 1
13 | words: List[str] = a.split() #Bug A: Should be `b' (values)
14 | word: str = ""
15 | for word in words: #and Bug B: Wrong indentation
16 | word: str = word.lower()
17 | freqdict[word]: int = freqdict[word] + weight
18 | print(freqdict) #outputs :, ...
--------------------------------------------------------------------------------
/src/lyra/engine/liveness/liveness_analysis.py:
--------------------------------------------------------------------------------
1 | """
2 | (Strongly) Live Variable Analysis
3 | =================================
4 |
5 | :Author: Caterina Urban
6 | """
7 |
8 | from lyra.engine.backward import BackwardInterpreter
9 | from lyra.engine.runner import Runner
10 | from lyra.semantics.backward import DefaultBackwardSemantics
11 |
12 | from lyra.abstract_domains.liveness.liveness_domain import LivenessState, StrongLivenessState
13 |
14 |
15 | class LivenessAnalysis(Runner):
16 |
17 | def interpreter(self):
18 | return BackwardInterpreter(self.cfgs, self.fargs, DefaultBackwardSemantics(), 3)
19 |
20 | def state(self):
21 | return LivenessState(self.variables)
22 |
23 |
24 | class StrongLivenessAnalysis(LivenessAnalysis):
25 |
26 | def state(self):
27 | return StrongLivenessState(self.variables)
28 |
--------------------------------------------------------------------------------
/src/lyra/tests/code_jam/pancake_flipper/pancakes_mofhu.py:
--------------------------------------------------------------------------------
1 | n: int = int(input())
2 | for case in range(1, (n + 1)):
3 | line: List[str] = input().split()
4 | tmps: str = line[0]
5 | tmpk: str = line[1]
6 | s: List[str] = list(tmps)
7 | k: int = int(tmpk)
8 | n: int = 0
9 | for i in range(0, len(s)):
10 | if (s[i] == '-'):
11 | if (i > (len(s) - k)):
12 | print('Case #' + str(case) + ': ' + 'IMPOSSIBLE')
13 | break
14 | else:
15 | n += 1
16 | for i in range((i + 1), (i + k)):
17 | if (s[i] is '-'):
18 | s[i]: str = '+'
19 | else:
20 | s[i]: str = '-'
21 | else:
22 | pass
23 | else:
24 | print('Case #' + str(case) + ': ' + str(n))
25 |
--------------------------------------------------------------------------------
/src/lyra/unittests/usage/dict_simple_example.py:
--------------------------------------------------------------------------------
1 |
2 | # INITIAL: example -> W; i -> W; keys(example) -> W; len(example) -> [0, inf]; value -> W; values(example) -> W
3 | value: int = input()
4 | # STATE: example -> W; i -> W; keys(example) -> W; len(example) -> [0, inf]; value -> U; values(example) -> W
5 | example: Dict[str, int] = {"a": 0, "b": 1, "c": 2}
6 | # STATE: example -> U; i -> W; keys(example) -> U; len(example) -> [0, inf]; value -> U; values(example) -> U
7 | example["a"]: int = value
8 | # STATE: example -> U; i -> W; keys(example) -> U; len(example) -> [0, inf]; value -> N; values(example) -> U
9 | i: int = example["a"]
10 | # STATE: example -> N; i -> U; keys(example) -> N; len(example) -> [0, inf]; value -> N; values(example) -> N
11 | print(i)
12 | # FINAL: example -> N; i -> N; keys(example) -> N; len(example) -> [0, inf]; value -> N; values(example) -> N
13 |
--------------------------------------------------------------------------------
/src/lyra/unittests/usage/dataframes/call.py:
--------------------------------------------------------------------------------
1 | import pandas as pd
2 |
3 | # INITIAL: a -> {_ -> W}; b -> {_ -> W}; x -> {_ -> W}; y -> {_ -> W}
4 |
5 | x : pd.DataFrame = pd.read_csv("...")
6 | y : pd.DataFrame = pd.read_csv("...")
7 | a : pd.DataFrame = pd.read_csv("...")
8 | b : pd.DataFrame = pd.read_csv("...")
9 |
10 | def f(x: pd.DataFrame) -> pd.DataFrame:
11 | return x
12 |
13 | # STATE: a -> {A -> U, B -> U, _ -> N}; b -> {_ -> W}; x -> {X -> U, Y -> U, _ -> N}; y -> {_ -> W}
14 | y = g(x[["X","Y"]])
15 |
16 | # STATE: a -> {A -> U, B -> U, _ -> N}; b -> {_ -> W}; x -> {_ -> N}; y -> {_ -> U}
17 | b = f(a[["A","B"]])
18 |
19 | # STATE: a -> {_ -> N}; b -> {_ -> U}; x -> {_ -> N}; y -> {_ -> U}
20 | y.head()
21 | # STATE: a -> {_ -> N}; b -> {_ -> U}; x -> {_ -> N}; y -> {_ -> N}
22 | b.head()
23 |
24 | # FINAL: a -> {_ -> N}; b -> {_ -> N}; x -> {_ -> N}; y -> {_ -> N}
25 |
26 |
--------------------------------------------------------------------------------
/src/lyra/tests/code_jam/pancake_flipper/pancakes_gahou.py:
--------------------------------------------------------------------------------
1 | T: int = int(input())
2 | for t in range(1, (T + 1)):
3 | line: List[str] = input().split()
4 | S: str = line[0]
5 | K: int = int(line[1])
6 | a: List[int] = list()
7 | for index in range(len(S)):
8 | a.append(0)
9 | for i in range(len(S)):
10 | if (S[i] == '-'):
11 | a[i] += 1
12 | cnt: int = 0
13 | for i in range(((len(S) - K) + 1)):
14 | if ((a[i] % 2) == 1):
15 | cnt += 1
16 | for j in range(K):
17 | a[(i + j)] += 1
18 | is_valid: bool = True
19 | for i in range(len(S)):
20 | if ((a[i] % 2) == 1):
21 | is_valid: bool = False
22 | break
23 | if is_valid:
24 | print(((('Case #' + str(t)) + ': ') + str(cnt)))
25 | else:
26 | print((('Case #' + str(t)) + ': IMPOSSIBLE'))
27 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/indexing3/dictionary1.py:
--------------------------------------------------------------------------------
1 |
2 | value: int = 3
3 | # STATE: example -> _@[-inf, inf]; i -> [-inf, inf]; keys(example) -> _@[-inf, inf]; len(example) -> [0, inf]; value -> [3, 3]; values(example) -> [-inf, inf]
4 | example: Dict[str, int] = {'a': 0, 'b': 1, 'c': 2}
5 | # STATE: example -> "a"@[0, 0], "b"@[1, 1], "c"@[2, 2], _@⊥; i -> [-inf, inf]; keys(example) -> 0@[-inf, inf], _@⊥; len(example) -> [3, 3]; value -> [3, 3]; values(example) -> [0, 2]
6 | example['a']: int = value
7 | # STATE: example -> "a"@[3, 3], "b"@[1, 1], "c"@[2, 2], _@⊥; i -> [-inf, inf]; keys(example) -> 0@[-inf, inf], _@⊥; len(example) -> [3, 3]; value -> [3, 3]; values(example) -> [1, 3]
8 | i: int = example['a']
9 | # STATE: example -> "a"@[3, 3], "b"@[1, 1], "c"@[2, 2], _@⊥; i -> [3, 3]; keys(example) -> 0@[-inf, inf], _@⊥; len(example) -> [3, 3]; value -> [3, 3]; values(example) -> [1, 3]
10 | print(i)
11 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/indexing3/nested3.py:
--------------------------------------------------------------------------------
1 |
2 | D4: Dict[int, List[int]] = {1: [1, 1, 1], 2: [0, 0]}
3 | D5: Dict[int, List[List[int]]] = {1: [[1], [1, 1]], 2: [[0], [0, 0, 0]]}
4 | # STATE: D4 -> 1@[1, 1], 2@[0, 0], _@⊥; D5 -> 1@[1, 1], 2@[0, 0], _@⊥; keys(D4) -> [1, 2]; keys(D5) -> [1, 2]; len(D4) -> [2, 2]; len(D5) -> [2, 2]; values(D4) -> 0@[0, 1], 1@[0, 1], _@[1, 1]; values(D5) -> 0@[0, 1], 1@[0, 1], _@⊥
5 | D4[1][0] = 2
6 | # STATE: D4 -> 1@[1, 2], 2@[0, 0], _@⊥; D5 -> 1@[1, 1], 2@[0, 0], _@⊥; keys(D4) -> [1, 2]; keys(D5) -> [1, 2]; len(D4) -> [2, 2]; len(D5) -> [2, 2]; values(D4) -> 0@[0, 2], 1@[0, 1], _@[1, 1]; values(D5) -> 0@[0, 1], 1@[0, 1], _@⊥
7 | D5[1][1][0] = 2
8 | # STATE: D4 -> 1@[1, 2], 2@[0, 0], _@⊥; D5 -> 1@[1, 2], 2@[0, 0], _@⊥; keys(D4) -> [1, 2]; keys(D5) -> [1, 2]; len(D4) -> [2, 2]; len(D5) -> [2, 2]; values(D4) -> 0@[0, 2], 1@[0, 1], _@[1, 1]; values(D5) -> 0@[0, 1], 1@[0, 2], _@⊥
9 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/backward/summarization/subscriptions1d.py:
--------------------------------------------------------------------------------
1 |
2 | x: int = int(input())
3 | # STATE: D -> [-inf, inf]; keys(D) -> [-inf, inf]; l -> [-inf, inf]; len(D) -> [0, inf]; len(l) -> [0, inf]; values(D) -> [-inf, inf]; x -> [-inf, inf]; z -> [-inf, inf]
4 | D: Dict[int, List[int]] = {0: [0], 1: [1], 2: [x]}
5 | # STATE: D -> [-inf, inf]; keys(D) -> [-inf, inf]; l -> [-inf, inf]; len(D) -> [1, inf]; len(l) -> [0, inf]; values(D) -> [-inf, inf]; x -> [-inf, inf]; z -> [-inf, inf]
6 | l: List[int] = D[2]
7 | # STATE: D -> [-inf, inf]; keys(D) -> [-inf, inf]; l -> [-inf, inf]; len(D) -> [0, inf]; len(l) -> [1, inf]; values(D) -> [-inf, inf]; x -> [-inf, inf]; z -> [-inf, inf]
8 | z: int = l[0]
9 | # STATE: D -> [-inf, inf]; keys(D) -> [-inf, inf]; l -> [-inf, inf]; len(D) -> [0, inf]; len(l) -> [0, inf]; values(D) -> [-inf, inf]; x -> [-inf, inf]; z -> [2, 2]
10 | if z != 2:
11 | raise ValueError
12 |
--------------------------------------------------------------------------------
/src/lyra/tests/usage/running_example.py:
--------------------------------------------------------------------------------
1 | scores: Dict[int, int] = input() #dictinput() # id -> score
2 | # previous_ge_10: int = int(input()) # previous results
3 |
4 | score_occurrences: Dict[int, int] = {} # defaultdict(int) # initialized to 0
5 | for a, b in scores.items():
6 | if a < 100: # 'early adopter'
7 | weight: int = 3
8 | else:
9 | weight: int = 1
10 | if a not in score_occurrences.keys(): # workaround for defaultdict
11 | score_occurrences[a] = 0
12 | score_occurrences[a] += weight # BUG A: should be indexed by b & BUG B: wrong indentation
13 |
14 | # scores_gt_10: int = 0
15 | # if previous_ge_10 > 0:
16 | # scores_ge_10: int = previous_ge_10 # BUG C: scores_ge_10 instead of scores_gt_10
17 |
18 | scores_gt_10: int = 0
19 | for k in score_occurrences.keys():
20 | if k > 10:
21 | scores_gt_10 += score_occurrences[k]
22 |
23 | print(scores_gt_10)
24 |
--------------------------------------------------------------------------------
/src/lyra/unittests/assumption/type+quantity/cars.py:
--------------------------------------------------------------------------------
1 |
2 | # INITIAL: 3:(Integer, ⊤), 3.1 * [5:(Float, ≥0), 8:(Integer, ⊤), 8.1 * [11:(Integer, ⊤), 14:(Float, >0)]]
3 | cases: int = int(input())
4 | for case in range(cases):
5 | distance: float = float(input())
6 | if distance < 0:
7 | raise ValueError("Distance cannot be negative.")
8 | n: int = int(input())
9 | max: float = 0
10 | for i in range(n):
11 | position: int = int(input())
12 | if distance < position:
13 | raise ValueError("Distance cannot be smaller than the current position.")
14 | speed: float = float(input())
15 | if speed < 0:
16 | raise ValueError("Speed cannot be negative.")
17 | val: float = (distance - position) / speed
18 | if val > max:
19 | max: int = val
20 | print("Trip:")
21 | print(case + 1)
22 | print("with speed")
23 | print(distance / max)
24 | # FINAL: ε
25 |
--------------------------------------------------------------------------------
/src/lyra/unittests/assumption/type+quantity/convert.py:
--------------------------------------------------------------------------------
1 |
2 | # INITIAL: 3:(Integer, ≠0), 3.1 * [7:(String, ⊤), 8:(Integer, >0), 11:(String, ⊤)]
3 | items: int = int(input())
4 | if items == 0:
5 | raise ValueError
6 | for i in range(items):
7 | name: str = input()
8 | weight: float = int(input())
9 | if weight <= 0:
10 | raise ValueError
11 | unit: str = input()
12 | if unit == 'pounds' or unit == 'lb' or unit == 'lbs':
13 | weight: float = weight * 453.592 * 1e-3
14 | elif unit == 'ounces' or unit == 'oz' or unit == 'oz.':
15 | weight: float = weight * 28.35 * 1e-3
16 | elif unit == 'grams' or unit == 'gms' or unit == 'g':
17 | weight: float = weight * 1e-3
18 | elif unit == 'kilograms' or unit == 'kilo' or unit == 'kg':
19 | pass
20 | else:
21 | raise ValueError
22 | print("Item: " + name)
23 | print("weight:")
24 | print(weight)
25 | print("kg")
26 | # FINAL: ε
27 |
--------------------------------------------------------------------------------
/src/lyra/unittests/liveness/dict_simple_example.py:
--------------------------------------------------------------------------------
1 |
2 | # INITIAL: example -> Dead; i -> Dead; keys(example) -> Dead; len(example) -> [0, inf]; value -> Dead; values(example) -> Dead
3 | value: int = int(input())
4 | # STATE: example -> Dead; i -> Dead; keys(example) -> Dead; len(example) -> [0, inf]; value -> Live; values(example) -> Dead
5 | example: Dict[str, int] = {"a": 0, "b": 1, "c": 2}
6 | # STATE: example -> Live; i -> Dead; keys(example) -> Live; len(example) -> [0, inf]; value -> Live; values(example) -> Live
7 | example["a"]: int = value
8 | # STATE: example -> Live; i -> Dead; keys(example) -> Live; len(example) -> [0, inf]; value -> Dead; values(example) -> Live
9 | i: int = example["a"]
10 | # STATE: example -> Dead; i -> Live; keys(example) -> Dead; len(example) -> [0, inf]; value -> Dead; values(example) -> Dead
11 | print(i)
12 | # FINAL: example -> Dead; i -> Dead; keys(example) -> Dead; len(example) -> [0, inf]; value -> Dead; values(example) -> Dead
13 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/backward/indexing3/subscriptions1d.py:
--------------------------------------------------------------------------------
1 |
2 | x: int = int(input())
3 | # STATE: D -> _@[-inf, inf]; keys(D) -> [-inf, inf]; l -> _@[-inf, inf]; len(D) -> [0, inf]; len(l) -> [0, inf]; values(D) -> _@[-inf, inf]; x -> [-inf, inf]; z -> [-inf, inf]
4 | D: Dict[int, List[int]] = {0: [0], 1: [1], 2: [x]}
5 | # STATE: D -> 2@[-inf, inf], _@[-inf, inf]; keys(D) -> [-inf, inf]; l -> _@[-inf, inf]; len(D) -> [1, inf]; len(l) -> [0, inf]; values(D) -> _@[-inf, inf]; x -> [-inf, inf]; z -> [-inf, inf]
6 | l: List[int] = D[2]
7 | # STATE: D -> _@[-inf, inf]; keys(D) -> [-inf, inf]; l -> 0@[2, 2], _@[-inf, inf]; len(D) -> [0, inf]; len(l) -> [1, inf]; values(D) -> _@[-inf, inf]; x -> [-inf, inf]; z -> [-inf, inf]
8 | z: int = l[0]
9 | # STATE: D -> _@[-inf, inf]; keys(D) -> [-inf, inf]; l -> _@[-inf, inf]; len(D) -> [0, inf]; len(l) -> [0, inf]; values(D) -> _@[-inf, inf]; x -> [-inf, inf]; z -> [2, 2]
10 | if z != 2:
11 | raise ValueError
12 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 |
2 | language: python
3 | python:
4 | - "3.6"
5 | before_install:
6 | - sudo apt-get install graphviz
7 | install:
8 | - pip install -r requirements.txt
9 | stages:
10 | - unittests
11 | - linter
12 | jobs:
13 | include:
14 | - stage: unittests
15 | name: "Unit Tests"
16 | script:
17 | - cd src/lyra/unittests/
18 | - PYTHONPATH="${PYTHONPATH}:../../"
19 | - export PYTHONPATH
20 | - python -m unittest test_SignLattice.py
21 | - python -m unittest test_IntervalLattice.py
22 | - python -m unittest test_UsageLattice.py
23 | - python sign_tests.py
24 | - python interval_tests.py
25 | - python liveness_tests.py
26 | - python usage_tests.py
27 | - python assumption_tests.py
28 | - python fulara_tests.py
29 | - stage: linter
30 | name: "PEP 8 Coding Style"
31 | script:
32 | - cd src/
33 | - pycodestyle --filename=*.py .
34 |
--------------------------------------------------------------------------------
/src/lyra/engine/numerical/sign_analysis.py:
--------------------------------------------------------------------------------
1 | """
2 | Sign Analysis
3 | =============
4 |
5 | :Author: Jérôme Dohrau and Caterina Urban
6 | """
7 | from lyra.engine.backward import BackwardInterpreter
8 | from lyra.engine.forward import ForwardInterpreter
9 | from lyra.engine.runner import Runner
10 | from lyra.semantics.backward import DefaultBackwardSemantics
11 | from lyra.semantics.forward import DefaultForwardSemantics
12 | from lyra.abstract_domains.numerical.sign_domain import SignState
13 |
14 |
15 | class ForwardSignAnalysis(Runner):
16 |
17 | def interpreter(self):
18 | return ForwardInterpreter(self.cfgs, self.fargs, DefaultForwardSemantics(), 3)
19 |
20 | def state(self):
21 | return SignState(self.variables)
22 |
23 |
24 | class BackwardSignAnalysis(Runner):
25 |
26 | def interpreter(self):
27 | return BackwardInterpreter(self.cfgs, self.fargs, DefaultBackwardSemantics(), 3)
28 |
29 | def state(self):
30 | return SignState(self.variables)
31 |
--------------------------------------------------------------------------------
/src/lyra/engine/string/character_analysis.py:
--------------------------------------------------------------------------------
1 | """
2 | Character Inclusion Analysis
3 | ============================
4 |
5 | :Author: Caterina Urban
6 | """
7 | from lyra.abstract_domains.string.character_domain import CharacterState
8 | from lyra.engine.backward import BackwardInterpreter
9 | from lyra.engine.forward import ForwardInterpreter
10 | from lyra.engine.runner import Runner
11 | from lyra.semantics.backward import DefaultBackwardSemantics
12 | from lyra.semantics.forward import DefaultForwardSemantics
13 |
14 |
15 | class ForwardCharacterAnalysis(Runner):
16 |
17 | def interpreter(self):
18 | return ForwardInterpreter(self.cfg, DefaultForwardSemantics(), 3)
19 |
20 | def state(self):
21 | return CharacterState(self.variables)
22 |
23 |
24 | class BackwardCharacterAnalysis(Runner):
25 |
26 | def interpreter(self):
27 | return BackwardInterpreter(self.cfg, DefaultBackwardSemantics(), 3)
28 |
29 | def state(self):
30 | return CharacterState(self.variables)
31 |
--------------------------------------------------------------------------------
/docs/lyra.engine.rst:
--------------------------------------------------------------------------------
1 | lyra\.engine package
2 | ====================
3 |
4 | .. automodule:: lyra.engine
5 | :members:
6 | :undoc-members:
7 | :show-inheritance:
8 |
9 | Subpackages
10 | -----------
11 |
12 | .. toctree::
13 |
14 | lyra.engine.assumption
15 | lyra.engine.liveness
16 | lyra.engine.numerical
17 | lyra.engine.string
18 | lyra.engine.usage
19 |
20 | Submodules
21 | ----------
22 |
23 | .. automodule:: lyra.engine.backward
24 | :members:
25 | :undoc-members:
26 | :show-inheritance:
27 |
28 | .. automodule:: lyra.engine.forward
29 | :members:
30 | :undoc-members:
31 | :show-inheritance:
32 |
33 | .. automodule:: lyra.engine.interpreter
34 | :members:
35 | :undoc-members:
36 | :show-inheritance:
37 |
38 | .. automodule:: lyra.engine.result
39 | :members:
40 | :undoc-members:
41 | :show-inheritance:
42 |
43 | .. automodule:: lyra.engine.runner
44 | :members:
45 | :undoc-members:
46 | :show-inheritance:
47 |
48 |
49 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/summarization/concat.py:
--------------------------------------------------------------------------------
1 |
2 | L1: List[int] = [1, 2, 3]
3 | L2: List[int] = [4, 5, 6]
4 | L3: List[int] = L1 + L2
5 | # STATE: L1 -> [1, 3]; L2 -> [4, 6]; L3 -> [1, 6]; len(L1) -> [3, 3]; len(L2) -> [3, 3]; len(L3) -> [6, 6]
6 | L1: List[int] = []
7 | L2: List[int] = [4, 5, 6]
8 | L3: List[int] = L1 + L2
9 | # STATE: L1 -> ⊥; L2 -> [4, 6]; L3 -> [4, 6]; len(L1) -> [0, 0]; len(L2) -> [3, 3]; len(L3) -> [3, 3]
10 | L1: List[int] = [1, 2, 3]
11 | L2: List[int] = []
12 | L3: List[int] = L1 + L2
13 | # STATE: L1 -> [1, 3]; L2 -> ⊥; L3 -> [1, 3]; len(L1) -> [3, 3]; len(L2) -> [0, 0]; len(L3) -> [3, 3]
14 | L1: List[int] = [1]
15 | L2: List[int] = [4, 5, 6]
16 | L3: List[int] = L1 + L2
17 | # STATE: L1 -> [1, 1]; L2 -> [4, 6]; L3 -> [1, 6]; len(L1) -> [1, 1]; len(L2) -> [3, 3]; len(L3) -> [4, 4]
18 | L1: List[int] = [1, 2]
19 | L2: List[int] = [4]
20 | L3: List[int] = L1 + L2
21 | # FINAL: L1 -> [1, 2]; L2 -> [4, 4]; L3 -> [1, 4]; len(L1) -> [2, 2]; len(L2) -> [1, 1]; len(L3) -> [3, 3]
22 |
--------------------------------------------------------------------------------
/docs/lyra.abstract_domains.assumption.rst:
--------------------------------------------------------------------------------
1 | lyra\.abstract\_domains\.assumption package
2 | ===========================================
3 |
4 | .. automodule:: lyra.abstract_domains.assumption
5 | :members:
6 | :undoc-members:
7 | :show-inheritance:
8 |
9 | Submodules
10 | ----------
11 |
12 | .. automodule:: lyra.abstract_domains.assumption.alphabet_domain
13 | :members:
14 | :undoc-members:
15 | :show-inheritance:
16 |
17 | .. automodule:: lyra.abstract_domains.assumption.assumption_domain
18 | :members:
19 | :undoc-members:
20 | :show-inheritance:
21 |
22 | .. automodule:: lyra.abstract_domains.assumption.quantity_domain
23 | :members:
24 | :undoc-members:
25 | :show-inheritance:
26 |
27 | .. automodule:: lyra.abstract_domains.assumption.range_domain
28 | :members:
29 | :undoc-members:
30 | :show-inheritance:
31 |
32 | .. automodule:: lyra.abstract_domains.assumption.type_domain
33 | :members:
34 | :undoc-members:
35 | :show-inheritance:
36 |
37 |
38 |
--------------------------------------------------------------------------------
/src/lyra/engine/string/stringset_analysis.py:
--------------------------------------------------------------------------------
1 | """
2 | String Set Analysis
3 | ===================
4 |
5 | :Author: Caterina Urban
6 | """
7 | from lyra.abstract_domains.string.stringset_domain import StringSetState
8 | from lyra.engine.backward import BackwardInterpreter
9 | from lyra.engine.forward import ForwardInterpreter
10 | from lyra.engine.runner import Runner
11 | from lyra.semantics.backward import DefaultBackwardSemantics
12 | from lyra.semantics.forward import DefaultForwardSemantics
13 |
14 |
15 | class ForwardStringSetAnalysis(Runner):
16 |
17 | def interpreter(self):
18 | return ForwardInterpreter(self.cfgs, self.fargs, DefaultForwardSemantics(), 3)
19 |
20 | def state(self):
21 | return StringSetState(self.variables)
22 |
23 |
24 | class BackwardStringSetAnalysis(Runner):
25 |
26 | def interpreter(self):
27 | return BackwardInterpreter(self.cfgs, self.fargs, DefaultBackwardSemantics(), 3)
28 |
29 | def state(self):
30 | return StringSetState(self.variables)
31 |
--------------------------------------------------------------------------------
/docs/html/_sources/lyra.engine.rst.txt:
--------------------------------------------------------------------------------
1 | lyra\.engine package
2 | ====================
3 |
4 | .. automodule:: lyra.engine
5 | :members:
6 | :undoc-members:
7 | :show-inheritance:
8 |
9 | Subpackages
10 | -----------
11 |
12 | .. toctree::
13 |
14 | lyra.engine.assumption
15 | lyra.engine.liveness
16 | lyra.engine.numerical
17 | lyra.engine.string
18 | lyra.engine.usage
19 |
20 | Submodules
21 | ----------
22 |
23 | .. automodule:: lyra.engine.backward
24 | :members:
25 | :undoc-members:
26 | :show-inheritance:
27 |
28 | .. automodule:: lyra.engine.forward
29 | :members:
30 | :undoc-members:
31 | :show-inheritance:
32 |
33 | .. automodule:: lyra.engine.interpreter
34 | :members:
35 | :undoc-members:
36 | :show-inheritance:
37 |
38 | .. automodule:: lyra.engine.result
39 | :members:
40 | :undoc-members:
41 | :show-inheritance:
42 |
43 | .. automodule:: lyra.engine.runner
44 | :members:
45 | :undoc-members:
46 | :show-inheritance:
47 |
48 |
49 |
--------------------------------------------------------------------------------
/src/lyra/tests/code_jam/pancake_flipper/pancakes_jsphkn.py:
--------------------------------------------------------------------------------
1 | def flips(s: str, k: int) -> int:
2 | if (len(s) < k):
3 | pancake: str = ''
4 | for pancake in s:
5 | if (pancake == '-'):
6 | return (- 1)
7 | return 0
8 | elif (s[0] == '-'):
9 | a: str = ''
10 | for i in range(k):
11 | if (s[i] == '-'):
12 | a += '+'
13 | else:
14 | a += '-'
15 | new: str = (a + s[k:])
16 | subresult: int = flips(new, k)
17 | if (subresult == (- 1)):
18 | return (- 1)
19 | else:
20 | return (subresult + 1)
21 | else:
22 | return flips(s[1:], k)
23 |
24 | t: int = int(input())
25 | for i in range(1, (t + 1)):
26 | line: List[str] = input().split()
27 | result: int = flips(line[0], int(line[1]))
28 | if (result != (- 1)):
29 | print('Case #' + str(i) + ': ' + str(result))
30 | else:
31 | print('Case #' + str(i) + ': ' + 'IMPOSSIBLE')
32 |
--------------------------------------------------------------------------------
/docs/html/_sources/lyra.abstract_domains.assumption.rst.txt:
--------------------------------------------------------------------------------
1 | lyra\.abstract\_domains\.assumption package
2 | ===========================================
3 |
4 | .. automodule:: lyra.abstract_domains.assumption
5 | :members:
6 | :undoc-members:
7 | :show-inheritance:
8 |
9 | Submodules
10 | ----------
11 |
12 | .. automodule:: lyra.abstract_domains.assumption.alphabet_domain
13 | :members:
14 | :undoc-members:
15 | :show-inheritance:
16 |
17 | .. automodule:: lyra.abstract_domains.assumption.assumption_domain
18 | :members:
19 | :undoc-members:
20 | :show-inheritance:
21 |
22 | .. automodule:: lyra.abstract_domains.assumption.quantity_domain
23 | :members:
24 | :undoc-members:
25 | :show-inheritance:
26 |
27 | .. automodule:: lyra.abstract_domains.assumption.range_domain
28 | :members:
29 | :undoc-members:
30 | :show-inheritance:
31 |
32 | .. automodule:: lyra.abstract_domains.assumption.type_domain
33 | :members:
34 | :undoc-members:
35 | :show-inheritance:
36 |
37 |
38 |
--------------------------------------------------------------------------------
/src/lyra/unittests/assumption/type+range+alphabet/cars.py:
--------------------------------------------------------------------------------
1 |
2 | # INITIAL: 3:(Integer, [-inf, inf], (∅, Σ)), 3.1 * [5:(Float, [0, inf], (∅, Σ)), 8:(Integer, [-inf, inf], (∅, Σ)), 8.1 * [11:(Integer, [-inf, inf], (∅, Σ)), 14:(Float, [0, inf], (∅, Σ))]]
3 | cases: int = int(input())
4 | for case in range(cases):
5 | distance: float = float(input())
6 | if distance < 0:
7 | raise ValueError("Distance cannot be negative.")
8 | n: int = int(input())
9 | max: float = 0
10 | for i in range(n):
11 | position: int = int(input())
12 | if distance < position:
13 | raise ValueError("Distance cannot be smaller than the current position.")
14 | speed: float = float(input())
15 | if speed < 0:
16 | raise ValueError("Speed cannot be negative.")
17 | val: float = (distance - position) / speed
18 | if val > max:
19 | max: int = val
20 | print("Trip:")
21 | print(case + 1)
22 | print("with speed")
23 | print(distance / max)
24 | # FINAL: ε
25 |
--------------------------------------------------------------------------------
/src/lyra/unittests/assumption/type+wordset/convert.py:
--------------------------------------------------------------------------------
1 |
2 | # INITIAL: 3:(Integer, ⊤), 3.1 * [7:(String, ⊤), 8:(Integer, ⊤), 11:(String, {'g', 'gms', 'grams', 'kg', 'kilo', 'kilograms', 'lb', 'lbs', 'ounces', 'oz', 'oz.', 'pounds'})]
3 | items: int = int(input())
4 | if items == 0:
5 | raise ValueError
6 | for i in range(items):
7 | name: str = input()
8 | weight: float = int(input())
9 | if weight <= 0:
10 | raise ValueError
11 | unit: str = input()
12 | if unit == 'pounds' or unit == 'lb' or unit == 'lbs':
13 | weight: float = weight * 453.592 * 1e-3
14 | elif unit == 'ounces' or unit == 'oz' or unit == 'oz.':
15 | weight: float = weight * 28.35 * 1e-3
16 | elif unit == 'grams' or unit == 'gms' or unit == 'g':
17 | weight: float = weight * 1e-3
18 | elif unit == 'kilograms' or unit == 'kilo' or unit == 'kg':
19 | pass
20 | else:
21 | raise ValueError
22 | print("Item: " + name)
23 | print("weight:")
24 | print(weight)
25 | print("kg")
26 | # FINAL: ε
27 |
--------------------------------------------------------------------------------
/src/lyra/engine/numerical/octagon_analysis.py:
--------------------------------------------------------------------------------
1 | """
2 | Octagon Analysis
3 | ================
4 |
5 | :Author: Caterina Urban
6 | """
7 | from lyra.abstract_domains.numerical.octagon_domain import OctagonStateWithSummarization
8 | from lyra.engine.backward import BackwardInterpreter
9 | from lyra.engine.forward import ForwardInterpreter
10 | from lyra.engine.runner import Runner
11 | from lyra.semantics.backward import DefaultBackwardSemantics
12 | from lyra.semantics.forward import DefaultForwardSemantics
13 |
14 |
15 | class ForwardOctagonAnalysis(Runner):
16 |
17 | def interpreter(self):
18 | return ForwardInterpreter(self.cfgs, self.fargs, DefaultForwardSemantics(), 3)
19 |
20 | def state(self):
21 | return OctagonStateWithSummarization(self.variables)
22 |
23 |
24 | class BackwardOctagonAnalysis(Runner):
25 |
26 | def interpreter(self):
27 | return BackwardInterpreter(self.cfgs, self.fargs, DefaultBackwardSemantics(), 3)
28 |
29 | def state(self):
30 | return OctagonStateWithSummarization(self.variables)
31 |
--------------------------------------------------------------------------------
/src/lyra/tests/code_jam/pancake_flipper/pancakes_billjeff.py:
--------------------------------------------------------------------------------
1 | def update(s: List[str], i: int) -> None:
2 | if (s[i] == '+'):
3 | s[i]: str = '-'
4 | elif (s[i] == '-'):
5 | s[i]: str = '+'
6 |
7 | num: int = int(input().strip())
8 | for case in range(num):
9 | input_line: str = input().strip()
10 | s: List[str] = list()
11 | split_line: List[str] = input_line.split()
12 | first_line: str = split_line[0]
13 | i: str
14 | for i in first_line:
15 | s.append(i)
16 | num: int = int(split_line[1])
17 | move: int = 0
18 | for i in range(len(s)):
19 | if (s[i] == '-'):
20 | if (i < ((len(s) - num) + 1)):
21 | for j in range(num):
22 | update(s, (i + j))
23 | move += 1
24 | else:
25 | move: int = (- 1)
26 | case_number: int = case + 1
27 | if (move != (- 1)):
28 | print('Case #' + str(case_number) + ': ' + str(move))
29 | else:
30 | print('Case #' + str(case_number) + ':' + ' IMPOSSIBLE')
31 |
--------------------------------------------------------------------------------
/src/lyra/engine/numerical/polyhedra_analysis.py:
--------------------------------------------------------------------------------
1 | """
2 | Polyhedra Analysis
3 | ==================
4 |
5 | :Author: Caterina Urban
6 | """
7 | from lyra.abstract_domains.numerical.polyhedra_domain import PolyhedraStateWithSummarization
8 | from lyra.engine.backward import BackwardInterpreter
9 | from lyra.engine.forward import ForwardInterpreter
10 | from lyra.engine.runner import Runner
11 | from lyra.semantics.backward import DefaultBackwardSemantics
12 | from lyra.semantics.forward import DefaultForwardSemantics
13 |
14 |
15 | class ForwardPolyhedraAnalysis(Runner):
16 |
17 | def interpreter(self):
18 | return ForwardInterpreter(self.cfgs, self.fargs, DefaultForwardSemantics(), 3)
19 |
20 | def state(self):
21 | return PolyhedraStateWithSummarization(self.variables)
22 |
23 |
24 | class BackwardPolyhedraAnalysis(Runner):
25 |
26 | def interpreter(self):
27 | return BackwardInterpreter(self.cfgs, self.fargs, DefaultBackwardSemantics(), 3)
28 |
29 | def state(self):
30 | return PolyhedraStateWithSummarization(self.variables)
31 |
--------------------------------------------------------------------------------
/src/lyra/tests/code_jam/pancake_flipper/pancakes_real.py:
--------------------------------------------------------------------------------
1 | def all_true(a: List[bool]) -> bool:
2 | for i in range(len(a)):
3 | if a[i] == False:
4 | return False
5 | return True
6 |
7 | def gao(s: str, k: int) -> int:
8 | a: List[bool] = list()
9 | c: str = ''
10 | for c in s:
11 | if c == '+':
12 | a.append(True)
13 | else:
14 | a.append(False)
15 | n: int = len(s)
16 | ans: int = 0
17 | for i in range(((n - k) + 1)):
18 | if a[i] == False:
19 | for j in range(k):
20 | a[(i + j)]: bool = (not a[(i + j)])
21 | ans += 1
22 | if all_true(a):
23 | return ans
24 | return (- 1)
25 |
26 |
27 | for no_t in range(1, (int(input()) + 1)):
28 | line: List[str] = input().split()
29 | s: str = line[0]
30 | k: str = line[1]
31 | result: int = gao(s, int(k))
32 | if (result == (- 1)):
33 | print('Case #' + str(no_t) + ': ' + 'IMPOSSIBLE')
34 | else:
35 | print('Case #' + str(no_t) + ': ' + str(result))
36 |
--------------------------------------------------------------------------------
/src/lyra/unittests/assumption/type+range+alphabet/convert.py:
--------------------------------------------------------------------------------
1 |
2 | # INITIAL: 3:(Integer, [-inf, inf], (∅, Σ)), 3.1 * [7:(String, [-inf, inf], (∅, Σ)), 8:(Integer, [1, inf], (∅, Σ)), 11:(String, [-inf, inf], (∅, {'.', 'a', 'b', 'c', 'd', 'e', 'g', 'i', 'k', 'l', 'm', 'n', 'o', 'p', 'r', 's', 'u', 'z'}))]
3 | items: int = int(input())
4 | if items == 0:
5 | raise ValueError
6 | for i in range(items):
7 | name: str = input()
8 | weight: float = int(input())
9 | if weight <= 0:
10 | raise ValueError
11 | unit: str = input()
12 | if unit == 'pounds' or unit == 'lb' or unit == 'lbs':
13 | weight: float = weight * 453.592 * 1e-3
14 | elif unit == 'ounces' or unit == 'oz' or unit == 'oz.':
15 | weight: float = weight * 28.35 * 1e-3
16 | elif unit == 'grams' or unit == 'gms' or unit == 'g':
17 | weight: float = weight * 1e-3
18 | elif unit == 'kilograms' or unit == 'kilo' or unit == 'kg':
19 | pass
20 | else:
21 | raise ValueError
22 | print("Item: " + name)
23 | print("weight:")
24 | print(weight)
25 | print("kg")
26 | # FINAL: ε
27 |
--------------------------------------------------------------------------------
/src/lyra/main.py:
--------------------------------------------------------------------------------
1 | """
2 | Lyra Static Program Analyzer
3 | ============================
4 | """
5 |
6 | import argparse
7 | from lyra.engine.liveness.liveness_analysis import StrongLivenessAnalysis
8 | from lyra.engine.numerical.interval_analysis import ForwardIntervalAnalysisWithSummarization
9 | from lyra.engine.usage.usage_analysis import SimpleUsageAnalysis
10 |
11 |
12 | def main():
13 | """Static analyzer entry point."""
14 | parser = argparse.ArgumentParser()
15 | parser.add_argument(
16 | 'python_file',
17 | help='Python file to analyze')
18 | parser.add_argument(
19 | '--analysis',
20 | help='analysis to be used (interval, liveness, or usage)',
21 | default='usage')
22 | args = parser.parse_args()
23 |
24 | if args.analysis == 'intervals':
25 | ForwardIntervalAnalysisWithSummarization().main(args.python_file)
26 | if args.analysis == 'liveness':
27 | StrongLivenessAnalysis().main(args.python_file)
28 | if args.analysis == 'usage':
29 | SimpleUsageAnalysis().main(args.python_file)
30 |
31 |
32 | if __name__ == '__main__':
33 | main()
34 |
--------------------------------------------------------------------------------
/docs/lyra.abstract_domains.rst:
--------------------------------------------------------------------------------
1 | lyra\.abstract\_domains package
2 | ===============================
3 |
4 | .. automodule:: lyra.abstract_domains
5 | :members:
6 | :undoc-members:
7 | :show-inheritance:
8 |
9 | Subpackages
10 | -----------
11 |
12 | .. toctree::
13 |
14 | lyra.abstract_domains.assumption
15 | lyra.abstract_domains.liveness
16 | lyra.abstract_domains.numerical
17 | lyra.abstract_domains.string
18 | lyra.abstract_domains.usage
19 |
20 | Submodules
21 | ----------
22 |
23 | .. automodule:: lyra.abstract_domains.basis
24 | :members:
25 | :undoc-members:
26 | :show-inheritance:
27 |
28 | .. automodule:: lyra.abstract_domains.lattice
29 | :members:
30 | :undoc-members:
31 | :show-inheritance:
32 |
33 | .. automodule:: lyra.abstract_domains.stack
34 | :members:
35 | :undoc-members:
36 | :show-inheritance:
37 |
38 | .. automodule:: lyra.abstract_domains.state
39 | :members:
40 | :undoc-members:
41 | :show-inheritance:
42 |
43 | .. automodule:: lyra.abstract_domains.store
44 | :members:
45 | :undoc-members:
46 | :show-inheritance:
47 |
48 |
49 |
--------------------------------------------------------------------------------
/docs/html/_sources/lyra.abstract_domains.rst.txt:
--------------------------------------------------------------------------------
1 | lyra\.abstract\_domains package
2 | ===============================
3 |
4 | .. automodule:: lyra.abstract_domains
5 | :members:
6 | :undoc-members:
7 | :show-inheritance:
8 |
9 | Subpackages
10 | -----------
11 |
12 | .. toctree::
13 |
14 | lyra.abstract_domains.assumption
15 | lyra.abstract_domains.liveness
16 | lyra.abstract_domains.numerical
17 | lyra.abstract_domains.string
18 | lyra.abstract_domains.usage
19 |
20 | Submodules
21 | ----------
22 |
23 | .. automodule:: lyra.abstract_domains.basis
24 | :members:
25 | :undoc-members:
26 | :show-inheritance:
27 |
28 | .. automodule:: lyra.abstract_domains.lattice
29 | :members:
30 | :undoc-members:
31 | :show-inheritance:
32 |
33 | .. automodule:: lyra.abstract_domains.stack
34 | :members:
35 | :undoc-members:
36 | :show-inheritance:
37 |
38 | .. automodule:: lyra.abstract_domains.state
39 | :members:
40 | :undoc-members:
41 | :show-inheritance:
42 |
43 | .. automodule:: lyra.abstract_domains.store
44 | :members:
45 | :undoc-members:
46 | :show-inheritance:
47 |
48 |
49 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/summarization/same.py:
--------------------------------------------------------------------------------
1 |
2 | b: bool = bool(input())
3 | D1: Dict[int, int] = dict()
4 | D2: Dict[int, int] = dict()
5 | if b:
6 | x: int = 3
7 | D1[x] = 0
8 | # STATE: D1 -> [0, 3]; D2 -> ⊥; b -> [1, 1]; keys(D1) -> [3, 3]; keys(D2) -> ⊥; len(D1) -> [1, 1]; len(D2) -> [0, 0]; values(D1) -> [0, 0]; values(D2) -> ⊥; x -> [3, 3]
9 | D1[3] = 1
10 | # STATE: D1 -> [0, 3]; D2 -> ⊥; b -> [1, 1]; keys(D1) -> [3, 3]; keys(D2) -> ⊥; len(D1) -> [1, 2]; len(D2) -> [0, 0]; values(D1) -> [0, 1]; values(D2) -> ⊥; x -> [3, 3]
11 | else:
12 | x: int = 4
13 | D1[x] = 0
14 | # STATE: D1 -> [0, 4]; D2 -> ⊥; b -> [0, 0]; keys(D1) -> [4, 4]; keys(D2) -> ⊥; len(D1) -> [1, 1]; len(D2) -> [0, 0]; values(D1) -> [0, 0]; values(D2) -> ⊥; x -> [4, 4]
15 | D1[3] = 1
16 | # STATE: D1 -> [0, 4]; D2 -> ⊥; b -> [0, 0]; keys(D1) -> [3, 4]; keys(D2) -> ⊥; len(D1) -> [2, 2]; len(D2) -> [0, 0]; values(D1) -> [0, 1]; values(D2) -> ⊥; x -> [4, 4]
17 | D2[x] = 0
18 | D2[3] = 1
19 | # FINAL: D1 -> [0, 4]; D2 -> [0, 4]; b -> [0, 1]; keys(D1) -> [3, 4]; keys(D2) -> [3, 4]; len(D1) -> [1, 2]; len(D2) -> [1, 2]; values(D1) -> [0, 1]; values(D2) -> [0, 1]; x -> [3, 4]
20 |
--------------------------------------------------------------------------------
/src/lyra/abstract_domains/container/fulara/value_wrapper.py:
--------------------------------------------------------------------------------
1 | from abc import ABCMeta, abstractmethod
2 |
3 | # (Class) Adapter pattern
4 | from lyra.abstract_domains.lattice import EnvironmentMixin
5 | from lyra.core.expressions import VariableIdentifier
6 |
7 |
8 | class ValueWrapper(metaclass=ABCMeta):
9 | """
10 | (Abstract) wrapper around a domain with some extra functions,
11 | that are needed for the value state of a FularaState.
12 | A concrete wrapper should inherit from this class and the state that should be 'wrapped'.
13 | """
14 |
15 | def __init__(self, v_var: VariableIdentifier):
16 | """
17 | :param v_var: special variable (with correct type)
18 | representing the value values at a specific segment
19 | """
20 | EnvironmentMixin.__init__(self)
21 | self._v_var = v_var
22 |
23 | @property
24 | def v_var(self) -> VariableIdentifier:
25 | """The special value variable of this abstraction"""
26 | return self._v_var
27 |
28 | @abstractmethod
29 | def is_bottom(self) -> bool:
30 | """Should be true if the special value variable is bottom
31 | (i.e. cannot have any concrete value)"""
32 |
--------------------------------------------------------------------------------
/src/lyra/unittests/usage/dict_varkey_example.py:
--------------------------------------------------------------------------------
1 |
2 | # INITIAL: example -> W; i -> W; key -> W; keys(example) -> W; len(example) -> [0, inf]; len(key) -> [0, inf]; value -> W; values(example) -> W
3 | value: int = input()
4 | # STATE: example -> W; i -> W; key -> W; keys(example) -> W; len(example) -> [0, inf]; len(key) -> [0, inf]; value -> U; values(example) -> W
5 | example: Dict[str, int] = {"a": 0, "b": 1, "c": 2}
6 | # STATE: example -> U; i -> W; key -> W; keys(example) -> U; len(example) -> [0, inf]; len(key) -> [0, inf]; value -> U; values(example) -> U
7 | key: str = "b"
8 | # STATE: example -> U; i -> W; key -> U; keys(example) -> U; len(example) -> [0, inf]; len(key) -> [0, inf]; value -> U; values(example) -> U
9 | example[key]: int = value
10 | # STATE: example -> U; i -> W; key -> N; keys(example) -> U; len(example) -> [0, inf]; len(key) -> [0, inf]; value -> N; values(example) -> U
11 | i: int = example["a"]
12 | # STATE: example -> N; i -> U; key -> N; keys(example) -> N; len(example) -> [0, inf]; len(key) -> [0, inf]; value -> N; values(example) -> N
13 | print(i)
14 | # FINAL: example -> N; i -> N; key -> N; keys(example) -> N; len(example) -> [0, inf]; len(key) -> [0, inf]; value -> N; values(example) -> N
15 |
--------------------------------------------------------------------------------
/src/lyra/unittests/assumption/type+range+alphabet/dna.py:
--------------------------------------------------------------------------------
1 |
2 | # INITIAL: 3:(Integer, [1, inf], (∅, Σ)), 3.1 * [7:(Integer, [-inf, inf], (∅, Σ)), 7.1 * 13:(String, [-inf, inf], (∅, {'A', 'C', 'G', 'T'})), 24:(String, [-inf, inf], (∅, {'#', '.'}))]
3 | sequences: int = int(input())
4 | if sequences < 1:
5 | raise ValueError("Expecting at least one DNA sequence")
6 | for s in range(sequences):
7 | length: int = int(input())
8 | a: int = 0
9 | c: int = 0
10 | g: int = 0
11 | t: int = 0
12 | for i in range(length):
13 | base: str = input()
14 | if base == 'A':
15 | a: int = a + 1
16 | elif base == 'C':
17 | c: int = c + 1
18 | elif base == 'G':
19 | g: int = g + 1
20 | elif base == 'T':
21 | t: int = t + 1
22 | else:
23 | raise ValueError
24 | separator: str = input()
25 | if separator == '.' or separator == '#':
26 | pass
27 | else:
28 | raise ValueError
29 | print("Frequency of A nucleotide:")
30 | print(a)
31 | print("Frequency of C nucleotide:")
32 | print(c)
33 | print("Frequency of G nucleotide:")
34 | print(g)
35 | print("Frequency of T nucleotide:")
36 | print(t)
37 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/indexing3/same.py:
--------------------------------------------------------------------------------
1 |
2 | b: bool = bool(input())
3 | D1: Dict[int, int] = dict()
4 | D2: Dict[int, int] = dict()
5 | if b:
6 | x: int = 3
7 | D1[x] = 0
8 | # STATE: D1 -> 3@[0, 0], _@⊥; D2 -> _@⊥; b -> [1, 1]; keys(D1) -> [3, 3]; keys(D2) -> ⊥; len(D1) -> [1, 1]; len(D2) -> [0, 0]; values(D1) -> [0, 0]; values(D2) -> ⊥; x -> [3, 3]
9 | D1[3] = 1
10 | # STATE: D1 -> 3@[1, 1], _@⊥; D2 -> _@⊥; b -> [1, 1]; keys(D1) -> [3, 3]; keys(D2) -> ⊥; len(D1) -> [1, 1]; len(D2) -> [0, 0]; values(D1) -> [1, 1]; values(D2) -> ⊥; x -> [3, 3]
11 | else:
12 | x: int = 4
13 | D1[x] = 0
14 | # STATE: D1 -> 4@[0, 0], _@⊥; D2 -> _@⊥; b -> [0, 0]; keys(D1) -> [4, 4]; keys(D2) -> ⊥; len(D1) -> [1, 1]; len(D2) -> [0, 0]; values(D1) -> [0, 0]; values(D2) -> ⊥; x -> [4, 4]
15 | D1[3] = 1
16 | # STATE: D1 -> 3@[1, 1], 4@[0, 0], _@⊥; D2 -> _@⊥; b -> [0, 0]; keys(D1) -> [3, 4]; keys(D2) -> ⊥; len(D1) -> [2, 2]; len(D2) -> [0, 0]; values(D1) -> [0, 1]; values(D2) -> ⊥; x -> [4, 4]
17 | D2[x] = 0
18 | D2[3] = 1
19 | # FINAL: D1 -> 3@[1, 1], _@[0, 0]; D2 -> 3@[1, 1], _@[0, 0]; b -> [0, 1]; keys(D1) -> [3, 4]; keys(D2) -> [3, 4]; len(D1) -> [1, 2]; len(D2) -> [1, 2]; values(D1) -> [0, 1]; values(D2) -> [0, 1]; x -> [3, 4]
20 |
--------------------------------------------------------------------------------
/src/lyra/unittests/usage/dataframes/loc.py:
--------------------------------------------------------------------------------
1 | import pandas as pd
2 |
3 | df : pd.DataFrame = pd.read_csv("...")
4 | x : pd.DataFrame = pd.read_csv("...")
5 | # l : List[int] = []
6 |
7 | # x: List[int] = l[1]
8 | # y: List[int] = l[1:4]
9 |
10 | # df2 : pd.DataFrame = df.loc[df["a"] > 2, "A"]
11 | # df2 : pd.DataFrame = df.loc[1, "A":"F"] # TODO slices
12 |
13 | # STATE: df -> {A -> U, B -> U, _ -> N}; df2 -> {_ -> W}; x -> {A -> U, B -> U, _ -> N}; x2 -> {_ -> W}
14 | df2 : pd.DataFrame = df.loc[1, ["A", "B"]]
15 | x2 : pd.DataFrame = x[["A", "B"]]
16 |
17 | # STATE: df -> {_ -> N}; df2 -> {B -> U, C -> W, Y -> W, Z -> U, _ -> U}; x -> {_ -> N}; x2 -> {B -> U, C -> W, _ -> U}
18 | df2.loc[3, "B"].head()
19 | x2["B"].head()
20 |
21 | # df3 = df2.loc[df2["Z"] > 4, "C"]
22 | # df3 = df2["Z"] + df2["C"]
23 |
24 | # STATE: df -> {_ -> N}; df2 -> {C -> W, Y -> W, Z -> U, _ -> U}; x -> {_ -> N}; x2 -> {C -> W, _ -> U}
25 | df2.loc[df2["Z"] > 4, "Y"] = 1
26 | # equivalent?
27 |
28 | # STATE: df -> {_ -> N}; df2 -> {C -> W, _ -> U}; x -> {_ -> N}; x2 -> {C -> W, _ -> U}
29 | df2.loc[3, "C"] = 1
30 | x2["C"] = 1
31 |
32 | # STATE: df -> {_ -> N}; df2 -> {_ -> U}; x -> {_ -> N}; x2 -> {_ -> U}
33 | df2.loc[3].head()
34 | x2.head()
35 |
36 | # FINAL: df -> {_ -> N}; df2 -> {_ -> N}; x -> {_ -> N}; x2 -> {_ -> N}
37 |
--------------------------------------------------------------------------------
/src/lyra/abstract_domains/numerical/polyhedra_domain.py:
--------------------------------------------------------------------------------
1 | """
2 | Polyhedra Abstract Domain
3 | =========================
4 |
5 | Relational abstract domain to be used for **numerical analysis**.
6 | The set of possible numerical values of a program variable in a program state
7 | is represented by a conjunction of linear constraints.
8 |
9 | :Authors: Caterina Urban
10 | """
11 | from typing import Set
12 |
13 | from apronpy.polka import PyPolkaMPQstrictManager, PyPolka
14 |
15 | from lyra.abstract_domains.numerical.apron_domain import APRONStateWithSummarization
16 | from lyra.abstract_domains.state import State
17 | from lyra.core.expressions import VariableIdentifier
18 |
19 |
20 | class PolyhedraStateWithSummarization(APRONStateWithSummarization):
21 | """Polyhedra analysis state based on APRON. An element of the polyhedra abstract domain.
22 |
23 | .. document private methods
24 | .. automethod:: PolyhedraState._assign
25 | .. automethod:: PolyhedraState._assume
26 | .. automethod:: PolyhedraState._output
27 | .. automethod:: PolyhedraState._substitute
28 |
29 | """
30 |
31 | def __init__(self, variables: Set[VariableIdentifier], precursory: State = None):
32 | super().__init__(PyPolka, variables, precursory=precursory)
33 |
34 | manager = PyPolkaMPQstrictManager()
35 |
--------------------------------------------------------------------------------
/src/lyra/unittests/numerical/interval/forward/indexing3/concat.py:
--------------------------------------------------------------------------------
1 |
2 | L1: List[int] = [1, 2, 3]
3 | L2: List[int] = [4, 5, 6]
4 | L3: List[int] = L1 + L2
5 | # STATE: L1 -> 0@[1, 1], 1@[2, 2], 2@[3, 3], _@⊥; L2 -> 0@[4, 4], 1@[5, 5], 2@[6, 6], _@⊥; L3 -> 0@[1, 1], 1@[2, 2], 2@[3, 3], _@[4, 6]; len(L1) -> [3, 3]; len(L2) -> [3, 3]; len(L3) -> [6, 6]
6 | L1: List[int] = []
7 | L2: List[int] = [4, 5, 6]
8 | L3: List[int] = L1 + L2
9 | # STATE: L1 -> _@⊥; L2 -> 0@[4, 4], 1@[5, 5], 2@[6, 6], _@⊥; L3 -> 0@[4, 4], 1@[5, 5], 2@[6, 6], _@⊥; len(L1) -> [0, 0]; len(L2) -> [3, 3]; len(L3) -> [3, 3]
10 | L1: List[int] = [1, 2, 3]
11 | L2: List[int] = []
12 | L3: List[int] = L1 + L2
13 | # STATE: L1 -> 0@[1, 1], 1@[2, 2], 2@[3, 3], _@⊥; L2 -> _@⊥; L3 -> 0@[1, 1], 1@[2, 2], 2@[3, 3], _@⊥; len(L1) -> [3, 3]; len(L2) -> [0, 0]; len(L3) -> [3, 3]
14 | L1: List[int] = [1]
15 | L2: List[int] = [4, 5, 6]
16 | L3: List[int] = L1 + L2
17 | # STATE: L1 -> 0@[1, 1], _@⊥; L2 -> 0@[4, 4], 1@[5, 5], 2@[6, 6], _@⊥; L3 -> 0@[1, 1], 1@[4, 4], 2@[5, 5], _@[6, 6]; len(L1) -> [1, 1]; len(L2) -> [3, 3]; len(L3) -> [4, 4]
18 | L1: List[int] = [1, 2]
19 | L2: List[int] = [4]
20 | L3: List[int] = L1 + L2
21 | # FINAL: L1 -> 0@[1, 1], 1@[2, 2], _@⊥; L2 -> 0@[4, 4], _@⊥; L3 -> 0@[1, 1], 1@[2, 2], 2@[4, 4], _@⊥; len(L1) -> [2, 2]; len(L2) -> [1, 1]; len(L3) -> [3, 3]
22 |
--------------------------------------------------------------------------------
/src/lyra/abstract_domains/numerical/octagon_domain.py:
--------------------------------------------------------------------------------
1 | """
2 | Octagon Abstract Domain
3 | =======================
4 |
5 | Relational abstract domain to be used for **numerical analysis**.
6 | The set of possible numerical values of a program variable in a program state
7 | is represented by a conjunction of linear constraints.
8 |
9 | :Authors: Caterina Urban
10 | """
11 | from typing import Set
12 |
13 | from apronpy.manager import PyManager, PyOctMPQManager
14 | from apronpy.oct import PyOct
15 |
16 | from lyra.abstract_domains.numerical.apron_domain import APRONStateWithSummarization
17 | from lyra.abstract_domains.state import State
18 | from lyra.core.expressions import VariableIdentifier
19 |
20 |
21 | class OctagonStateWithSummarization(APRONStateWithSummarization):
22 | """Octagon analysis state based on APRON. An element of the octagon abstract domain.
23 |
24 | .. document private methods
25 | .. automethod:: OctagonState._assign
26 | .. automethod:: OctagonState._assume
27 | .. automethod:: OctagonState._output
28 | .. automethod:: OctagonState._substitute
29 |
30 | """
31 |
32 | def __init__(self, variables: Set[VariableIdentifier], precursory: State = None):
33 | super().__init__(PyOct, variables, precursory=precursory)
34 |
35 | manager: PyManager = PyOctMPQManager()
36 |
--------------------------------------------------------------------------------
/src/lyra/unittests/liveness_tests.py:
--------------------------------------------------------------------------------
1 | """
2 | Strongly Live Variable Analysis - Unit Tests
3 | ============================================
4 |
5 | :Authors: Caterina Urban and Simon Wehrli
6 | """
7 |
8 |
9 | import glob
10 | import os
11 | import unittest
12 |
13 | import sys
14 |
15 | from lyra.abstract_domains.liveness.liveness_domain import StrongLivenessState
16 | from lyra.engine.backward import BackwardInterpreter
17 | from lyra.semantics.backward import DefaultBackwardSemantics
18 |
19 | from lyra.unittests.runner import TestRunner
20 |
21 |
22 | class StrongLivenessTest(TestRunner):
23 |
24 | def interpreter(self):
25 | return BackwardInterpreter(self.cfgs, self.fargs, DefaultBackwardSemantics(), 3)
26 |
27 | def state(self):
28 | return StrongLivenessState(self.variables)
29 |
30 |
31 | def test_suite():
32 | suite = unittest.TestSuite()
33 | name = os.getcwd() + '/liveness/**.py'
34 | for path in glob.iglob(name):
35 | if os.path.basename(path) != "__init__.py":
36 | print(os.path.basename(path))
37 | suite.addTest(StrongLivenessTest(path))
38 | return suite
39 |
40 |
41 | if __name__ == '__main__':
42 | runner = unittest.TextTestRunner()
43 | result = runner.run(test_suite())
44 | if not result.wasSuccessful():
45 | sys.exit(1)
46 |
--------------------------------------------------------------------------------