Skip to content

Commit 44a5735

Browse files
Allow tensor and cartesian products to take in terms
1 parent e4ffaea commit 44a5735

File tree

3 files changed

+20
-8
lines changed

3 files changed

+20
-8
lines changed

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,9 @@ Type check a benchmark in the examples directory with the following command.
2525
dune exec -- nfuzz examples/BENCHMARK.fz
2626
```
2727

28-
28+
Changelog
29+
=====
30+
1. Allow resources to go unused (so functions can be dead, etc.).
31+
2. Add support for `sub : num x num -> num`. Intended to used with a paired NumFuzz semantics.
32+
3. Allow cartesian and tensor products to take in expressions (rather than values).
33+
4. Add a `factor : (M[q] 𝜎) x (M[q]𝜏) --o M[q] (𝜎 x 𝜏)` primitive for a tighter sensitivity and roundoff error analysis.

src/lexer.mll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ let reservedWords = [
6060
("num", fun i -> Parser.NUM i);
6161
("bool", fun i -> Parser.BOOL i);
6262
("string", fun i -> Parser.STRING i);
63+
("factor", fun i -> Parser.FACTOR i);
6364
(* ("sens", fun i -> Parser.SENS i); *)
6465
]
6566

src/parser.mly

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ let from_args_to_type arg_list oty = match oty with
6767
%token <Support.FileInfo.info> EQUAL
6868
%token <Support.FileInfo.info> EQOP
6969
%token <Support.FileInfo.info> EOF
70+
%token <Support.FileInfo.info> FACTOR
7071
(* %token <Support.FileInfo.info> FALSE *)
7172
%token <Support.FileInfo.info> FUNCTION
7273
%token <Support.FileInfo.info> FUN
@@ -217,6 +218,18 @@ Term :
217218
(* extra *)
218219
| LPAREN Term RPAREN
219220
{ $2 }
221+
(* tuples can take in arbitrary terms *)
222+
| LPAREN PairSeq RPAREN
223+
{ fun ctx -> $2 ctx }
224+
| LPAREN PIPE Term COMMA Term PIPE RPAREN
225+
{ fun ctx -> TmAmpersand($1, $3 ctx, $5 ctx) }
226+
227+
(* Sugar for n-ary tuples *)
228+
PairSeq:
229+
Term COMMA Term
230+
{ fun ctx -> TmTens($2, $1 ctx, $3 ctx) }
231+
| Term COMMA PairSeq
232+
{ fun ctx -> TmTens($2, $1 ctx, $3 ctx) }
220233

221234
Argument :
222235
LPAREN ID COLON Type RPAREN
@@ -233,13 +246,6 @@ Arguments :
233246
(l @ l2, ctx'')
234247
}
235248

236-
(* Sugar for n-ary tuples *)
237-
PairSeq:
238-
Val COMMA Val
239-
{ fun ctx -> TmTens($2, $1 ctx, $3 ctx) }
240-
| Val COMMA PairSeq
241-
{ fun ctx -> TmTens($2, $1 ctx, $3 ctx) }
242-
243249
Val:
244250
LPAREN RPAREN
245251
{ fun _cx -> TmPrim ($1, PrimTUnit) }

0 commit comments

Comments
 (0)