forall

Coq convert non exist to forall statement

无人久伴 提交于 2019-12-02 10:10:24
I'm new to Coq. Here's my problem. I have a statement says: H : forall x : term, ~ (exists y : term, P x y /\ ~ P y x) I guess it is equivalent to: forall x y : term, (P x y /\ ~ P y x) -> false But which tactic can I use to convert the hypothesis? I don't know of a tactic to turn not-exists into forall-not, but you can always just assert and prove it. (If you need that repeatedly, you can pack that up into an Ltac tactic definition or a simple theorem[1].) Here's three ways of getting this proved. (You should be able to just copy/paste this transcript into CoqIDE or Emacs/ProofGeneral and

How can I ensure that my Fortran FORALL construct is being parallelized?

岁酱吖の 提交于 2019-11-30 15:28:20
问题 I've been given a 2D matrix representing temperature points on the surface of a metal plate. The edges of the matrix (plate) are held constant at 20 degrees C and there is a constant heat source of 100 degrees C at one pre-defined point. All other grid points are initially set to 50 degrees C. My goal is to take all interior grid points and compute its steady-state temperature by iteratively averaging over the surrounding four grid points (i+1, i-1, j+1, j-1) until I reach convergence (a

How can I ensure that my Fortran FORALL construct is being parallelized?

陌路散爱 提交于 2019-11-30 15:17:15
I've been given a 2D matrix representing temperature points on the surface of a metal plate. The edges of the matrix (plate) are held constant at 20 degrees C and there is a constant heat source of 100 degrees C at one pre-defined point. All other grid points are initially set to 50 degrees C. My goal is to take all interior grid points and compute its steady-state temperature by iteratively averaging over the surrounding four grid points (i+1, i-1, j+1, j-1) until I reach convergence (a change of less than 0.02 degrees C between iterations). As far as I know, the order in which I iterate over

Using Contract.ForAll in Code Contracts

对着背影说爱祢 提交于 2019-11-28 11:01:22
Okay, I have yet another Code Contracts question. I have a contract on an interface method that looks like this (other methods omitted for clarity): [ContractClassFor(typeof(IUnboundTagGroup))] public abstract class ContractForIUnboundTagGroup : IUnboundTagGroup { public IUnboundTagGroup[] GetAllGroups() { Contract.Ensures(Contract.Result<IUnboundTagGroup[]>() != null); Contract.Ensures(Contract.ForAll(Contract.Result<IUnboundTagGroup[]>(), g => g != null)); return null; } } I have code consuming the interface that looks like this: public void AddRequested(IUnboundTagGroup group) { foreach

forall in Scala

 ̄綄美尐妖づ 提交于 2019-11-27 10:26:06
As shown below, in Haskell, it's possible to store in a list values with heterogeneous types with certain context bounds on them: data ShowBox = forall s. Show s => ShowBox s heteroList :: [ShowBox] heteroList = [ShowBox (), ShowBox 5, ShowBox True] How can I achieve the same in Scala, preferably without subtyping? As @Michael Kohl commented, this use of forall in Haskell is an existential type and can be exactly replicted in Scala using either the forSome construct or a wildcard. That means that @paradigmatic's answer is largely correct. Nevertheless there's something missing there relative

Using Contract.ForAll in Code Contracts

狂风中的少年 提交于 2019-11-27 05:54:29
问题 Okay, I have yet another Code Contracts question. I have a contract on an interface method that looks like this (other methods omitted for clarity): [ContractClassFor(typeof(IUnboundTagGroup))] public abstract class ContractForIUnboundTagGroup : IUnboundTagGroup { public IUnboundTagGroup[] GetAllGroups() { Contract.Ensures(Contract.Result<IUnboundTagGroup[]>() != null); Contract.Ensures(Contract.ForAll(Contract.Result<IUnboundTagGroup[]>(), g => g != null)); return null; } } I have code

forall in Scala

蓝咒 提交于 2019-11-26 15:09:32
问题 As shown below, in Haskell, it's possible to store in a list values with heterogeneous types with certain context bounds on them: data ShowBox = forall s. Show s => ShowBox s heteroList :: [ShowBox] heteroList = [ShowBox (), ShowBox 5, ShowBox True] How can I achieve the same in Scala, preferably without subtyping? 回答1: As @Michael Kohl commented, this use of forall in Haskell is an existential type and can be exactly replicted in Scala using either the forSome construct or a wildcard. That

What does the `forall` keyword in Haskell/GHC do?

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-26 08:38:37
问题 I\'m beginning to understand how the forall keyword is used in so-called \"existential types\" like this: data ShowBox = forall s. Show s => SB s This is only a subset, however, of how forall is used and I simply cannot wrap my mind around its use in things like this: runST :: forall a. (forall s. ST s a) -> a Or explaining why these are different: foo :: (forall a. a -> a) -> (Char, Bool) bar :: forall a. ((a -> a) -> (Char, Bool)) Or the whole RankNTypes stuff... I tend to prefer clear,