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 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 ยง ...
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 ยง ...
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 " ๐ก ! ๐ ๐โฒ ๐โฒ
Consider two isomorphic sets (data types) ๐ and ๐ ! with ๐ โถ ๐ โถ ๐โฒ and ๐ "# โถ ๐โฒ โถ ๐ . ๐ ๐ "# โ ๐ = ๐๐ $ ๐ "# ๐ ๐ โ ๐ "# = ๐๐ $! ๐โฒ
Consider two isomorphic sets (data types) ๐ and ๐ ! with ๐ โถ ๐ โถ ๐โฒ and ๐ "# โถ ๐โฒ โถ ๐ . Consider two isomorphic sets (data types) ๐ and ๐โฒ with ๐ โถ ๐ โถ ๐โฒ and ๐ "# โถ ๐โฒ โถ ๐ . ๐ ๐ ๐ "# โ ๐ = ๐๐ $ ๐ "# โ ๐ = ๐๐ % ๐ "# ๐ "# ๐ ๐ ๐ โ ๐ "# = ๐๐ $! ๐ โ ๐ "# = ๐๐ %! ๐โฒ ๐โฒ
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 ๐ . ๐ ๐ ๐ ๐ "# โ ๐ = ๐๐ $ ๐ "# โ ๐ = ๐๐ % ๐ "# ๐ "# ๐ ๐ ๐ โ ๐ "# = ๐๐ $! ๐ โ ๐ "# = ๐๐ %! ๐โฒ ๐โฒ
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. ๐ ๐ ๐ ๐ "# โ ๐ = ๐๐ $ ๐ "# โ ๐ = ๐๐ % ๐ "# ๐ "# ๐ ๐ ๐ โ ๐ "# = ๐๐ $! ๐ โ ๐ "# = ๐๐ %! ๐โฒ ๐โฒ ๐โฒ ๐ = ๐ "# โ ๐โฒ โ ๐ ๐โฒ = ๐ โ ๐ โ ๐ "# โบ
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 ๐ "# ๐ "# ๐ ๐ ๐โฒ โก ๐ โ ๐ โ ๐ "# ๐โฒ ๐โฒ ๐โฒ ๐โฒ = ๐ โ ๐ โ ๐ "#
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 ๐โฒ ๐ฆ " โก ๐ฃ๐ ๐(๐ &# ๐ฆ " ) ๐ฎ๐ข๐๐จ ๐(๐(๐ &# ๐ฆ " )) ๐โฒ ๐๐ฆ๐ญ๐ ๐(๐(๐ &# ๐ฆ " , ๐ &# ๐โฒ(๐ ๐(๐ &# ๐ฆ " ) ) )) ๐โฒ ๐โฒ ๐โฒ = ๐ โ ๐ โ ๐ "#
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 โข ๐โฒ = ๐ โ ๐ โ ๐ "#
๐ ๐ฆ โก ๐ฃ๐ ๐ ๐ฆ ๐ฎ๐ข๐๐จ ๐ ๐ฆ ๐๐ฆ๐ญ๐ ๐(๐ฆ, ๐(๐(๐ฆ))) ๐ ๐ ๐ keep the same structure automatic and add the conversions ๐โฒ ๐ฆ " โก ๐ฃ๐ ๐(๐ &# ๐ฆ " ) ๐ "# ๐ "# ๐ ๐ ๐ฎ๐ข๐๐จ ๐(๐(๐ &# ๐ฆ " )) ๐๐ฆ๐ญ๐ ๐(๐(๐ &# ๐ฆ " , ๐ &# ๐โฒ(๐ ๐(๐ &# ๐ฆ " ) ) )) expand the definitions user-guided and rewrite/simplify ๐โฒ ๐โฒ ๐โฒ ๐โฒโฒ ๐ฆ " โก ๐ฃ๐ ๐โฒ ๐ฆโฒ goal: no trace of ๐ฎ๐ข๐๐จ ๐โฒ ๐ฆโฒ โข ๐โฒ = ๐ โ ๐ โ ๐ "# ๐ , ๐ , ๐ , ๐ &# , ๐ , ๐ &# ๐๐ฆ๐ญ๐ ๐โฒ(๐ฆโฒ, ๐โฒโฒ(๐โฒ(๐ฆโฒ))) โข ๐ "" = ๐โฒ
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 ๐โฒโฒ ๐ฆ " โก โฆ ๐โฒโฒ โฆ โก โฆ
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