Skip to content

Instantly share code, notes, and snippets.

@KKostya
KKostya / keybase.md
Created June 28, 2022 09:51
keybase.md

Keybase proof

I hereby claim:

To claim this, I am signing this object:

@KKostya
KKostya / code.cpp
Created March 2, 2021 21:53
PierceCPP
#include <functional>
class A {};
class B {};
typedef std::function<B(A)> F;
typedef std::function<B(F)> G;
typedef std::function<B(G)> H;
F proof(H h){
auto t = [](A a){
pairwise = lambda b: zip(*((lambda a: (lambda x: (next(x[1]), x))((iter(a), iter(a))))(b)[1]))
@KKostya
KKostya / heap.py
Created May 5, 2020 20:23
Algorithms
# Python3 implementation of Heap's algorithm
# https://en.wikipedia.org/wiki/Heap%27s_algorithm
def heap(lst, k=None):
if k is None: k = len(lst)
if k == 1:
yield(tuple(lst))
return
yield from heap(lst, k - 1)
for i in range(k-1):
m = i if k % 2 == 0 else 0
instance ( (strategy) => Real.({
valid_strategy(strategy) &&
( expected_reward (
make_scenario_pmf(pDoorsEqual,strategy)
) == 2000000.0 / 3.0 )
}))
verify ( (strategy) => Real.({
valid_strategy(strategy) ==>
( expected_reward (
make_scenario_pmf(pDoorsEqual,strategy)
) <= 2000000.0 / 3.0 )
}))
let pDoorsEqual : (door => real) = (door) => Real.(1.0 / 3.0)
let random_then_swap_strategy = (door : door,choice) =>
switch(door,choice){ | (_,Swap) => Real.(1.0 / 3.0) | _ => 0.0 };
expected_reward(
make_scenario_pmf(pDoorsEqual,random_then_swap_strategy)
)
verify ( (strategy) => Real.({
valid_strategy(strategy) ==>
( expected_reward (
make_scenario_pmf(pDoorsBiased,strategy)
) <= 800000.0 )
}))
let aStayStrategy = (door,choice) =>
switch(door,choice){ | (DoorA,Stay) => 1.0 | _ => 0.0 };
expected_reward(
make_scenario_pmf(pDoorsBiased,aStayStrategy)
);
let cSwapStrategy = (door,choice) =>
switch(door,choice){ | (DoorC,Swap) => 1.0 | _ => 0.0 };
expected_reward(
make_scenario_pmf(pDoorsBiased,cSwapStrategy)
);