Parse error on embedded Cryptol with `π` (or other extended characters)
WeeknightMVP opened this issue · comments
// Permutation.cry
module Permutation where
/** permutation table */
π : [256][8]
π = join (transpose (groupBy`{16} [0..255]))
/** inverse permutation table */
π' : [256][8]
π' = updates π π [0..255]
/** permute sequence according to table */
permute : {n, a, ix} (fin n, Integral ix) => [n]ix -> [n]a -> [n]a
permute table xs =
updates xs table xs
/** π' and π are inverses w.r.t. permutation */
π'_inverts_π : {a} (Eq a) => [256]a -> Bool
property π'_inverts_π xs =
permute π' (permute π xs) == xs
// Permutation.saw
import "Permutation.cry";
enable_experimental;
let main : TopLevel () = do {
inverse_lemma <- prove_print z3 {{ π'_inverts_π`{[8]} }};
summarize_verification;
};
$ saw Permutation.saw
[22:05:05.091] Loading file "Permutation.saw"
[22:05:05.092] Parse error at Permutation.saw:6:36-6:37: Unexpected `{'
$ cryptol
┏━╸┏━┓╻ ╻┏━┓╺┳╸┏━┓╻
┃ ┣┳┛┗┳┛┣━┛ ┃ ┃ ┃┃
┗━╸╹┗╸ ╹ ╹ ╹ ┗━┛┗━╸
version 3.1.0.99 (5bbc3dc, modified)
https://cryptol.net :? for help
Loading module Cryptol
Cryptol> :m Permutation
Loading module Cryptol
Loading module Permutation
Permutation> :prove π'_inverts_π`{[8]}
Q.E.D.
(Total Elapsed Time: 0.121s, using "Z3")
I believe this happens because SAW's embedded Cryptol lexer only lexes a subset of characters that does not include π
. We should take inspiration from Cryptol's lexer, which specially handles Unicode characters via these Alex productions and this utility function.