Skip to content

Instantly share code, notes, and snippets.

@aqjune
aqjune / tactic.lean
Last active March 1, 2018 17:47
Creating random test from proposition using tactic library
open tactic
private constant mk_eq (sz:size) (x y:bitvector sz): x = y
constant smt_eq {sz:size}: sbitvec sz → sbitvec sz → Prop
theorem eq_add2 (sz:size): ∀ (x y: bitvector sz),
smt_eq (sbitvec.add (sbitvec.of_bv x) (sbitvec.of_bv y))
(sbitvec.of_bv (bitvector.add x y)) :=
by do
x ← intro `x,
@aqjune
aqjune / tactic2.lean
Created March 2, 2018 15:49
Just some copy and paste
/-
constant eq_test {sz:size}: sbitvec sz → bitvector sz → Prop
axiom eq_const (sz:size): ∀ (z:ℤ),
eq_test (sbitvec.of_int sz z) (bitvector.of_int sz z)
meta instance eq_const_decidable (sz:size): decidable (∀ (z:ℤ),
eq_test (sbitvec.of_int sz z) (bitvector.of_int sz z)) :=
@aqjune
aqjune / example.lean
Created March 15, 2018 23:32
Lean example
class C {α:ℕ → Type} :=
(myf:α 1 → α 1 → α 1)
(cx cy:α 1)
variable {α:ℕ → Type}
variable [s1:@C α]
include s1
def f1 := C.myf (C.cx α) (C.cy α)
def f2 := f1 /- don't know how to synthesize placeholder
@aqjune
aqjune / include.lean
Created March 16, 2018 10:43
Lean code
class C {α:ℕ → Type} :=
(myf:α 1 → α 1 → α 1)
(cx cy:α 1)
variable {α':ℕ → Type}
variable [s1:@C α']
include α'
include s1
def f1 := C.myf (C.cx α') (C.cy α')
@aqjune
aqjune / foo.lean
Created March 19, 2018 18:27
monad
inductive any
| val : ∀ (α:Type), α → any
def bar (n:nat):option nat :=
return n
def foo:option any :=
do
dummy ← bar 10,
return (any.val nat 3)
@aqjune
aqjune / move.cpp
Created November 20, 2018 09:12
C++'s move semantics - example
#include <vector>
#include <iostream>
#include<utility>
using namespace std;
class C {
public:
int *ptr;
C(int val) {
cout << " Constructor: " << (intptr_t) this << endl;
define <4 x i8*> @tinkywinky() {
%patatino = getelementptr i8, i8* undef, <4 x i64> undef
ret <4 x i8*> %patatino
}
=>
define <4 x i8*> @tinkywinky() {
ret <4 x i8*> undef
}
@aqjune
aqjune / fib.c
Last active March 26, 2020 05:58
Practice session 2 - fibonacci
unsigned fib(unsigned n) {
unsigned answ;
if (n <= 1)
answ = n;
else
answ = fib(n - 1) + fib(n - 2);
return answ;
}
target datalayout="e"
;target datalayout="E" ; both is fine
define void @src(i8** %q) {
%ofs = shl i64 7, 60
%p = getelementptr i8, i8* null, i64 %ofs
store i8* %p, i8** %q
ret void
}
@aqjune
aqjune / diff.txt
Created January 16, 2021 11:36
Diff
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
index 6a7fe9d707a2..ad4b13a52300 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
@@ -49,7 +49,7 @@ using namespace PatternMatch;
/// FIXME: Enabled by default until the pattern is supported well.
static cl::opt<bool> EnableUnsafeSelectTransform(
- "instcombine-unsafe-select-transform", cl::init(true),
+ "instcombine-unsafe-select-transform", cl::init(false),