Skip to content

Commit

Permalink
Allow generalizing memories
Browse files Browse the repository at this point in the history
  • Loading branch information
strub committed Oct 4, 2024
1 parent 5c4fd7f commit cee15a1
Showing 1 changed file with 51 additions and 0 deletions.
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

0 comments on commit cee15a1

Please sign in to comment.