Abstract
Following Lockwood Morris, a method for algebraically structuring a compiler and proving it correct is described. An example language with block structure and side-effects is presented. This determines an initial many-sorted algebra L which is the ‘abstract syntax’ of the example language. Then the semantics of L is completely determined by describing a semantic algebra M ‘similar’ to L. In particular, initiality of L ensures that there is a unique homomorphism Lsem: L→> M. This is algebraically structuring the semantic definition of the language. A category of flow-charts over a stack machine is used as a target language for the purposes of compilation. The semantics of the flow charts (Tsem: T→ S) is also algebraically determined given interpretations of the primitive operations on the stack and store. The homomorphism comp: L→ T is the compiler which is also uniquely determined by presenting an algebra T of flowcharts similar to L. This is algebraically structuring the compiler. Finally a function encode: M→ S describes source meanings in terms of target meanings. The proof that the compiler is correct reduces to a proof that encode: M→ S is a homomorphism; then both comp ∘ Tsem and Lsem ∘ encode are homomorphisms from L to S and they must be equal because there is only one homomorphism from L to S.
Talk to us
Join us for a 30 min session where you can share your feedback and ask us any queries you have
Disclaimer: All third-party content on this website/platform is and will remain the property of their respective owners and is provided on "as is" basis without any warranties, express or implied. Use of third-party content does not indicate any affiliation, sponsorship with or endorsement by them. Any references to third-party content is to identify the corresponding services and shall be considered fair use under The CopyrightLaw.