2024-04-09 11:09:33 +02:00
|
|
|
%{
|
2024-04-16 10:07:09 +02:00
|
|
|
open Lam
|
2024-04-15 12:07:49 +02:00
|
|
|
open Types
|
2024-04-30 11:44:28 +02:00
|
|
|
open Proof
|
|
|
|
open Parser_entry
|
2024-04-09 11:09:33 +02:00
|
|
|
%}
|
|
|
|
|
2024-05-14 11:43:57 +02:00
|
|
|
%token EOF
|
|
|
|
|
2024-05-16 12:31:06 +02:00
|
|
|
%token DOT COMMA
|
2024-05-17 14:14:28 +02:00
|
|
|
%token BOT EXFALSO TILDE
|
2024-04-09 11:09:33 +02:00
|
|
|
%token LPAREN RPAREN
|
2024-04-16 10:07:09 +02:00
|
|
|
%token FUN ARR COLON TARR
|
2024-05-05 20:45:55 +02:00
|
|
|
%token AND OR
|
2024-04-09 11:09:33 +02:00
|
|
|
%token <string> VARID
|
|
|
|
%token <string> TYID
|
|
|
|
|
2024-05-13 18:05:28 +02:00
|
|
|
%token GOAL UNDO QED
|
|
|
|
%token EXACT ASSUMPTION INTRO INTROS CUT APPLY
|
2024-05-17 14:14:28 +02:00
|
|
|
%token LEFT RIGHT SPLIT TRY
|
2024-05-16 12:31:06 +02:00
|
|
|
%token L R
|
2024-04-30 11:44:28 +02:00
|
|
|
|
2024-05-05 20:45:55 +02:00
|
|
|
%right TARR
|
2024-05-06 10:12:24 +02:00
|
|
|
%right OR
|
|
|
|
%right AND
|
2024-05-05 20:45:55 +02:00
|
|
|
%right TILDE
|
2024-04-15 12:07:49 +02:00
|
|
|
|
2024-05-16 12:31:06 +02:00
|
|
|
|
2024-04-09 11:09:33 +02:00
|
|
|
%start main
|
2024-04-30 11:44:28 +02:00
|
|
|
%type <parser_entry> main
|
2024-04-09 11:09:33 +02:00
|
|
|
|
|
|
|
%%
|
|
|
|
main:
|
2024-05-14 11:43:57 +02:00
|
|
|
| e=expression EOF { Lam e }
|
2024-05-17 14:14:28 +02:00
|
|
|
| ts=nonempty_list(instr) EOF { Instr ts }
|
2024-04-30 11:44:28 +02:00
|
|
|
|
2024-05-17 14:14:28 +02:00
|
|
|
instr:
|
|
|
|
| c=command DOT { Cmd c }
|
|
|
|
| t=tactic DOT { Tact t }
|
2024-04-30 11:44:28 +02:00
|
|
|
|
|
|
|
command:
|
|
|
|
| GOAL t=ty { Goal t }
|
2024-05-11 11:44:43 +02:00
|
|
|
| UNDO { Undo }
|
2024-05-13 18:05:28 +02:00
|
|
|
| QED { Qed }
|
2024-04-30 11:44:28 +02:00
|
|
|
|
2024-05-17 14:14:28 +02:00
|
|
|
tactic:
|
|
|
|
| EXACT e=expression { TExact_term e }
|
|
|
|
| EXACT s=TYID { TExact_proof s }
|
|
|
|
| ASSUMPTION { TAssumption }
|
|
|
|
| INTROS { TIntros }
|
|
|
|
| INTRO { TIntro }
|
|
|
|
| SPLIT { TSplit }
|
|
|
|
| RIGHT { TRight }
|
|
|
|
| LEFT { TLeft }
|
|
|
|
| CUT t=ty { TCut t }
|
|
|
|
| APPLY s=TYID { TApply s }
|
|
|
|
| TRY t=tactic { TTry t }
|
2024-04-09 11:09:33 +02:00
|
|
|
|
|
|
|
ty_annot:
|
|
|
|
| id=VARID COLON t=ty { (id, t) }
|
|
|
|
|
2024-04-15 12:07:49 +02:00
|
|
|
ty:
|
|
|
|
| id=TYID { TVar(id) }
|
2024-04-16 10:07:09 +02:00
|
|
|
| BOT { Bot }
|
2024-04-15 12:07:49 +02:00
|
|
|
| LPAREN t=ty RPAREN { t }
|
2024-04-16 10:07:09 +02:00
|
|
|
| TILDE t=ty { Arr(t, Bot) }
|
2024-05-05 20:33:39 +02:00
|
|
|
| t1=ty AND t2=ty { And(t1, t2) }
|
|
|
|
| t1=ty OR t2=ty { Or(t1, t2) }
|
2024-04-16 10:07:09 +02:00
|
|
|
| t1=ty TARR t2=ty { Arr(t1, t2) }
|
2024-04-15 12:07:49 +02:00
|
|
|
|
2024-04-09 11:09:33 +02:00
|
|
|
expression:
|
|
|
|
| FUN LPAREN annot=ty_annot RPAREN ARR e=expression
|
|
|
|
{ Fun (annot, e) }
|
2024-04-16 10:07:09 +02:00
|
|
|
| EXFALSO LPAREN e=expression COLON t=ty RPAREN
|
|
|
|
{ Exf (e, t) }
|
2024-05-16 12:31:06 +02:00
|
|
|
| LPAREN e1=expression COMMA e2=expression RPAREN
|
|
|
|
{ Pair(e1, e2) }
|
2024-05-17 08:10:26 +02:00
|
|
|
| L LPAREN e=expression COLON t=ty RPAREN
|
|
|
|
{ Left(e, t) }
|
|
|
|
| R LPAREN e=expression COLON t=ty RPAREN
|
|
|
|
{ Right(e, t) }
|
2024-04-09 11:09:33 +02:00
|
|
|
| e=app_expr { e }
|
|
|
|
|
|
|
|
app_expr:
|
|
|
|
| e=app_expr a=atomic { App (e, a) }
|
|
|
|
| a=atomic { a }
|
|
|
|
|
|
|
|
atomic:
|
|
|
|
| id=VARID { Var id }
|
|
|
|
| LPAREN e=expression RPAREN
|
|
|
|
{ e }
|