dependent-type

Agda: Can't find std-lib when installing with Stack

我的未来我决定 提交于 2020-08-05 06:00:10
问题 I'm trying to compile an Agda file, but I'm having trouble getting it to find the standard library. I've seen the documentation here. I've used Stack to install it: > which agda /home/joey/.local/bin/agda And I've set the environment variable for my Agda directory: > echo $AGDA_DIR /home/joey/.agda Which is populated with the correct files: /home/joey/agda/agda-stdlib/standard-library.agda-lib > cat "$AGDA_DIR"/libraries /home/joey/agda/agda-stdlib/standard-library.agda-lib > cat "$AGDA_DIR"

Mapping enum values to types

混江龙づ霸主 提交于 2020-06-28 05:36:15
问题 The problem Suppose I have some code like this: // Events we might receive: enum EventType { PlaySong, SeekTo, StopSong }; // Callbacks we would handle them with: type PlaySongCallback = (name: string) => void; type SeekToCallback = (seconds: number) => void; type StopSongCallback = () => void; In the API I'm given, I can register such a callback with declare function registerCallback(t: EventType, f: (...args: any[]) => void); But I want to get rid of that any[] and make sure I can't

When using the singleton type feature of Scala shapeless, how to force the compiler to use narrow/singleton type as an implicit parameter?

只愿长相守 提交于 2020-05-14 07:22:05
问题 This is a follow-up of one of my previous questions: In scala shapeless, is it possible to use literal type as a generic type parameter? I'm trying to write scala code for vector multiplication, while using shapeless to make the compiler aware of the dimension of each vector: trait IntTypeMagnet[W <: Witness.Lt[Int]] extends Serializable { def witness: W } object IntTypeMagnet { case class Impl[W <: Witness.Lt[Int]](witness: W) extends IntTypeMagnet[W] {} implicit def fromInt[W <: Int](v: W):

When using the singleton type feature of Scala shapeless, how to force the compiler to use narrow/singleton type as an implicit parameter?

余生颓废 提交于 2020-05-14 07:21:44
问题 This is a follow-up of one of my previous questions: In scala shapeless, is it possible to use literal type as a generic type parameter? I'm trying to write scala code for vector multiplication, while using shapeless to make the compiler aware of the dimension of each vector: trait IntTypeMagnet[W <: Witness.Lt[Int]] extends Serializable { def witness: W } object IntTypeMagnet { case class Impl[W <: Witness.Lt[Int]](witness: W) extends IntTypeMagnet[W] {} implicit def fromInt[W <: Int](v: W):

What is the difference between path-dependent types and dependent types?

允我心安 提交于 2020-05-12 11:50:13
问题 Scala has path-dependent types, but it is said that Scala doesn’t support dependent typing. What is the difference between path-dependent types and dependent types? As far as I understand, path-dependent types are one kind of dependent types. 回答1: A dependent type is a type that depends on a value. A path dependent type is a specific kind of dependent type in which the type depends on a path. I am not sure if the term "path dependent type" exists outside the Scala community. In any case, the

In scala shapeless, is it possible to use literal type as a generic type parameter?

生来就可爱ヽ(ⅴ<●) 提交于 2020-04-13 06:45:09
问题 Assuming that I'm writing a program for vector multiplication. Following the requirement in this article: https://etrain.github.io/2015/05/28/type-safe-linear-algebra-in-scala The multiplication should only compile successfully if the dimension of both vectors are equal. For this I define a generic type Axis that uses a shapeless literal type (the number of dimension) as the type parameter: import shapeless.Witness trait Axis extends Serializable case object UnknownAxis extends Axis trait

Agda: how does one obtain a value of a dependent type?

老子叫甜甜 提交于 2020-01-31 05:52:26
问题 I recently asked this question: An agda proposition used in the type -- what does it mean? and received a very well thought out answer on how to make types implicit and get a real compile time error. However, it is still unclear to me, how to create a value with a dependent type. Consider: div : (n : N) -> even n -> N div zero p = zero div (succ (succ n)) p= succ (div n p) div (succ zero) () Where N is the natural numbers and even is the following proposition. even : N -> Set even zero = \top

Ltac: repeating a tactic n times with backtracking

六眼飞鱼酱① 提交于 2020-01-25 00:37:46
问题 Suppose I have a tactic like this (taken from HaysTac), that searches for an argument to specialize a particular hypothesis with: Ltac find_specialize_in H := multimatch goal with | [ v : _ |- _ ] => specialize (H v) end. However, I'd like to write a tactic that searches for n arguments to specialize a tactic with. The key is that it needs to backtrack. For example, if I have the following hypotheses: y : T H : forall (x : T), x = y -> P x x1 : T x2 : T Heq : x1 = y If I write do 2 (find

An agda proposition used in the type — what does it mean?

好久不见. 提交于 2020-01-23 12:34:51
问题 I am taking this from the "Brutal Introduction to Agda" http://oxij.org/note/BrutalDepTypes/ Suppose we want to define division by two on even numbers. We can do this as: div : (n : N) -> even n -> N div zero p = zero div (succ (succ n)) p= succ (div n p) div (succ zero) () N is the natural numbers and even is the following "proposition" even : N -> Set even zero = \top even (succ zero) = \bot even (succ (succ n)) = even n data \bot : Set where record \top : Set where When you evaluate the

Problems with dependent types in Coq proof assistant

狂风中的少年 提交于 2020-01-14 15:01:27
问题 Consider the following simple expression language: Inductive Exp : Set := | EConst : nat -> Exp | EVar : nat -> Exp | EFun : nat -> list Exp -> Exp. and its wellformedness predicate: Definition Env := list nat. Inductive WF (env : Env) : Exp -> Prop := | WFConst : forall n, WF env (EConst n) | WFVar : forall n, In n env -> WF env (EVar n) | WFFun : forall n es, In n env -> Forall (WF env) es -> WF env (EFun n es). which basically states that every variable and function symbols must be defined