I'm particularly interested to understand the K prelude (how it is structured, why its content is like that, how "kompile" calculates dependencies, etc). The main question is: what is the criterion for a hooked symbol from the K prelude to be copied into the generated Kore file?
Here some examples of potential problems:
The symbol andBool is copied with its associated rewrite rules, which does not seem to be the case for the symbol in_keys, which is simply copied without its rewrite rules. Other symbols seem to be useless (for the IMP semantic) but exist, with or without its rewrite rules, in the generated Kore file, such as countAllOccurrences, findChar, signExtendBitRangeInt or Float2String.
It seems that SortId is generated by the line
syntax Id [token]. However, the lines"syntax Bool ::= "true" [token]andsyntax Bool ::= "false" [token]do not generate true and false symbols. (Moreover, is it a choice that true and false are values and not constructors?)The sort named SortId is not generated for the following example, whereas some generated hooked symbols depend on this sort. This problem does not exist with the IMP semantic.
module MAX-OW-SYNTAX
imports INT
imports BOOL
syntax Exp ::= Int | "(" Exp ")" [bracket]
| "max" Exp Exp
endmodule
module MAX-OW
imports MAX-OW-SYNTAX
syntax KResult ::= Int
rule max X Y => Y requires X <Int Y
rule max X _ => X [owise]
endmodule
Is it correct that the K prelude is implemented in each language of each backend, and that an implementation in the Kore language is available in the K prelude? Do you have the necessary interface to implement for a new backend? (For instance,
Bagis obsolete, but notSet,ListandMap, but I don't know the list of set operators, map operators, etc. that the new backend must provide.)Is there a reason why andThenBool and andBool have the same semantics once implemented in the Kore syntax (Booleans module)?
Where are the rewrite rules defined for ==Bool, used in the definition of =/=Bool (Booleans module)?
The best reference point for the K internals is the User Manual, along with the K source for the prelude. To respond to your specific questions as best as I can:
in_keysonly has simplification rules that apply on symbolic backends. These will not apply on concrete backends, and so those backends use the hooked implementationMAP.in_keys. Some functions (such asandBool) can be implemented both in K and as an efficient backend hook. For example, on the K LLVM backend,andBoolis implemented by code generation. If a backend didn't support that hook, the (relatively) inefficient K rewriting implementation would be used.Idsort is built in for convenience. It represents program identifiers.DOMAINSin this example. Doing so will pull in theIdsort and related rewrites.andThenBoolis required to short-circuit its arguments;andBoolis permitted to short-circuit, but may evaluate both arguments strictly. An implementation that makes both perform short-circuiting is valid.==Boolis implemented only in terms of a hook. Indomains.md, you can see thehook(BOOL.eq)attribute that indicates how==Boolis implemented.Do let us know if you have further questions, or would like help implementing a specific semantics in K.