Commit 421a078
committed
feat(notations): add user-extensible notations
Adds a `notation` construct that lets users declare `#`-prefixed
syntactic sugar for formulas, with template-based parsing and
typing-time expansion.
Notations are stored as operators (sharing abbreviation
infrastructure), so they work uniformly with import/export, clone,
locality, sections, qualified lookup, and `rewrite /#foo` unfolds.
Declarations:
notation #big ['a] #< i : 'a >
(r : 'a list)
(P : i ==> bool = predT)
(F : i ==> t)
"[" i " : " r ("| " P)? "] " F =
big P F r.
Uses:
lemma L (d : 'a distr) (f : 'a -> real) J :
uniq J =>
BRA.#big [ x : J ] (mu1 d x * f x).`1 <= 1%r.
lemma M &m (bs : out_t list) :
Dst.#big [ b : bs ] (Pr[A.guess() @ &m : res = b]) <= 1%r.
(* slot placeholders work as pose / rewrite patterns *)
pose c := #big [ _ : _ | _ ] _.
Expansions round-trip back to template syntax in the pretty-printer.
Includes a stdlib port: `#big` / `#bigi` are declared in Bigop.eca
and used across algebra, analysis, distributions, modules, and
crypto files.
Tests under tests/notations/ (wired into `make unit`) and reference
documentation under doc/notation.rst.1 parent d100a1e commit 421a078
67 files changed
Lines changed: 2640 additions & 519 deletions
File tree
- config
- doc
- src
- tests
- notations-ko
- notations
- theories
- algebra
- analysis
- crypto
- datatypes
- distributions
- encryption
- modules
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
| 18 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
0 commit comments