Skip to content

Instantly share code, notes, and snippets.

View anlun's full-sized avatar

Anton Podkopaev anlun

View GitHub Profile
@anlun
anlun / ConstantFolding.v
Last active February 17, 2023 11:14
Semantics-Neapolis23: Lecture files
Require Import BinInt ZArith_dec Zorder.
Require Export Id.
Require Export State.
Require Export Expr.
From hahn Require Import HahnBase.
Definition eval_op (op : bop) (z1 z2 : Z) : option Z :=
match op with
| Add => Some (z1 + z2)%Z
@anlun
anlun / egg_relation.rs
Last active October 25, 2022 06:17
Attempt to encode relational algebra rules in Egg
use egg::*;
define_language! {
enum RelLanguage {
"top" = Top,
"bot" = Bot,
";;" = Seq([Id; 2]),
"+" = CT(Id),
@anlun
anlun / fieldfixer.sh
Created March 10, 2021 06:39
A script to transform "X.(Y)" to "(Y X)" in Coq files
#!/bin/bash
sed -i "s|\([a-zA-Z0-9\'\_]\+\)\.(\([a-zA-Z0-9\_\.\']\+\))\.(\([a-zA-Z0-9\_\.\']\+\))|(\3 (\2 \1))|g" src/*/*.v
sed -i "s|\([a-zA-Z0-9\'\_]\+\)\.(\([a-zA-Z0-9\_\.\']\+\))|(\2 \1)|g" src/*/*.v
sed -i "s|\(([a-zA-Z0-9\'\_\.\ ]\+)\)\.(\([a-zA-Z0-9\_\.\']\+\))|(\2 \1)|g" src/*/*.v
@anlun
anlun / Sort2021.v
Created February 15, 2021 11:19
List sorting. Curry-Howard isomorphism example
From hahn Require Import Hahn.
Require Import Lia.
Require Import Bool List.
Export ListNotations.
Require Import Arith Arith.EqNat.
Require Extraction.
Inductive is_smallest : nat -> list nat -> Prop :=
smallest_unit : forall n, is_smallest n [n]
| smallest_head : forall n m tl,
From hahn Require Import Hahn.
Require Import Omega.
Require Import Bool List.
Export ListNotations.
Require Import Arith Arith.EqNat.
Require Extraction.
Inductive is_smallest : nat -> list nat -> Prop :=
smallest_unit : forall n, is_smallest n [n]
| smallest_head : forall n m tl,
@anlun
anlun / Sort.v
Created February 13, 2020 14:09
List sorting. Curry-Howard isomorphism example
From hahn Require Import Hahn.
Require Import Omega.
Require Import Bool List.
Export ListNotations.
Require Import Arith Arith.EqNat.
Require Extraction.
Inductive is_smallest : nat -> list nat -> Prop :=
smallest_unit : forall n, is_smallest n [n]
| smallest_head : forall n m tl,
@anlun
anlun / redexMacros.rkt
Created February 25, 2016 15:37
A semantics with macros rules. Redex.
#lang racket
(require redex/reduction-semantics)
(require (for-syntax racket/match))
(define-language L
(E ::= (list v ... E e ...) (car E) (cdr E) hole)
(v ::= (list v ...) natural)
(e ::= (list e ...) (car e) (cdr e) natural))
(define-syntax-rule (==> a b)
@anlun
anlun / rcu.rkt
Last active February 24, 2016 14:39
This is a simple RCU written in our language (https://github.com/anlun/OperationalSemanticsC11).
#lang at-exp racket
(require redex/reduction-semantics)
(require "../core/parser.rkt")
(define term_RCU
@prog{ ;; Preparing visible state counters.
cw_na := 0;
cr1_na := 0;
cr2_na := 0;
lhead_na := null;