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

Allow generalizing memories #631

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
51 changes: 51 additions & 0 deletions src/ecHiGoal.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1675,6 +1675,57 @@ let process_generalize1 ?(doeq = false) pattern (tc : tcenv1) =
let id = fst (LDecl.by_name s hyps) in
t_generalize_hyp ~clear id tc

| PFmem { pl_loc = loc; pl_desc = m; } -> begin
if doeq then
tacuerror "cannot generate an equation when generalizing a memory";

let m, lc =
try
LDecl.by_name m hyps
with LDecl.LdeclError (LookupError _) ->
tc_error !!tc ~loc "cannot find memory `%s'" m
in

let lc = match lc with LD_mem mt -> mt | _ -> assert false in

if is_none occ then
t_generalize_hyp ~clear m tc
else begin
let occ = norm_rwocc occ in

let ptnpos =
try
FPosition.select ?o:occ (fun ctxt f ->
if Sid.mem m ctxt then
`Continue
else
match f.f_node with
| Fglob (_, m')
| Fpvar (_, m')
| Fpr { pr_mem = m' } when EcIdent.id_equal m m' -> `Accept 0
| _ -> `Continue
) concl
with InvalidOccurence -> tacuerror "invalid occurence selector"
in

let m' = EcIdent.fresh m in

let newconcl =
concl |> FPosition.map ptnpos (fun f ->
match f.f_node with
| Fglob (a, _) -> f_glob a m'
| Fpvar (p, _) -> f_pvar p f.f_ty m'
| Fpr pr -> f_pr_r { pr with pr_mem = m' }
| _ -> assert false
) in

let newconcl = f_forall [(m', GTmem lc)] newconcl in
let pt = ptcut ~args:[PAMemory m] newconcl in

EcLowGoal.t_apply pt tc
end
end

| _ ->
let (ptenv, p) =
let (ps, ue), p = TTC.tc1_process_pattern tc pf in
Expand Down
Loading