Module Synext

External Syntax Definition

ASTs 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:

External LF Syntax

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:

      \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 ... end

External Contextual LF Syntax

The 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:

      \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 ... end

External Meta-Syntax

The 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:

      \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 ... end

External Computation-Level Syntax

The representation of computation-level kinds, types, expressions and patterns after parsing and data-dependent disambiguation.

In the following grammar, the metavariable:

      \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 ... end

External Harpoon Syntax

module Harpoon : sig ... end

External Signature Syntax

module Signature : sig ... end

Constants

val default_associativity : Syncom.Associativity.t

The default associativity for user-defined infix operators.

val default_precedence : int

The default precedence for user-defined operators.

Type Aliases

LF

type lf_kind = LF.Kind.t
type lf_typ = LF.Typ.t
type lf_term = LF.Term.t

Contextual LF

type clf_typ = CLF.Typ.t
type clf_term = CLF.Term.t
type clf_term_pattern = CLF.Term.Pattern.t
type clf_substitution = CLF.Substitution.t
type clf_substitution_pattern = CLF.Substitution.Pattern.t
type clf_context = CLF.Context.t
type clf_context_pattern = CLF.Context.Pattern.t

Meta-level

type meta_typ = Meta.Typ.t
type meta_object = Meta.Object.t
type meta_pattern = Meta.Pattern.t
type schema = Meta.Schema.t
type meta_context = Meta.Context.t

Computation-level

type comp_kind = Comp.Kind.t
type comp_typ = Comp.Typ.t
type comp_expression = Comp.Expression.t
type comp_case_branch = Comp.Case_branch.t
type comp_cofunction_branch = Comp.Cofunction_branch.t
type comp_pattern = Comp.Pattern.t
type comp_copattern = Comp.Copattern.t
type comp_context = Comp.Context.t

Harpoon

type harpoon_command = Harpoon.Command.t
type harpoon_directive = Harpoon.Directive.t
type harpoon_proof = Harpoon.Proof.t
type harpoon_hypothetical = Harpoon.Hypothetical.t
type harpoon_repl_command = Harpoon.Repl.Command.t
type harpoon_split_branch = Harpoon.Split_branch.t
type harpoon_split_branch_label = Harpoon.Split_branch.Label.t
type harpoon_suffices_branch = Harpoon.Suffices_branch.t

Signature

type signature_pragma = Signature.Pragma.t
type signature_global_pragma = Signature.Global_pragma.t
type signature_totality_declaration = Signature.Totality.Declaration.t
type 'argument signature_totality_order = 'argument Signature.Totality.Order.t
type signature_declaration = Signature.Declaration.t
type signature_entry = Signature.Entry.t
type signature_file = Signature.signature_file
type signature = Signature.t

Common

include module type of struct include Syncom end

Operators

module Associativity = Syncom.Associativity
module Fixity = Syncom.Fixity
module Operator = Syncom.Operator

Annotations

module Depend = Syncom.Depend
module Inductivity = Syncom.Inductivity
module Plicity = Syncom.Plicity

Pretty-Printing

module Parenthesizer = Syncom.Parenthesizer

Identifiers

module Identifier = Syncom.Identifier
module Qualified_identifier = Syncom.Qualified_identifier
module Binding_tree = Syncom.Binding_tree
module Id = Syncom.Id
module HoleId = Syncom.HoleId

Legacy Names

module Name = Syncom.Name
module Gensym = Syncom.Gensym

Utilities

module Error = Syncom.Error
module Position = Syncom.Position
module Location = Syncom.Location

Locations

LF

val location_of_lf_kind : lf_kind -> Syncom.Location.t
val location_of_lf_typ : lf_typ -> Syncom.Location.t
val location_of_lf_term : lf_term -> Syncom.Location.t

Contextual LF

val location_of_clf_typ : clf_typ -> Syncom.Location.t
val location_of_clf_term : clf_term -> Syncom.Location.t
val location_of_clf_substitution : clf_substitution -> Syncom.Location.t
val location_of_clf_substitution_pattern : clf_substitution_pattern -> Syncom.Location.t
val location_of_clf_context : clf_context -> Syncom.Location.t
val location_of_clf_context_pattern : clf_context_pattern -> Syncom.Location.t
val location_of_clf_term_pattern : clf_term_pattern -> Syncom.Location.t

Meta-Level

val location_of_meta_type : meta_typ -> Syncom.Location.t
val location_of_meta_object : meta_object -> Syncom.Location.t
val location_of_meta_object_pattern : meta_pattern -> Syncom.Location.t
val location_of_meta_context : meta_context -> Syncom.Location.t
val location_of_schema : schema -> Syncom.Location.t

Computation-Level

val location_of_comp_kind : comp_kind -> Syncom.Location.t
val location_of_comp_typ : comp_typ -> Syncom.Location.t
val location_of_comp_expression : comp_expression -> Syncom.Location.t
val location_of_comp_case_branch : comp_case_branch -> Syncom.Location.t
val location_of_comp_cofunction_branch : comp_cofunction_branch -> Syncom.Location.t
val location_of_comp_pattern : comp_pattern -> Syncom.Location.t
val location_of_comp_copattern : comp_copattern -> Syncom.Location.t

Harpoon

val location_of_harpoon_proof : harpoon_proof -> Syncom.Location.t
val location_of_harpoon_command : harpoon_command -> Syncom.Location.t
val location_of_harpoon_directive : harpoon_directive -> Syncom.Location.t
val location_of_harpoon_split_branch : harpoon_split_branch -> Syncom.Location.t
val location_of_harpoon_split_branch_label : harpoon_split_branch_label -> Syncom.Location.t
val location_of_harpoon_suffices_branch : harpoon_suffices_branch -> Syncom.Location.t
val location_of_harpoon_hypothetical : harpoon_hypothetical -> Syncom.Location.t
val location_of_harpoon_repl_command : harpoon_repl_command -> Syncom.Location.t

Signature

val location_of_signature_pragma : signature_pragma -> Syncom.Location.t
val location_of_signature_global_pragma : signature_global_pragma -> Syncom.Location.t
val location_of_signature_totality_declaration : signature_totality_declaration -> Syncom.Location.t
val location_of_signature_totality_order : 'a signature_totality_order -> Syncom.Location.t
val location_of_signature_entry : signature_entry -> Syncom.Location.t
val location_of_signature_declaration : signature_declaration -> Syncom.Location.t

Precedences

module type BASE_PRECEDENCE = sig ... end
module type PRECEDENCE_STATE = sig ... end
module Make_precedences (S : sig ... end) : sig ... end

Explicit Arguments

val explicit_arguments_lf_kind : lf_kind -> int
val explicit_arguments_lf_typ : lf_typ -> int
val explicit_arguments_comp_kind : comp_kind -> int
val explicit_arguments_comp_typ : comp_typ -> int

Pretty-Printing

module type PRINTING_STATE = sig ... end

Abstract definition for the pretty-printing state.

module Printing_state : sig ... end

Concrete implementation of PRINTING_STATE backed by a mutable data structure.

module type PRINTER = sig ... end

Abstract definition for pretty-printing Beluga signatures.

module Make_printer (Printing_state : sig ... end) : sig ... end
module Printer : sig ... end

Concrete implementation of pretty-printing for Beluga signatures.