Skip to content

Commit a5255ef

Browse files
authored
New flag GDV + epsilon terms + annotations (#51)
* Parsing (and typing) of espilon-terms in TPTP input files (TPTP syntax # [ X ] : ... ) * Producing an annotation term for TPTP input * WIP finding the name of a Skolem symbol from annotations * Add annotation.ml to Makefile * New flag -gdv instead of flag -lp-package
1 parent ae7d5c9 commit a5255ef

14 files changed

Lines changed: 62 additions & 40 deletions

‎Makefile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ VERSION = $(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_BUGFIX)
2222
# modules in linking order.
2323

2424
SOURCES = log.ml version.ml config.dummy misc.ml heap.ml globals.ml error.ml \
25-
progress.ml namespace.ml expr.ml \
25+
progress.ml namespace.ml annotation.ml expr.ml \
2626
phrase.ml llproof.ml mlproof.ml index.ml print.ml \
2727
watch.ml eqrel.ml \
2828
rewrite.ml typer.ml \

‎annotation.ml‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
type annotation =
2+
Atom of string
3+
| Fun of string * annotation list
4+
| List of annotation list
5+
| Colon of annotation * annotation

‎annotation.mli‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
type annotation =
2+
Atom of string
3+
| Fun of string * annotation list
4+
| List of annotation list
5+
| Colon of annotation * annotation
6+

‎globals.ml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ let debug_rwrt = ref false;;
3131

3232
let output_sig = ref false;;
3333
let signature_name = ref "";;
34-
let lp_package = ref "";;
34+
let gdv = ref false;;
3535
let conjecture = ref "";;
3636
let check_axiom = ref false;;
3737
let szs = ref false;;

‎globals.mli‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ val debug_rwrt : bool ref;;
3131

3232
val output_sig : bool ref;;
3333
val signature_name : string ref;;
34-
val lp_package : string ref;;
34+
val gdv : bool ref;;
3535
val conjecture : string ref;;
3636
val check_axiom : bool ref;;
3737
val szs : bool ref;;

‎lextptp.mll‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ rule token = parse
5757
| "." { DOT }
5858
| "?" { EX }
5959
| "!" { ALL }
60+
| "#" { HASH }
6061
| "~" { NOT }
6162
| "|" { OR }
6263
| "&" { AND }

‎lltolp.ml‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1061,13 +1061,10 @@ let output_term oc phrases _ llp =
10611061
let dkproof = make_proof_term (List.hd goal) prooftree in
10621062
fprintf oc "require open Stdlib.Prop Stdlib.Set Stdlib.Eq Stdlib.FOL \
10631063
Logic.Zenon.Main;\n";
1064-
if !Globals.lp_package <> "" then begin
1065-
fprintf oc "require %s.Signature as S;\n" !Globals.lp_package;
1066-
fprintf oc "require %s.Formulae as F;\n" !Globals.lp_package;
1064+
if !Globals.gdv then
10671065
fprintf oc "\nrule F.%s ↪ " goal_name
1068-
end
10691066
else
1070-
fprintf oc "\nsymbol %s ≔ " goal_name;
1067+
fprintf oc "\nsymbol %s ≔ " goal_name;
10711068
if !Globals.conjecture <> "" then
10721069
fprintf oc "λ __negated_conjecture_proof__,";
10731070
begin

‎lpprint.ml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ and print_dk_cst typ o (t, var_context) =
112112
if Mltoll.is_meta s then fprintf o "select (%a)" print_dk_zentype_aux (typ, var_context)
113113
else
114114
begin
115-
fprintf o (if !Globals.lp_package = "" then "%s"
115+
fprintf o (if !Globals.gdv then "%s"
116116
else if is_formula then "F.%s"
117117
else "S.%s")
118118
(escape_name s);

‎main.ml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,8 @@ let argspec = [
217217
" print the proof in Dk script format (force -rename)";
218218
"-sig", Arg.String (fun s -> Globals.signature_name := s),
219219
"<n> set the module path of the signature";
220-
"-lp-package", Arg.String (fun s -> Globals.lp_package := s),
221-
"<n> set the module path for lambdapi";
220+
"-gdv", Arg.Set Globals.gdv,
221+
" use the format expected by GDV for the lambdapi output";
222222
"-odkterm", Arg.Unit (fun () -> proof_level := Proof_dkterm;
223223
opt_level := 0;
224224
Globals.output_dk := true),

‎parsetptp.mly‎

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
Version.add "$Id: parsetptp.mly,v 1.9 2012-04-24 17:32:04 doligez Exp $";;
55

66
open Expr;;
7+
open Annotation
78

89
let ns pre s = (if !Globals.namespace_flag then pre else "") ^ s;;
910
(* Renaming is now done during typechecking *)
@@ -73,6 +74,7 @@ let cnf_to_formula l =
7374
%token XOR
7475
%token NOR
7576
%token NAND
77+
%token HASH
7678
%token <string> ANNOT
7779

7880
%nonassoc OPEN
@@ -100,55 +102,53 @@ phrase:
100102
| INCLUDE OPEN LIDENT COMMA LBRACKET name_list RBRACKET CLOSE DOT
101103
{ Phrase.Include ($3, Some ($6)) }
102104
| INPUT_FORMULA OPEN name COMMA LIDENT COMMA formula annotations CLOSE DOT
103-
{ Phrase.Formula (ns_hyp $3, $5, $7, None) }
105+
{ Phrase.Formula (ns_hyp $3, $5, $7, $8) }
104106
| INPUT_CLAUSE OPEN name COMMA LIDENT COMMA cnf_formula annotations CLOSE DOT
105-
{ Phrase.Formula (ns_hyp $3, $5, cnf_to_formula $7, None) }
106-
| INPUT_TFF_FORMULA OPEN name COMMA LIDENT COMMA formula COMMA LIDENT annotations CLOSE DOT
107-
{ Phrase.Formula (ns_hyp $3, "tff_" ^ $5, $7, Some $9) }
107+
{ Phrase.Formula (ns_hyp $3, $5, cnf_to_formula $7, $8) }
108108
| INPUT_TFF_FORMULA OPEN name COMMA LIDENT COMMA formula annotations CLOSE DOT
109-
{ Phrase.Formula (ns_hyp $3, "tff_" ^ $5, $7, None) }
109+
{ Phrase.Formula (ns_hyp $3, "tff_" ^ $5, $7, $8) }
110110
| INPUT_TFF_FORMULA OPEN name COMMA LIDENT COMMA type_def annotations CLOSE DOT
111-
{ Phrase.Formula (ns_hyp $3, "tff_" ^ $5, $7, None) }
111+
{ Phrase.Formula (ns_hyp $3, "tff_" ^ $5, $7, $8) }
112112
| ANNOT { Phrase.Annotation $1 }
113113
;
114114
annotations:
115-
| {}
116-
| COMMA source optional_info {}
115+
| {None}
116+
| COMMA source optional_info {Some $2}
117117
;
118118

119119
source:
120-
general_term {}
120+
general_term {$1}
121121
;
122122

123123
general_term:
124-
general_data {}
125-
| general_data COLON general_term {}
126-
| general_list {}
124+
general_data {$1}
125+
| general_data COLON general_term {Colon ($1, $3)}
126+
| general_list {List $1}
127127
;
128128

129129
general_data:
130-
LIDENT {}
131-
| general_function {}
132-
| UIDENT {}
133-
| INT {}
134-
| RAT {}
135-
| REAL {}
136-
| STRING {}
130+
LIDENT {Atom $1}
131+
| general_function {$1}
132+
| UIDENT {Atom $1}
133+
| INT {Atom $1}
134+
| RAT {Atom $1}
135+
| REAL {Atom $1}
136+
| STRING {Atom $1}
137137
/* | formula_data {} unsupported */
138138
;
139139

140140
general_function:
141-
LIDENT OPEN general_terms CLOSE {}
141+
LIDENT OPEN general_terms CLOSE {Fun ($1, $3)}
142142
;
143143

144144
general_terms:
145-
general_term {}
146-
| general_term COMMA general_terms {}
145+
general_term { [$1] }
146+
| general_term COMMA general_terms {$1::$3}
147147
;
148148

149149
general_list:
150-
LBRACKET RBRACKET {}
151-
| LBRACKET general_terms RBRACKET {}
150+
LBRACKET RBRACKET {[]}
151+
| LBRACKET general_terms RBRACKET {$2}
152152
;
153153

154154
optional_info:
@@ -168,6 +168,7 @@ expr:
168168
| expr EQSYM expr { eeq $1 $3 }
169169
| expr NEQSYM expr { enot (eeq $1 $3) }
170170
| OPEN expr CLOSE { $2 }
171+
| HASH LBRACKET var_list RBRACKET COLON unit_formula { etau (List.hd $3, $6) }
171172
;
172173
arguments:
173174
| OPEN expr_list CLOSE { $2 }

0 commit comments

Comments
 (0)