我试图用和编译这个示例。以下是代码:
module hello-world where
open import IO
main = run (putStrLn "Hello, World!")
在使用Agda (agda --compile hello-world.agda)编译时,报告了以下错误:
Unsolved metas at the following locations:
$HOME/hello-world.agda:5,8-11
报告的位置(5,8-11)对应于令牌run。
我没有在Agda和Agda-stdlib问题中找到任何相关信息,也没有在这样或其他
考虑以下(无效) Agda代码 data Example : Example ex → Set where
ex : Example ex 这种类型可以通过以下方式在Agda中有效地写入,利用Agda允许先给定值,再给定义值的特性 exampleex : Set
ex' : exampleex
data Example : exampleex → Set where
ex : Example ex'
exampleex = Example ex'
ex' = ex 这一切都被编译了,Agda正确地知道ex : Example ex 但是,尝试使用模
我在使用字符串可判断性时遇到了问题。首先,我搞不懂为什么在Agda中使用可判断性如此困难,而在Coq中它看起来像黄油一样顺利。当我试图证明这个关于字符串的简单定理时,Agda展开了这个混乱的定义,除非你确切地知道你想要做什么,否则几乎不可能使用它。如何通过模式匹配来处理字符串的可判断性,使定义保持得体? 我正在使用Stump的keep函数,而不是Agda的inspect。 keep : ∀{ℓ}{A : Set ℓ} → (x : A) → Σ A (λ y → x ≡ y)
keep x = ( x , refl )
--first roadblock
eqbStringrefl'
下面是与Data.List.All中的定义类似的定义
open import Data.Vec
data All {α π} {A : Set α} (P : A -> Set π) : ∀ {n} -> Vec A n -> Set π where
[]ₐ : All P []
_∷ₐ_ : ∀ {n x} {xs : Vec A n} -> P x -> All P xs -> All P (x ∷ xs)
All为什么要躺在Set π里
Agda版本2.4.3。
下列Agda代码:
module test where
open import Data.Float
import Relation.Binary.PropositionalEquality as Eq
open Eq using (_≡_)
open Eq.≡-Reasoning using (begin_; _≡⟨⟩_; step-≡; _∎)
postulate
distrib : {m a b : Float} → m * (a + b) ≡ (m * a) + (m * b)
dbg : (m a b : Float) → m * (a + b) ≡ (m * a) +
我在我的windows764位电脑上运行Agda时遇到了问题。我尝试运行以下命令:
cabal install agda
和
cabal install agda-executable
这两个都能用,但我还是不能使用emacs,有人能帮我吗?我试过的一键安装程序,但似乎不起作用,我遇到了这样的抱怨:
C:\agda2\bin\agda2-install.cmd failed.
Code = 1
Incorrect Function
Setup was not completed.
Please correct the problem and run setup again
我正在尝试按照instructions in the docs安装AGDA2.6.1.2,但在运行命令cabal install Agda时,我收到以下错误: src\full\Agda\Utils\Maybe.hs:13:1: error:
Could not load module `Control.Monad.Trans.Maybe'
It is a member of the hidden package `transformers-0.5.6.2'.
Perhaps you need to add `transformers' to
我有以下几点: open import Agda.Builtin.Equality
open import Agda.Builtin.Nat renaming (Nat to ℕ)
open import Agda.Builtin.Sigma
open import Agda.Primitive
_×_ : {n m : Level} (A : Set n) (B : Set m) → Set (n ⊔ m)
X × Y = Σ X (λ _ → Y)
ℕ² : Set
ℕ² = ℕ × ℕ
canonical : ℕ² → ℕ²
canonical (x , 0) = (x , 0
我编写了一个函数来获取除了std中的List的最后一个元素之外的所有内容:
open import Data.List
allButLast : ∀ {a} {A : Set a} → List A → List A
allButLast [] = []
allButLast (x ∷ []) = []
allButLast (x ∷ xs) = x ∷ allButLast xs
为了证明起见,我想用∷ʳ重写这个函数:
allButLast2 : ∀ {a} {A : Set a} → List A → List A
allButLast2 [] = []
all
我不能让agda模式在Aquamacs上工作。我负责macOS塞拉。Agda版本2.5.4和Aquamacs 3.3
下面是我在运行agda模式命令时得到的信息。
agda-mode setup
It seems as if setup has already been performed.
agda-mode locate
/usr/local/Cellar/agda/2.5.4/share/x86_64-osx-ghc-8.4.3/Agda-2.5.4/emacs-mode/agda2.el
agda-mode compile
Symbol's function defi
open import Data.Vec
open import Data.Nat
open import Data.Fin
open import Data.Integer
open import Data.Rational
open import Data.Product
open import Relation.Binary.PropositionalEquality using (_≡_; refl)
Infoset = ℕ
Size = ℕ
Player = ℤ
data GameTree (infoset-size : Infoset → Size) : Set where
我曾尝试实现我的"sprintf“函数(它从一个格式化字符串和许多不同类型的参数构造一个字符串),但是失败了。同样的技术也适用于Idris。 module Printf where
open import Agda.Builtin.List
open import Agda.Builtin.Char
open import Agda.Builtin.String
open import Agda.Builtin.Float
open import Agda.Builtin.Int
data Format : Set where
TChar : Char → Format →
我有一些代码在Haskell中工作,我想把它转换成Agda。
这是Haskell代码
main = do
putStrLn "A string"
putStrLn "second string"
输出结果是
A string
second string
我试着把它转换成Agda:
open import Common.IO
main = do
putStrLn "A string"
putStrLn "second string"
但我只是得到了错误消息
'_>>_ needs to be i
我正在尝试使用 plfa库,但是导入似乎没有正常工作。
我已经克隆了存储库,并将存储库路径添加到:~/.agda/libraries和plfa到~/.agda/defaults。
当我创建一个test.agda文件并检查一行时
module plfa.part1.Naturals where
我收到一个导入错误:
You tried to load /Users/johngfisher/Desktop/agda_test/nats.agda
which defines the module plfa.part1.Naturals. However, according to
the inclu
我用以下代码编写了一个.sh脚本
#!/bin/sh
cd ~/Projects/Agda\ projects/
emacs
但是,每当我启动它时,我都会得到以下错误
File is missing: Cannot open load file, no such file or directory, /bin/bash: agda-mode: command not found
To ensure normal operation, you should investigate and remove the
cause of the error in your initialization
在以下示例中
open import Agda.Builtin.Nat
open import Agda.Builtin.Equality
postulate
f : Nat → Nat
g : ∀{x y} → f x ≡ suc y → Nat
h : Nat → Nat
h x with f x
h x | zero = zero
h x | suc y = g {x} {y} {!refl!}
Agda不接受refl作为参数。
主要的问题是,
我做错了什么?证明这类事情的正确/最佳/确定/首选的方法是什么?
当然,对Agda行为的任何见解都是非常值得赞赏的。
除了在文件系统上使用Agda (通过EMACS、终端等),是否可以直接从Haskell中将其用作库?例如:
-- UsingAgda.hs
import Agda
-- Prints the type of a term on some Agda code
main :: IO ()
main = typeOf "true" agdaCode where
agdaCode :: String
agdaCode = unlines
["module Hello where "
," &
我使用以下代码创建了一个emacs文件trial_agda.agda:
module trial_agda where
data : Set where
zero :
suc : →
data _even : → Set where
ZERO : zero even
STEP : ∀ x → x even → suc (suc x) even
_+_ : → →
(zero + n) = n
(suc n) + n′ = suc (n + n′)
在中,作者写道:
现在我们将在Agda中证明四是偶数。在emacs缓冲区中键入以下内容,然后键入C
-- \
大多数与Agda的交互都是用EMACS完成的,但是有没有办法以编程的方式完成呢?也就是说,是否可以通过命令行或某些API完成所有操作?主要目标是构建一个瘦包装器,以便我们可以从另一种语言(例如:
var Agda = require("agda");
var code = `
data Bool: Set where
true: Bool
false: Bool
not : Bool -> Bool
not true = false
not false = true
val : Bool
我正在尝试加入agda语言中的字符串。到目前为止我的代码是 open import Common.IO
open import Common.String
f : String → String
f x = x
main = putStrLn (f "Hello, world!") 我如何连接字符串。在ruby中,它应该是 open import Common.IO
open import Common.String
f : String → String
f x = x + ' second string'
main =
我正在写一篇论文,试图用Agda实现他们的Haskell代码。他们希望通过这样的方式来制定停顿问题:让bot成为一个程序,这样对于任何数据类型a
bot :: a
bot = bot
他们继续定义
data S = T
所以停机问题是这样说的:
定义的函数diverges : S → S
diverges(T)= bot
diverges(bot)= T
是不可计算的,因此在我们的语言中是不可定义的
我尝试在Agda中实现它,如下所示:
data S : Set where
⊤ : S
⊥ : _
⊥ = ⊥
diverges : S → S
diverges ⊤ = ⊥
diverg
我刚开始学习Agda阅读。在第一章中,有一个乘法的定义,其中一种情况是(suc m) * n = n + (m * n)。我认为它可以更好地表达为(m + 1) * n = n + (m * n),但显然情况并非如此。以下程序:
data ℕ : Set where
zero : ℕ
suc : ℕ → ℕ
_+_ : ℕ → ℕ → ℕ
zero + n = n
(suc m) + n = suc (m + n)
{-# BUILTIN NATURAL ℕ #-}
_*_ : ℕ → ℕ → ℕ
zero * n = zero
-- This is fine:
-- (suc
我在Emacs模式下使用agda。我正试图开始一个依赖立方体图书馆的项目。我想导入模块Cubical.Core.Everything。我只写了以下几篇
{-# OPTIONS --without-K #-}
open import Cubical.Core.Everything
当我试图加载文件时,我会收到以下错误
/home/rymndbkr/myHoTT/Agda/intro.agda:3,1-36
Importing module Cubical.Core.Everything using the
--cubical/--erased-cubical flag from a modul
使用下面的Agda代码,我在A₂中得到了一个关于B定义的错误:
module Whatever where
module A₁ where
data B : Set where
module A₂ where
open A₁ renaming (B to B₁)
data B : Set where
错误消息为:
Duplicate definition of module B. Previous definition of datatype
module B at /home/cactus/prog/agda/modules.agda:4,8-9
when scope che
我有一些Agda代码,如下所示(剪裁以关注我认为的问题,即使用map的递归):
open import Data.List using (List; map)
data Foo : Set where
Bar : List Foo → Foo
data Foo2 : Set where
Bar2 : List Foo2 → Foo2
process : Foo → Foo2
process (Bar x) = Bar2 (map process x)
{...}/Foo.agda:9,1-10,39
Termination checking failed for the foll
为什么模式匹配有时在Agda中是“必不可少的”?
我要把这个从里拿出来。
当不进行模式匹配时,Agda给出的不允许refl进入洞:
η-× : ∀ {A B : Set} (w : A × B) → ⟨ proj₁ w , proj₂ w ⟩ ≡ w
η-× x = ?
它报告了这个目标和假设:
Goal: ⟨ proj₁ x , proj₂ x ⟩ ≡ x
————————————————————————————————————————————————————————————
x : A × B
但是,如果我告诉它案例拆分(ctrl-c ctrl-c x Ret) ),Agda就能搞清楚到底
我是Agda的新手,我试图定义一个类型为prod的常量Z → (Z → ((Z → Set) → Set)):Z → (Z → ((Z → Set) → Set))
现在,我编写了以下Agda代码:
data Prod (X : Set) : ℕ → X where
prod : ℕ → (ℕ → ((ℕ → X) → X))
当我键入它时,agda会生成以下错误消息:
X != Set (_33 X_) of type Set
when checking the definition of Prod
任何帮助都是非常感谢的。