coinduction

Is an infinite list of ones sane?

戏子无情 提交于 2019-12-23 08:17:01
问题 In Prolog, is the unification X = [1|X] a sane way to get an infinite list of ones? SWI-Prolog does not have any problem with it, but GNU Prolog simply hangs. I know that in most cases I could replace the list with one(1). one(X) :- one(X). but my question is explicitly if one may use the expression X = [1|X], member(Y, X), Y = 1 in a "sane" Prolog implementation. 回答1: In Prolog, is the unification X = [1|X] a sane way to get an infinite list of ones? It depends on whether or not you consider

Proving equality on coinductive lazy lists in Coq

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-07 23:14:27
问题 I am experimenting with Coq Coinductive types. I use the lazy list type form the Coq'Art book (sect. 13.1.4): Set Implicit Arguments. CoInductive LList (A:Set) : Set := | LNil : LList A | LCons : A -> LList A -> LList A. Implicit Arguments LNil [A]. CoFixpoint LAppend (A:Set) (u v:LList A) : LList A := match u with | LNil => v | LCons a u' => LCons a (LAppend u' v) end. In order to match the guard condition I also use the following decomposition functions form this book: Definition LList

Proving equality on coinductive lazy lists in Coq

南笙酒味 提交于 2019-12-06 08:40:12
I am experimenting with Coq Coinductive types. I use the lazy list type form the Coq'Art book (sect. 13.1.4): Set Implicit Arguments. CoInductive LList (A:Set) : Set := | LNil : LList A | LCons : A -> LList A -> LList A. Implicit Arguments LNil [A]. CoFixpoint LAppend (A:Set) (u v:LList A) : LList A := match u with | LNil => v | LCons a u' => LCons a (LAppend u' v) end. In order to match the guard condition I also use the following decomposition functions form this book: Definition LList_decomp (A:Set) (l:LList A) : LList A := match l with | LNil => LNil | LCons a l' => LCons a l' end. Lemma

Compute an (infinite) tree from fixpoint operator using delay modality

蹲街弑〆低调 提交于 2019-12-05 02:03:35
问题 Here is a functional programming puzzle involving loop-tying and infinite data structures. There is a bit of background, so hang tight. The setting. Let us define a data type representing recursive data types: type Var = String data STerm = SMu Var STerm | SVar Var | SArrow STerm STerm | SBottom | STop deriving (Show) i.e. t ::= μα. t | α | t → t | ⊥ | ⊤ . Note that ⊥ denotes the type with no inhabitants, while ⊤ denotes the type with all inhabitants. Note that (μα. α) = ⊥ , as μ is a least