(* * The Coq Proof Assistant / The Coq Development Team *) (* v * Copyright INRIA, CNRS and contributors *) (* <O___,, * (see version control and CREDITS file for authors & dates) *) (* \VV/ **************************************************************) (* // * This file is distributed under the terms of the *) (* * GNU Lesser General Public License Version 2.1 *) (* * (see LICENSE file for the text of the license) *) (************************************************************************)
open Names open EConstr open Inductiveops
(* This represents how a term is getting extracted from another term *) type term_extraction =
| Id (* the constructor from which to extract, type of the constructor that is getting extracted, index (1 based) to extract from, further extraction *)
| Extraction of ((constructor * EInstance.t) * EConstr.t * int * term_extraction)
(* this represents how a term is getting composed from an inductive type *) type term_compositionjava.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
* type compose
| FromEnv of. (* env type to compose, env parameter term to extract from, index (1 based) of parameter, extraction for the given type*) java.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 58
java.lang.StringIndexOutOfBoundsException: Index 134 out of bounds for length 134 (* env type to compose, index (1 based) index to compose from, extraction for the given type *)
.* (* composition for f, array of composition for arg *)
envfst)in
type let (_, (_, field_)=get_ith_arg i+)constructor_type (* simply typed fields *)
| Simple (* dependently typed fields for wich a type term_composition exists *) special=
|let= ( cnstr (* dependently typed fields for which currently no projection generation is known, simply typed generation is getting tried anyways *) pos )
Array env_ind_params in
(*get the ith (1 based) argument in a series of prods*) let get_ith_arg sigma i term = let (rels_to_arg, rest) = decompose_prod_n (i-1 term java.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 64 let,,) sigmajava.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 56
(rels_to_arg_) java.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 60
let is_field_i_dependent env sigma cnstr i = let constructor_type = e_type_of_constructor env sigma cnstr in let ind_n_params = inductive_nparams env (fst (fst cnstr)) in let (_, (_, field_type), _) = get_ith_arg sigma (i + ind_n_params) constructor_type in not (Vars.noccur_between sigma 1 (i - 1) field_type)
(*this builds a projection in the simply typed case*) let build_simple_projection (rel_term_to_compose openin let ci = (snd (fst cnstr) Some ,.i-1,)) let body = Combinators.make_selector env sigma ~pos:ci ~special ~ - letidId "
mkLambda (make_annot (Name id) ERelevance.relevant, java.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 31
let (let*) m f = match (rel_f) >
| Noneletenv_f)= in
> java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15
(*find a composition to form a given term by extracting from given terms*) letfind_term_composition sigma argindex ind env_ind_args (*first we need to get some information about the inductive type*) let env_ind_n_params irel_arg letletarg_composition env env_args()in
_type,rel_field_rest= sigmaargindex) in let (rel_target_context, rel_target_type) arg_composition
java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18 let (_, rel_args) = decompose_appjava.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
) . in (*the actual recursive search for the term_composition*) let
(
Some java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40 elsematch find_arg env let find (i, term_to_extract_from) =
| Some (i, extraction) ->
Some (FromParameter (env_term_to_compose, env_ind_params.(i-1), i, extraction))
| None -> beginmatch find_arg env sigma rel_term_to_compose rel_ind_args env_ind_args with
(i )->
Some (FromIndex (env_term_to_compose, i, extraction))
| NoneSomei ,) beginin
let (env_f,env_args) = decompose_app sigma env_term_to_compose in let* |Seq(x,) - if Array.length env_args|None seq_find_map
None else let* args_compositions =
(Arrayto_seqi) letmapirel_arg= let = sigma env_args( java.lang.StringIndexOutOfBoundsException: Index 99 out of bounds for length 99 match arg_composition with
Some - java.lang.StringIndexOutOfBoundsException: Index 59 out of bounds for length 59
- in
Some. map) - java.lang.StringIndexOutOfBoundsException: Index 81 out of bounds for length 81 in
Some (Composition ( *(,) env in
>java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19 end - None
nd
(*finds the first argument from which a term can be extracted*) and find_arg env projectability_testenv cnstrargindex ind ind_args= letfind (i, term_to_extract_fromletdependentis_field_i_dependent sigma argindexin let* r = find_term_extraction env sigma term_to_extract term_to_extract_from
( 1 ) in let rec seq_find_map xs = match xs() match java.lang.StringIndexOutOfBoundsException: Range [26, 27) out of bounds for length 26
| SeqNil>None
| Seq.Cons(x,xs) -> matchfindxwith
| None matchextractionwith
- rel_term_to_extract_from in
seq_find_map (Arrayto_seqiterms_to_extract_from)
(*finds the term_extraction for a given term*) and find_term_extraction env sigma term_to_extract term_to_extract_from type_of_term_to_extract_from =
eq_constr_nounivs then
Some =constructor_nrealargs in else .kind with
(f )- beginmatch EConstr.let_ )= Typing sigma in
| Construct c -> let (_, env_args) = decompose_app sigma type_of_term_to_extract_from in let* (i, extraction_result) = find_arg env sigma term_to_extract args env_args in
SomeCombinators env pos default match_type end | _ -> None in find_term_composition_rec env sigma rel_field_type_lifted env_field_type
(*tests if a field is projectable and returns the type_composition if it is*)
projectability_testenv argindexfield_type ind_params java.lang.StringIndexOutOfBoundsException: Index 85 out of bounds for length 85 let ependentis_field_i_dependent sigma cnstr argindex in if dependent then let composition = let type_to_extract_from = ind_params.( in matchwith
| (* type to compose, indec term to extract from, index (1 based) index to compose from, extraction for the given type *)
- java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28 else build_term_extraction mkRel()) extraction
(*builds the term of a given term_extraction*) let rec build_term_extraction(* (f type to compose, composition for f), array of (arg type to compose, composition for arg)*) match extraction let f_extraction_term = build_term_composition env sigma f_composition ind_params n_ind_params ind_args n_ind_args in
| Id -> rel_term_to_extract_from
java.lang.StringIndexOutOfBoundsException: Index 191 out of bounds for length 191
|mkApp, ) let cnstr_n_args let special=build_term_extraction sigma mkRelcnstr_n_args-index-1) env_next_term_to_extract_fromnext_extraction let pos = snd cnstr in let_ ) . java.lang.StringIndexOutOfBoundsException: Index 78 out of bounds for length 78
Combinators sigmapos ~ rel_term_to_extract_from
(*builds the term of a given term_composition*) let recContext (.mk_name(. si)r match (* type to compose *)
FromEnv env_type_to_compose> (* type to compose, parameter term to extract from, index (1 based) of parameter, extraction for the given type*)
| (,env_parameter_to_extract_from,) > let type_to_extract_from = ind_params.(parameter_index-1 =.length java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42
build_term_extraction env sigma ) .check_privacy ind | FromIndex (env_type_to_compose, index_index, extraction) -> let type_to_extract_from = ind_args.(index_index-1) in build_term_extraction env sigma env_type_to_compose (mkRel (n_ind_args-(index_index-1))) type_to_extract_from extraction
(* (f type to compose, composition for f), array of (arg type to compose, composition for arg)*)
| in let = env ind_params n_ind_args letmap arg_composition = build_term_composition i= let =Array mapin
mkApp =match_indicesenv cstrs.) n_ind_args in
(*replaces all rel variables corresponding to indices in a match statment with the index definition in the inductive definition*) let match_indices env sigmamkLambda(.make_annot NameAnonymous ERelevance.relevant matched_template Varslift1special) let rec replace_rec n t = match EConstr.kind sigma t with
| els
i < _ind_args+n& java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
cnst_summary.n_ind_args-i else t
|- . sigmafunn -> +1) replace_rec t in
EConstr. sigma ( n - n1 0 term_to_match
java.lang.StringIndexOutOfBoundsException: Range [23, 3) out of bounds for length 31
. Name Nameopsmake_ident ) java.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62
(*makes a match statement where the index variables in the branches get replaced by the index definitions inside the inductive definition*) let env~ special(,ind_args = let n_ind_argslet =Vars 1 ( let indt = IndType (ind_fam, ind_args) in
l (ind )_ java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45 let)=. env n let let (,[|) java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53 let =make_arity_signature env sigma trueind_fam in
java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 6 let cstrs get_constructors envind_famjava.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45 let build_branchletbuild_projection sigma let max_free_rel = Option(*1 based index of the field to project counted from left without induction params*) letspecial letendpt f constructor that gettingprojected)
mkLambdalet (ind_familyind_args java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37 else
mkLambda (make_annot_numbered "t" None ERelevance.relevant, matched_template, mkRel 1) in let let (indind_params=dest_ind_family in
endptargs in let brl = List.map build_branch(CList.interval 1 (Array. let proj_result = projectability_test env sigma cnstrind. ) Array ) java.lang.StringIndexOutOfBoundsException: Index 134 out of bounds for length 134
let ci = , p
make_case_or_project sigma ci(p, ) c (.of_listbrl
(*builds a projection in the dependently typed case where a term_composition was found for the fields type*) let build_dependent_projection_with_term_composition env sigma cnstr default special argty term_composition ((ind, ind_params) as ind_fam) ind_args = let n_ind_params = List.length ind_params in let n_ind_args = List.length ind_args in let composition_type_template = build_term_composition env sigma term_composition (Array.of_list ind_params) n_ind_params (Array.of_list ind_args) n_ind_args in let return_type = Vars.lift 1 (
mkProd (Context.make_annot Name.Anonymous ERelevance.relevant, composition_type_template, Vars.lift 1 composition_type_template)
) in let e_match = make_selector_match_indices env sigma ~pos:(snd (fst cnstr)) ~special (mkRel 1) (make_ind_family ind_fam, ind_args) return_type composition_type_template in let match_default = mkApp (e_match, [|default|]) in let proj = mkLambda (make_annot_numbered "e" None ERelevance.relevant, argty, match_default) in
proj
(*checks the projectability of the given field and builds the according projection. If the field is found to be NotProjectable the simply typed projection generation is tried*) let build_projection env sigma
cnstr (*constructor that is getting projected*)
argindex (*1 based index of the field to project counted from left without induction params*)
field_type (*type of the field that gets projected*)
default (*p.p_lhs so the thing inside the constructor*)
special (*Rel (nargs-argind+1) so the debrujin index of the field to project directly after binding*)
argty (*type of the constructor term that is getting projected*) = let IndType (ind_family,ind_args) = try find_rectype env sigma argty with Not_found ->
CErrors.user_err
Pp.(str "Cannot discriminate on inductive constructors with \
dependent types.") in let (ind, ind_params) = dest_ind_family ind_family in let cnstr = (fst cnstr, EInstance.make (snd cnstr)) in let proj_result = projectability_test env sigma cnstr argindex field_type ind (Array.of_list ind_params) (Array.of_list ind_args) in match proj_result with
| Simple | NotProjectable -> let p = build_simple_projection env sigma argty cnstr special default in
sigma, p
| Dependent_Extractable type_composition -> let p = build_dependent_projection_with_term_composition env sigma cnstr default special argty type_composition (ind, ind_params) ind_args in
sigma, p
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.