isomorphic data type transformations
play

Isomorphic Data Type Transformations Alessandro Coglio Stephen - PowerPoint PPT Presentation

Isomorphic Data Type Transformations Alessandro Coglio Stephen Westfold KESTREL INSTITUTE Isomorphic data type transformations are useful in program synthesis. some of these may be ! requirements specification isomorphic


  1. Isomorphic Data Type Transformations Alessandro Coglio Stephen Westfold KESTREL INSTITUTE

  2. Isomorphic data type transformations are useful in program synthesis. some of these may be ๐‘ก ! requirements specification isomorphic transformations ๐‘ก ! e.g. stepwise refinements . . . intermediate specifications ยง represent finite sets as repetition-free ordered lists ยง turn unbounded integers ๐‘ก " into bounded integers code generation (under preconditions) (optional in ACL2) ๐‘ž implementation ยง add redundant record components for caching ยง change loop direction ยง ...

  3. Isomorphic data type transformations are useful in program synthesis. They are also useful in program analysis. some of these may be isomorphic transformations, " ๐‘ก $ which are inherently reversible higher-level representations, e.g. anti-refinements, . . . which may be easier to verify via โ€œinversesโ€ of the transformations ยง represent repetition-free for refinements " ๐‘ก # ordered lists as finite sets ยง turn bounded integers into " ๐‘ก ! code representation unbounded integers (under preconditions) code lifting ยง remove redundant record ๐‘žโ€ฒ existing program components for caching ยง change loop direction ยง ...

  4. Isomorphic data type transformations are useful in program synthesis. They are also useful in program analysis, as well as in analysis-by-synthesis. ๐‘ก ! " ๐‘ก ! ๐‘ก $ top-down . . . derivation ๐‘ก # . . . ๐‘ก % equal or trivially . . . end-to-end proof " equivalent ๐‘ก $ " ๐‘ก # that ๐‘žโ€ฒ satisfies ๐‘ก ! . . . " ๐‘ก % ๐‘ก ! bottom-up anti-derivation " ๐‘ก ! ๐‘ž ๐‘žโ€ฒ ๐‘žโ€ฒ

  5. Consider two isomorphic sets (data types) ๐‘Œ and ๐‘Œ ! with ๐œŠ โˆถ ๐‘Œ โŸถ ๐‘Œโ€ฒ and ๐œŠ "# โˆถ ๐‘Œโ€ฒ โŸถ ๐‘Œ . ๐‘Œ ๐œŠ "# โˆ˜ ๐œŠ = ๐‘—๐‘’ $ ๐œŠ "# ๐œŠ ๐œŠ โˆ˜ ๐œŠ "# = ๐‘—๐‘’ $! ๐‘Œโ€ฒ

  6. Consider two isomorphic sets (data types) ๐‘Œ and ๐‘Œ ! with ๐œŠ โˆถ ๐‘Œ โŸถ ๐‘Œโ€ฒ and ๐œŠ "# โˆถ ๐‘Œโ€ฒ โŸถ ๐‘Œ . Consider two isomorphic sets (data types) ๐‘ and ๐‘โ€ฒ with ๐œ‘ โˆถ ๐‘ โŸถ ๐‘โ€ฒ and ๐œ‘ "# โˆถ ๐‘โ€ฒ โŸถ ๐‘ . ๐‘Œ ๐‘ ๐œŠ "# โˆ˜ ๐œŠ = ๐‘—๐‘’ $ ๐œ‘ "# โˆ˜ ๐œ‘ = ๐‘—๐‘’ % ๐œŠ "# ๐œ‘ "# ๐œŠ ๐œ‘ ๐œŠ โˆ˜ ๐œŠ "# = ๐‘—๐‘’ $! ๐œ‘ โˆ˜ ๐œ‘ "# = ๐‘—๐‘’ %! ๐‘Œโ€ฒ ๐‘โ€ฒ

  7. Consider two isomorphic sets (data types) ๐‘Œ and ๐‘Œ ! with ๐œŠ โˆถ ๐‘Œ โŸถ ๐‘Œโ€ฒ and ๐œŠ "# โˆถ ๐‘Œโ€ฒ โŸถ ๐‘Œ . Consider two isomorphic sets (data types) ๐‘ and ๐‘โ€ฒ with ๐œ‘ โˆถ ๐‘ โŸถ ๐‘โ€ฒ and ๐œ‘ "# โˆถ ๐‘โ€ฒ โŸถ ๐‘ . Consider a function ๐‘” โˆถ ๐‘Œ โŸถ ๐‘ , a computation from inputs of type ๐‘Œ to outputs of type ๐‘ . ๐‘Œ ๐‘ ๐‘” ๐œŠ "# โˆ˜ ๐œŠ = ๐‘—๐‘’ $ ๐œ‘ "# โˆ˜ ๐œ‘ = ๐‘—๐‘’ % ๐œŠ "# ๐œ‘ "# ๐œŠ ๐œ‘ ๐œŠ โˆ˜ ๐œŠ "# = ๐‘—๐‘’ $! ๐œ‘ โˆ˜ ๐œ‘ "# = ๐‘—๐‘’ %! ๐‘Œโ€ฒ ๐‘โ€ฒ

  8. Consider two isomorphic sets (data types) ๐‘Œ and ๐‘Œ ! with ๐œŠ โˆถ ๐‘Œ โŸถ ๐‘Œโ€ฒ and ๐œŠ "# โˆถ ๐‘Œโ€ฒ โŸถ ๐‘Œ . Consider two isomorphic sets (data types) ๐‘ and ๐‘โ€ฒ with ๐œ‘ โˆถ ๐‘ โŸถ ๐‘โ€ฒ and ๐œ‘ "# โˆถ ๐‘โ€ฒ โŸถ ๐‘ . Consider a function ๐‘” โˆถ ๐‘Œ โŸถ ๐‘ , a computation from inputs of type ๐‘Œ to outputs of type ๐‘ . We can mechanically construct a function ๐‘” ! โˆถ ๐‘Œโ€ฒ โŸถ ๐‘โ€ฒ that makes the diagram commute. ๐‘Œ ๐‘ ๐‘” ๐œŠ "# โˆ˜ ๐œŠ = ๐‘—๐‘’ $ ๐œ‘ "# โˆ˜ ๐œ‘ = ๐‘—๐‘’ % ๐œŠ "# ๐œ‘ "# ๐œŠ ๐œ‘ ๐œŠ โˆ˜ ๐œŠ "# = ๐‘—๐‘’ $! ๐œ‘ โˆ˜ ๐œ‘ "# = ๐‘—๐‘’ %! ๐‘”โ€ฒ ๐‘Œโ€ฒ ๐‘โ€ฒ ๐‘” = ๐œ‘ "# โˆ˜ ๐‘”โ€ฒ โˆ˜ ๐œŠ ๐‘”โ€ฒ = ๐œ‘ โˆ˜ ๐‘” โˆ˜ ๐œŠ "# โŸบ

  9. Consider two isomorphic sets (data types) ๐‘Œ and ๐‘Œ ! with ๐œŠ โˆถ ๐‘Œ โŸถ ๐‘Œโ€ฒ and ๐œŠ "# โˆถ ๐‘Œโ€ฒ โŸถ ๐‘Œ . Consider two isomorphic sets (data types) ๐‘ and ๐‘โ€ฒ with ๐œ‘ โˆถ ๐‘ โŸถ ๐‘โ€ฒ and ๐œ‘ "# โˆถ ๐‘โ€ฒ โŸถ ๐‘ . Consider a function ๐‘” โˆถ ๐‘Œ โŸถ ๐‘ , a computation from inputs of type ๐‘Œ to outputs of type ๐‘ . We can mechanically construct a function ๐‘” ! โˆถ ๐‘Œโ€ฒ โŸถ ๐‘โ€ฒ that makes the diagram commute. ๐‘Œ ๐‘ ๐‘” we could just define ๐‘”โ€ฒ like this, but that is not very interesting ๐œŠ "# ๐œ‘ "# ๐œŠ ๐œ‘ ๐‘”โ€ฒ โ‰ก ๐œ‘ โˆ˜ ๐‘” โˆ˜ ๐œŠ "# ๐‘”โ€ฒ ๐‘Œโ€ฒ ๐‘โ€ฒ ๐‘”โ€ฒ = ๐œ‘ โˆ˜ ๐‘” โˆ˜ ๐œŠ "#

  10. Consider two isomorphic sets (data types) ๐‘Œ and ๐‘Œ ! with ๐œŠ โˆถ ๐‘Œ โŸถ ๐‘Œโ€ฒ and ๐œŠ "# โˆถ ๐‘Œโ€ฒ โŸถ ๐‘Œ . Consider two isomorphic sets (data types) ๐‘ and ๐‘โ€ฒ with ๐œ‘ โˆถ ๐‘ โŸถ ๐‘โ€ฒ and ๐œ‘ "# โˆถ ๐‘โ€ฒ โŸถ ๐‘ . Consider a function ๐‘” โˆถ ๐‘Œ โŸถ ๐‘ , a computation from inputs of type ๐‘Œ to outputs of type ๐‘ . We can mechanically construct a function ๐‘” ! โˆถ ๐‘Œโ€ฒ โŸถ ๐‘โ€ฒ that makes the diagram commute. ๐‘Œ ๐‘ ๐‘” ๐‘ฆ โ‰ก ๐ฃ๐  ๐‘ ๐‘ฆ representative ๐‘” ๐ฎ๐ข๐Ÿ๐จ ๐‘ ๐‘ฆ recursive ๐Ÿ๐ฆ๐ญ๐Ÿ ๐‘‘(๐‘ฆ, ๐‘”(๐‘’(๐‘ฆ))) definition ๐‘ โŠ† ๐‘Œ ๐‘ โˆถ ๐‘Œ โŸถ ๐‘ ๐‘‘ โˆถ ๐‘Œ ร— ๐‘ โŸถ ๐‘ ๐‘’ โˆถ ๐‘Œ โŸถ ๐‘Œ ๐‘” terminates โŠข ยฌ๐‘ ๐‘ฆ โŸน ๐œˆ(๐‘’(๐‘ฆ)) โ‰บ ๐œˆ(๐‘ฆ) ๐œŠ "# ๐œ‘ "# ๐œŠ ๐œ‘ keep the same structure and add the conversions ๐‘”โ€ฒ ๐‘ฆ " โ‰ก ๐ฃ๐  ๐‘(๐œŠ &# ๐‘ฆ " ) ๐ฎ๐ข๐Ÿ๐จ ๐œ‘(๐‘(๐œŠ &# ๐‘ฆ " )) ๐‘”โ€ฒ ๐Ÿ๐ฆ๐ญ๐Ÿ ๐œ‘(๐‘‘(๐œŠ &# ๐‘ฆ " , ๐œ‘ &# ๐‘”โ€ฒ(๐œŠ ๐‘’(๐œŠ &# ๐‘ฆ " ) ) )) ๐‘Œโ€ฒ ๐‘โ€ฒ ๐‘”โ€ฒ = ๐œ‘ โˆ˜ ๐‘” โˆ˜ ๐œŠ "#

  11. Consider two isomorphic sets (data types) ๐‘Œ and ๐‘Œ ! with ๐œŠ โˆถ ๐‘Œ โŸถ ๐‘Œโ€ฒ and ๐œŠ "# โˆถ ๐‘Œโ€ฒ โŸถ ๐‘Œ . Consider two isomorphic sets (data types) ๐‘ and ๐‘โ€ฒ with ๐œ‘ โˆถ ๐‘ โŸถ ๐‘โ€ฒ and ๐œ‘ "# โˆถ ๐‘โ€ฒ โŸถ ๐‘ . Consider a function ๐‘” โˆถ ๐‘Œ โŸถ ๐‘ , a computation from inputs of type ๐‘Œ to outputs of type ๐‘ . We can mechanically construct a function ๐‘” ! โˆถ ๐‘Œโ€ฒ โŸถ ๐‘โ€ฒ that makes the diagram commute. ๐‘Œ ๐‘ ๐‘” ๐‘ฆ โ‰ก ๐ฃ๐  ๐‘ ๐‘ฆ representative ๐‘” ๐ฎ๐ข๐Ÿ๐จ ๐‘ ๐‘ฆ recursive ๐Ÿ๐ฆ๐ญ๐Ÿ ๐‘‘(๐‘ฆ, ๐‘”(๐‘’(๐‘ฆ))) definition ๐‘ โŠ† ๐‘Œ ๐‘ โˆถ ๐‘Œ โŸถ ๐‘ ๐‘‘ โˆถ ๐‘Œ ร— ๐‘ โŸถ ๐‘ ๐‘’ โˆถ ๐‘Œ โŸถ ๐‘Œ ๐‘” terminates โŠข ยฌ๐‘ ๐‘ฆ โŸน ๐œˆ(๐‘’(๐‘ฆ)) โ‰บ ๐œˆ(๐‘ฆ) ๐œŠ "# ๐œ‘ "# ๐œŠ ๐œ‘ keep the same structure automatic and add the conversions ๐‘”โ€ฒ ๐‘ฆ " โ‰ก ๐ฃ๐  ๐‘(๐œŠ &# ๐‘ฆ " ) ๐ฎ๐ข๐Ÿ๐จ ๐œ‘(๐‘(๐œŠ &# ๐‘ฆ " )) ๐‘”โ€ฒ ๐Ÿ๐ฆ๐ญ๐Ÿ ๐œ‘(๐‘‘(๐œŠ &# ๐‘ฆ " , ๐œ‘ &# ๐‘”โ€ฒ(๐œŠ ๐‘’(๐œŠ &# ๐‘ฆ " ) ) )) ๐‘Œโ€ฒ ๐‘โ€ฒ n o i t ๐œˆ " โ‰ก ๐œˆ โˆ˜ ๐œŠ &# c u ๐‘”โ€ฒ terminates because ๐‘” does d n i y b โŠข ๐‘”โ€ฒ = ๐œ‘ โˆ˜ ๐‘” โˆ˜ ๐œŠ "#

  12. ๐‘” ๐‘ฆ โ‰ก ๐ฃ๐  ๐‘ ๐‘ฆ ๐ฎ๐ข๐Ÿ๐จ ๐‘ ๐‘ฆ ๐Ÿ๐ฆ๐ญ๐Ÿ ๐‘‘(๐‘ฆ, ๐‘”(๐‘’(๐‘ฆ))) ๐‘Œ ๐‘ ๐‘” keep the same structure automatic and add the conversions ๐‘”โ€ฒ ๐‘ฆ " โ‰ก ๐ฃ๐  ๐‘(๐œŠ &# ๐‘ฆ " ) ๐œŠ "# ๐œ‘ "# ๐œŠ ๐œ‘ ๐ฎ๐ข๐Ÿ๐จ ๐œ‘(๐‘(๐œŠ &# ๐‘ฆ " )) ๐Ÿ๐ฆ๐ญ๐Ÿ ๐œ‘(๐‘‘(๐œŠ &# ๐‘ฆ " , ๐œ‘ &# ๐‘”โ€ฒ(๐œŠ ๐‘’(๐œŠ &# ๐‘ฆ " ) ) )) expand the definitions user-guided and rewrite/simplify ๐‘”โ€ฒ ๐‘Œโ€ฒ ๐‘โ€ฒ ๐‘”โ€ฒโ€ฒ ๐‘ฆ " โ‰ก ๐ฃ๐  ๐‘โ€ฒ ๐‘ฆโ€ฒ goal: no trace of ๐ฎ๐ข๐Ÿ๐จ ๐‘โ€ฒ ๐‘ฆโ€ฒ โŠข ๐‘”โ€ฒ = ๐œ‘ โˆ˜ ๐‘” โˆ˜ ๐œŠ "# ๐‘Œ , ๐‘ , ๐œŠ , ๐œŠ &# , ๐œ‘ , ๐œ‘ &# ๐Ÿ๐ฆ๐ญ๐Ÿ ๐‘‘โ€ฒ(๐‘ฆโ€ฒ, ๐‘”โ€ฒโ€ฒ(๐‘’โ€ฒ(๐‘ฆโ€ฒ))) โŠข ๐‘” "" = ๐‘”โ€ฒ

  13. This is a general method: Consider a function ๐‘• that calls ๐‘” , ๐‘” # , ๐‘” 0 , etc. automatically create an isomorphic version We can apply the same general method to ๐‘• . and semi-automatically rewrite/simplify it. If ๐‘• manipulates the data being transformed only through ๐‘” , ๐‘” # , ๐‘” 0 , etc., we can automate We can do it for ๐‘” , ๐‘” # , ๐‘” 0 , etc., obtaining ๐‘”โ€ฒ , ๐‘”โ€ฒโ€ฒ , ๐‘” # โ€ฒ , ๐‘” # โ€ฒโ€ฒ , ๐‘” 0 โ€ฒ , ๐‘” 0 โ€ฒโ€ฒ , etc., the rewriting/simplification step as well. ๐‘” ๐‘ฆ โ‰ก โ€ฆ ๐‘• โ€ฆ โ‰ก โ€ฆ ๐‘” โ€ฆ โ€ฆ keep the same structure keep the same structure and add the conversions and add the conversions โŠข ๐‘” = ๐œ‘ "# โˆ˜ ๐‘”โ€ฒ โˆ˜ ๐œŠ โ‰ก โ€ฆ ๐œ‘(๐‘”(๐œŠ &# โ€ฆ )) โ€ฆ ๐‘”โ€ฒ ๐‘ฆโ€ฒ โ‰ก โ€ฆ ๐‘•โ€ฒ โ€ฆ expand the definitions expand the definitions and rewrite/simplify and rewrite/simplify ๐‘”โ€ฒโ€ฒ ๐‘ฆ " โ‰ก โ€ฆ ๐‘•โ€ฒโ€ฒ โ€ฆ โ‰ก โ€ฆ

  14. This is a general method: Consider a function ๐‘• that calls ๐‘” , ๐‘” # , ๐‘” 0 , etc. automatically create an isomorphic version We can apply the same general method to ๐‘• . and semi-automatically rewrite/simplify it. If ๐‘• manipulates the data being transformed only through ๐‘” , ๐‘” # , ๐‘” 0 , etc., we can automate We can do it for ๐‘” , ๐‘” # , ๐‘” 0 , etc., obtaining ๐‘”โ€ฒ , ๐‘”โ€ฒโ€ฒ , ๐‘” # โ€ฒ , ๐‘” # โ€ฒโ€ฒ , ๐‘” 0 โ€ฒ , ๐‘” 0 โ€ฒโ€ฒ , etc., the rewriting/simplification step as well. And we can do everything in one step. ๐‘” ๐‘ฆ โ‰ก โ€ฆ ๐‘• โ€ฆ โ‰ก โ€ฆ ๐‘” โ€ฆ โ€ฆ keep the same structure and add the conversions keep the same structure and replace ๐‘” with ๐‘”โ€ฒ etc. ๐‘”โ€ฒ ๐‘ฆโ€ฒ โ‰ก โ€ฆ expand the definitions ๐‘•โ€ฒ โ€ฆ โ‰ก โ€ฆ ๐‘”โ€ฒ โ€ฆ โ€ฆ and rewrite/simplify ๐‘”โ€ฒโ€ฒ ๐‘ฆ " โ‰ก โ€ฆ

Recommend


More recommend