Open ehildenb opened 3 years ago
LESSON-11-C
example. I kept getting parsing ambiguity and? in the end, I decided to skip it. Does it actually have a solution? Check that the solution for this exercise exists/works.--search
option, but does not mention that the llvm
backend does not support it. I suggest mentioning that the definition should be compiled with kompile --backend haskell
for the --search
option to be usable. By default kompile
uses the llvm
backend. Specify that you must do kompile --enable-search
for search on the LLVM backend.You need to kompile --enable-search --backend llvm
to have the binary generated that will do a search on LLVM backend. This should be made clearer.
Some minor notes:
[x] Lesson 9: Some formatting errors in the table, because of how "paragraphs" within table cells are handled. Check that tables are formatted correctly on github.com and on kframework.org.
[x] Lesson 9: It would be nice to see example of how the color attribute is used, since its a little unclear if/what the color attribute takes as an arguments (and what are valid colors? I see that certain named colors work). Provide an example the user can run on the command-line with the color attribute.
[x] Lesson 10: Formatting errors in tables; some of the escaped need double-backslashes. Check formatting of tables on github.com and kframework.org.
[x] Link to lesson 11 is broken. Check end-of-document links.
[x] Lesson 11: typo: “provies” => “provides”. Fix.
[ ] Lesson 12: what a "freezer" is is not clearly explained. Make the link between the user-defined freezers (with manual strictness) and generated ones more explicit, maybe explaining the naming scheme for freezers.
[x] Lesson 10: typo: end => start
=> end >= start
. Fix
[x] Lesson 11: It's sort of mentioned off-hand, but it might help to state clearly that casts/strict casts are a compile-time feature, while projection casts are a runtime feature that can cause runtime errors. Make explicit that casts/strict casts are for parsing, and projection casts will cause a runtime halt (but nothing at kompile time). Maybe make sure there is an example of such a runtime halt in the exercises.
[x] Lesson 12: unbalanced paren before the last code block, I'm not sure what was intended there. Fix typo.
[x] Lesson 13: "be aware" => "remember"? Change wording.
[x] Lesson 14: isKResult
is referred to as builtin, but this can't be the case if we have to define it ourselves. Shouldn't it be that the name isKResult
is treated specially? Specify how the KResult sort is the default sort used for heating/cooling when using strict
or seqstrict
, and that we're overriding the definition of the automatically generated predicate isKResult
. Also double-check that we do introduce somewhere the notion of sort predicates isSORT(_)
for each sort.
[x] Lesson 14: "if I wrote" => "if we wrote" [editorial]. Change wording.
[ ] Although honestly, I'm not sure I see why a basic tutorial needs to explain how seq
and seqstrict
work under the hood. The old tutorial showed why they are needed and how to use them and then moved on, and I was able to use K for some toy examples easily with just that knowledge. Showing how they work under the hood later would be great, but starting off with the fully desugared rules in a basic tutorial feels like a huge leap. Consider moving the explanation of strict
and seqstrict
later, after explaining rewrite rules/semantic rule and other simple things?
Here are some more typos and minor issues I spotted. These are rather low-hanging fruits. I will prepare a PR.
mechinism
-> mechanism
have
-> has
~~ @JKTKops pointed out to me that have
is actually correct here because the phrase is subjunctive.proves
-> prove
on
-> to
or on
-> at
comma separated
-> comma-separated
startin
-> starting
funtion
-> function
syntax Id ::= "[a-zA-Z_][a-zA-Z0-9_]*" [token]
-> syntax Id ::= r"[a-zA-Z_][a-zA-Z0-9_]*" [token]
disamiguation
-> disambiguation
These attribute
-> These attributes
determinstic
-> deterministic
nonterminal
or non-terminal
, same for nondeterministic and non-deterministic
left-hand-side
and left hand side
-> left-hand side
, same for right-hand side
What I really like about the tutorial is that it often introduces a topic from the bottom up and then shows how to simplify things. This is, for example, how evaluation orders are introduced. It is much more rewarding for the reader than first presenting the "simple" bits and then claiming, "but wait, there are more complicated cases, and you also need to know about these things under the hood."
I submitted https://github.com/kframework/k/pull/2087
I took some notes but I see that a lot of them have been mentioned previously. The only one I have is this:
requires lesson-06-a.k
as the first line.Ids
with NeList{},...' should be changed to 'replaced List with NeList,...'Strict casts
shouldn't (I1:Int + I2:Int)::Exp2
choose the second derivation and (I1:Int + I2:int)::Exp
choose the first one?LESSON-16-B-SYNTAX
- import ID-SYNTAX
instead of imports ID-SYNTAX
LESSON-16-B-SYNTAX
function declarations start with fun
but in the example program foo.func
we are given int foo
and int main
Sert
instead of Set
language
colors
attribute crashes with something like /usr/local/bin/kore-print: line 25: 4832 Abort trap: 6 "$@"
. I guess this can be a bit cryptic so maybe the error can be handled better.%c
do when it reaches the end of the list? How does %c
interact with %r
? If %r
resets to the default foreground color, that means the current color may no longer be in the list at all, so it's unclear what %c
would do. lesson-13-b.k
being very simple (addition with concrete values only), some of the heating/cooling rules can be commented out and evaluation would still be correct. Maybe there's an opportunity for an exercise like "extend the grammar such that all given types of rules are necessary for evaluation".lesson-16-b.k
instead of lesson-16-a.k
.--search
to ascertain they run deterministically, as to avoid such "silent" branching. Lesson 20 did this indirectly for me but I had to scratch my head for a while.I enjoyed working through the tutorial and look forward to keeping up with the lessons. Big thanks to everyone developing it!
which we will name lesson-04-D.k
=> lesson-04-d.k
true
whenever a term should not be heated (because it is a value) and false
"LESSON-14-C
. Shouldn't it point to LESSON-14-D
instead?[function]
label. Maybe the lesson could explain a bit why it's used or point to another lesson (like Lesson 1.6) where the label is needed.lesson-02-d.k
from lesson 1.2" - Lesson 2 doesn't tell the user to save module LESSON-02-D
in a file called lesson-02-d.k
(but yes, it's obvious what lesson-02-d.k
means)lesson-12-c.k
should require "lesson-12-a.k"
<thread>
cells to be wrapped inside a <threads>
cellI appreciate the developers of the tutorial and all contributors to it. It is a straightforward and perfect introduction to K. The first part is pretty simple, and the second one is a bit more difficult. I have the following notes and proposals for the tutorial:
syntax Stmt ::= "{" Stmt "}" [color(red), format(%1%i%n%2%d%n%3)]
| "{" "}" [color(red), format(%1%2)]
> right:
Stmt Stmt [format(%1%n%2)]
| "if" "(" Bool ")" Stmt [colors(blue,red,yellow,red), format(%1 %2%c%3%4 %5)]
| "if" "(" Bool Bool ")" Stmt "else" Stmt [avoid, colors(blue,red,yellow,red,blue), format(%1 %2%c%3 %r%4%5 %6 %7 %8)]
endmodule
Thanks for this tutorial, it was really helpful to understand the basics of K. Following are some tips that might help on improving it.
[bracket]
production in order to be able to write more complex expressions and see both heating rules being applied.[bracket]
production. In the nondeterministic evaluation order with the strict
attribute, we can only observe 2 possible different behaviors when using the --search
if we have expressions like (5 + 3) + (2 + 1), for instance.Stmts
for instance and the $PGM
configuration variable would have sort Stmts
so one can have programs with more than one statement. $PGM:K
doesn't allow to write a program that properly test spawn
and join
. It should be changed to $PGM:Stmts
."join" Exp ";"
should have [strict]
and the ";"
is not necessary in this production since the sort Stmt
already has the semicolon in its productions....
before the end of the k
cell:
<k> spawn { Ss } => NEXTID ...</k>
Thanks for the tutorial! It was fun going through them, playing/ experimenting K features with toy examples and incrementally building up bigger codes. Here are some issues or confusions I have run to. Hope they will be helpful for the others.
[ ] Lesson 1: Building K using maven on MacOS (for me is version 12.2.1), might be encounter a install_name_tool failure (building Haskell Backend module). This could be due to LLVM 13 has an incompatible version of this command. The workaround is to uninstall llvm
and reinstall llvm@12
using Homebrew
, referred to issue #2988. (One more tip: brew install llvm@12
might suggest you to echo 'export PATH="/usr/local/opt/llvm@12/bin:$PATH"' >> ~/.zshrc
. You may not do this, it might causing the problem that you build system cannot find llvm.)
After the llvm@12 update, you might also run into an issue where stack
fails, refer to this fix.
[ ] Lesson 4: Associativity. The manual explains well, though there might be too much to remember. The mistake I have made is to define associativity for a group operators with different priorities, e.g., syntax left times div mod plus minus
(where times > plus). The expected way should be syntax left times div mod
and syntax left plus minus
. Refer to this slack thread for more details.
[ ] Lesson 6: When using builtin INT
sort, -2
and +3
are treated as a token. This will result in 1+2
to be parsed as tokens of 1
and +2
instead of an addition expression, thus resulting a parsing error. Referred to issue #2455.
[ ] Lesson 9: Regarding the color
and colors
paragraph, since colors
gives the color for every terminal, there is no needs to control the curser with %c
or %r
. And color
attribute allows multiple colors to be listed. Thus, suggest edit of this paragraph: “At a more advanced level, ... colors
attribute ”, colors
=> color
; delete "You can essentially...the same color."
[ ] Lesson 19: The latest version of llvm-backend, has removed interpreter-gdb.py
. If the tutorial instruction was followed and the first recommended command was executed, it might cause a problem of no such file or directory
problem. The solution worked for me was to follow the second recommended command to disable the security protection by adding set auto-load safe-path /
to ~/.gdbinit
. You might need to delete the ~/.gdbinit
file and redefine it if previous step is not working.
[ ] Lesson 16, Sets: "A set with a variable of sort Set
also matches any superset of such a set." Should it be: "A set pattern..." instead?
[ ] Lesson 16, Sets: "As with map, the elements left over will be bound to the Set
variable (or
.Set
if no elements are left over)." => "As with map, the elements left over (or
.Set
if no elements are left over) will be bound to the variable of sort Set
."
colors
is not clear about the %c
and %r
placeholders. Let's add an exampleisKResult
, we suddenly encounter the symbol
attribute with no explanation.a
implicitly introduces a variable (symbol?) A
<first-number>
, then the cell sort name would be FirstNumberCell." --> is that what we'd get if we used <firstNumber>
as well?--search
doesn't work if the module name includes underscores. See https://runtimeverification.slack.com/archives/C022YGTV4JK/p1656498523114479?thread_ts=1656442281.531069&cid=C022YGTV4JKlesson-19-b.k
putting a breakpoint at line 9 didn't work for me. All the other examples were okay but when I tried to put a breakpoint at line 9, I didn't get the expected input; instead the run just finished without breaking. It might be my mistake though I tried to follow the provided example as much as possible.krun -cPGM='2+5'
, it wastes too much time to understand why it doesn't work.Thanks for the tutorial, it's a great piece of writing for the fact that K is not the easiest thing to learn. A couple of thoughts:
--definition
flag because the tutorials often worked with multiple definitions. The tutorial said we would come to this later but it was quite handy to know before. I guess the tutorial meant the Modules Lesson, but --definition
is often much faster than to have a central module and import everything every time.lesson-04-d.k
has &&
and |
instead of ||
, which is used in the rest of tutorial (inconsistency)“ABB”
and “A” “B” B”
. The following grammar is formally ambiguous but looks totally OK to the parser because of how it understands tokens:
syntax Expr ::= "a" Expr "b"
| "abb"
| "b"
"abb" can be parsed in two different ways, with the token "abb" or with a sequence of tokens "a" "b" "b". It can lead to problems when one is not aware of it in some more complicated example.
LESSON-05-D-2
=> LESSON-05-D
?domains.md
. I suggest putting Ex2 without built-in Boolean functions into Exercises in Lesson 7, when one learns about the side conditions and order of evaluation so that it can be correct. For example,
A == A => true
_A == _B => false [owise]
Now assuming you can only use built-in Integer functions, A < B
is fun to implement.
Compile this file
I had to go looking for it on GitHub.In practice, _un_parsing is not always precisely reversible
=> In practice, parsing is not always precisely reversible
(we want to reverse parsing ~ unparse, not reverse unparsing ~ parse, right?)%c
is not very well explained, I needed to experiment with it to see how it works. An example would be useful.concat
, because how would we test concat
without this?... , but when a definition is compiled,...
=> ... . When a definition is compiled, ...
? :
? It would be more informative.eval
from lesson 1.11 problem 2. But this evaluator actually works without eval
. So it might be better actually to just say rework the evaluator to use seqstrict
or something like that.seqstrict
works under the hood. I'm not sure if all the talk about contexts is that necessary. Wouldn't it be better just to say arguments are evaluated strict in ltr manner by heating and cooling back to their original places? This is how a human remembers it intuitively anyway.Consider the following definition which is equivalent to the one in LESSON-15-B (lesson-15-c.k)
=> Consider the following definition (lesson-15-c.k) which is equivalent to the one in LESSON-15-B
.reset ;
works. It'd be good to add an exercise to do this along with instructions to modify the syntax.A List pattern in K consists of zero or more list elements (as represented by the ListItem symbol), followed by zero or one variables of sort List, followed by zero or more list elements.
=> just add an example.First, make sure you have not passed -O1, -O2, or -O3 to kompile. Second, simply add the command line flags -ccopt -g -ccopt -O1 to kompile
. Is the first sentence necessary? I would just say run kompile
with these flags...--no-haskell-binary
, see https://runtimeverification.slack.com/archives/C7E701MFG/p1660319199525119Lesson 1:
update your $PATH with <checkout-dir>/result/bin
).sudo update-alternatives --config java
then select the openjdk-11-jdk
version) before running mvn package
. I initially had openjdk-17-jdk
as my Java version, but it was incompatible with Maven.sudo apt remove kframework
.Lesson 13:
depth
works. --depth 1
, then gradually increase the value of --depth
to see successive states which may in turn help them understand the code. This method works for me quite well.Lesson 16:
Lesson 19:
.gdbinit
file in my ~/
directory, create one yourself. And that it is required to run commands k start
, k step
and k match
in the lesson.Lesson 22:
VERIFICATION
module with two simplifications that capture the meaning of maxInt(A:Int, B:Int)
, it is actually not required as there are maxInt
rules in domains.md
. From sonzu on Discord:
.k .exclude
syntax Int ::= r"[\\+-]?[0-9]+" [token]
fmt
as dependence to build K. It should be included in the list of dependencies to be installed with brew.Fruits
in the "Booleans in K - Exercise" sentence is miss highlighted.krun input
and krun -cPGM
behaves differently: https://github.com/runtimeverification/k/issues/3166 [Warning] Compiler: Could not find main syntax module with name FOO-SYNTAX in definition.
Use --syntax-module to specify one. Using FOO as default.
We should either introduce syntax modules from the beginning (currently not done until Lesson 5), add instructions to pass the --syntax-module flag, or at least indicate that this warning can be ignored for now.
lesson-04-E.k
=> lesson-04-e.k
LESSON-09-A
"LESSON-12-B-SYNTAX
..." => LESSON-12-A-SYNTAX
....
on the RHS of a rule if there is a configuration variable preventing the cell from being concretized.Map
sort on the RHS of a rule for map patterns, but the semantics is never well-explained (what happens if the keys overlap, or do they need to be disjoint, etc.?)LESSON-17-A
even though it has multiplicity "?") Is there a reason this is required, or is there a way to specify what the cells should contain without providing a concrete value like this?
Issues found by the folks going through the tutorial. I short check-list is provided here, more details for each issues are provided in comments.
@dwightguth I've gone through and put (in bold following each bullet point) the things to check for that bullet point.