Closed dijkstracula closed 1 year ago
While I'm in there, the grammar for logicvar
should make the sort an ident.
Up to this point I had been handling this by requiring all formulas on my end to be in prenex normal form. Unfortunately, this puts us in a bit of a bind because Ivy's quantifier bounds heuristic fails us in the case where we move the inner quantifier to the outside:
18 ensure forall P1:pid,P2:pid, I. msg_count = 0 ->
19 host(P1).contents.end = host(P2).contents.end &
20 (I < host(P1).contents.end -> host(P1).contents.value(I) = host(P2).contents.val ue(I));
(venv) ➜ /tmp ivyc target=test foo.ivy
foo.ivy: line 18: error: cannot find an upper bound for I:index
(venv) ➜ /tmp
Essentially this is because Ivy never walks the conjunction when exists=False
in ivy_to_cpp::get_bound_exprs
.
So, we need to actually handle arbitrary quantifiers in formulas. This is a problem because I was lazy and tried to separate out "quantifier definitions" from "the expression that might make use of them".
This will require:
[ ] Changing the grammar to support nested quantifiers; [ ] Changing the AST to not just hold expressions; [ ] Changing the visitor module to walk formulas without ever falling back to expressions.
This has the side benefit that we can also trivially emit custom code for formulae that we might not want to with expressions, so it's objectively the right thing to do anyway. Still, though, irritating.
b7c60a3f0cc1dc6e41a9c98a962d5abb1ed00aa8 .
The chain replication program fails to parse because of the following invariant:
Basically, the logic parser forces us to push quantifiers to the outside but clearly there are cases where we want this to work..
Looks like Ivy knows how to push quantifiers outside the
&
expression, but maybe we should automate doing the same.