Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions spectec/doc/semantics/il/0-aux.spectec
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,8 @@ def $equiv_(syntax X, x_1*, x_2*) = false -- otherwise
def $transpose_(syntax X, X**) : X**
def $transpose_(syntax X, eps^n) = eps
def $transpose_(syntax X, (x_1 x*)*) = x_1* $transpose_(X, x**)


def $forall(bool*) : bool
def $forall(eps) = true
def $forall(bool_1 bool*) = bool_1 /\ $forall(bool*)
8 changes: 4 additions & 4 deletions spectec/doc/semantics/il/6-typing.spectec
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,16 @@ rule Sub_typ/struct:
E |- t_1 <: t_2
-- Expand_typ: E |- t_1 => STRUCT tf_1*
-- Expand_typ: E |- t_2 => STRUCT tf_2*
-- (if (a `: t_2a `- `{q*} pr*) = tf_2)*
-- (if (a `: t_1a `- `{q*} pr*) <- tf_1*)*
-- (if (a `: t_2a `- `{q*} pr_2*) = tf_2)*
-- (if (a `: t_1a `- `{q*} pr_1*) <- tf_1* /\ $forall((pr_2 <- pr_1*)*))*
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this not work without the auxiliary forall?

Suggested change
-- (if (a `: t_1a `- `{q*} pr_1*) <- tf_1* /\ $forall((pr_2 <- pr_1*)*))*
-- (if (a `: t_1a `- `{q*} pr_1*) <- tf_1*)*
-- (if pr_2 <- pr_1*)**

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trying this myself I noted my suggestion works, but is ambiguous and may not have the intended semantics. When I put in explicit sizes to disambiguate, SpecTec dimension inference complains, because using x^n^m in a context []^n^k^m is too much for it to handle.

I also realised that this flexibility in the rule isn't really useful if it doesn't also allow subsetting the quantifier list. But that is rather tricky, due to possible dependencies and possible shadowing. It would at least need to take α-equivalence into account correctly.

Since the flexibility of weakening side conditions isn't currently needed for anything, I'd rather keep it simple, keep requiring equality and adjusting docs and implementation accordingly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also initially thought that syntactic removal would be feasible, but I had concerns about whether it would preserve the intended semantics. If this flexibility is not actually required in practice, I agree that it is better not to introduce it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. I think you can close this one. But thanks for pointing out the discrepancy!

-- (Sub_typ: E |- t_1a <: t_2a)*

rule Sub_typ/variant:
E |- t_1 <: t_2
-- Expand_typ: E |- t_1 => VARIANT tc_1*
-- Expand_typ: E |- t_2 => VARIANT tc_2*
-- (if (m `: t_1a `- `{q*} pr*) = tc_1)*
-- (if (m `: t_2a `- `{q*} pr*) <- tc_2*)*
-- (if (m `: t_1a `- `{q*} pr_1*) = tc_1)*
-- (if (m `: t_2a `- `{q*} pr_2*) <- tc_2* /\ $forall((pr_2 <- pr_1*)*))*
-- (Sub_typ: E |- t_1a <: t_2a)*

rule Sub_typ/iter:
Expand Down
Loading