This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| inductive Void : Prop | |
| | void (v : Void) : Void | |
| /- | |
| def inf : Void → Nat | |
| | .void v => .succ (inf v) | |
| -/ | |
| noncomputable def inf : Void → Nat := @Void.rec _ fun _ => .succ | |
| example (v : Void) : inf v = inf (.void v) := rfl |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Batteries.WF | |
| abbrev ExistsAfter (P : Nat → Prop) := Acc fun y x => y = x.succ ∧ ¬P x | |
| inductive Nat.ge (n : Nat) : Nat → Prop | |
| | refl : ge n n | |
| | step : ge n m.succ → ge n m | |
| theorem Nat.ge_succ : ge n m → ge n.succ m | |
| | .refl => .step .refl |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use std::{ | |
| mem::ManuallyDrop, | |
| ops::{Deref, DerefMut}, | |
| }; | |
| pub trait BoxDrop { | |
| fn drop(self: Box<Self>); | |
| } | |
| #[repr(transparent)] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #[repr(usize)] | |
| pub enum Tree<T> { | |
| Leaf(T), | |
| Node(DropBox<Self>, DropBox<Self>), | |
| } | |
| impl<T> BoxDrop for Tree<T> { | |
| fn drop(self: Box<Self>) { | |
| #[repr(usize)] | |
| enum RawTree<T> { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| docker run -it --rm alpine | |
| # inside | |
| apk add gdb-multiarch | |
| wget https://gist.githubusercontent.com/cppio/6576572073a424b01b9d0c9a2e4bade5/raw/42aa93d2be602e343792a59587d7a8ad7152a7d8/hello.x86_64 | |
| chmod +x hello.x86_64 | |
| ROSETTA_DEBUGSERVER_PORT=12345 ./hello.x86_64 & | |
| gdb-multiarch hello.x86_64 -ex 'tar rem :12345' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def bsearch0(l, x): | |
| assert all(i < j for i, j in zip(l, l[1:])) | |
| lo, hi = 0, len(l) | |
| while lo < hi: | |
| # l[:lo] < x < l[hi:] | |
| mid = hi - (hi - lo) // 2 - 1 | |
| assert lo <= mid < hi | |
| if x > l[mid]: | |
| lo = mid + 1 | |
| elif x < l[mid]: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {-# OPTIONS --cubical-compatible --rewriting --confluence-check #-} | |
| open import Agda.Builtin.Bool | |
| open import Agda.Builtin.Equality | |
| import Agda.Builtin.Equality.Rewrite | |
| private module _ {a} {A : Set a} where | |
| Path⇒≡ : (p : .Bool → A) → p false ≡ p true | |
| Path⇒≡ _ = refl |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {-# OPTIONS --cubical-compatible #-} | |
| open import Data.Nat.Base | |
| open import Data.Product | |
| open import Relation.Nullary | |
| open import Relation.Unary | |
| module Markov {p} (P : ℕ → Set p) (dec : Decidable P) .(h : Σ ℕ P) where | |
| {-# TERMINATING #-} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import struct | |
| def float32_bin(x): | |
| x, = struct.unpack("=I", struct.pack("=f", x)) | |
| sign, exponent, mantissa = x >> 31, x >> 23 & 0xff, x & 0x7fffff | |
| if exponent != 255: | |
| return f"{['', '-'][sign]}0b{int(exponent != 0)}.{mantissa:023b}p{max(exponent, 1) - 127}" | |
| elif mantissa: | |
| return "nan" | |
| else: |