小编Ger*_*ely的帖子

驯服 Isar 证明中的元蕴涵

证明一个简单的定理 我在证明中遇到了元级别的含义。可以拥有它们还是可以避免它们?如果我应该处理它们,这是正确的方法吗?

theory Sandbox
imports Main
begin

lemma "(x::nat) > 0 ? x = 0"
proof (cases x)
  assume "x = 0"
  show "0 < x ? x = 0" by (auto)
next
  have "x = Suc n ? 0 < x" by (simp only: Nat.zero_less_Suc)
  then have "x = Suc n ? 0 < x ? x = 0" by (auto)
  then show "?nat. x = Suc nat ? 0 < x ? x = 0" by (auto)
qed …
Run Code Online (Sandbox Code Playgroud)

isabelle isar

4
推荐指数
1
解决办法
280
查看次数

如何在Nodejs中通过dgram发送UDP数据包?

我尝试了各种版本的 Nodejs 数据报套接字模块的发送功能:

var dgram = require('dgram');

var client = dgram.createSocket('udp4');

client.send('Hello World!',0, 12, 12000, '127.0.0.1', function(err, bytes) {});
client.send('Hello2World!',0, 12, 12000, '127.0.0.1');
client.send('Hello3World!',12000, '127.0.0.1');

client.close();
Run Code Online (Sandbox Code Playgroud)

我的服务器确实与另一个客户端一起工作,但不是这个,没有数据包到达。

Nodejs 的 dgram 发送文档

socket.send(msg[, offset, length], port[, address][, callback])
Run Code Online (Sandbox Code Playgroud)

是我填写的参数有问题还是其他原因导致它失败?在服务器程序中,我确实使用了端口 12000 和环回 IP 地址。

sockets udp node.js dgrams

4
推荐指数
1
解决办法
9296
查看次数

Haskell monad不能执行的绝对类别monad的身份是什么?

http://blog.sigfpe.com/2006/08/you-could-have-invented-monads-and.html

写道:

如果您没有猜到,这与单子有关,因为它们出现在像Haskell这样的纯函数式编程语言中。它们与范畴论的单子关系密切,但是由于Haskell并不强制分类单子满足的身份而并不完全相同。

以上文字是在谈论这些身份吗?

Haskell是否执行monad法律?

return a >>= k  =  k a
m >>= return  =  m
m >>= (\x -> k x >>= h)  =  (m >>= k) >>= h
Run Code Online (Sandbox Code Playgroud)

monads haskell category-theory

4
推荐指数
1
解决办法
75
查看次数

如何在Isabelle中定义部分函数?

我试图用partial_function关键字定义部分函数.那没起效.这是最能表达直觉的:

partial_function (tailrec) oddity :: "nat => nat"
where
  "oddity Zero = Zero "
| "oddity (Succ (Succ n)) = n"
Run Code Online (Sandbox Code Playgroud)

然后我尝试了以下内容:

partial_function (tailrec) oddity :: "nat => nat"
where
  "oddity arg = ( case arg of (Succ (Succ n)) => n
                          | Zero => Zero
                )"

partial_function (tailrec) oddity :: "nat => nat"
where
  "oddity (Succ(Succ n)) = n
   | oddity Zero = Zero"

partial_function (tailrec) oddity :: "nat => nat"
where
  "oddity n =
   (if n …
Run Code Online (Sandbox Code Playgroud)

isabelle

3
推荐指数
1
解决办法
574
查看次数

Haskell中&lt;-的类型是什么?

我有一个工作程序

main = do

  inpStr <- getLine
  putStrLn ( "Hello " ++ inpStr )
Run Code Online (Sandbox Code Playgroud)

哪里

putStrLn :: String -> IO ()
Run Code Online (Sandbox Code Playgroud)

getLine :: IO String  
Run Code Online (Sandbox Code Playgroud)

由此我可以断定的类型<-

IO a -> a
Run Code Online (Sandbox Code Playgroud)

monads haskell types do-notation io-monad

2
推荐指数
1
解决办法
76
查看次数

在Isabelle中加载预编译的堆映像

遵循如何使用 - 持久堆 - 图像 - 使理论加载 - 更快 - 在isabelle和另一个建议我为Nominal Isabelle创建了一个图像:

isabelle build -v -b -d . Nominal2
Run Code Online (Sandbox Code Playgroud)

堆映像是在〜/ .isabelle下创建的:

.isabelle/Isabelle2013-2/heaps/polyml-5.5.1_x86-linux/Nominal2
Run Code Online (Sandbox Code Playgroud)

然后我开始了

isabelle jedit -d /path/to/Nominal-distribution -l Nominal2
Run Code Online (Sandbox Code Playgroud)

我希望系统能够快速加载一个导入名义部分的理论,但这花了差不多一分钟.这是通常的吗?

isabelle

1
推荐指数
1
解决办法
383
查看次数

如何在存在证明中使用获取?

我试图证明一个存在定理

\n\n
lemma "\xe2\x88\x83 x. x * (t :: nat) = t"\nproof\n  obtain y where "y * t = t" by (auto)\n
Run Code Online (Sandbox Code Playgroud)\n\n

但我无法完成证明。所以我有了必要的东西y,但我怎样才能将其纳入最初的目标呢?

\n

isabelle isar

1
推荐指数
2
解决办法
909
查看次数

如何保存Lisp编译器的状态?

我想保存Lisp编译器的状态,以便我不需要在几分钟内加载我的文件,而是我会在几秒钟内加载该图像.

哪个Common Lisp编译器对我有利?

我接受了这个想法,因为新泽西州的标准ML做到了这一点:出口堆.

我在sbcl手册ecl手册中找不到类似的东西.

lisp common-lisp

1
推荐指数
1
解决办法
71
查看次数

IO monad中的功能组成

linesHaskell中的函数将字符串的行分成字符串列表:

lines :: String -> [String]
Run Code Online (Sandbox Code Playgroud)

readFile函数将文件读取为字符串:

readFile :: FilePath -> IO String
Run Code Online (Sandbox Code Playgroud)

尝试组合这些函数以获取文件中的行列表会导致类型错误:

Prelude> (lines . readFile) "quux.txt"
<interactive>:26:10: error:
    • Couldn't match type ‘IO String’ with ‘[Char]’
      Expected type: FilePath -> String
        Actual type: FilePath -> IO String
    • In the second argument of ‘(.)’, namely ‘readFile’
      In the expression: lines . readFile
      In the expression: (lines . readFile) "quux.txt"
Run Code Online (Sandbox Code Playgroud)

我该怎么做单子戏?

io monads haskell function-composition io-monad

1
推荐指数
1
解决办法
81
查看次数