How to represent software code for code generation / automatic programming? How to integrate procedural and declarative knowledge? I am learning about deontic logics and there I can make the following inferences: If A then there is **duty to create an entity of class C**, If B then there is **duty to assign value 5 to the attribute c.a**, if A and B then **the computation D should be executed**. I. e. those deontic logic statements contain the usual propositional variables A, B, C, but they also contain actions - pieces of procedural knowledge, like create an entity of class C and so on. The questions are:


How do I represent those actions in such manner that they can be used for the code generation/automatic programming? The simple approach can be to represent them by their content - e.g. by the code in the industrial programming language.
The goal of such reasoning is to create the syntactical tree of the program from which the source code in the industrial programming language can be read as source file. How do I represent actions that they can form the syntactical tree?


I feel that the deontic logic (formalized norms) are enough for generating software code (at least business layer - classes and their behavior), but I am struggling with the consequent end of the inference - how to represent actions/source code?

This may be seen as the more general question as well: formalized norms can be seen as the declarative knowledge and we should create reactive, procedural programs / procedural knowledge from the declarative knowledge - how to represent procedural knowledge and how to create procedural knowledge from the declarative knowledge? Are there research efforts to do this and what are keywords for this type of reasearch (so - I can find the already achieved results in Google or journal databases).
Use some form of metamodelling :


  The outputs are represented as abstract syntax trees (ASTs):





  and constructed by a decoder with a dynamically-determined modular structure paralleling the structure of the output tree.




References


Modelling homogeneous generative meta-programming
Abstract Syntax Networks for Code Generation and Semantic Parsing
Canonical Abstract Syntax Trees
Pattern Reification as the Basis for Description-Driven Systems
Metamodelling: State of the Art and Research Challenges
DSL development based on target meta-models. Using AST transformations for automating semantic analysis in a textual DSL framework
The Machine that Builds Itself:
How the Strengths of Lisp Family Languages
Facilitate Building Complex and Flexible
Bioinformatic Models
Reasoning About LLVM Code Using Codewalker
Foundations of meta-programming