Skip to content

Instantly share code, notes, and snippets.

-- PERMANENT
CREATE TABLE sat_problems (
problem_id BIGINT NOT NULL AUTO_INCREMENT,
source VARCHAR(128) NOT NULL,
n_vars BIGINT NOT NULL,
n_clauses BIGINT NOT NULL,
bcname VARCHAR(128) NOT NULL,
bname VARCHAR(2048) NOT NULL,
PRIMARY KEY(problem_id),
CONSTRAINT bname_unique UNIQUE(bcname, bname)
@dselsam
dselsam / ToyDelab.lean
Last active April 15, 2021 02:50
Toy demo for delab path to textual porting
import Lean
import Std.Data.HashSet
open Lean Lean.PrettyPrinter.Delaborator
open Std (HashSet)
namespace CollectTerms
structure State where
visitedExpr : HashSet Expr := {}
@dselsam
dselsam / ElabArithGoalsNoMathlib.lean
Last active May 1, 2021 17:35
Elaboration goals for concrete arithmetic (no mathlib dependency)
-- Fail annotations refer to e70e924327c3b42d28dd8a59340a89cbafb3d5b6
namespace ElabArithGoalsNoMathlib
constant Rat : Type
constant Real : Type
constant Complex : Type
notation "ℕ" => Nat
notation "ℤ" => Int
notation "ℚ" => Rat
@dselsam
dselsam / ElabArithGoals.lean
Last active April 5, 2021 18:12
Elaboration goals for concrete arithmetic
import Mathlib.all
import PostPort
namespace ElabArithGoals
open Mathlib hiding coe
variable (k k₁ k₂ k₃ : ℕ)
variable (n n₁ n₂ n₃ : ℕ)
variable (z z₁ z₂ z₃ : ℤ)
/-
Design challenge: how to represent problems that require "determining" a set.
------------------------------------------------------------------------------
Consider the following problem:
"""
[IMO 2019, Problem 1]
Let ℤ be the set of integers. Determine all functions f : ℤ → ℤ such that, for all integers a and b,
f(2a) + 2f(b) = f(f(a+b))
@dselsam
dselsam / match_wrong_branch.lean
Last active August 5, 2019 16:36
match goes down wrong branch
inductive Term : Type
| const : Nat -> Term
| app : List Term -> Term
namespace Term
instance : Inhabited Term := ⟨Term.const 0⟩
partial def hasToString : Term -> String | (const n) := "CONST(" ++ toString n ++ ")" | (app ts) := "APP"
instance : HasToString Term := ⟨hasToString⟩
end Term
@dselsam
dselsam / match_repro.lean
Last active August 5, 2019 14:18
Multiple match cases trigger
inductive Term : Type
| const : Nat -> Term
| app : List Term -> Term
namespace Term
instance : Inhabited Term := ⟨Term.const 0⟩
partial def hasToString : Term -> String | (const n) := "[CONST]" | (app ts) := "[APP]"
instance : HasToString Term := ⟨hasToString⟩
end Term