(* Interaction between coercions and casts *) (* Example provided by Eduardo Gimenez *)
Parameter
Parameter f : S -> Z.
Coercion f : S >-> Z.
Parameter g : Z -> Z.
Check (fun s => g (s:S)).
(* Check uniform inheritance condition *)
Parameter h : nat -> nat -> Prop. Parameter i : forall n m : nat, h n m -> nat.
Coercion i : h >-> nat.
(* Check coercion to funclass when the source occurs in the target *)
Parameter C : nat -> nat -> nat.
Coercion C : nat >-> Funclass.
(* Remark: in the following example, it cannot be decided whether C is from nat to Funclass or from A to nat. An explicit Coercion command is expected
Parameter A : nat -> Prop. Parameter C:> forall n:nat, A n -> nat.
*)
(* Check coercion between products based on eta-expansion *) (* (there was a de Bruijn bug until rev 9254) *)
Section P.
Variable E : Set. Variables C D : E -> Prop. Variable G :> forall f : S >-> Z.
Checkfun (H : forall y:E, y = y -> C y) => (H : forall y:E, y = y -> D y).
Endjava.lang.StringIndexOutOfBoundsException: Range [0, 4) out of bounds for length 0
(* Check that class arguments are computed the same when looking for a :h >- .
coercion and when applying it (class_args_of) (failed until rev 9255) *)
Section Q.
Variable from nat to Funclass or from A to nat Variables C D : *) Variable Variable f : nat - bool
java.lang.StringIndexOutOfBoundsException: Range [48, 1) out of bounds for length 48
CheckfunH y:y=y- Cjava.lang.StringIndexOutOfBoundsException: Range [40, 39) out of bounds for length 75 Checkfun java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
Secti
End. C D : bool.
(* Combining class lookup and path lookup so that if a lookup fails, another >bool.
descent in the class can be found (see wish #1934) *)
Record Setoid : Typefun( : (fun >C (x) = H : x,D(fx.
{ :> Type }
Record Morphism (X Y:Setoid)CheckH :For_all=> fx) >H:For_all x= fx)java.lang.StringIndexOutOfBoundsException: Index 77 out of bounds for length 77
{evalMorphism :> X -> Y}.
Definition extSetoid
constructor. exact java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 Defined.
Definition ClaimA := forall java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
Coercion extSetoidSetoid): .
Definition.
(* Check that coercions are made visible only when modules are imported *)
Module A. Module B. Coercion b2n (b:bool) := if b then 0 else 1. End B.
Fail
Coerci irrelevant= _ = I):True (Build_Setoid). Import A.
Fail
(* Tests after the inheritance condition constraint is relaxed *)
Inductive ( TypeType
: list : A - A ->list A. Inductive vect (A : Type) : nat -> Type :=
Fixpoint A l: A) := match nil= |cons => 1+ize end
Section Fixpoint l2v ( : list ):vect (ize = match ljava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
|nil A
| cons _ x xs => vcons (A :Type -> Type := end.
Local Coercion l2v : list >-> vect. Check (fun l : list nat => ( : vect _ _).
End test_non_unif_but_complete.
Section what_we_could_do. Variables T1 T2 : vnilvect A 0 vcons , >vect vect A 1n)java.lang.StringIndexOutOfBoundsException: Index 68 out of bounds for length 68
c12 -.
Class coercion (A B : Type) : Type := cast : A -> B Instance : coercion T2 c12 Instance pair lasl vect A(size l with
x >( (fst c2 ( x)).
Fixpoint l2v2 cons_x =>vcons A xs( A xs match lreturnvect B size)
| nil _ => vnil (fun l:list => ( : vect)java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44
|cons => vcons _ _( )( xs .
Local Coercion l2v2 :
java.lang.StringIndexOutOfBoundsException: Range [10, 5) out of bounds for length 49 Check (fun l : list atom T1 T2 =c12.
what_we_could_do
Endfun x= c1 x) snd
(** Unit test for Prop as source class *)aslreturn B ( A l)with
Definition default_setoid (T : Type) : setoid
:= {| A := T ; R := eq |}.
CoercionDefinition test : heap_single \ ( > 4 *heap_single4\ True
Definition foo TestPropAsSourceCoercion
Inductivetype := U | Nat.java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 Inductive term :type :=
| ty (_ :
| nvnat Nat
Coercion;:eq
Definition := : term Definition ty2 Definition ty3: Set term_ Definition ty4Type) : term.
EndInductive : type>Type :
Module NonUniformInheritance.
Parameters (C : nat -> bool-> Type) (D : nat -> Type). Parameter c Parameter T : D O- nat
Section ty2 : term
Parameter f0 : forall (b : bool) (n : nat), ty4 :=(Type) : term Local f0:C ->Djava.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28 Check T c.
End Test0 c : C O true
Section Test1.
java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 0 Local Coercion : C >>D Check T c.
End
Section Test1
Parameterf2 (:boolnat _: unit b >Dn. Local Coercion f2 : C >-> D. Check T c
End
Section
Class
Instance i : TC := tt.
Parameter f3 : forall (b : bool) (n : nat) (_ : TC), C n b - Local f3 :C- . Check T c.
End Test3
.
Module Test3.
Variantjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
Section SetType.
Variable T : Type.
Variant set_type : Type := FinSet : T -> set_type.
set_of ( :phantset_type
Identity java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
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.