File extension: .elf
Comment (single line): Starts with %
Comment (multi-line): between %{
and
%}
Coverage check
Totality check
Adequacy
%name
ʳNot mandatory, but makes twelf output messages more readable.
If %name
is given for a type, names of variables of that
type which twelf generates will have the prefix indicated by
%name
.
Name starts with an uppercase letter. Usually a single letter would do, though multi-character prefixes are fine too.
For example, with the following definitions,
nat: type.
z: nat.
s: nat -> nat.
plus: nat -> nat -> nat -> type.
plus/z: plus z N N.
plus/s: plus (S N1) N2 (S N3) <- plus N1 N2 N3.
% plus/s: plus N1 N2 N3 -> plus (S N1) N2 (S N3).
Twelf gives:
_ = plus/s (plus/s plus/z).
% _ : {X1:nat -> nat} {X2:nat -> nat} {X3:nat} plus (X1 (X2 z)) X3 (X1 (X2 X3))
% = [X1:nat -> nat] [X2:nat -> nat] [X3:nat] plus/s (plus/s plus/z).
But if we add a %name
for ~nat, like
%name nat N.
It would have been:
_ = plus/s (plus/s plus/z).
% _ : {N1:nat -> nat} {N2:nat -> nat} {N3:nat} plus (N1 (N2 z)) N3 (N1 (N2 N3))
% = [N1:nat -> nat] [N2:nat -> nat] [N3:nat] plus/s (plus/s plus/z).
%. |
%abbrev |
%assert |
%block |
%clause |
%covers |
%define |
%deterministic |
%establish |
%freeze |
%infix |
%prefix |
%postfix |
%mode |
%name |
%prove |
%query |
%querytabled |
%reduces |
%solve |
%subord |
%tabled |
%terminates |
%thaw |
%theorem |
%total |
%trustme |
%unique |
%use |
%worlds |
As of January 2024, twelf.el file for emacs mode needs some brackets removed. Other than that, it should work right out of the box.
(Got to set twelf-root
variable first.)
First, twelf-server needs to be started:
M-x twelf-server
(will display a 'Server OK' message).
C-c C-c
: Load a configuration file
C-c C-s
: Load an elf fileC-c C-d
: Type check a specific declarationFirst run the cfg file. Afterwards individual elf files can be run as needed.
All files in a twelf project should be listed in a
sources.cfg
files. Those files are compiled in the order in
which they are listed.
https://github.com/Beluga-lang/Beluga
.bel
%
[ |- stuff ]
.Data variables will always be within a box
Program variables will never be within a box
Convention:
Key | Description | elisp function |
---|---|---|
C-c C-c | Compile | 'compile |
C-c C-l | Highlight holes | 'beluga-highlight-holes |
C-c C-x | Run command | 'beluga-run-command |
C-c C-t | Get type | 'beluga-get-type |
C-c C-s | Split hole | 'beluga-split-hole |
C-c C-i | Intro hole | 'beluga-intro-hole |
C-c C-j | Jump hole | 'beluga-hole-jump |
C-c C-p | Get hole info | 'beluga-hole-info |
C-c C-e | Erase holes | 'beluga-erase-holes |
Example:
$ harpoon --sig hello.bel
## Type Reconstruction begin: hello.bel ##
## Type Reconstruction done: hello.bel ##
Configuring theorem #1
Name of theorem (:quit or empty to finish):
Reference:
Line number starts from 0.
https://www.gnu.org/software/gawk/manual/gawk.html#Built_002din-Variables
\n
.Special patterns.
Follwing two statements have the same effect:
printf "%s %s\n", "hello", "world"
printf "%2$s %1$s\n", "world", "hello"
and prints 'hello world'.
$ echo 'a' | awk 'BEGIN {a="1"} /.+/ {a=a$0} END{print a}'
1a
function <name> {
}
https://faculty.cs.niu.edu/~berezin/330/N/awk-fun.html
int()
https://www.gnu.org/software/gawk/manual/html_node/String-Functions.html
A trick:
length { <code> }
This works because length
of empty line gives
0
, which is considered as false value.
Thanks to tirnanog from #awk.
print ""
: outputs a blank line (with
\n
?)sprintf
, printf
awk | Meaning |
---|---|
record | line |
smtlib2 is a format for SAT/SMT solvers like z3.
(declare-const a Bool)
is short for
(define-fun b () Bool)
https://computationalthinking.mit.edu/Fall24/installation/
using pkgname
LatexStrings
can be used to write labels in latex
syntax]
pkg>
Commands:
In interactive mode:
yosys>
: Entire design selectedyosys*>
: Only a part of design selectedyosys [modname]>
: Entire module named
modname
selectedyosys [modname]*>
: Only a part of module named
modname
selectedshell
: enter shellshow
: make diagram (graphviz) for selected designproc
: translate process blocks to netlistsfsm
:memory
:hierarchy
:cd: alias for ~select -module <modname>
cd ..
to back to topmost level ??sta
:
perform static timing analysisclean
difflibmap
printattrs
Resources:
xmlstarlet is a tool that can handle xpath.
. |
Current node |
.. |
Parent node |
@ |
Specify attribute |
/ |
Directly under current node |
// |
Anywhere under current node |
last |
|
starts-with |
/* 2nd node under root */
/root/node[2]
Get all hrefs from an html file: //@href
xmlstarlet sel -t -v "//@href" ../build/html/blog/index.html
Theorem prover.
(* comment *)
// comment
.fst
Interactive mode:
HOL4 theorem prover: https://hol-theorem-prover.org/cheatsheet.html
File extension: .sml
>>
?rw
: rewrite ?tac1 >> tac2
: apply tac1
, then use
tac2
on all generated goals
tac1; tac2
in coqf $ g
: f (g x)
lst :: Data a => [a] -> [a]
| _:xs =:= l
lst l = xs
where xs free
The where
clause tells that xs
does not
appear in l
(is free in l
) so that the
compiler can see that it came out of the blue.
=:=
is an equation invoking unification.
Used KICS2 v3.1 for the above snippet. https://www-ps.informatik.uni-kiel.de/kics2/Manual.pdf
lst [1,2,3]
gave this:
-------------------------------------
Executing with KiCS2 3.1 /all-values:
-------------------------------------
[2,3]
KiCS2 compilation time: 1.21s / elapsed: 0:01.54
KiCS2 compilation time: 1.19s / elapsed: 0:01.48
GHC compilation time: 1.64s / elapsed: 0:02.46
Execution time: 0.00s / elapsed: 0:00.01
Looks like lst []
simply doesn't result in any value
instead of giving error as in Haskell:
-------------------------------------
Executing with KiCS2 3.1 /all-values:
-------------------------------------
KiCS2 compilation time: 1.22s / elapsed: 0:02.13
KiCS2 compilation time: 1.16s / elapsed: 0:01.50
GHC compilation time: 1.68s / elapsed: 0:06.56
Execution time: 0.00s / elapsed: 0:00.01
Curry lang
https://curry.pages.ps.informatik.uni-kiel.de/curry-lang.org/
endAsStart :: Data a => [a] -> Bool
| x:(xs ++ [x]) =:= l
endAsStart l = True
where x,xs free
= False endAsStart'default _
Links:
Language associated with NixOS.
References:
Nix is like json with functions.
List elements are separated by a space.
Attribute names needn't be within quotes. Can be though.
Derivation: A build task in nix
a.b.c=1
means a = {b = {c = 1}}
??
Comments: starts with #
nix-repl
: A repl to try out nix expressions
nix-instantiate
: evaluate a nix file
nix-instantiate --eval file.nix
Examples:
x: x+1
: Incrementx: y: x+y
: Addition{x, y}: x+y
: AdditionTags:
#include <systemc.h>
sc_in
: input port
sc_out
: output port
sc_bit
: bit type
sc_signal
SC_CTOR
: constructor
SC_METHOD
: a block with its sensitivity list
sensitive
keywordSC_MODULE
SC_CTHREAD
sc_time_stamp()
wait()
sc_trace
sc_start
: starts simulation
scmain: like main()
in C
—
—
Links: