Add tactics left and right
This commit is contained in:
parent
8fc21a0988
commit
24f78f58cd
@ -37,6 +37,8 @@ rule token = parse
|
|||||||
| "intro" { INTRO }
|
| "intro" { INTRO }
|
||||||
| "cut" { CUT }
|
| "cut" { CUT }
|
||||||
| "apply" { APPLY }
|
| "apply" { APPLY }
|
||||||
|
| "left" { LEFT }
|
||||||
|
| "right" { RIGHT }
|
||||||
|
|
||||||
| var_id as s { VARID(s) }
|
| var_id as s { VARID(s) }
|
||||||
| ty_id as s { TYID(s) }
|
| ty_id as s { TYID(s) }
|
||||||
|
@ -9,19 +9,20 @@ open Parser_entry
|
|||||||
%token PLUS TIMES
|
%token PLUS TIMES
|
||||||
%token TOP BOT EXFALSO TILDE
|
%token TOP BOT EXFALSO TILDE
|
||||||
%token LPAREN RPAREN
|
%token LPAREN RPAREN
|
||||||
%token AND OR
|
|
||||||
%token FUN ARR COLON TARR
|
%token FUN ARR COLON TARR
|
||||||
|
%token AND OR
|
||||||
%token <string> VARID
|
%token <string> VARID
|
||||||
%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 EOL
|
%token EOL
|
||||||
|
|
||||||
%right TARR
|
|
||||||
%right TILDE
|
|
||||||
%right AND
|
%right AND
|
||||||
%right OR
|
%right OR
|
||||||
|
%right TARR
|
||||||
|
%right TILDE
|
||||||
|
|
||||||
%start main
|
%start main
|
||||||
%type <parser_entry> main
|
%type <parser_entry> main
|
||||||
@ -41,6 +42,8 @@ command:
|
|||||||
| ASSUMPTION { Tact (Assumption) }
|
| ASSUMPTION { Tact (Assumption) }
|
||||||
| INTROS { Tact (Intros) }
|
| INTROS { Tact (Intros) }
|
||||||
| INTRO { Tact (Intro) }
|
| INTRO { Tact (Intro) }
|
||||||
|
| RIGHT { Tact (Right) }
|
||||||
|
| LEFT { Tact (Left) }
|
||||||
| CUT t=ty { Tact (Cut t) }
|
| CUT t=ty { Tact (Cut t) }
|
||||||
| APPLY s=TYID { Tact (Apply s) }
|
| APPLY s=TYID { Tact (Apply s) }
|
||||||
|
|
||||||
|
22
proof.ml
22
proof.ml
@ -23,6 +23,8 @@ type tactic =
|
|||||||
| Intro
|
| Intro
|
||||||
| Cut of ty
|
| Cut of ty
|
||||||
| Apply of id
|
| Apply of id
|
||||||
|
| Right
|
||||||
|
| Left
|
||||||
|
|
||||||
let count = ref 0
|
let count = ref 0
|
||||||
let get_fresh_hyp () =
|
let get_fresh_hyp () =
|
||||||
@ -168,6 +170,24 @@ let tact_intros : proof -> proof =
|
|||||||
with TacticFailed _ -> p
|
with TacticFailed _ -> p
|
||||||
in push
|
in push
|
||||||
|
|
||||||
|
let tact_right ((g, gs) : proof) : proof =
|
||||||
|
match g with
|
||||||
|
None -> raise (TacticFailed "no current goal")
|
||||||
|
| Some (h, goal_ty, cs) ->
|
||||||
|
match goal_ty with
|
||||||
|
| Or(_, t) ->
|
||||||
|
Some (h, t, cs), gs
|
||||||
|
| _ -> raise (TacticFailed "Not a disjunction")
|
||||||
|
|
||||||
|
let tact_left ((g, gs) : proof) : proof =
|
||||||
|
match g with
|
||||||
|
None -> raise (TacticFailed "no current goal")
|
||||||
|
| Some (h, goal_ty, cs) ->
|
||||||
|
match goal_ty with
|
||||||
|
| Or(t, _) ->
|
||||||
|
Some (h, t, cs), gs
|
||||||
|
| _ -> raise (TacticFailed "Not a disjunction")
|
||||||
|
|
||||||
let apply_tactic (p : proof) (t : tactic) : proof =
|
let apply_tactic (p : proof) (t : tactic) : proof =
|
||||||
match t with
|
match t with
|
||||||
Exact_term e -> tact_exact_term p e
|
Exact_term e -> tact_exact_term p e
|
||||||
@ -177,6 +197,8 @@ 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
|
||||||
|
| Right -> tact_right p
|
||||||
|
| Left -> tact_left p
|
||||||
|
|
||||||
|
|
||||||
let tact_try (p : proof) (t : tactic) : proof =
|
let tact_try (p : proof) (t : tactic) : proof =
|
||||||
|
Loading…
Reference in New Issue
Block a user