Skip to content

Instantly share code, notes, and snippets.

View MarcusVoelker's full-sized avatar

Marcus Völker MarcusVoelker

View GitHub Profile
@MarcusVoelker
MarcusVoelker / Kleene.v
Last active May 28, 2023 06:46
Proof of Kleene Fix Point Theorem in Coq
Require Import Ensembles.
Require Import Setoid.
Definition map {A B : Type} (f : A -> B) (S : Ensemble A) :=
fun b => exists a, In A S a /\ f a = b.
Section lat.
Variable A : Type.
Variable leA : A -> A -> Prop.
@MarcusVoelker
MarcusVoelker / W.hs
Last active September 27, 2019 16:41
Algorithm W
module W where
import qualified Data.Map.Strict as M
import Control.Monad.State.Lazy
data LExpr = Var String | App LExpr LExpr | Abs String LExpr | Let String LExpr LExpr
instance Show LExpr where
show (Var s) = s
show (App l r) = "(" ++ show l ++ ")(" ++ show r ++ show ")"
module Main where
import Data.List
data CTL a = AG (CTL a) | AF (CTL a) | EG (CTL a) | EF (CTL a) | EU (CTL a) (CTL a) | AU (CTL a) (CTL a) | EX (CTL a) | AX (CTL a) | And (CTL a) (CTL a) | Or (CTL a) (CTL a) | Not (CTL a) | Atom a
data Kripke a = Kripke { t :: (Int -> [Int]), l :: (Int -> [a]) }
paths :: Kripke a -> Int -> [[Int]]
paths m s = paths' [] m s
@MarcusVoelker
MarcusVoelker / ToDot.hs
Last active August 29, 2015 14:21
Adjacency List Map to dot graph
module ToDot where
import Data.Map
generateDot :: (Ord a, Show a) => Map a [a] -> IO ()
generateDot mp = do
putStrLn "graph G {"
foldrWithKey (\k v r ->
putStrLn (" v" ++ show k) >> Prelude.foldr (\e r' -> r' >> when (k < e) (putStrLn (" v" ++ show k ++ " -- v" ++ show e)))
r v
@MarcusVoelker
MarcusVoelker / Test.cs
Last active August 29, 2015 14:17
InstanceHelper
internal interface I
{
int Foo(int i);
}
internal class B
{
public int TestFunc(int i)
{
return 1;
@MarcusVoelker
MarcusVoelker / ArrayAlgo.java
Last active August 29, 2015 14:16
Some chunks of Java code
import java.util.Random;
public class Main
{
private static void doThing(int[] param, int x, int y)
{
if (x >= y)
return;
int i = x;
@MarcusVoelker
MarcusVoelker / Fun.hs
Last active August 29, 2015 14:03
Fun with Haskell
f :: [(a,a)] -> [[a]]
f [] = []
f (x:xs) = (snd x : fst (unzip xs)): map (fst x :) (f xs)
@MarcusVoelker
MarcusVoelker / main.cpp
Created May 14, 2014 15:28
Short testing program to benchmark the performance of various timers on your linux system
#include <iostream>
const unsigned long long SEC = 1000L*1000L*1000L;
inline unsigned long long timespecTo64( const timespec &_time ) {
return ( _time.tv_sec*SEC + _time.tv_nsec );
}
void runTest(clockid_t clkid, std::string const& name)
{
module Main where
data SK = S | K | App SK SK deriving Eq
data CC = CCAtom Combinator | CCApp CC CC
data Combinator = Comb String SK deriving Eq
data BaseCombinator = BC String CC