type-theory

How to define a subformula of an inductively defined type in Agda?

强颜欢笑 提交于 2021-01-29 08:11:22
问题 I'm trying to define a simple predicate to determine if a formula is a subformula of a given formal over a simple inductively defined syntax. I'm running into a few, presumably simple, problems. (i) I'd rather use a parameterized module with a given type A. How can one import the information that A is a set, in the sense that A has decideable equality? If this can't be done, what are some workarounds? This is why I have Nat instead. (ii) Is the t1 ≡ (t2 // t3) (and similairly defined)

Function which generically takes a type and returns the same type

你说的曾经没有我的故事 提交于 2020-01-20 19:42:05
问题 I am having a tough time understanding why the Scala compiler is unhappy about this function definition: def trimNonWordCharacters[T <: Iterable[String]](items: T): T = items map { _.replaceAll("\\W", "") } Here is the REPL output: scala> def trimNonWordCharacters[T <: Iterable[String]](items: T): T = items map { _.replaceAll("\\W", "") } <console>:5: error: type mismatch; found : Iterable[java.lang.String] required: T def trimNonWordCharacters[T <: Iterable[String]](items: T): T = items map

What is an Isabelle/HOL subtype? What Isar commands produce subtypes?

橙三吉。 提交于 2020-01-10 02:53:24
问题 I'd like to know about Isabelle/HOL subtypes. I explain a little about why it's important to me in my partial answer to my last SO question: Trying to Treat Type Classes and Sub-types Like Sets and Subsets Basically, I only have one type, so it might be useful to me if I could exploit the power of HOL types through subtypes. I've done searches in the Isabelle documentation, on the Web, and on the Isabelle mailing lists. The word "subtype" is used, though not much, and it seems like it's not a

Self-representation and universes in OTT

老子叫甜甜 提交于 2020-01-02 07:16:09
问题 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 α)

Singleton types in Haskell

删除回忆录丶 提交于 2019-12-31 09:11:22
问题 As part of doing a survey on various dependently typed formalization techniques, I have ran across a paper advocating the use of singleton types (types with one inhabitant) as a way of supporting dependently typed programming. Acording to this source, in Haskell, there is a separation betwen runtime values and compile-time types that can be blurred when using singleton types, due to the induced type/value isomorphism. My question is: How do singleton types differ from type-classes or from

What is predicativity?

爷,独闯天下 提交于 2019-12-28 08:08:22
问题 I have pretty decent intuition about types Haskell prohibits as "impredicative": namely ones where a forall appears in an argument to a type constructor other than -> . But just what is predicativity? What makes it important? How does it relate to the word "predicate"? 回答1: Let me just add a point regarding the "etymology" issue, since the other answer by @DanielWagner covers much of the technical ground. A predicate on something like a is a -> Bool . Now a predicate logic is one that can in

Universal quantification in generic function type

白昼怎懂夜的黑 提交于 2019-12-21 21:18:11
问题 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

Kind vs Rank in type theory

跟風遠走 提交于 2019-12-20 12:36:11
问题 I'm having a hard time understanding Higher Kind vs Higher Rank types. Kind is pretty simple (thanks Haskell literature for that) and I used to think rank is like kind when talking about types but apparently not! I read the Wikipedia article to no avail. So can someone please explain what is a Rank? and what is meant by Higher Rank? Higher Rank Polymorphism? how that comes to Kinds (if any) ? Comparing Scala and Haskell would be awesome too. 回答1: The concept of rank is not really related to

Why do we need containers?

拜拜、爱过 提交于 2019-12-20 09:23:15
问题 (As an excuse: the title mimics the title of Why do we need monads?) There are containers (and indexed ones) (and hasochistic ones) and descriptions. But containers are problematic and to my very small experience it's harder to think in terms of containers than in terms of descriptions. The type of non-indexed containers is isomorphic to Σ — that's quite too unspecific. The shapes-and-positions description helps, but in ⟦_⟧ᶜ : ∀ {α β γ} -> Container α β -> Set γ -> Set (α ⊔ β ⊔ γ) ⟦ Sh ◃ Pos

Difference between type parameters and indices?

感情迁移 提交于 2019-12-17 06:37:19
问题 I am new to dependent types and am confused about the difference between the two. It seems people usually say a type is parameterized by another type and indexed by some value . But isn't there no distinction between types and terms in a dependently typed language? Is the distinction between parameters and indices fundamental? Can you show me examples showing difference in their meanings in both programming and theorem proving? 回答1: When you see a family of types, you may wonder whether each