Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

coq export: treat P_NLit as P_Iden #1015

Merged
merged 1 commit into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/options.rst
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ It instructs Lambdapi to replace any occurrence of the unqualified identifier ``

if the symbols corresponding to the builtins ``"arr"``, ``"imp"`` and ``"all"`` occurs partially applied in the input file. Example: `coq.v <https://github.com/Deducteam/lambdapi/blob/master/libraries/coq.v>`__.

* ``--erasing <LP_FILE>`` where ``<LP_FILE>`` contains a sequence of builtin declarations like for the option ``--renaming`` except that, this time, ``lp_id`` can be a qualified identifier. It has the same effect as the option ``--renaming`` plus it removes any declaration of the renamed symbols. ``coq_expr`` therefore needs to be defined in Coq standard library or in the Coq file specified with the option ``-requiring``. It is not necessary to have entries for the symbols corresponding to the builtins ``"El"`` and ``"Prf"`` declared with the option ``--encoding`` since they are erased automatically. Example: `erasing.lp <https://github.com/Deducteam/lambdapi/blob/master/libraries/erasing.lp>`__.
* ``--erasing <LP_FILE>`` where ``<LP_FILE>`` contains a sequence of builtin declarations like for the option ``--renaming`` except that, this time, ``lp_id`` can be a qualified identifier. It has the same effect as the option ``--renaming`` plus it removes any declaration of the renamed symbols. ``coq_expr`` therefore needs to be defined in Coq standard library or in the Coq file specified with the option ``--requiring``. It is not necessary to have entries for the symbols corresponding to the builtins ``"El"`` and ``"Prf"`` declared with the option ``--encoding`` since they are erased automatically. Example: `erasing.lp <https://github.com/Deducteam/lambdapi/blob/master/libraries/erasing.lp>`__.

* ``--use-notations`` instructs Lambdapi to use the usual Coq notations for the symbols corresponding to the builtins ``"eq"``, ``"not"``, ``"and"`` and ``"or"``.

Expand Down
12 changes: 9 additions & 3 deletions src/export/coq.ml
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,9 @@ let set_erasing : string -> unit = fun f ->
| {elt=P_builtin(coq_id,lp_qid);_} ->
if Logger.log_enabled() then
log "rename %a into %s" Pretty.qident lp_qid coq_id;
if Logger.log_enabled() then log "erase %s" (snd lp_qid.elt);
erase := StrSet.add (snd lp_qid.elt) !erase;
let id = snd lp_qid.elt in
if Logger.log_enabled() then log "erase %s" id;
erase := StrSet.add id !erase;
map_erased_qid_coq := QidMap.add lp_qid.elt coq_id !map_erased_qid_coq
| {pos;_} -> fatal pos "Invalid command."
in
Expand Down Expand Up @@ -194,7 +195,12 @@ let rec term : p_term pp = fun ppf t ->
| P_Expl _ -> wrn t.pos "TODO"; assert false
| P_Type -> out ppf "Type"
| P_Wild -> out ppf "_"
| P_NLit i -> raw_ident ppf i
| P_NLit i ->
if !stt then
match QidMap.find_opt ([],i) !map_erased_qid_coq with
| Some s -> string ppf s
| None -> raw_ident ppf i
else raw_ident ppf i
| P_Iden(qid,b) ->
if b then out ppf "@@";
if !stt then
Expand Down
Loading