Skip to content

Commit

Permalink
Merge remote-tracking branch 'dk/master' into set
Browse files Browse the repository at this point in the history
  • Loading branch information
fblanqui committed Apr 30, 2024
2 parents 5b90602 + 0a22cf9 commit 21287fc
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 26 deletions.
29 changes: 16 additions & 13 deletions doc/lambdapi.bnf
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,22 @@ QID ::= [UID "."]+ UID

<search_query_alone> ::= <search_query> EOF

<command> ::= "opaque" <qid_or_nat> ";"
<command> ::= "opaque" <qid_or_int> ";"
| "require" "open" <path>* ";"
| "require" <path>* ";"
| "require" <path> "as" <uid> ";"
| "open" <path>* ";"
| <modifier>* "symbol" <uid_or_nat> <param_list>* ":" <term>
| <modifier>* "symbol" <uid_or_int> <param_list>* ":" <term>
[<proof>] ";"
| <modifier>* "symbol" <uid_or_nat> <param_list>* [":" <term>]
| <modifier>* "symbol" <uid_or_int> <param_list>* [":" <term>]
"≔" <term_proof> ";"
| [<exposition>] <param_list>* "inductive" <inductive> ("with"
<inductive>)* ";"
| "rule" <rule> ("with" <rule>)* ";"
| "builtin" <stringlit> "≔" <qid_or_nat> ";"
| "builtin" <stringlit> "≔" <qid_or_int> ";"
| "coerce_rule" <rule> ";"
| "unif_rule" <unif_rule> ";"
| "notation" <qid_or_nat> <notation> ";"
| "notation" <qid_or_int> <notation> ";"
| <query> ";"


Expand Down Expand Up @@ -70,11 +70,11 @@ QID ::= [UID "."]+ UID

<uid> ::= UID

<uid_or_nat> ::= <uid>
| <nat>
<uid_or_int> ::= <uid>
| <int>

<qid_or_nat> ::= <qid>
| <nat>
<qid_or_int> ::= <qid>
| <int>

<param_list> ::= <param>
| "(" <param>+ ":" <term> ")"
Expand Down Expand Up @@ -104,6 +104,7 @@ QID ::= [UID "."]+ UID
| "(" <term> ")"
| "[" <term> "]"
| <nat>
| "-"<nat>

<env> ::= "." "[" [<term> (";" <term>)*] "]"

Expand Down Expand Up @@ -151,7 +152,7 @@ QID ::= [UID "."]+ UID
| "reflexivity"
| "remove" <uid>+
| "rewrite" [<side>] [<rw_patt_spec>] <term>
| "simplify" [<qid_or_nat>]
| "simplify" [<qid_or_int>]
| "solve"
| "symmetry"
| "try" <tactic>
Expand All @@ -168,7 +169,7 @@ QID ::= [UID "."]+ UID
<inductive> ::= <uid> <param_list>* ":" <term> "≔" ["|"] [<constructor>
("|" <constructor>)*]

<constructor> ::= <uid_or_nat> <param_list>* ":" <term>
<constructor> ::= <uid_or_int> <param_list>* ":" <term>

<rule> ::= <term> "↪" <term>

Expand All @@ -183,8 +184,10 @@ QID ::= [UID "."]+ UID
| "quantifier"

<float_or_int> ::= <float>
| "-"<nat>
| <nat>
| <int>

<int> ::= "-"<nat>
| <nat>

<maybe_generalize> ::= ["generalize"]

Expand Down
5 changes: 3 additions & 2 deletions src/parsing/lpLexer.ml
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,9 @@ type token =
(** Some regexp definitions. *)
let space = [%sedlex.regexp? Chars " \t\n\r"]
let digit = [%sedlex.regexp? '0' .. '9']
let nat = [%sedlex.regexp? '0' | ('1' .. '9', Star digit)]
let neg_nat = [%sedlex.regexp? '-', nat]
let pos = [%sedlex.regexp? ('1' .. '9', Star digit)]
let nat = [%sedlex.regexp? '0' | pos]
let neg_nat = [%sedlex.regexp? '-', pos]
let float = [%sedlex.regexp? (nat | neg_nat), '.', Plus digit]
let oneline_comment = [%sedlex.regexp? "//", Star (Compl ('\n' | '\r'))]
let string = [%sedlex.regexp? '"', Star (Compl '"'), '"']
Expand Down
26 changes: 15 additions & 11 deletions src/parsing/lpParser.mly
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ search_query_alone:
{ q }

command:
| OPAQUE i=qid_or_nat SEMICOLON { make_pos $sloc (P_opaque i) }
| OPAQUE i=qid_or_int SEMICOLON { make_pos $sloc (P_opaque i) }
| REQUIRE OPEN l=list(path) SEMICOLON
{ make_pos $sloc (P_require(true,l)) }
| REQUIRE l=list(path) SEMICOLON
Expand All @@ -159,13 +159,13 @@ command:
{ make_pos $sloc (P_require_as(p,i)) }
| OPEN l=list(path) SEMICOLON
{ make_pos $sloc (P_open l) }
| ms=modifier* SYMBOL s=uid_or_nat al=param_list* COLON a=term
| ms=modifier* SYMBOL s=uid_or_int al=param_list* COLON a=term
po=proof? SEMICOLON
{ let sym =
{p_sym_mod=ms; p_sym_nam=s; p_sym_arg=al; p_sym_typ=Some(a);
p_sym_trm=None; p_sym_def=false; p_sym_prf=po}
in make_pos $sloc (P_symbol(sym)) }
| ms=modifier* SYMBOL s=uid_or_nat al=param_list* ao=preceded(COLON, term)?
| ms=modifier* SYMBOL s=uid_or_int al=param_list* ao=preceded(COLON, term)?
ASSIGN tp=term_proof SEMICOLON
{ let sym =
{p_sym_mod=ms; p_sym_nam=s; p_sym_arg=al; p_sym_typ=ao;
Expand All @@ -176,11 +176,11 @@ command:
{ make_pos $sloc (P_inductive(Option.to_list exp,xs,is)) }
| RULE rs=separated_nonempty_list(WITH, rule) SEMICOLON
{ make_pos $sloc (P_rules(rs)) }
| BUILTIN s=STRINGLIT ASSIGN i=qid_or_nat SEMICOLON
| BUILTIN s=STRINGLIT ASSIGN i=qid_or_int SEMICOLON
{ make_pos $loc (P_builtin(s,i)) }
| COERCE_RULE r=rule SEMICOLON { make_pos $loc (P_coercion r) }
| UNIF_RULE r=unif_rule SEMICOLON { make_pos $loc (P_unif_rule(r)) }
| NOTATION i=qid_or_nat n=notation SEMICOLON
| NOTATION i=qid_or_int n=notation SEMICOLON
{ make_pos $loc (P_notation(i,n)) }
| q=query SEMICOLON { make_pos $sloc (P_query(q)) }
| EOF { raise End_of_file }
Expand Down Expand Up @@ -238,13 +238,13 @@ exposition:

uid: s=UID { make_pos $sloc s}

uid_or_nat:
uid_or_int:
| i=uid { i }
| n=NAT { make_pos $sloc n }
| n=int { make_pos $sloc n }

qid_or_nat:
qid_or_int:
| i=qid { i }
| n=NAT { make_pos $sloc ([],n) }
| n=int { make_pos $sloc ([],n) }

param_list:
| x=param { ([x], None, false) }
Expand Down Expand Up @@ -290,6 +290,7 @@ aterm:
| L_PAREN t=term R_PAREN { make_pos $sloc (P_Wrap(t)) }
| L_SQ_BRACKET t=term R_SQ_BRACKET { make_pos $sloc (P_Expl(t)) }
| n=NAT { make_pos $sloc (P_NLit n) }
| n=NEG_NAT { make_pos $sloc (P_Iden(make_pos $sloc ([],n), false)) }

env: DOT L_SQ_BRACKET ts=separated_list(SEMICOLON, term) R_SQ_BRACKET { ts }

Expand Down Expand Up @@ -348,7 +349,7 @@ tactic:
| REWRITE d=SIDE? p=rw_patt_spec? t=term
{ let b = match d with Some Pratter.Left -> false | _ -> true in
make_pos $sloc (P_tac_rewrite(b,p,t)) }
| SIMPLIFY i=qid_or_nat? { make_pos $sloc (P_tac_simpl i) }
| SIMPLIFY i=qid_or_int? { make_pos $sloc (P_tac_simpl i) }
| SOLVE { make_pos $sloc P_tac_solve }
| SYMMETRY { make_pos $sloc P_tac_sym }
| TRY t=tactic { make_pos $sloc (P_tac_try t) }
Expand Down Expand Up @@ -377,7 +378,7 @@ inductive: i=uid ps=param_list* COLON t=term ASSIGN
{ let t = make_prod $startpos(ps) ps t $endpos(t) in
make_pos $sloc (i,t,l) }

constructor: i=uid_or_nat ps=param_list* COLON t=term
constructor: i=uid_or_int ps=param_list* COLON t=term
{ (i, make_prod $startpos(ps) ps t $endpos(t)) }

rule: l=term HOOK_ARROW r=term { make_pos $sloc (l, r) }
Expand Down Expand Up @@ -406,6 +407,9 @@ notation:

float_or_int:
| s=FLOAT { s }
| s=int { s }

int:
| s=NEG_NAT { s }
| s=NAT { s }

Expand Down
3 changes: 3 additions & 0 deletions tests/OK/1103.lp
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
symbol A:TYPE;
symbol 2:A;
symbol -2:A;
3 changes: 3 additions & 0 deletions tests/OK/1103b.lp
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
require tests.OK.1103;
symbol a ≔ tests.OK.1103.2;
symbol b ≔ tests.OK.1103.-2;

0 comments on commit 21287fc

Please sign in to comment.