Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nondeterministic choice #985

Merged
merged 54 commits into from
Sep 13, 2023
Merged
Changes from 1 commit
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
54c6c11
Add nondeterministic choice operator to lexer, parser, AST, and lustr…
lorchrob Mar 21, 2023
cf28582
Make local variable explicitly typed in choose expression
lorchrob Mar 22, 2023
6a7f0ed
Fill out pattern matching for ChooseOp
lorchrob Mar 23, 2023
94ba49d
Update pattern matching ChooseOp
lorchrob Mar 23, 2023
890db8a
Add desugaring for ChooseOp in lustreAstNormalizer
lorchrob Mar 28, 2023
0837616
Move desugaring earlier in the pipeline
lorchrob Mar 29, 2023
8aa459d
Clean up
lorchrob Mar 29, 2023
31609dc
Debug chooseop desugaring
lorchrob Mar 30, 2023
9e0463a
Update syntax and desugaring
lorchrob Mar 30, 2023
8e459c3
Update nondeterministic choice generated node name
lorchrob Apr 3, 2023
b1f73db
Update syntax for array concatenation to not overlap with choice oper…
lorchrob Apr 3, 2023
29b082c
Update lexing and parsing for choose operator
lorchrob Apr 4, 2023
84eecff
Update naming of generated function for choose op
lorchrob May 25, 2023
b1d18f3
Merge branch 'develop' into nondeterministic-choice
lorchrob May 25, 2023
4fa4f03
Update user documentation for nondeterministic choice operator
lorchrob May 25, 2023
870b26f
Add tests for choice op
lorchrob May 25, 2023
a24f916
Update printing choose op
lorchrob May 25, 2023
a1f2193
Clean up lustreParser.messages
lorchrob May 25, 2023
d68e43a
Merge remote-tracking branch 'upstream/develop' into nondeterministic…
daniel-larraz Jun 22, 2023
4fa97ea
Merge branch 'develop' into nondeterministic-choice
daniel-larraz Aug 22, 2023
5d019c2
Resolve conflict
daniel-larraz Aug 22, 2023
fe47d2e
Update choose operator type checking
lorchrob Aug 22, 2023
02844cc
Add test file
lorchrob Aug 22, 2023
e386018
Fix arrow operator type checking
daniel-larraz Aug 22, 2023
fa94022
Update expected error in test
daniel-larraz Aug 22, 2023
0d1f66b
Remove garbage code
lorchrob Aug 23, 2023
98162f0
Update unreachable areas for ChooseOp in pattern matching
lorchrob Aug 23, 2023
5787087
Remove some unnecessary instances of node_id being passed around the …
lorchrob Aug 23, 2023
e94d36c
remove more unnecessary node_id in lustreAstNormalizer
lorchrob Aug 23, 2023
c5dc6db
Remove context return from interface of normalize function
lorchrob Aug 23, 2023
7be34fe
Expand desugaring to properties and if statement conditions
lorchrob Aug 24, 2023
75467a2
Expand choose op desugaring to asserts
lorchrob Aug 24, 2023
7dd84da
Expand choose op desugaring to contracts
lorchrob Aug 24, 2023
25889c1
Fix choose op bug in lustreSyntaxChecks
lorchrob Aug 25, 2023
ddb665f
Move choose op desugaring earlier in pipeline, and make some updates …
lorchrob Aug 29, 2023
6a637c9
Fix choose op bug involving a constant in choose op predicate
lorchrob Aug 29, 2023
61f0bfc
Allow assumptions to be specified in choose operation
lorchrob Sep 5, 2023
a116861
Expand choose op desugaring to modes, contract calls, and contract no…
lorchrob Sep 11, 2023
95423d4
Do best effort to pinpoint choose op items
daniel-larraz Sep 11, 2023
33a0643
Pass variables from 'provided' clause of choose op into generated nod…
lorchrob Sep 11, 2023
6aee317
Finish pending issue of choose op pipeline reordering by commenting o…
lorchrob Sep 12, 2023
6381c89
Revert 'vars' function in LAH to its original state as Daniel will ha…
lorchrob Sep 12, 2023
2e5e850
Update substitute function to error out on cases that introduce bound…
lorchrob Sep 12, 2023
cd58f4e
Disallow node calls and choose ops in constants
lorchrob Sep 12, 2023
434d87c
Change vars function so that it does not return node call ids
daniel-larraz Sep 12, 2023
aa9a362
Switch 'provided' keyword to 'assuming' in choose ops
lorchrob Sep 12, 2023
a8ef041
Remove unused code from get_node_call_from_expr
daniel-larraz Sep 12, 2023
4d8b4e7
Update choose op printing function (provided -> assuming)
lorchrob Sep 12, 2023
fd041a1
Remove unreachable code from lustreAstHelpers
daniel-larraz Sep 13, 2023
4b0c6c8
Disallow choose ops in functions
daniel-larraz Sep 13, 2023
a1aa151
Fix dangling identifier checks for choose ops
lorchrob Sep 13, 2023
e9c24e3
Fix bug with last commit
lorchrob Sep 13, 2023
52cc786
Update user doc for choose op
daniel-larraz Sep 13, 2023
1f56846
Update choose_simple test
daniel-larraz Sep 13, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 27 additions & 2 deletions src/lustre/lustreDesugarChooseOps.ml
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,29 @@
| CallParam (pos, id, types, expr_list) ->
let expr_list, gen_nodes = List.map (desugar_expr ctx node_name) expr_list |> List.split in
CallParam (pos, id, types, expr_list), List.flatten gen_nodes

let desugar_contract_item ctx node_name ci =
match ci with
| A.GhostVars (pos, lhs, e) ->
let e, gen_nodes = desugar_expr ctx node_name e in
A.GhostVars (pos, lhs, e), gen_nodes
| Assume (pos, name, b, e) ->
let e, gen_nodes = desugar_expr ctx node_name e in
Assume (pos, name, b, e), gen_nodes
| Guarantee (pos, name, b, e) ->
let e, gen_nodes = desugar_expr ctx node_name e in
Guarantee (pos, name, b, e), gen_nodes
| GhostConst _
| Mode _
| ContractCall _
daniel-larraz marked this conversation as resolved.
Show resolved Hide resolved
| AssumptionVars _ -> ci, []

let desugar_contract ctx node_name contract =
match contract with
| Some contract_items ->
let items, gen_nodes = (List.map (desugar_contract_item ctx node_name) contract_items) |> List.split in
Some items, List.flatten gen_nodes
| None -> None, []

let rec desugar_node_item ctx node_name ni =
match ni with
Expand Down Expand Up @@ -216,16 +239,18 @@
| A.NodeDecl (span, ((id, ext, params, inputs, outputs, locals, items, contract) as d)) ->
let ctx = Chk.get_node_ctx ctx d |> unwrap in
let items, gen_nodes = List.map (desugar_node_item ctx id) items |> List.split in
let contract, gen_nodes2 = desugar_contract ctx id contract in
let gen_nodes = List.flatten gen_nodes in
let summary = update_node_summary summary gen_nodes in
decls @ gen_nodes @ [A.NodeDecl (span, (id, ext, params, inputs, outputs, locals, items, contract))],
decls @ gen_nodes @ gen_nodes2 @ [A.NodeDecl (span, (id, ext, params, inputs, outputs, locals, items, contract))],
summary
| A.FuncDecl (span, ((id, ext, params, inputs, outputs, locals, items, contract) as d)) ->
let ctx = Chk.get_node_ctx ctx d |> unwrap in
let items, gen_nodes = List.map (desugar_node_item ctx id) items |> List.split in
let contract, gen_nodes2 = desugar_contract ctx id contract in
let gen_nodes = List.flatten gen_nodes in
let summary = update_node_summary summary gen_nodes in
decls @ gen_nodes @ [A.FuncDecl (span, (id, ext, params, inputs, outputs, locals, items, contract))],
decls @ gen_nodes @ gen_nodes2 @ [A.FuncDecl (span, (id, ext, params, inputs, outputs, locals, items, contract))],
summary
| _ -> decl :: decls, node_summary
) ([], node_summary) decls in
Expand Down