在尝试在列表上的归纳谓词上编写可重用代码时,我自然会声明:
Parameter A:Type.
Run Code Online (Sandbox Code Playgroud)
然后我继续定义二元谓词(例如):
Inductive prefix : list A -> list A -> Prop :=
| prefixNil: forall (l: list A), prefix nil l
| prefixCons: forall (a: A)(l m:list A), prefix l m -> prefix (a::l) (a::m).
Run Code Online (Sandbox Code Playgroud)
表达了给定列表是另一个列表的前缀这一事实.然后,人们可以继续研究这种关系并显示(例如)它是一个偏序.到现在为止还挺好.但是,很容易定义一个与数学概念不符的归纳谓词.我想通过进一步定义函数来验证归纳定义:
isPrefixOf: list A -> list A -> bool
Run Code Online (Sandbox Code Playgroud)
为了证明等价:
Theorem prefix_validate: forall (l m: list A),
prefix l m <-> isPrefixOf l m = true.
Run Code Online (Sandbox Code Playgroud)
这是我需要限制代码的一般性的地方,因为我不能再使用了list A.在Haskell,我们有isPrefixOf :: Eq a => [a] -> [a] -> Bool,所以我理解我需要做一些假设A …
我试图跟进这个线程,遗憾的是它并没有完全解决我的问题.我试图运行的代码如下:
; File hello.asm
section .data
msg: db "Hello World!",0x0a,0
section .text
global main
extern printf
main:
push rbp
mov rbp, rsp
lea rdi, [msg] ; parameter 1 for printf
xor eax, eax ; 0 floating point parameter
call printf
xor eax, eax ; returns 0
pop rbp
ret
Run Code Online (Sandbox Code Playgroud)
我的系统是debian stretch:
$ uname -a
Linux <host> 4.8.0-1-amd64 #1 SMP Debian 4.8.7-1 (2016-11-13) x86_64 GNU/Linux
Run Code Online (Sandbox Code Playgroud)
我使用yasm汇编程序如下:
$ yasm -f elf64 -g dwarf2 hello.asm
Run Code Online (Sandbox Code Playgroud)
因为我在上面的源代码中的入口点是main最后的ret …
我的GNU-Linux平台(Debian的拉伸)有C型u_int8_t,u_int16_t,u_int32_t并u_int64_t在文件中定义sys/types.h的同时uint8_t,uint16_t,uint32_t和uint64_t中定义stdint.h.我发现这些类型在练习X86-64汇编语言和与C交互的过程中很有用.有什么理由我更喜欢一个头文件而不是另一个头文件(无论是'最佳实践',可移植性等)?C++的答案有何不同?
6.3版本接受以下内容作为有效c代码gcc:
char white[] = { 'a', 'b', 'c' };
char blue[] = "abc";
char *red = "abc";
Run Code Online (Sandbox Code Playgroud)
但是以下失败:
char *green = { 'a', 'b', 'c' }; // gcc error
Run Code Online (Sandbox Code Playgroud)
我确信这是一个非常合理的理由,但我想知道它是什么.这个问题是由具有初始化字节数组(所以当案件的动机unsigned char,而不是char),这是非常诱人的喜欢写东西{ '\x43', '\xde', '\xa0' },而不是"\x43\xde\xa0",并且只要你忘了写my_array[],而不是*my_array,你被编译器捕获.
我试图在此页面之后从源代码构建GHC .安装依赖项时,我必须安装happy并alex:
$ cabal install alex happy
Resolving dependencies...
Configuring alex-3.2.1...
Configuring happy-1.19.5...
Building happy-1.19.5...
Building alex-3.2.1...
Installed alex-3.2.1
Installed happy-1.19.5
Run Code Online (Sandbox Code Playgroud)
但是在运行时configure我收到一条错误消息:
$ ./configure
...
checking for happy... no
checking for version of happy...
configure: error: Happy version 1.19.4 or later is required to compile GHC.
Run Code Online (Sandbox Code Playgroud)
我在Debian上运行stretch:
$ uname -a
Linux <host> 4.8.0-1-amd64 #1 SMP Debian 4.8.5-1 (2016-10-28) x86_64 GNU/Linux
Run Code Online (Sandbox Code Playgroud)
任何人都可以建议一个明显的步骤我可以尝试解决这个问题
同一个Linux命令在一个环境中成功,而在另一个环境中失败:
$ coqtop -lv test.v -I Lib
Run Code Online (Sandbox Code Playgroud)
我得到的失败是Debian延伸和Coq v8.5
$ uname -a
Linux front 4.8.0-1-amd64 #1 SMP Debian 4.8.7-1 (2016-11-13) x86_64 GNU/Linux
$ coqtop -v
The Coq Proof Assistant, version 8.5 (June 2016)
compiled on Jun 9 2016 12:4:46 with OCaml 4.02.3
Run Code Online (Sandbox Code Playgroud)
我得到的错误信息是:
Welcome to Coq 8.5 (June 2016)
Require Import libtest.
Error during initialization:
File "/home/user/dev/coq/test.v", line 1, characters 15-22:
Error: Unable to locate library libtest.
Run Code Online (Sandbox Code Playgroud)
与同一源相关的相同命令成功的环境是:
$ uname -a
Linux back 3.16.0-4-amd64 #1 SMP Debian 3.16.36-1+deb8u2 (2016-10-19)x86_64 GNU/... …Run Code Online (Sandbox Code Playgroud) 这是对这篇文章的跟进。我有一个小示例项目,gradle涉及一个scala无法在我的新机器上构建的文件(它曾经在相同的硬件 + 上工作debian stretch):
$ gradle build
:compileJava UP-TO-DATE
:compileScala FAILED
FAILURE: Build failed with an exception.
* What went wrong:
A problem was found with the configuration of task ':compileScala'.
> No value has been specified for property 'zincClasspath'.
Run Code Online (Sandbox Code Playgroud)
我的build.gradle文件如下:
version = 0.1
apply plugin: 'scala'
repositories {
mavenCentral()
}
dependencies {
compile 'org.scala-lang:scala-library:2.11.8'
}
Run Code Online (Sandbox Code Playgroud)
我目前的gradle版本是:
$ gradle -version
------------------------------------------------------------
Gradle 3.2.1
------------------------------------------------------------
Build time: 2012-12-21 00:00:00 UTC
Revision: …Run Code Online (Sandbox Code Playgroud) 这感觉就像一个微不足道的问题,但它一直在唠叨我一段时间:在关注'真实世界Haskell'的过程中,我一直在尝试Word8使用Data.ByteString.Lazy.Char8模块的数据类型的示例代码.大多数工作正常,但我不得不删除涉及符号的类型声明,Word8因为ghci无法识别它.当使用:对涉及此类型的一些功能型ghci中,它被称为GHC.Word.Word8,但替换Word8的GHC.Word.Word8代码没有改善的事情,任何import我身边有猜到声明GHC.Word.Word8失败.我已经在hackage网站上看了一下这个建议,Data.Word8但是没有.在此论坛上搜索较早的帖子并没有给我答案.我正在使用:GHCi, version 7.6.3: http://www.haskell.org/ghc/在Debian 8上.
我一直在努力解决这个问题.我有一个归纳类型:
Definition char := nat.
Definition string := list char.
Inductive Exp : Set :=
| Lit : char -> Exp
| And : Exp -> Exp -> Exp
| Or : Exp -> Exp -> Exp
| Many: Exp -> Exp
Run Code Online (Sandbox Code Playgroud)
我从中定义了一系列类型:
Inductive Language : Exp -> Set :=
| LangLit : forall c:char, Language (Lit c)
| LangAnd : forall r1 r2: Exp, Language(r1) -> Language(r2) -> Language(And r1 r2)
| LangOrLeft : forall r1 r2: Exp, Language(r1) …Run Code Online (Sandbox Code Playgroud) 出于这个问题的目的,假设我有:
Parameter eq_bool : forall (A:Type), A -> A -> bool.
Arguments eq_bool {A} _ _.
Axiom eq_bool_correct : forall (A:Type) (x y:A),
eq_bool x y = true -> x = y.
Axiom eq_bool_correct' : forall (A:Type) (x y:A),
x = y -> eq_bool x y = true.
Run Code Online (Sandbox Code Playgroud)
我有一个函数,给出两个值x y:A返回随时和否则的Some证明.此函数通过模式匹配来实现,以测试相等性,并使用convoy模式作为一种技巧,在代码中访问对应于匹配分支的相等性证明:x = yx = yNoneeq_bool x y
Definition test (A:Type) (x y:A) : option (x = y) :=
match eq_bool x y as …Run Code Online (Sandbox Code Playgroud)