Skip to content

Commit e4eb5d3

Browse files
authored
[tactic] Improve robustness of one-sided match (fixes #775)
1 parent 5f5d3f6 commit e4eb5d3

2 files changed

Lines changed: 45 additions & 6 deletions

File tree

src/phl/ecPhlCond.ml

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,6 @@ end = struct
150150
let+ tc = EcPhlSkip.t_skip tc in
151151
let+ tc = EcLowGoal.t_intro_s `Fresh tc in
152152
let+ tc = EcLowGoal.t_elim_and tc in
153-
154153
let e = EcEnv.LDecl.fresh_id (FApi.tc1_hyps tc) "e" in
155154

156155
let+ tc = EcLowGoal.t_intros_i [e] tc in
@@ -173,14 +172,36 @@ end = struct
173172
in
174173

175174
let clean (tc : tcenv1) =
175+
let discharge_pre tc =
176+
let+ tc =
177+
if Option.is_some side
178+
then EcLowGoal.t_intros_n 2 tc
179+
else EcLowGoal.t_intros_n 1 tc
180+
in
181+
let+ tc = EcLowGoal.t_elim_and tc in
182+
let+ tc = EcLowGoal.t_intro_s `Fresh tc in
183+
let+ tc = EcLowGoal.t_elim_and tc in
184+
let+ tc = EcLowGoal.t_intros_n ~clear:true 1 tc in
185+
let+ tc = EcLowGoal.t_intro_s `Fresh tc in
186+
tc
187+
|> EcLowGoal.t_split
188+
@! EcLowGoal.t_assumption `Alpha
189+
in
190+
let discharge_post tc =
191+
let+ tc =
192+
if Option.is_some side
193+
then EcLowGoal.t_intros_n 3 tc
194+
else EcLowGoal.t_intros_n 2 tc
195+
in
196+
EcLowGoal.t_assumption `Alpha tc
197+
in
198+
176199
let pre = oget (EcLowPhlGoal.get_pre (FApi.tc1_goal tc)) in
177200
let post = oget (EcLowPhlGoal.get_post (FApi.tc1_goal tc)) in
178201
let eq, _, pre = destr_and3 pre in
179-
let tc = EcPhlConseq.t_conseq (f_and eq pre) post tc in
180-
181-
FApi.t_onall
182-
(EcLowGoal.t_clears names)
183-
(FApi.t_firsts (EcLowGoal.t_trivial ~keep:false) 2 tc)
202+
tc
203+
|> EcPhlConseq.t_conseq (f_and eq pre) post
204+
@+ [discharge_pre; discharge_post; EcLowGoal.t_clears names]
184205
in
185206

186207
tc

tests/single_match.ec

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
op w : unit option.
2+
3+
module M = {
4+
proc f() = {
5+
match w with
6+
| None => {}
7+
| Some y => {}
8+
end;
9+
}
10+
}.
11+
12+
hoare L: M.f: exists x, x = true ==> true.
13+
proof.
14+
proc.
15+
match.
16+
+ by skip.
17+
+ by skip.
18+
qed.

0 commit comments

Comments
 (0)