In this repository, we formally define the translation of the K Frontend Language into axioms in Matching Logic, the logic over which the semantics of the K Framework are defined. K being a Language used in formal verification, it is important the K frontend constructs have clearly defined semantics.
After installing python3, ninja-build and pandoc simply run ./build.
After cloning the repo and initializing the submodules (git submodule update --init --recursive),
build K-in-K with ./build kink. Then:
- to kompile an ekore definition, use
./bin/kink kompile -- foo.ekore - to parse a program, use
./bin/kink kast program.foo -- foo.k
Note that the foo.k/ekore files are arguments to KRun, whereas kompile and
kast program.foo are arguments to the K-in-K definition. See
src/command-line.md and ./bin/kink for details.
- To build K-in-K run:
./build kink - To build and run all tests run
./build - To build tests for a particlar definition run:
./build t/<lang>(e.g../build t/foobar) - To run a single test, (e.g.
t/foobar/<TEST>.ekore), run./build .build/t/foobar/<TEST>.ekore.kink.kore.test. If you need to see the generated configuration, runcat .build/t/foobar-<TEST>.ekore.kink.
Each folder is the t/ directory defines a language. For each language we have
two tests for the EKORE pipeline:
- That we generate the expected final ekore from the ekore with kasted bubbles
- That the ekore pipeline is the identity over the expected ekore
In addition, there are additional tests to check that we can execute programs in each of those languages.
-
Extend EKORE to allow bubbles (using k-light's parser)
-
#parse- Generate grammar needed for
#parse(Configuration grammar, Rule grammar) #parsetakes list of productions, string to parse, and start symbol
- Generate grammar needed for
-
Disambiguation
-
(Done) foobar: Get a module with only function symbols working.
Define sortsDefine symbolsTranslate function axioms
-
Arithmetic Expressions:
Identify exactly what axioms are needed for the haskell backend to exectute definitionsGeneralize sorts declaration codeGeneralize symbols declaration codeGeneralize function axioms- Desugar
syntaxdeclarations with multiple productions, into multiplesyntaxdeclarations with one production. Multiple passes will become easier in this format (passing grammars to the parser, declaring symbols, and adding function and constructor axioms). - Add
functional&constructoraxioms to all non-function productions. - (Not needed for execution semantics) Define functional and no-junk/mu axioms for constructors
-
Imp:
- Get rewrites working when configuration is pre-concretized for every rule.
- Concretize configuration / Use contexts
- Error messages
- A more K-style implementation: More configuration/cell/matching based rules, fewer functions and iteration.
Most transformations will use the infrastructure for iterating over declarations in modules, documented here. A concrete example is documented in detail here to help new developers get started.
Style guidelines:
- Align text to 80 characters.
- Align code to 100 characters.
- There must be exactly one newline before and after code blocks; and no consecutive empty lines (this causes line numbers in tangle output to differ from the actual line numbers and costs developer time).
- Implement each transformation in a module of its own (e.g.
CONCRETIZE-CONFIGURATION). If the transformation adds a symbol to the pipeline this should be the same as the module name, but in camel case (e.g.#concretizeConfiguration).
TODO: Choose better names for EKore-0, ...
-
Frontend K
- Includes:
- K Frontend syntax for defining grammar, rules, configuration
- Rules may use:
- User defined syntax (concrete syntax)
- KAST syntax (abstract syntax)
- Eliminate User defined syntax by converting to KAST
- Choose KLabels for each production
#bubble(...)is replaced with KAST syntax- Disabiguation
require "file.k"should be expanded to the contents of the file.- ...
- Includes:
-
Extended-Kore
- (EKore-0 -> EKore-1) : Turn
#KProductions into koresortdeclarations - (EKore-1 -> EKore-2) :
#KProductions replaced with kore'ssymboldeclaration - (EKore-2 -> EKore-3) : Rules for functional symbols become axioms (of the form equations, not rewrites).
- (EKore-? -> EKore-?) : Other rules for symbols become
\rewriteswith contexts - Define configuration cell sorts ...
- ...
- (EKore-0 -> EKore-1) : Turn
-
Pre-Kore : No more K frontend constructs
- Generate "No Junk" Axioms
- Generate Functional Axioms
- Generate Strictness Axioms
- Generate Configuration init functions
- Configuration concretization
- ...
K allows using Sorts before they are declared (so long as they are declared
later in the module). However, kore more strict:
- Every declared symbol or alias should have their argument sorts and return sorts declared;
- All sorts, symbols, and aliases should be declared before being used;
Is it OK to assume that this holds in K-Definitions too for now?
kore.ksays thatNameis aSort, but I think it should be aSortVariableinstead?kore-parsethrows: "Sort variable 'Foo' not declared" otherwise.kore.khas sort names likeDeclarationwhereaskore-parsecalls its corresponding constructObjectSentences. I think we should converge?
-
How will AC lookuPs look
-
Should
#KRequires(\dv{Bool{}("true"))be#KRequires(\top{..}()) -
Why are bubbles inside
#NoAttrs/#Attrs, can we instead have:#KRule{}(#bubble(...), #KAttrs(#KAttrsEmpty(){}, #KRequires{}(...))
- We expect top-level
requires "file.k"to be handled anddomains.ketc to be included in the definition.