type-theory

Proof in COQ that equality is reflexivity

假装没事ソ 提交于 2019-12-12 18:28:34
问题 The HOTT book writes on page 51: ... we can prove by path induction on p: x = y that $(x, y, p) =_{ \sum_{(x,y:A)} (x=y)} (x, x, refl x)$ . Can someone show me how to proof this in COQ? Remarks: Sorry that I do not know how to render latex code here. That is not homework. 回答1: Actually, it is possible to prove this result in Coq: Notation "y ; z" := (existT _ y z) (at level 80, right associativity). Definition hott51 T x y e : (x; y; e) = (x; x; eq_refl) :> {x : T & {y : T & x = y} } := match

Modeling System F's parametric polymorphism at Set₀

三世轮回 提交于 2019-12-11 12:13:29
问题 In System F, the kind of a polymorphic type is * (as that's the only kind in System F anyway...), so e.g. for the following closed type: [] ⊢ (forall α : *. α → α) : * I would like to represent System F in Agda, and because everything is in * , I thought I'd interpret types (like the above) as Agda Set s; so something like evalTy : RepresentationOfAWellKindedClosedType → Set However, Agda doesn't have polymorphic types, so the above type, in Agda, would need to be a (large!) Π type: idType =

Is Z.le as defined in the standard library proof irrelevant?

对着背影说爱祢 提交于 2019-12-10 20:16:41
问题 In the Coq standard library, there is an enumerated type called comparison with three elements Eq,Lt,Gt . This is used to define the less-than or less-than-or-equal operators in ZArith : m < n is defined as m ?= n = Lt and m <= n is defined as m ?= n <> Gt . By virtue of Hedberg's theorem ( UIP_dec in the standard library) I can prove that < is proof-irrelevant, but I run into issues when it comes to <= , since it is defined negatively. I find this particularly annoying, since if <= were

How to make these dynamically typed functions type-safe? [closed]

試著忘記壹切 提交于 2019-12-09 05:27:53
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 4 years ago . Is there any programming language (or type system) in which you could express the following Python-functions in a statically typed and type-safe way (without having to use casts, runtime-checks etc)? #1 : # My function - What would its type be? def Apply(x): return x(x) # Example

What is the correct term for _ in a type hint?

江枫思渺然 提交于 2019-12-08 15:53:49
问题 In type hints in Rust it is possible to use partial types in annotations like this: let myvec: Vec<_> = vec![1, 2, 3]; What is the correct terminology for the underscore in the partial type annotation? I'm interested in both the Rust terminology as well as more academic type theory terminology. 回答1: I was able to find a piece of official documentation where the underscore is named in the context of patterns, but I doubt it's a "strict" name: Patterns consist of some combination of literals,

Scala: “Static values” in traits?

烈酒焚心 提交于 2019-12-08 02:43:10
问题 Let's say I have: trait X { val x: String } Using mix-in, I can define a trait such as trait XPrinter { self: X => def printX: String = "X is: " + x } such that a value/object implementing XPrinter implements x and give its methods such as printX access to the values specified in X such as x . So far, so good. I want to know if there is a way of having a trait in the form of: trait XDependent[T <: X] { def printX: String = ??? } So that XDependent instances have access to the value of T.x ,

Scala: “Static values” in traits?

浪尽此生 提交于 2019-12-06 11:04:06
Let's say I have: trait X { val x: String } Using mix-in, I can define a trait such as trait XPrinter { self: X => def printX: String = "X is: " + x } such that a value/object implementing XPrinter implements x and give its methods such as printX access to the values specified in X such as x . So far, so good. I want to know if there is a way of having a trait in the form of: trait XDependent[T <: X] { def printX: String = ??? } So that XDependent instances have access to the value of T.x , with x assumed to be a "static value" glued with the type definition. Now I understand why T.x can't be

Self-representation and universes in OTT

送分小仙女□ 提交于 2019-12-06 02:19:59
The question is about Observational Type Theory . Consider this setting: data level : Set where # : ℕ -> level ω : level _⊔_ : level -> level -> level # α ⊔ # β = # (α ⊔ℕ β) _ ⊔ _ = ω _⊔ᵢ_ : level -> level -> level α ⊔ᵢ # 0 = # 0 α ⊔ᵢ β = α ⊔ β mutual Prop = Univ (# 0) Type = Univ ∘ # ∘ suc data Univ : level -> Set where bot : Prop top : Prop nat : Type 0 univ : ∀ α -> Type α σ≡ : ∀ {α β γ} -> α ⊔ β ≡ γ -> (A : Univ α) -> (⟦ A ⟧ -> Univ β) -> Univ γ π≡ : ∀ {α β γ} -> α ⊔ᵢ β ≡ γ -> (A : Univ α) -> (⟦ A ⟧ -> Univ β) -> Univ γ πᵤ : ∀ {α} -> (A : Univ α) {k : ⟦ A ⟧ -> level} -> (∀ x -> Univ (k x))

Pattern matching in Observational Type Theory

帅比萌擦擦* 提交于 2019-12-04 16:32:05
问题 In the end of the "5. Full OTT" section of Towards Observational Type Theory the authors show how to define coercible-under-constructors indexed data types in OTT. The idea is basically to turn indexed data types into parameterized like this: data IFin : ℕ -> Set where zero : ∀ {n} -> IFin (suc n) suc : ∀ {n} -> IFin n -> IFin (suc n) data PFin (m : ℕ) : Set where zero : ∀ {n} -> suc n ≡ m -> PFin m suc : ∀ {n} -> suc n ≡ m -> PFin n -> PFin m Conor also mentions this technique at the bottom

Universal quantification in generic function type

瘦欲@ 提交于 2019-12-04 16:08:04
Reading the paper on Types and Polymorphism in programming languages, i wondered is it possible to express the similar universal quantification on type members with Scala. Example from the paper: type GenericID = ∀A.A ↦ A Which is a type for generic identity function and the following example in their paper language Fun was correct: value inst = fun(f: ∀a.a ↦ a) (f[Int], f[Bool]) value intId = fst(inst(id)) // return a function Int ↦ Int Is there some way to express the similar thing in Scala? This is not the same as type constructor type GenericId[A] = A => A , cause it's a type operation