package lambdapi

  1. Overview
  2. Docs

Module Parsing.SyntaxSource

Parser-level abstract syntax.

Representation of a (located) identifier.

Sourceval check_notin : string -> p_ident list -> unit

check_notin id ids checks that id does not occur in ids.

Sourceval check_distinct : p_ident list -> unit

check_distinct ids checks that the elements of ids are pairwise distinct.

Sourceval check_notin_idopts : string -> p_ident option list -> unit

check_notin_idopts id idopts checks that id does not occur in idopts.

Sourceval check_distinct_idopts : p_ident option list -> unit

check_distinct_idopts idopts checks that the elements of idopts of the form Some _ are pairwise distinct.

Sourcetype p_meta_ident = int Common.Pos.loc

Identifier of a metavariable.

Representation of a module name.

Representation of a possibly qualified (and located) identifier.

Parser-level (located) term representation.

Sourceand p_term_aux =
  1. | P_Type
    (*

    TYPE constant.

    *)
  2. | P_Iden of p_qident * bool
    (*

    Identifier. The boolean indicates whether the identifier is prefixed by "@".

    *)
  3. | P_Wild
    (*

    Underscore.

    *)
  4. | P_Meta of p_meta_ident * p_term array
    (*

    Meta-variable with explicit substitution.

    *)
  5. | P_Patt of p_ident option * p_term array option
    (*

    Pattern.

    *)
  6. | P_Appl of p_term * p_term
    (*

    Application.

    *)
  7. | P_Arro of p_term * p_term
    (*

    Arrow.

    *)
  8. | P_Abst of p_params list * p_term
    (*

    Abstraction.

    *)
  9. | P_Prod of p_params list * p_term
    (*

    Product.

    *)
  10. | P_LLet of p_ident * p_params list * p_term option * p_term * p_term
    (*

    Let.

    *)
  11. | P_NLit of Common.Path.t * string
    (*

    Integer literal.

    *)
  12. | P_SLit of string
    (*

    String literal.

    *)
  13. | P_Wrap of p_term
    (*

    Term between parentheses.

    *)
  14. | P_Expl of p_term
    (*

    Term between curly brackets.

    *)
Sourceand p_params = p_ident option list * p_term option * bool

Parser-level representation of a group of parameters. The boolean is true if the group is marked as implicit (i.e. between curly braces).

Sourceval nb_params : p_params list -> int

nb_params ps returns the number of parameters in a list of parameters ps.

Sourceval get_impl_params_list : p_params list -> bool list

get_impl_params_list l gives the implicitness of l.

Sourceval get_impl_term : p_term -> bool list

get_impl_term t gives the implicitness of t.

Sourceval get_impl_term_aux : p_term_aux -> bool list
Sourceval p_get_args : p_term -> p_term * p_term list

p_get_args t is like Core.Term.get_args but on syntax-level terms. Note that P_Wrap's are not decomposed (important for handling infix symbols used in prefix notation.

pvars_lhs t computes the set of pattern variable names in t, assuming that t is a rule LHS.

Sourcetype p_rule_aux = p_term * p_term

Parser-level rewriting rule representation.

Sourcetype p_inductive_aux = p_ident * p_term * (p_ident * p_term) list

Parser-level inductive type representation.

Sourcemodule P : sig ... end

Module to create p_term's with no positions.

Sourcetype ('term, 'binder) rwpatt =
  1. | Rw_Term of 'term
  2. | Rw_InTerm of 'term
  3. | Rw_InIdInTerm of 'binder
  4. | Rw_IdInTerm of 'binder
  5. | Rw_TermInIdInTerm of 'term * 'binder
  6. | Rw_TermAsIdInTerm of 'term * 'binder

Rewrite selection forms based on Coq/SSReflect, with Lambdapi binder terms allowed inside each term component. See "A Small Scale Reflection Extension for the Coq system", by Georges Gonthier, Assia Mahboubi and Enrico Tassi, INRIA Research Report 6455, 2016,

Sourcetype p_assertion =
  1. | P_assert_typing of p_term * p_term
    (*

    The given term should have the given type.

    *)
  2. | P_assert_conv of p_term * p_term
    (*

    The two given terms should be convertible.

    *)

Parser-level representation of an assertion.

Sourcetype side =
  1. | Lhs
  2. | Rhs

Search queries.

Sourcetype relation =
  1. | Exact
  2. | Inside
Sourcetype 'a where =
  1. | Spine of 'a
  2. | Conclusion of 'a
  3. | Hypothesis of 'a
Sourcetype search_constr =
  1. | QType of relation option where option
  2. | QXhs of relation option * side option
Sourcetype search_base =
  1. | QName of string
  2. | QSearch of p_term * bool * search_constr option
Sourcetype op =
  1. | Intersect
  2. | Union
Sourcetype filter =
  1. | Path of string
  2. | RegExp of string
Sourcetype print =
  1. | Builtin
  2. | Coerce_rule
  3. | Debug
  4. | Flag
  5. | Goal
  6. | Notation
  7. | Prover
  8. | Prover_timeout
  9. | String of string
  10. | Symbol of p_qident
  11. | Unif_rule
  12. | Verbose
Sourcetype p_query_aux =
  1. | P_query_verbose of string
    (*

    Sets the verbosity level.

    *)
  2. | P_query_debug of bool * string
    (*

    Toggles logging functions described by string according to boolean.

    *)
  3. | P_query_flag of string * bool
    (*

    Sets the boolean flag registered under the given name (if any).

    *)
  4. | P_query_assert of bool * p_assertion
    (*

    Assertion (must fail if boolean is true).

    *)
  5. | P_query_infer of p_term * Core.Eval.strat
    (*

    Type inference command.

    *)
  6. | P_query_normalize of p_term * Core.Eval.strat
    (*

    Normalisation command.

    *)
  7. | P_query_prover of string
    (*

    Set the prover to use inside a proof.

    *)
  8. | P_query_prover_timeout of string
    (*

    Set the timeout of the prover (in seconds).

    *)
  9. | P_query_print of print
    (*

    Print information about a symbol or the current goals.

    *)
  10. | P_query_proofterm
    (*

    Print the current proof term (possibly containing open goals).

    *)

Parser-level representation of a query command.

Sourcetype simp_flag =
  1. | SimpAll
  2. | SimpBetaOnly
  3. | SimpSym of p_qident
Sourcetype p_tactic_aux =
  1. | P_tac_admit
  2. | P_tac_and of p_tactic * p_tactic
  3. | P_tac_all_hyps of p_term
  4. | P_tac_apply of p_term
  5. | P_tac_assume of p_ident option list
  6. | P_tac_assumption
  7. | P_tac_change of p_term
  8. | P_tac_eval of p_term
  9. | P_tac_fail
  10. | P_tac_first_hyp of p_term
  11. | P_tac_focus of string
  12. | P_tac_generalize of p_ident
  13. | P_tac_have of p_ident * p_term
  14. | P_tac_induction
  15. | P_tac_orelse of p_tactic * p_tactic
  16. | P_tac_query of p_query
  17. | P_tac_refine of p_term
  18. | P_tac_refl
  19. | P_tac_remove of p_ident list
  20. | P_tac_repeat of p_tactic
  21. | P_tac_rewrite of bool * p_rwpatt option * p_term
  22. | P_tac_set of p_ident * p_term
  23. | P_tac_simpl of simp_flag
  24. | P_tac_solve
  25. | P_tac_sym
  26. | P_tac_try of p_tactic
  27. | P_tac_why3 of string option

Parser-level representation of a tactic.

Sourceval is_destructive : p_tactic_aux Common.Pos.loc -> bool

is_destructive t says whether tactic t changes the current goal.

Sourceval query_keyword : p_query -> string

query_keyword q returns the keyword introducing query q.

Sourceval tactic_keyword : p_tactic -> string option

tactic_keyword t returns the keyword introducing tactic t, or None for tactics that no single keyword introduces (not produced by the LP parser).

Sourceval tactic_keyword_pos : p_tactic -> Common.Pos.popt

tactic_keyword_pos t returns the position of the keyword introducing tactic t, or the position of the whole of t when no single keyword does.

Sourcetype p_subproof = p_proofstep list

Parser-level representation of a proof.

Sourceand p_proofstep =
  1. | Tactic of p_tactic * p_subproof list
Sourcetype p_proof = p_subproof list
Sourcetype p_proof_end_aux =
  1. | P_proof_end
    (*

    The proof is done and fully checked.

    *)
  2. | P_proof_admitted
    (*

    Give up current state and admit the theorem.

    *)
  3. | P_proof_abort
    (*

    Abort the proof (theorem not admitted).

    *)
Sourcetype p_modifier_aux =
  1. | P_mstrat of Core.Term.match_strat
    (*

    pattern matching strategy

    *)
  2. | P_expo of Core.Term.expo
    (*

    visibility of symbol outside its modules

    *)
  3. | P_prop of Core.Term.prop
    (*

    symbol properties: constant, definable, ...

    *)
  4. | P_opaq
    (*

    opacity

    *)

Parser-level representation of modifiers.

Sourceval eq_p_modifier : 'a Common.Pos.loc -> 'a Common.Pos.loc -> bool
Sourceval is_prop : p_modifier_aux Common.Pos.loc -> bool
Sourceval is_opaq : p_modifier_aux Common.Pos.loc -> bool
Sourceval is_expo : p_modifier_aux Common.Pos.loc -> bool
Sourceval is_mstrat : p_modifier_aux Common.Pos.loc -> bool
Sourceval is_priv : p_modifier_aux Common.Pos.loc -> bool
Sourcetype p_symbol = {
  1. p_sym_mod : p_modifier list;
    (*

    modifiers

    *)
  2. p_sym_kw : Common.Pos.popt;
    (*

    position of the "symbol" keyword

    *)
  3. p_sym_nam : p_ident;
    (*

    symbol name

    *)
  4. p_sym_arg : p_params list;
    (*

    arguments before ":"

    *)
  5. p_sym_typ : p_term option;
    (*

    symbol type

    *)
  6. p_sym_trm : p_term option;
    (*

    symbol definition

    *)
  7. p_sym_prf : (p_proof * p_proof_end) option;
    (*

    proof script

    *)
  8. p_sym_def : bool;
    (*

    is it a definition ?

    *)
}

Parser-level representation of symbol declarations.

Sourcetype p_command_aux =
  1. | P_require of bool option * p_path list
  2. | P_require_as of p_path * p_ident
  3. | P_open of Common.Pos.popt * bool * p_path list
  4. | P_symbol of p_symbol
  5. | P_rules of p_rule list
  6. | P_inductive of Common.Pos.popt * p_modifier list * p_params list * p_inductive list
  7. | P_builtin of string * p_qident
  8. | P_notation of p_qident * string Core.Term.notation
  9. | P_unif_rule of p_rule
  10. | P_coercion of p_rule
  11. | P_query of p_query
  12. | P_opaque of p_qident

Parser-level representation of a single command.

Parser-level representation of a single (located) command.

Sourceval command_keyword_pos : p_command -> Common.Pos.popt

command_keyword_pos c returns the position of the keyword introducing command c ("symbol", "rule", "require", …). Symbol, inductive and open commands record it in the AST, as modifiers or parameters may precede their keyword; for the other commands it is a prefix of the position of c. When no position was recorded (e.g. on Dedukti input), the position of the whole of c is returned instead.

Sourcetype p_commands = p_command Stream.t

Top level data structure returned by the parser.

Equality functions on the syntactic expressions ignoring positions.

Sourceval eq_p_ident : p_ident Lplib.Base.eq
Sourceval eq_p_meta_ident : p_meta_ident Lplib.Base.eq
Sourceval eq_p_qident : p_qident Lplib.Base.eq
Sourceval eq_p_path : p_path Lplib.Base.eq
Sourceval eq_p_term : p_term Lplib.Base.eq
Sourceval eq_p_params : p_params Lplib.Base.eq
Sourceval eq_p_rule : p_rule Lplib.Base.eq
Sourceval eq_p_inductive : p_inductive Lplib.Base.eq
Sourceval eq_p_rwpatt : p_rwpatt Lplib.Base.eq
Sourceval eq_p_assertion : p_assertion Lplib.Base.eq
Sourceval eq_p_query : p_query Lplib.Base.eq
Sourceval eq_simp_flag : simp_flag Lplib.Base.eq
Sourceval eq_p_tactic : p_tactic Lplib.Base.eq
Sourceval eq_p_subproof : p_subproof Lplib.Base.eq
Sourceval eq_p_proofstep : p_proofstep Lplib.Base.eq
Sourceval eq_p_proof : p_proof Lplib.Base.eq
Sourceval eq_p_sym_prf : (p_proof * p_proof_end) Lplib.Base.eq
Sourceval eq_p_symbol : p_symbol Lplib.Base.eq
Sourceval eq_p_command : p_command Lplib.Base.eq

eq_command c1 c2 tells whether c1 and c2 are the same commands. They are compared up to source code positions.

Sourceval fold_proof : ('a -> p_tactic -> int -> 'a) -> 'a -> p_proof -> 'a

fold_proof f acc p recursively builds a value of type 'a by starting from acc and by applying f to every tactic of p.

fold_idents f a cs allows to recursively build a value of type 'a starting from a and by applying f on each identifier occurring in cs corresponding to a function symbol: variables (term variables or assumption names) are excluded.

NOTE: This function is incomplete if an assumption name hides a function symbol. Example:

symbol A:TYPE; symbol a:A; symbol p:((A->A)->A->A)->A := begin assume h apply h // proof of A->A assume a apply a // here a is an assumption // proof of A apply a // here a is a function symbol end;

Sourceval fold_idents : ('a -> p_qident -> 'a) -> 'a -> p_command list -> 'a