Skip to content
This repository has been archived by the owner on Apr 2, 2023. It is now read-only.

Performance tuning #630

Closed
wants to merge 1 commit into from
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
2 changes: 1 addition & 1 deletion lib/sml-typed-abts
2 changes: 2 additions & 0 deletions src/redprl/refiner.fun
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ struct
let
val tr = ["True.Witness"]
val H >> AJ.TRUE ty = jdg
val () = assertWellScoped H tm
val goal = makeMem tr H (tm, ty)
in
|>: goal #> (H, tm)
Expand All @@ -166,6 +167,7 @@ struct
let
val tr = ["Term.Exact"]
val H >> AJ.TERM tau = jdg
val () = assertWellScoped H tm
val tau' = Abt.sort tm
val _ = Assert.sortEq (tau, tau')
in
Expand Down
16 changes: 6 additions & 10 deletions src/redprl/refiner_kit.fun
Original file line number Diff line number Diff line change
Expand Up @@ -35,24 +35,21 @@ struct
end
end

(* assert that the term 'm' has only free variables 'us' and free variables 'xs' at most. *)
fun assertWellScoped xs m =
(* assert that the term 'm' has only free variables from 'H' at most. *)
fun assertWellScoped H m =
let
val vars = List.foldl (fn (x, vars) => Var.Ctx.remove vars x) (Abt.varctx m) xs
fun ppVars us = Fpp.Atomic.squares @@ Fpp.hsep @@ List.map TermPrinter.ppVar us
val vars = Hyps.foldl (fn (x, tau, vars) => Var.Ctx.remove vars x) (Abt.varctx m) H
fun ppVars xs = Fpp.Atomic.squares @@ Fpp.hsep @@ List.map TermPrinter.ppVar xs
val varsOk = Var.Ctx.isEmpty vars
in
if varsOk then
()
else
raise E.error
[Fpp.text "Internal Error:",
Fpp.text "Validation term",
[Fpp.text "Term",
TermPrinter.ppTerm m,
Fpp.text "had unbound variables",
ppVars (Var.Ctx.domain vars),
Fpp.text "whereas we expected only",
ppVars xs]
ppVars (Var.Ctx.domain vars)]
end

(* hypotheses *)
Expand All @@ -67,7 +64,6 @@ struct
let
val (xs, taus) = Hyps.foldr (fn (x, jdg, (xs, taus)) => (x::xs, AJ.synthesis jdg::taus)) ([],[]) H
in
assertWellScoped xs m;
Abt.checkb (Abt.\ (xs, m), (taus, Abt.sort m))
end

Expand Down