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

Inconsistent subtyping with covariance #3361

Open
gebner opened this issue Jul 18, 2024 · 0 comments
Open

Inconsistent subtyping with covariance #3361

gebner opened this issue Jul 18, 2024 · 0 comments

Comments

@gebner
Copy link
Contributor

gebner commented Jul 18, 2024

This is an MWE extracted from the issue I had in the thunk module I showed yesterday. There are three types here, r is a subtype of s, which is in turn a subtype of t.

module Subtyping

let t = unit -> Dv nat
let s = unit -> Dv (n:nat { n >= 42 })
let f (x: nat) : s = fun _ -> x + 42
let p (g: t) = exists x. f x == g
let r = x:t { p x }

let does_work_1 (x: s) : t = x
let does_work_2 (x: r) : t = x
[@@expect_failure] let should_work_3 (x: r) : s = x

let elim_subtype #a (#b:_ { subtype_of a b }) (x: a) : b = x

[@@expect_failure] let should_work_4 (x: s) : t = elim_subtype x
let does_work_5 (x: r) : t = elim_subtype x
let does_work_6 (x: r) : s = elim_subtype x

[@@expect_failure] let should_work_7 : squash (subtype_of s t) = ()
let does_work_8 : squash (subtype_of r t) = ()
let does_work_9 : squash (subtype_of r s) = ()

If we replace Dv by Tot, then 4 and 7 work but 3 still fails.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant