Skip to content

Instantly share code, notes, and snippets.

View andrejbauer's full-sized avatar

Andrej Bauer andrejbauer

View GitHub Profile
@andrejbauer
andrejbauer / mandelbrot.c
Created December 11, 2013 22:23
A simple program for computing the Mandelbrot set.
/*
This program is an adaptation of the Mandelbrot program
from the Programming Rosetta Stone, see
http://rosettacode.org/wiki/Mandelbrot_set
Compile the program with:
gcc -o mandelbrot -O4 mandelbrot.c
Usage:
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@andrejbauer
andrejbauer / LaTeX.inputplugin
Last active February 7, 2025 15:40
LaTeX symbols input method for MacOS
#
METHOD: TABLE
ENCODE: Unicode
PROMPT: LaTeX
VERSION: 1.0
DELIMITER: ,
VALIDINPUTKEY: ^,.?!:;"'/\()[]{}<>$%&@*01234567890123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
TERMINPUTKEY:
BEGINCHARACTER
alpha α
@andrejbauer
andrejbauer / Primrec.agda
Created July 6, 2021 10:21
Primitive recursive functions in Agda
open import Data.Nat
open import Data.Fin as Fin
module Primrec where
-- The datatype of primitive recursive function
data PR : ∀ (k : ℕ) → Set where
pr-zero : PR 0 -- zero
pr-succ : PR 1 -- successor
pr-proj : ∀ {k} (i : Fin k) → PR k -- projection
@andrejbauer
andrejbauer / forcing.v
Last active December 22, 2024 14:35
The construction of the least closure operator that forces a given predicate to be true.
(* A proof that there is a least closure operator which forces a given
predicate to be true. The construction can be found in, e.g.,
Martin Hyland's “Effective topos” paper, Proposition 16.3. *)
(* A closure operator on [Prop] is an idempotent, monotone, inflationary enodmap.
One often requires additionally that the operator preserves conjunctions,
in which case these are also called j-operators and Lawvere-Tierney topologies.
We eschew the condition to obtain a slighly more general result, but we
also show that the closure operator of interst happens to preserve conjunctions.
@andrejbauer
andrejbauer / PropositionalCalculus.v
Created December 1, 2024 14:47
A formalization of a classical propositional calculus used in some questions and answers at ProofAssistants StackExchange
(* A formalization of a classical propositional calculus a la user4035,
see https://proofassistants.stackexchange.com/q/4443/169 and
https://proofassistants.stackexchange.com/q/4468/169 ,
with the following modifications:
1) We use a set of assumptions rather than a list of assumptions.
2) We use derivation trees to represent proofs instead of lists of formulas.
Proofs-as-lists are used in Hilbert-style systems, whereas
derivation trees are more common in natural-deduction style rules.
@andrejbauer
andrejbauer / AgdaSolver.agda
Last active November 9, 2024 16:28
How to use Agda ring solvers to prove equations?
{- Here is a short demonstration on how to use Agda's solvers that automatically
prove equations. It seems quite impossible to find complete worked examples
of how Agda solvers are used.
Thanks go to @anormalform who helped out with these on Twitter, see
https://twitter.com/andrejbauer/status/1549693506922364929?s=20&t=7cb1TbB2cspIgktKXU8rng
I welcome improvements and additions to this file.
This file works with Agda 2.6.2.2 and standard-library-1.7.1
@andrejbauer
andrejbauer / Tarski.agda
Last active October 10, 2024 22:12
A predicative version of Tarski's fixed-point theorem.
-- A predicative version of Tarski's fixed-point theorem
open import Level
open import Data.Product
module Tarski where
-- a complete preorder with carrier at level a, the preorder is at level b,
-- and suprema indexed by sets from level c
record CompletePreorder a b c : Setω where
@andrejbauer
andrejbauer / README.md
Last active August 23, 2024 08:47
Playing around with Miquel's theorem
@andrejbauer
andrejbauer / algebraic.py
Created August 14, 2019 12:47
Pictures of algebraic numbers
#!/usr/local/bin/python3
# Compute algebraic numbers in the complex plane and draw a nice picture
import numpy
import sys
import argparse
import math
import cairo
import pickle