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

Generate all projectors/method via the tactic #3166

Open
mtzguido opened this issue Dec 15, 2023 · 2 comments
Open

Generate all projectors/method via the tactic #3166

mtzguido opened this issue Dec 15, 2023 · 2 comments
Assignees

Comments

@mtzguido
Copy link
Member

mtzguido commented Dec 15, 2023

unfold
let maybe_ghost (b:bool) (post : unit -> prop) =
  if b
  then unit -> squash (post ())
  else unit -> squash (post ())

noeq
type r (p:Type) = {
   ghost : bool;
   pred : p -> prop;
   ( ! ) : y:p -> maybe_ghost ghost (fun _ -> pred y);
}

Error:

* Error 19 at LimitationOfProjectors.fst(13,5-13,6):
  - Subtyping check failed; expected type y: p
      -> maybe_ghost (Mkr?.ghost (Mkr ghost pred op_Bang))
          (fun _ -> Mkr?.pred (Mkr ghost pred op_Bang) y); got type y: p -> maybe_ghost ghost (fun _ -> pred y)
  - The SMT solver could not prove the query. Use --query_stats for more
    details.
  - See also LimitationOfProjectors.fst(13,18-13,53)

Query (from .smt2):

; Encoding query formula : forall (p: Type)
;   (projectee: LimitationOfProjectors.r p)
;   (b: Prims.bool)
;   (b: (_: p -> Prims.prop))
;   (b:
;   (y: p
;       -> ((match b with
;             | true -> _: Prims.unit -> Prims.squash (b y)
;             | _ -> _: Prims.unit -> Prims.squash (b y))
;           <:
;           Type)))
;   (_: _: Prims.unit{projectee == LimitationOfProjectors.Mkr b b b})
;   (y: p).
;   (*Subtyping check failed; expected type y: p
;   -> maybe_ghost (Mkr?.ghost (Mkr ghost pred op_Bang))
;       (fun _ -> Mkr?.pred (Mkr ghost pred op_Bang) y); got type y: p -> maybe_ghost ghost (fun _ -> pred y)*)
;   (match b with
;     | true -> _: Prims.unit -> Prims.squash (b y)
;     | _ -> _: Prims.unit -> Prims.squash (b y)) ==
;   (match Mkr?.ghost (LimitationOfProjectors.Mkr b b b) with
;     | true -> _: Prims.unit -> Prims.squash (Mkr?.pred (LimitationOfProjectors.Mkr b b b) y)
;     | _ -> _: Prims.unit -> Prims.squash (Mkr?.pred (LimitationOfProjectors.Mkr b b b) y))

I think this fails due to a combination of the dependency and use of pred under a binder in (!)'s type, so #1948 applies. It actually works if we just unfold the projectors for ghost and pred before checking (!).

While that unfolding may work, with @nikswamy we're thinking using the tactic from #1355 (comment) would be better overall. Trying...

@mtzguido mtzguido self-assigned this Dec 15, 2023
@mtzguido
Copy link
Member Author

image

Fails in the exact same way : )

The problem is that the unfolding of the projectors is blocked because we are under a match. Adding zeta_full to the tactic also makes it work, but is probably dangerous in general.

mtzguido added a commit to mtzguido/FStar that referenced this issue Dec 15, 2023
mtzguido added a commit to mtzguido/FStar that referenced this issue Dec 15, 2023
mtzguido added a commit to mtzguido/FStar that referenced this issue Dec 15, 2023
mtzguido added a commit to mtzguido/FStar that referenced this issue Dec 16, 2023
@mtzguido
Copy link
Member Author

Tactic now in master and can be used instead of the builtin projector generation by attaching the meta_projectors attribute to the typeclass in question.

@mtzguido mtzguido changed the title Projector fails to typecheck Generate all projectors/method via the tactic Dec 18, 2023
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