Add tactic split

This commit is contained in:
augustin64 2024-05-06 10:09:40 +02:00
parent 24f78f58cd
commit 6251bb0b64
3 changed files with 15 additions and 1 deletions

View File

@ -39,6 +39,7 @@ rule token = parse
| "apply" { APPLY } | "apply" { APPLY }
| "left" { LEFT } | "left" { LEFT }
| "right" { RIGHT } | "right" { RIGHT }
| "split" { SPLIT }
| var_id as s { VARID(s) } | var_id as s { VARID(s) }
| ty_id as s { TYID(s) } | ty_id as s { TYID(s) }

View File

@ -15,7 +15,7 @@ open Parser_entry
%token <string> TYID %token <string> TYID
%token GOAL EXACT ASSUMPTION INTRO INTROS CUT APPLY %token GOAL EXACT ASSUMPTION INTRO INTROS CUT APPLY
%token LEFT RIGHT %token LEFT RIGHT SPLIT
%token EOL %token EOL
@ -42,6 +42,7 @@ command:
| ASSUMPTION { Tact (Assumption) } | ASSUMPTION { Tact (Assumption) }
| INTROS { Tact (Intros) } | INTROS { Tact (Intros) }
| INTRO { Tact (Intro) } | INTRO { Tact (Intro) }
| SPLIT { Tact (Split) }
| RIGHT { Tact (Right) } | RIGHT { Tact (Right) }
| LEFT { Tact (Left) } | LEFT { Tact (Left) }
| CUT t=ty { Tact (Cut t) } | CUT t=ty { Tact (Cut t) }

View File

@ -23,6 +23,7 @@ type tactic =
| Intro | Intro
| Cut of ty | Cut of ty
| Apply of id | Apply of id
| Split
| Right | Right
| Left | Left
@ -170,6 +171,16 @@ let tact_intros : proof -> proof =
with TacticFailed _ -> p with TacticFailed _ -> p
in push in push
let tact_split ((g, gs) : proof) : proof =
match g with
None -> raise (TacticFailed "no current goal")
| Some (h, goal_ty, cs) ->
match goal_ty with
| And(t1, t2) ->
Some (h, t1, cs), (h, t2, cs)::gs
| _ -> raise (TacticFailed "Not a conjonction")
let tact_right ((g, gs) : proof) : proof = let tact_right ((g, gs) : proof) : proof =
match g with match g with
None -> raise (TacticFailed "no current goal") None -> raise (TacticFailed "no current goal")
@ -197,6 +208,7 @@ let apply_tactic (p : proof) (t : tactic) : proof =
| Assumption -> tact_assumption p | Assumption -> tact_assumption p
| Cut t -> tact_cut p t | Cut t -> tact_cut p t
| Apply h -> tact_apply p h | Apply h -> tact_apply p h
| Split -> tact_split p
| Right -> tact_right p | Right -> tact_right p
| Left -> tact_left p | Left -> tact_left p