SynextASTs constructed with the constructors in this module are not necessarily in normal form.
These types are suited for pretty-printing and elaboration to the internal syntax. Note that this is a named representation without ambiguities.
There are three kinds of variables to consider in Beluga:
Contextual variables are further classified in four variants:
#, which range over contextual LF terms. These are bound variables implicit to a context variable.$, which range over contextual LF substitutions.The representation of LF kinds, types, and terms after parsing and data-dependent disambiguation.
These types are only intended to be used in the definition of LF type-level or term-level constants. This is a weak, representational function space without case analysis or recursion.
LF terms as defined below may contain free variables. During the abstraction phase of term reconstruction, implicit binders are introduced for those free variables.
In the following grammar, the metavariable:
x ranges over variablesc ranges over term-level constantsa ranges over type-level constants \begin{aligned}
&\text{LF kinds} &K &\Coloneqq
\mathsf{type}
\mid \Pi x {:} A. K
\mid A \to K\\
&\text{LF types} &A, B &\Coloneqq
a
\mid \Pi x {:} A. B
\mid A \to B
\mid A \; M_1 \; M_2 \; \dots \; M_n\\
&\text{LF terms} &M, N &\Coloneqq
c
\mid x
\mid \_
\mid \lambda x {:} A. M
\mid M \; N_1 \; N_2 \; \dots \; N_n
\mid M : A
\end{aligned}
module LF : sig ... endThe representation of contextual LF types, terms, and patterns after parsing and data-dependent disambiguation.
The distinction between contextual LF objects and plain LF objects is that contextual LF objects may have substitutions, and may appear in patterns. Plain LF objects are only used in the definition of type-level or term-level LF constants.
Contextual LF terms as defined below may contain free variables. During the abstraction phase of term reconstruction, implicit binders are introduced for those free variables.
Additionally, free contextual LF variables occurring in a computation-level pattern are considered as pattern variables. That is, free variables occurring in a type annotation to a computation-level pattern count as pattern variables, and are added to the case analysis branch's meta-context.
In the following grammar, the metavariable:
x ranges over variablesc ranges over term-level constantsa ranges over type-level constants\$s ranges over substitutionsg ranges over contexts\mathsf{id} ranges over identifiersn ranges over integers \begin{aligned}
&\text{Contextual LF types} &A, B &\Coloneqq
a
\mid \Pi x {:} A. B
\mid A \to B
\mid A \; M_1 \; M_2 \; \dots \; M_n \\&&&
\mid \mathsf{block} (x_1 : A_1, x_2 : A_2, \dots, x_n : A_n)\\
&\text{Contextual LF terms} &M, N &\Coloneqq
c
\mid x
\mid \#x
\mid \_
\mid \lambda x {:} A. M
\mid M \; N_1 \; N_2 \; \dots \; N_n \\&&&
\mid M : A
\mid M[\sigma]
\mid \;?
\mid \;?\mathsf{id}
\mid \langle M_1; M_2; \dots; M_n \rangle
\mid M.n
\mid M.\mathsf{id}\\
&\text{Contextual LF substitutions} &\sigma &\Coloneqq
\char`\^
\mid \dots
\mid \sigma, M
\mid \$s[\sigma]\\
&\text{Contextual LF contexts} &\Psi &\Coloneqq
\char`\^
\mid g
\mid \Psi, x : A\\
&\text{Contextual LF patterns} &M_p, N_p &\Coloneqq
c
\mid x
\mid \#x
\mid \_
\mid \lambda x {:} A. M_p
\mid M_p \; N_{p,1} \; N_{p,2} \; \dots \; N_{p_n} \\&&&
\mid M_p : A
\mid M_p[\sigma]
\mid \langle M_{p,1}; M_{p,2}; \dots; M_{p,n} \rangle
\mid M.n
\mid M.\mathsf{id}\\
&\text{Contextual LF substitution patterns} &\sigma_p &\Coloneqq
\char`\^
\mid \dots
\mid \sigma_p, M_p
\mid \$s[\sigma]\\
&\text{Contextual LF context patterns} &\Psi_p &\Coloneqq
\char`\^
\mid g
\mid \Psi_p, x : A
\end{aligned}
module CLF : sig ... endThe representation of meta-types, meta-objects, meta-object patterns, meta-substitutions and meta-contexts after parsing and data-dependent disambiguation.
In the following grammar, the metavariable:
X ranges over meta-level variables\psi ranges over contextsg ranges over context schemas \begin{aligned}
&\text{Meta-types} &U &\Coloneqq
g
\mid [\Psi \vdash A]
\mid \#[\Psi \vdash A]
\mid \$[\Psi ⊢ \Psi]
\mid \$[\Psi \vdash\!\!\#\; \Psi]\\
&\text{Meta-objects} &C &\Coloneqq
[\Psi]
\mid [\Psi \vdash M]
\mid \$[\Psi \vdash \sigma]
\mid \$[\Psi \vdash\!\!\#\; \sigma]\\
&\text{Meta-substitutions} &\theta &\Coloneqq
\char`\^
\mid \theta, C / X\\
&\text{Meta-contexts} &\Delta &\Coloneqq
\char`\^
\mid \psi
\mid \Delta, X : U\\
&\text{Schemas} &G &\Coloneqq
g
\mid G + G
\mid \mathsf{some} [x_1 : A_1, x_2 : A_2, \dots, x_n : A_n] \;
\mathsf{block} (y_1 : B_1, y_2 : B_2, \dots, y_m : B_m)\\
&\text{Meta-object patterns} &C_p &\Coloneqq
[\Psi_p]
\mid [\Psi_p \vdash M_p]
\mid \$[\Psi_p \vdash \sigma_p]
\mid \$[\Psi_p \vdash\!\!\#\; \sigma_p]
\end{aligned}
module Meta : sig ... endThe representation of computation-level kinds, types, expressions and patterns after parsing and data-dependent disambiguation.
In the following grammar, the metavariable:
x ranges over computation-level variablesc ranges over computation-level constantsX ranges over meta-level variables \begin{aligned}
&\text{Computation-level kinds} &K &\Coloneqq
\mathsf{ctype}
\mid \Pi X {:} U. K
\mid U \to K\\
&\text{Computation-level types} &T, S &\Coloneqq
\Pi X {:} U. S
\mid T \to S
\mid T_1 \times T_2 \times \dots \times T_n
\mid U \\&&&
\mid T \; C_1 \; C_2 \; \dots \; C_n\\
&\text{Computation-level expressions} &E &\Coloneqq
x
\mid c
\mid \mathsf{let} \; x = P \; \mathsf{in} \; E
\mid \mathsf{impossible} \; E \\&&&
\mid (E_1, E_2, \dots, E_n)
\mid \;?
\mid \;?\mathsf{id}
\mid \_
\mid E \; E_1 \; E_2 \; \dots \; E_n \\&&&
\mid \mathsf{case} \; E \; \mathsf{of} \; P_1 \Rightarrow E_1 | P_2 \Rightarrow E_2 | \dots | P_n \Rightarrow E_n \\&&&
\mid \mathsf{fn} \; x_1 \; x_2 \; \dots \; x_n \Rightarrow E
\mid \mathsf{mlam} \; X_1 \; X_2 \; \dots \; X_n \Rightarrow E \\&&&
\mid \mathsf{fun} \; P_1 \Rightarrow E_1 | P_2 \Rightarrow E_2 | \dots | P_n \Rightarrow E_n\\&&&
\mid e .c\\
&\text{Computation-level patterns} &P &\Coloneqq
x
\mid c
\mid C_p
\mid (P_1, P_2, \dots, P_n)
\mid P \; P_1 \; P_2 \; \dots \; P_n\\
&\text{Computation-level context} &\Gamma &\Coloneqq
\char`\^
\mid \Gamma, x : T
\end{aligned}
Name resolution for computation-level patterns is intricate.
module Comp : sig ... endmodule Harpoon : sig ... endmodule Signature : sig ... endval default_associativity : Syncom.Associativity.tThe default associativity for user-defined infix operators.
type lf_kind = LF.Kind.ttype lf_typ = LF.Typ.ttype lf_term = LF.Term.ttype clf_typ = CLF.Typ.ttype clf_term = CLF.Term.ttype clf_term_pattern = CLF.Term.Pattern.ttype clf_substitution = CLF.Substitution.ttype clf_substitution_pattern = CLF.Substitution.Pattern.ttype clf_context = CLF.Context.ttype clf_context_pattern = CLF.Context.Pattern.ttype meta_typ = Meta.Typ.ttype meta_object = Meta.Object.ttype meta_pattern = Meta.Pattern.ttype schema = Meta.Schema.ttype meta_context = Meta.Context.ttype comp_kind = Comp.Kind.ttype comp_typ = Comp.Typ.ttype comp_expression = Comp.Expression.ttype comp_case_branch = Comp.Case_branch.ttype comp_cofunction_branch = Comp.Cofunction_branch.ttype comp_pattern = Comp.Pattern.ttype comp_copattern = Comp.Copattern.ttype comp_context = Comp.Context.ttype harpoon_command = Harpoon.Command.ttype harpoon_directive = Harpoon.Directive.ttype harpoon_proof = Harpoon.Proof.ttype harpoon_hypothetical = Harpoon.Hypothetical.ttype harpoon_repl_command = Harpoon.Repl.Command.ttype harpoon_split_branch = Harpoon.Split_branch.ttype harpoon_split_branch_label = Harpoon.Split_branch.Label.ttype harpoon_suffices_branch = Harpoon.Suffices_branch.ttype signature_pragma = Signature.Pragma.ttype signature_global_pragma = Signature.Global_pragma.ttype signature_totality_declaration = Signature.Totality.Declaration.ttype 'argument signature_totality_order = 'argument Signature.Totality.Order.ttype signature_declaration = Signature.Declaration.ttype signature_entry = Signature.Entry.ttype signature_file = Signature.signature_filetype signature = Signature.tinclude module type of struct include Syncom endmodule Associativity = Syncom.Associativitymodule Fixity = Syncom.Fixitymodule Operator = Syncom.Operatormodule Depend = Syncom.Dependmodule Inductivity = Syncom.Inductivitymodule Plicity = Syncom.Plicitymodule Parenthesizer = Syncom.Parenthesizermodule Identifier = Syncom.Identifiermodule Qualified_identifier = Syncom.Qualified_identifiermodule Binding_tree = Syncom.Binding_treemodule Id = Syncom.Idmodule HoleId = Syncom.HoleIdmodule Name = Syncom.Namemodule Gensym = Syncom.Gensymmodule Error = Syncom.Errormodule Position = Syncom.Positionmodule Location = Syncom.Locationval location_of_lf_kind : lf_kind -> Syncom.Location.tval location_of_lf_typ : lf_typ -> Syncom.Location.tval location_of_lf_term : lf_term -> Syncom.Location.tval location_of_clf_typ : clf_typ -> Syncom.Location.tval location_of_clf_term : clf_term -> Syncom.Location.tval location_of_clf_substitution : clf_substitution -> Syncom.Location.tval location_of_clf_substitution_pattern :
clf_substitution_pattern ->
Syncom.Location.tval location_of_clf_context : clf_context -> Syncom.Location.tval location_of_clf_context_pattern : clf_context_pattern -> Syncom.Location.tval location_of_clf_term_pattern : clf_term_pattern -> Syncom.Location.tval location_of_meta_type : meta_typ -> Syncom.Location.tval location_of_meta_object : meta_object -> Syncom.Location.tval location_of_meta_object_pattern : meta_pattern -> Syncom.Location.tval location_of_meta_context : meta_context -> Syncom.Location.tval location_of_schema : schema -> Syncom.Location.tval location_of_comp_kind : comp_kind -> Syncom.Location.tval location_of_comp_typ : comp_typ -> Syncom.Location.tval location_of_comp_expression : comp_expression -> Syncom.Location.tval location_of_comp_case_branch : comp_case_branch -> Syncom.Location.tval location_of_comp_cofunction_branch :
comp_cofunction_branch ->
Syncom.Location.tval location_of_comp_pattern : comp_pattern -> Syncom.Location.tval location_of_comp_copattern : comp_copattern -> Syncom.Location.tval location_of_harpoon_proof : harpoon_proof -> Syncom.Location.tval location_of_harpoon_command : harpoon_command -> Syncom.Location.tval location_of_harpoon_directive : harpoon_directive -> Syncom.Location.tval location_of_harpoon_split_branch :
harpoon_split_branch ->
Syncom.Location.tval location_of_harpoon_split_branch_label :
harpoon_split_branch_label ->
Syncom.Location.tval location_of_harpoon_suffices_branch :
harpoon_suffices_branch ->
Syncom.Location.tval location_of_harpoon_hypothetical :
harpoon_hypothetical ->
Syncom.Location.tval location_of_harpoon_repl_command :
harpoon_repl_command ->
Syncom.Location.tval location_of_signature_pragma : signature_pragma -> Syncom.Location.tval location_of_signature_global_pragma :
signature_global_pragma ->
Syncom.Location.tval location_of_signature_totality_declaration :
signature_totality_declaration ->
Syncom.Location.tval location_of_signature_totality_order :
'a signature_totality_order ->
Syncom.Location.tval location_of_signature_entry : signature_entry -> Syncom.Location.tval location_of_signature_declaration :
signature_declaration ->
Syncom.Location.tmodule type BASE_PRECEDENCE = sig ... endmodule type PRECEDENCE_STATE = sig ... endmodule Make_precedences (S : sig ... end) : sig ... endval explicit_arguments_lf_kind : lf_kind -> intval explicit_arguments_lf_typ : lf_typ -> intval explicit_arguments_comp_kind : comp_kind -> intval explicit_arguments_comp_typ : comp_typ -> intmodule type PRINTING_STATE = sig ... endAbstract definition for the pretty-printing state.
module Printing_state : sig ... endConcrete implementation of PRINTING_STATE backed by a mutable data structure.
module type PRINTER = sig ... endAbstract definition for pretty-printing Beluga signatures.
module Make_printer (Printing_state : sig ... end) : sig ... endmodule Printer : sig ... endConcrete implementation of pretty-printing for Beluga signatures.