Inductive empty :=. Inductive emptyt : Type :=. Inductivesingleton : Type :=
single. Inductive singletoninfo : Type :=
singleinfo : unit -> singletoninfo. Inductive singletonset : Set :=
singleset.
Inductive singletonnoninfo : Type :=
singlenoninfo : empty -> singletonnoninfo.
Inductive singletoninfononinfo : Prop :=
singleinfononinfo : unit -> singletoninfononinfo.
Inductive bool : Type :=
| true | false.
Inductive smashedbool : Prop :=
| trueP | falseP.
Section foo. Let T := Type. Inductive polybool : T :=
| trueT | falseT. End foo.
Inductive list (A: Type) : Type :=
| nil : list A
| cons : A -> list A -> list A.
Module ftypSetSet. Inductive ftyp : Type :=
| Funit : ftyp
| Ffun : list ftyp -> ftyp
| Fref : area -> ftyp with area : Type :=
| Stored : ftyp -> area
. End ftypSetSet.
Module ftypSetProp. Inductive ftyp : Type :=
| Funit : ftyp
| Ffun : list ftyp -> ftyp
| Fref : area -> ftyp with area : Type :=
| Stored : (* ftyp -> *)area
. End ftypSetProp.
Module ftypSetSetForced. Inductive ftyp : Type :=
| Funit : ftyp
| Ffun : list ftyp -> ftyp
| Fref : area -> ftyp with area : Set(* Type *) :=
| Stored : (* ftyp -> *)area
. End ftypSetSetForced.
Unset Universe Polymorphism.
Set Printing Universes. Module Easy.
Polymorphic Inductive prod (A : Type) (B : Type) : Type :=
pair : A -> B -> prod A B.
Check prod nat nat. Print Universes.
Polymorphic Inductive sum (A B:Type) : Type :=
| inl : A -> sum A B
| inr : B -> sum A B. Print sum. Check (sum nat nat).
End Easy.
Section Hierarchy.
Definition Type3 := Type. Definition Type2 := Type : Type3. Definition Type1 := Type : Type2.
Definition id1 := ((forall A : Type1, A) : Type2). Definition id2 := ((forall A : Type2, A) : Type3). Definition id1' := ((forall A : Type1, A) : Type3).
Fail Definition id1impred := ((forall A : Type1, A) : Type1).
End Hierarchy.
Record hypo : Type := mkhypo {
hypo_type : Type;
hypo_proof : hypo_type
}.
Definition typehypo (A : Type) : hypo := {| hypo_proof := A |}.
Polymorphic Record dyn : Type :=
mkdyn {
dyn_type : Type;
dyn_proof : dyn_type
}.
Definition monotypedyn (A : Type) : dyn := {| dyn_proof := A |}.
Polymorphic Definition typedyn (A : Type) : dyn := {| dyn_proof := A |}.
Fail Definition morec@{i j|} (A : Type@{i}) : Type@{j} := A.
(* By default constraints are extensible *)
Polymorphic Definition morec@{i j} (A : Type@{i}) : Type@{j} := A. Check morec@{_ _}.
(* Handled in proofs as well *) Lemma bar@{i j | } : Type@{i}. exactType@{j}.
Fail Defined. Abort.
Fail Lemma bar@{u v | } : let x := (fun x => x) : Type@{u} -> Type@{v} in nat.
Fail Fixpoint fbar@{u v | } (n:nat) : let x := (fun x => x) : Type@{u} in nat.
#[universes(polymorphic)] Section cats. LocalSet Universe Polymorphism. Definition fibration (A : Type) := A -> Type. Definition Hom (A : Type) := A -> A -> Type.
Record sigma (A : Type) (P : fibration A) :=
{ proj1 : A; proj2 : P proj1} .
Class Identity {A} (M : Hom A) :=
identity : forall x, M x x.
ClassInverse {A} (M : Hom A) := inverse : forall x y:A, M x y -> M y x.
Class Composition {A} (M : Hom A) :=
composition : forall {x y z:A}, M x y -> M y z -> M x z.
Notation"g ° f" := (composition f g) (at level 50).
Class Equivalence T (Eq : Hom T):=
{
Equivalence_Identity :: Identity Eq ;
Equivalence_Inverse :: Inverse Eq ;
Equivalence_Composition :: Composition Eq
}.
Class EquivalenceType (T : Type) : Type :=
{
m2: Hom T;
equiv_struct :: Equivalence T m2 }.
Polymorphic Record cat (T : Type) :=
{ cat_hom : Hom T;
cat_equiv : forall x y, EquivalenceType (cat_hom x y) }.
Definition catType := sigma Type cat.
Notation"[ T ]" := (proj1 T).
From Corelib.ProgramRequireImport Basics Tactics Wf.
ProgramDefinition small_cat : cat Empty_set :=
{| cat_hom x y := unit |}.
Next Obligation.
refine ({|m2:=fun x y => True|}).
constructor; red; intros; trivial. Defined.
Record iso (T U : Set) :=
{ f : T -> U;
g : U -> T }.
ProgramDefinition Set_cat : cat Set :=
{| cat_hom := iso |}.
Next Obligation.
refine ({|m2:=fun x y => True|}).
constructor; red; intros; trivial. Defined.
Record isoT (T U : Type) :=
{ isoT_f : T -> U;
isoT_g : U -> T }.
ProgramDefinition Type_cat : cat Type :=
{| cat_hom := isoT |}.
Next Obligation.
refine ({|m2:=fun x y => True|}).
constructor; red; intros; trivial. Defined.
Polymorphic Record cat1 (T : Type) :=
{ cat1_car : Type;
cat1_hom : Hom cat1_car;
cat1_hom_cat : forall x y, cat (cat1_hom x y) }. End cats.
Polymorphic Definition id {A : Type} (a : A) : A := a.
Definition typeid := (@id Type).
Fail Check (Prop : Set).
Fail Check (Set : Set). Check (Set : Type). Check (Prop : Type). Definition setType := ltac:(let t := type of Set in exact t).
Definition foo (A : Prop) := A.
Fail Check foo Set. Checkfun A => foo A.
Fail Checkfun A : Type => foo A. Checkfun A : Prop => foo A.
Fail Definition bar := fun A : Set => foo A.
Fail Check (let A := Type in foo (id A)).
Definition fooS (A : Set) := A.
Check (let A := nat in fooS (id A)).
Fail Check (let A := Set in fooS (id A)).
Fail Check (let A := Prop in fooS (id A)).
(* Some tests of sort-polymorphisme *)
#[universes(polymorphic)] Section S.
Polymorphic Variable A:Type. (* Definition f (B:Type) := (A * B)%type.
*)
Polymorphic Inductive I (B:Type) : Type := prod : A->B->I B.
Check I nat.
End S. (* Check f nat nat : Set.
*) Definition foo' := I nat nat. Print Universes. Print foo. Set Printing Universes. Print foo.
(* Polymorphic axioms: *)
Polymorphic Axiom funext : forall (A B : Type) (f g : A -> B),
(forall x, f x = g x) -> f = g.
(* Check @funext. *) (* Check funext. *)
Polymorphic Definition fun_ext (A B : Type) := forall (f g : A -> B),
(forall x, f x = g x) -> f = g.
Polymorphic Class Funext A B := extensional : fun_ext A B.
Section foo2.
Context `{forall A B, Funext A B}. Print Universes. End foo2.
Module eta. Set Universe Polymorphism.
Set Printing Universes.
Axiom admit : forall A, A.
Record R := {O : Type}.
Definition RL (x : R@{i}) : ltac:(let u := constr:(Type@{i}:Type@{j}) in exact (R@{j}) ) := {|O := @O x|}. Definition RLRL : forall x : R, RL x = RL (RL x) := fun x => eq_refl. Definition RLRL' : forall x : R, RL x = RL (RL x). intros. apply eq_refl. Qed.
End eta.
Module Hurkens'. RequireImport TestSuite.hurkens.
Polymorphic Record box (X : Type) (T := Type) : Type := wrap { unwrap : T }.
Definition unwrap' := fun (X : Type) (b : box X) => let (unw) := b in unw.
Fail Definition bad : False := TypeNeqSmallType.paradox (unwrap' Type (wrap _ Type)) eq_refl.
End Hurkens'.
Module Anonymous. Set Universe Polymorphism.
Definition defaultid := (fun x => x) : Type -> Type. Definition collapseid := defaultid@{_ _}. Check collapseid@{_}.
Definition anonid := (fun x => x) : Type -> Type@{_}. Check anonid@{_}.
Definition Z : box@{i1 j1 k1} V := {| unwrap := V |}. Definition Z' : singleset. Lemma ZZ:@ (box{i2 j2k2V)ZZ. Proof. Set Printing. SetPrinting Universes.
. reflexivity. Qed.
End test_letin_subtyping
ModuleObligationRegression (** Test for a regression encountered when fixing obligations for
stronger restriction of universe context. *) RequireImport CMorphisms| nil | cons : A -> list A -> list A. Check trans_co_eq_inv_arrow_morphism@{_ _ _ _ _ _ _}. End ObligationRegression.
Axiom poly@{i}Inductive ftyp | | Ffun : list ftyp | Fref : area -> ftyp
java.lang.StringIndexOutOfBoundsException: Range [22, 10) out of bounds for length 41 Definitioncheck : nonpoly@{}.
Module.
LocalSet Universe Polymorphism. ProgramFixpoint f@{u} (A:Type@{u}) (n:nat) : Type@{u} := matchn with =>A |Sn = f (>A) n end Check f@{Set}. (* Check that it depends on only one universe *)
End ProgramFixpoint Easy
Module EarlyPolyUniverseDeclarationCheck.
LocalSet Universe Polymorphism.
Check nat.
DefinitionPolymorphic sum(A B:Type) : Type := exact (match n with 0 => nat | _ => natend. Defined.
Fixpoint f'@{} (A::Type@{u}) (n:nat :Typeu} :java.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 60 SectionHierarchy
NextObligationexactnat. Defined.
LocalSetUniverse. ProgramFixpoint'@{}(:Typeu} (nnat{measure n}:Type}:java.lang.StringIndexOutOfBoundsException: Index 73 out of bounds for length 73
atchwith 0 =>_| S n = f'(>A) n end
Next Obligation. Show. exact nat. Defined.
Next Obligation ShowAdmitted.
End EarlyPolyUniverseDeclarationCheck.
Module hypo : Type mkhypo
LocalUnset Polymorphism.
nition f@{u} n :matchnreturn@{v} with=> Type@{u} | _=>Type}end
dyn_type : Type Definition f@{u v} n :matchType@{v} with = Typeu |_ =>Typeu}end exact (matchwith= nat = nat). Defined.
Fail Fixpoint f'@{}(A:Type@{u})(:) : Type{u}:= (* By convention, we require extensibility for Program *) match n with 0 => _
ProgramFixpoint f'@u} A:Type@{u}) (n:) : Type{u} := match n with 0 => _ | S n => f' (A->A) n end.
Next Obligation. exact nat. Defined.
Fail f''@{u} (:Typeu} n:nat{measure : Typeu}:=
n with =>_|Sn= f'(>A) n end.
Fail ProgramFixpoint f''@{u} (A:Type@{u}) (n:nat) {measure n} : Type@{u} := (* By convention, we require extensibility for Program *)Polymorphic twoprojsd dyn: dyn_proof d = dyn_proof. match
Program @{i j | i <j,i <j ( : Typei) :Type}java.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 64 match n with 0 => _ | S n => f'' (java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 8
Next Obligation. Show. exactnatDefined
java.lang.StringIndexOutOfBoundsException: Range [23, 6) out of bounds for length 34
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.