Skip to content

Commit d3b87c0

Browse files
lyonel2017strub
andcommitted
Add optional parameter to the split tactic to specify
on which conjunction the split should be done. Co-authored-by: Pierre-Yves Strub <[email protected]>
1 parent 13acf05 commit d3b87c0

File tree

15 files changed

+135
-31
lines changed

15 files changed

+135
-31
lines changed

src/ecCoreLib.ml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ module CI_Logic = struct
241241
let p_and_proj_r = _Logic "andWr"
242242
let p_anda_proj_l = _Logic "andaWl"
243243
let p_anda_proj_r = _Logic "andaWr"
244+
let p_anda_proj_rs = _Logic "andaWrs"
244245
let p_or_elim = _Logic "orW"
245246
let p_ora_elim = _Logic "oraW"
246247
let p_iff_elim = _Logic "iffW"
@@ -249,6 +250,7 @@ module CI_Logic = struct
249250
let p_true_intro = _Logic "trueI"
250251
let p_and_intro = _Logic "andI"
251252
let p_anda_intro = _Logic "andaI"
253+
let p_anda_intro_s = _Logic "andaIs"
252254
let p_or_intro_l = _Logic "orIl"
253255
let p_ora_intro_l = _Logic "oraIl"
254256
let p_or_intro_r = _Logic "orIr"

src/ecCoreLib.mli

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ module CI_Logic : sig
213213
val p_and_proj_r : path
214214
val p_anda_proj_l : path
215215
val p_anda_proj_r : path
216+
val p_anda_proj_rs : path
216217
val p_or_elim : path
217218
val p_ora_elim : path
218219
val p_iff_elim : path
@@ -221,6 +222,7 @@ module CI_Logic : sig
221222
val p_true_intro : path
222223
val p_and_intro : path
223224
val p_anda_intro : path
225+
val p_anda_intro_s : path
224226
val p_or_intro_l : path
225227
val p_ora_intro_l : path
226228
val p_or_intro_r : path

src/ecFol.ml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1039,9 +1039,7 @@ let destr_ands ~deep =
10391039

10401040
in fun f -> doit f
10411041

1042-
1043-
(*---------------------------------------------*)
1044-
1042+
(* -------------------------------------------------------------------- *)
10451043
let rec one_sided mem fp =
10461044
match fp.f_node with
10471045
| Fint _ -> true

src/ecHiGoal.ml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2025,10 +2025,17 @@ let process_right (tc : tcenv1) =
20252025
tc_error !!tc "cannot apply `right` on that goal"
20262026

20272027
(* -------------------------------------------------------------------- *)
2028-
let process_split (tc : tcenv1) =
2029-
try t_ors [EcLowGoal.t_split; EcLowGoal.t_split_prind] tc
2028+
let process_split ?(i : int option) (tc : tcenv1) =
2029+
let tactics : FApi.backward list =
2030+
match i with
2031+
| None -> [EcLowGoal.t_split; EcLowGoal.t_split_prind]
2032+
| Some i -> [EcLowGoal.t_split ~i] in
2033+
2034+
try t_ors tactics tc
20302035
with InvalidGoalShape ->
2031-
tc_error !!tc "cannot apply `split` on that goal"
2036+
tc_error !!tc
2037+
"cannot apply `split/%a` on that goal"
2038+
(EcPrinting.pp_opt Format.pp_print_int) i
20322039

20332040
(* -------------------------------------------------------------------- *)
20342041
let process_elim (pe, qs) tc =

src/ecHiGoal.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ val process_cut : ?mode:cutmode -> engine -> ttenv -> cut_t -> backward
8282
val process_cutdef : ttenv -> cutdef_t -> backward
8383
val process_left : backward
8484
val process_right : backward
85-
val process_split : backward
85+
val process_split : ?i:int -> backward
8686
val process_elim : prevert * pqsymbol option -> backward
8787
val process_case : ?doeq:bool -> prevertv -> backward
8888
val process_exists : ppt_arg located list -> backward

src/ecHiTacticals.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ and process1_logic (ttenv : ttenv) (t : logtactic located) (tc : tcenv1) =
129129
| Preflexivity -> process_reflexivity
130130
| Passumption -> process_assumption
131131
| Psmt pi -> process_smt ~loc:(loc t) ttenv (Some pi)
132-
| Psplit -> process_split
132+
| Psplit i -> process_split ?i
133133
| Pfield st -> process_algebra `Solve `Field st
134134
| Pring st -> process_algebra `Solve `Ring st
135135
| Palg_norm -> EcStrongRing.t_alg_eq

src/ecLowGoal.ml

Lines changed: 85 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,7 @@ type cutsolver = {
638638
smt : FApi.backward;
639639
done_ : FApi.backward;
640640
}
641-
641+
642642
(* -------------------------------------------------------------------- *)
643643
let tt_apply ?(cutsolver : cutsolver option) (pt : proofterm) (tc : tcenv) =
644644
let (hyps, concl) = FApi.tc_flat tc in
@@ -1509,16 +1509,91 @@ let t_elim_iso_or ?reduce tc =
15091509

15101510
let tc = t_elim_prind_r ?reduce ~accept `Case tc in (oget !outgoals, tc)
15111511

1512+
1513+
(* -------------------------------------------------------------------- *)
1514+
let t_split_and_i i b f1 f2 tc =
1515+
let i = i - 1 in
1516+
let rec destr acc_sym acc_f i f =
1517+
if i < 0 then
1518+
acc_sym, acc_f, f
1519+
else
1520+
match sform_of_form f with
1521+
| SFand (b, (f1, f2)) ->
1522+
destr (b :: acc_sym) (f1 :: acc_f) (i - 1) f2
1523+
| _ -> tc_error !!tc ~catchable:true "not enought conjunctions" in
1524+
1525+
let l_sym , l_fsl, fsr = destr [b] [f1] i f2 in
1526+
1527+
let sym = List.hd l_sym in
1528+
let syms = List.tl l_sym in
1529+
let fsl = List.hd l_fsl in
1530+
let fsls = List.tl l_fsl in
1531+
1532+
let fsl =
1533+
List.fold_left2(fun acc sym f ->
1534+
match sym with
1535+
| `Asym -> f_anda f acc
1536+
| `Sym -> f_and f acc
1537+
) fsl syms fsls in
1538+
1539+
let tc = FApi.tcenv_of_tcenv1 tc in
1540+
let tc, gl = FApi.newgoal tc fsl in
1541+
1542+
let tc, gr =
1543+
match sym with
1544+
| `Asym ->
1545+
let fsr = f_imp fsl fsr in
1546+
let tc, gr = FApi.newgoal tc fsr in
1547+
tc,`App (`HD gr, [`Sub (`HD gl:>prept)])
1548+
| `Sym ->
1549+
let tc, gr = FApi.newgoal tc fsr in
1550+
tc,(`HD gr:>prept) in
1551+
1552+
let pelim (sym : [`Sym | `Asym]) (side : [`L | `R]) =
1553+
match sym, side with
1554+
| `Sym , `L -> LG.p_and_proj_l
1555+
| `Sym , `R -> LG.p_and_proj_r
1556+
| `Asym, `L -> LG.p_anda_proj_l
1557+
| `Asym, `R -> LG.p_anda_proj_rs in
1558+
1559+
let pte = ptenv_of_penv (FApi.tc_hyps tc) !$tc in
1560+
1561+
let proj, projs =
1562+
List.fold_left_map (fun h sym ->
1563+
let j : prept = `App (`G (pelim sym `L, []), [`H_; `H_; `Sub h]) in
1564+
let h : prept = `App (`G (pelim sym `R, []), [`H_; `H_; `Sub h]) in
1565+
let j = pt_of_prept_r pte j in
1566+
let h = pt_of_prept_r pte h in
1567+
(`PE h, (sym, `PE j))
1568+
) (`HD gl :> prept) (List.rev syms) in
1569+
1570+
let projs = projs @ [sym, proj] in
1571+
1572+
let pintro (sym : [`Sym | `Asym]) =
1573+
match sym with
1574+
| `Sym -> LG.p_and_intro
1575+
| `Asym -> LG.p_anda_intro_s in
1576+
1577+
let pt =
1578+
List.fold_right
1579+
(fun (sym, ptproj) pt ->
1580+
`App (`G (pintro sym, []), [`H_; `H_; `Sub ptproj; `Sub pt]))
1581+
projs gr in
1582+
1583+
let pt = pt_of_prept_r pte pt in
1584+
1585+
FApi.t_first (Apply.t_apply_bwd_r pt) tc
1586+
15121587
(* -------------------------------------------------------------------- *)
1513-
let t_split ?(closeonly = false) ?reduce (tc : tcenv1) =
1588+
let t_split ?(i = 0) ?(closeonly = false) ?reduce (tc : tcenv1) =
15141589
let t_split_r (fp : form) (tc : tcenv1) =
15151590
let concl = FApi.tc1_goal tc in
15161591

15171592
match sform_of_form fp with
15181593
| SFtrue ->
15191594
t_true tc
1520-
| SFand (b, (f1, f2)) when not closeonly ->
1521-
t_and_intro_s b (f1, f2) tc
1595+
| SFand (b, (f1,f2)) when not closeonly ->
1596+
t_split_and_i i b f1 f2 tc
15221597
| SFiff (f1, f2) when not closeonly ->
15231598
t_iff_intro_s (f1, f2) tc
15241599
| SFeq (f1, f2) when not closeonly && (is_tuple f1 && is_tuple f2) ->
@@ -2182,13 +2257,14 @@ let t_progress ?options ?ti (tt : FApi.backward) (tc : tcenv1) =
21822257
end
21832258

21842259
| _ when options.pgo_split ->
2185-
let thesplit =
2260+
let (thesplit:tcenv1 -> tcenv) =
21862261
match options.pgo_delta.pgod_split with
2187-
| true -> t_split ~closeonly:false ~reduce:`Full
2262+
| true -> (fun x -> t_split ~closeonly:false ~reduce:`Full x)
21882263
| false ->
2189-
FApi.t_or
2190-
(t_split ~reduce:`NoDelta)
2191-
(t_split ~closeonly:true ~reduce:`Full) in
2264+
FApi.t_or
2265+
(t_split ~reduce:`NoDelta)
2266+
(t_split ~closeonly:true ~reduce:`Full)
2267+
in
21922268

21932269
FApi.t_try (FApi.t_seq thesplit aux0) tc
21942270

src/ecLowGoal.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ val t_right : ?reduce:lazyred -> FApi.backward
160160
val t_or_intro_prind : ?reduce:lazyred -> side -> FApi.backward
161161

162162
(* -------------------------------------------------------------------- *)
163-
val t_split : ?closeonly:bool -> ?reduce:lazyred -> FApi.backward
163+
val t_split : ?i: int -> ?closeonly:bool -> ?reduce:lazyred -> FApi.backward
164164
val t_split_prind : ?reduce:lazyred -> FApi.backward
165165

166166
(* -------------------------------------------------------------------- *)

src/ecMatching.ml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -501,8 +501,7 @@ let f_match_core opts hyps (ue, ev) f1 f2 =
501501

502502
let var_form_match ((x, xty) : ident * ty) (f : form) =
503503
match EV.get x !ev.evm_form with
504-
| None ->
505-
failure ()
504+
| None -> assert false
506505

507506
| Some `Unset ->
508507
let f = norm f in
@@ -583,10 +582,10 @@ let f_match_core opts hyps (ue, ev) f1 f2 =
583582
with EcUnify.UnificationFailure _ -> failure ()
584583
end
585584

586-
| Flocal x, _ ->
585+
| Flocal x, _ when EV.mem x !ev.evm_form ->
587586
var_form_match (x, f1.f_ty) f2
588587

589-
| _, Flocal y ->
588+
| _, Flocal y when EV.mem y !ev.evm_form ->
590589
var_form_match (y, f2.f_ty) f1
591590

592591
| Fapp (f1, fs1), Fapp (f2, fs2) ->

src/ecParser.mly

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2656,8 +2656,8 @@ logtactic:
26562656
| SMT LPAREN dbmap=dbmap1* RPAREN
26572657
{ Psmt (SMT.mk_smt_option [`WANTEDLEMMAS dbmap]) }
26582658

2659-
| SPLIT
2660-
{ Psplit }
2659+
| SPLIT i=word?
2660+
{ Psplit i }
26612661

26622662
| FIELD eqs=ident*
26632663
{ Pfield eqs }

0 commit comments

Comments
 (0)