Fix Undo try
This commit is contained in:
parent
6313af9346
commit
8b3b135184
12
main.ml
12
main.ml
@ -165,9 +165,15 @@ let rec interactive (get_instr : unit -> instr) (sl : (interactive_state) list)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
| Tact t ->
|
| Tact t ->
|
||||||
(* on applique la tactique et on copie l'état actuel de la preuve pour un futur Undo
|
(* on applique la tactique et on copie l'état actuel de la preuve pour un futur Undo *)
|
||||||
Comme OCaml évalue de la droite vers la gauche, on fait bien la copie avant de modifier les références dans la preuve *)
|
let previous_state = clean_state (cg, (g, gs)) in
|
||||||
(cg, (apply_tactic (g, gs) t))::(clean_state (cg, (g, gs)))::sq |> interactive get_instr
|
let new_proof, status = apply_tactic (g, gs) t in
|
||||||
|
(
|
||||||
|
if status then
|
||||||
|
(cg, new_proof)::previous_state::sq
|
||||||
|
else
|
||||||
|
previous_state::sq
|
||||||
|
) |> interactive get_instr
|
||||||
with
|
with
|
||||||
Parser.Error ->
|
Parser.Error ->
|
||||||
print_error "Invalid input" "";
|
print_error "Invalid input" "";
|
||||||
|
25
proof.ml
25
proof.ml
@ -210,17 +210,18 @@ let tact_left ((g, gs) : proof) : proof =
|
|||||||
Some (new_h, t_l, cs), gs
|
Some (new_h, t_l, cs), gs
|
||||||
| _ -> raise (TacticFailed "Not a disjunction")
|
| _ -> raise (TacticFailed "Not a disjunction")
|
||||||
|
|
||||||
let rec apply_tactic (p : proof) (t : tactic) : proof =
|
(* applies tactic to proof, returns (new_proof, true if p changed) *)
|
||||||
|
let rec apply_tactic (p : proof) (t : tactic) : proof * bool =
|
||||||
match t with
|
match t with
|
||||||
TExact_term e -> tact_exact_term p e
|
TExact_term e -> tact_exact_term p e, true
|
||||||
| TExact_proof hyp -> tact_exact_proof p hyp
|
| TExact_proof hyp -> tact_exact_proof p hyp, true
|
||||||
| TIntros -> tact_intros p
|
| TIntros -> tact_intros p, true
|
||||||
| TIntro -> tact_intro p
|
| TIntro -> tact_intro p, true
|
||||||
| TAssumption -> tact_assumption p
|
| TAssumption -> tact_assumption p, true
|
||||||
| TCut t -> tact_cut p t
|
| TCut t -> tact_cut p t, true
|
||||||
| TApply h -> tact_apply p h
|
| TApply h -> tact_apply p h, true
|
||||||
| TSplit -> tact_split p
|
| TSplit -> tact_split p, true
|
||||||
| TRight -> tact_right p
|
| TRight -> tact_right p, true
|
||||||
| TLeft -> tact_left p
|
| TLeft -> tact_left p, true
|
||||||
| TTry t -> try apply_tactic p t with TacticFailed _ -> p
|
| TTry t -> try apply_tactic p t with TacticFailed _ -> p, false
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
Goal A -> B -> A.
|
Goal A -> B -> A.
|
||||||
intros.
|
intros.
|
||||||
try intro.
|
try try try intro.
|
||||||
Undo.
|
Undo.
|
||||||
intro.
|
intro.
|
||||||
exact H0.
|
exact H0.
|
||||||
|
Loading…
Reference in New Issue
Block a user