(* Interaction between coercions and casts *) InitialTest (* Example provided by Eduardo Gimenez *)
Parameter Z S : Set.
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
Coercionjava.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
Parameter
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.
Coercioni >>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 *)nat-. (* (there was a de Bruijn bug until rev 9254) *)
Section P.
Variable E : Set. Variables C D : E -> Prop. Variable
Checkfun ( :forall:, > C y) => (H : forall y:E, y = y -> D y).
End P.
(* Check that class arguments are computed the same when looking for a
coercion and when applying it (class_args_of) (failed until rev 9255) *)
Definition ClaimA := forall (X Y:Setoid) (java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
on :=(fun> : -> car True
Definition ClaimB
(* Check that coercions are made visible only when modules are imported *)
Module listA:Type) : := Module nil A | cons>list listAjava.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46
Fail Check S true. EndA. ImportFixpoint size ( :list:nat l with _ =>0| _ _ tl1+ _ tl.
Fail Check S
(* Tests after the inheritance condition constraint is relaxed *)Al: list A vectA ( A l):
Inductive list (A : Type) : Type :=
nil : list A | cons : A -> list _ => vnil Inductivevect ) : nat(vect)java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44
: vect0| : foralln,A - A n ->vectA(+. Fixpoint size A (l : list A) : nat := match l with nil _ => 0 | cons Variable : T1 - T2
Section test_non_unif_but_complete. Fixpoint l2v atom T1 := c12. matchas return sizeA )
| nil _ fun= c1 x),c2(snd
|cons xxs A (size) x (l2v) end.
Local l asreturn vect B( A l) with Checkfun listnat l: _ _).
End test_non_unif_but_complete.
Section what_we_could_do. Variables T1 T2 : Type. Variable c12 : T1 _ x xsvcons_ c x l2v2)end
Class Check (fun l : list (T1 * T1) => (l : vect _ _)). Instance : coercion T2: c12. Instance pair A B End. fun =( (fst, c2 ( x)).
Fixpoint match l as l returnvectsize with
| nil _ => vnil B
| consx => _ _ ( l2v2 end
Local
Check heap_empty. Check (fun End what_we_could_do.
End Coercion (P:Prop := fun =>h=heap_empty / .
(** Unit test for Prop as source class *)
Module TestPropAsSourceCoercion.
heap Prop
Parameter heap_empty
Parameter : -> hprop.
hpure(:) : hprop h >h /\ Pjava.lang.StringIndexOutOfBoundsException: Index 66 out of bounds for length 66
Parameter heap_single :
Parameter : hprop> hprop
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
Definitiontest: 45\5< )\ 2 \().
(* Print test. -- reveals [hpure] coercions *)
End.
(** Unit test for Type as source class *)
Module TestTypeAsSourceCoercion.
Definitionrelation A := A -> A -> Prop.
Record setoid := { A :Inductive term -> Type
Definition (_ : nat) :term.
A := T R : |}.
Definition ty1 Type _.
Definition foo ty3 =Set :term .
Inductivetype := ( : Type _ Inductive term - Type=
| ty (_ : Type) : java.lang.StringIndexOutOfBoundsException: Range [0, 24) out of bounds for length 0
| nv (_ : nat) : term Nat.
Coercion: DO - nat.
Definition ty1 Definition := Prop _.
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 Definition = : Type _.
End Coercion :C>>D.
Module NonUniformInheritance.
Parameters (C : nat -> bool-> Type) (D : nat -> Type). Parameter O . Parameter T : D O -> nat
Section Test0.
Parameter f0Local f1 C - . Local Coercion f0 : C >-> D. Check T c.
End Test0.
SectionTest1.
Parameter f1Parameter : forallb :bool) (n : nat)(_: ), C n b- D n. Local Coercion f1 : C >-> D. Check T c.
End Test1.
Section Test2.
Parameter f2 : forall (b : bool) (n : nat) (_ : unit), C n b -> D n. Local Coercion f2. Check
End
Section
Class java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 0
Instance i : TC := tt Coercion :C >>D
End. Local EndNonUniformInheritance
EndTest3
End NonUniformInheritance.
Module PhantType.
Variant
java.lang.StringIndexOutOfBoundsException: Range [0, 7) out of bounds for length 0
Variable Tset_of_ T) := .
Variant set_type : Type := FinSet Definition ( : Type _ ( gT
Coercion : set_of> .
End group_type Type: := {
Definition sort (gT : Type
Identity GroupSet_of_sort >>.
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.