Skip to content

Commit

Permalink
tweaks and test setup
Browse files Browse the repository at this point in the history
  • Loading branch information
alexjbest committed Jan 5, 2024
1 parent c48dcec commit 16ec657
Show file tree
Hide file tree
Showing 20 changed files with 163 additions and 43 deletions.
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,11 @@
/lake-packages/*
lakefile.olean
/.lake
test/build
test/.lake
test/lake-packages/*
test/lakefile.olean
test2/build
test2/.lake
test2/lake-packages/*
test2/lakefile.olean
37 changes: 34 additions & 3 deletions Leaff/Diff.lean
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ def summarize (diffs : List Diff) : MessageData := Id.run do
| .typeChanged name _ => m!"! type changed for {name}"
| .speciesChanged name fro to _ => m!"! {name} changed from {fro} to {to}"
| .extensionEntriesModified ext => m!"! extension entry modified for {ext}"
| .docChanged name _ => m!"! doc _ ified for {name}"
| .docChanged name _ => m!"! doc modified for {name}"
| .docAdded name _ => m!"+ doc added to {name}"
| .docRemoved name _ => m!"- doc removed from {name}"
| .moduleAdded name => m!"+ module added {name}"
Expand Down Expand Up @@ -319,7 +319,7 @@ def importDiffs (old new : Environment) : List Diff := Id.run do
namespace PersistentEnvExtension

def getImportedState [Inhabited α] (ext : PersistentEnvExtension (Name × α) (Name × α) (NameMap α)) (env : Environment) : NameMap α :=
RBMap.fromArray ((ext.getState env).toList.toArray ++ (ext.toEnvExtension.getState env).importedEntries.flatten) Name.quickCmp
RBMap.fromArray (ext.exportEntriesFn (ext.getState env) ++ (ext.toEnvExtension.getState env).importedEntries.flatten) Name.quickCmp

-- TODO use mkStateFromImportedEntries maybe?
end PersistentEnvExtension
Expand Down Expand Up @@ -540,7 +540,38 @@ def extDiffs (old new : Environment) (renames : NameMap Name) (ignoreInternal :
-- let newexts := RBSet.ofList (new.constants.map₁.toList.map Prod.fst) Name.cmp -- TODO maybe quickCmp
pure out

-- #check reducibilityAttrs
-- Lean.namespacesExt
-- Lean.protectedExt
-- Lean.aliasExtension
-- Lean.attributeExtension
-- Lean.classExtension
-- Lean.reducibilityAttrs
-- Lean.Compiler.nospecializeAttr
-- Lean.Compiler.specializeAttr
-- Lean.externAttr
-- Lean.Compiler.implementedByAttr
-- Lean.neverExtractAttr
-- Lean.exportAttr
-- Lean.Compiler.CSimp.ext
-- Lean.noncomputableExt
-- Lean.Meta.globalInstanceExtension
-- Lean.structureExt
-- Lean.matchPatternAttr
-- Lean.Meta.instanceExtension
-- Lean.Meta.defaultInstanceExtension
-- Lean.Meta.coeDeclAttr
-- Lean.Linter.deprecatedAttr
-- Lean.declRangeExt
-- Lean.docStringExt
-- Lean.moduleDocExt
-- Lean.Meta.customEliminatorExt
-- Lean.Elab.Term.elabWithoutExpectedTypeAttr
-- Lean.Elab.Term.elabAsElim
-- Lean.Meta.recursorAttribute
-- Lean.Meta.simpExtension
-- Lean.Meta.congrExtension
-- Std.Tactic.Alias.aliasExt




Expand Down
5 changes: 0 additions & 5 deletions lakefile.lean
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@ package «leaff» {
-- add package configuration options here
}

lean_lib «test» {
globs := #[.submodules `test]
-- add library configuration options here
}

lean_lib «Leaff» {
-- add library configuration options here
}
Expand Down
1 change: 1 addition & 0 deletions test/Test/Basic.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
def hello := "world"
35 changes: 35 additions & 0 deletions test/Test/Test.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@

/-- has a doc -/
def a : Nat := 1

def c : Nat := 1
def bloop : Nat := 1

theorem sada : Int := 123


structure blah where
(a b : Nat)

/-- magic number-/
def hasdoc : Int := 123



class blasdf where
(a b : Nat)


def floo : blasdf := ⟨1, 2



theorem bloop1 : 39 := by decide



def defToLemma : 1 = 1 := rfl

set_option pp.all true
#print bloop1
-- #eval Leaff.printHashes ``bloop1
15 changes: 0 additions & 15 deletions test/TestA.lean

This file was deleted.

15 changes: 0 additions & 15 deletions test/TestB.lean

This file was deleted.

5 changes: 5 additions & 0 deletions test/diffin.lean
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ diff in
/-- ik heb een docstring -/
def aaa : LE Nat := sorry

structure Foo where
x : Nat
y : Nat
diff in
attribute [class] Foo
diff in
attribute [instance] aaa

Expand Down
5 changes: 5 additions & 0 deletions test/lake-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{"version": 7,
"packagesDir": ".lake/packages",
"packages": [],
"name": "test",
"lakeDir": ".lake"}
8 changes: 8 additions & 0 deletions test/lakefile.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import Lake
open Lake DSL

package «test» where
-- add package configuration options here

lean_lib «Test» where
globs := #[.submodules `Test]
1 change: 1 addition & 0 deletions test/lean-toolchain
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
leanprover/lean4:v4.5.0-rc1
7 changes: 2 additions & 5 deletions test/main.lean
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,9 @@ import Lean
open Lean

def sp : SearchPath :=
["."/".lake" /"build"/"lib","."/".lake" /"packages"/"std"/"build"/"lib","/home/alexanderbest/.elan/toolchains/leanprover--lean4---v4.3.0-rc2/lib/lean"]
["."/".lake" /"build"/"lib","."/".lake" /"packages"/"std"/"build"/"lib","/home/alexanderbest/.elan/toolchains/leanprover--lean4---v4.4.0-rc1/lib/lean"]

#eval summarizeDiffImports #[`Std.Classes.RatCast] #[`Std.Data.Rat] sp sp
-- #eval summarizeDiffImports #[`Mathlib] #[`Mathlib] sp₁ sp₂

#eval summarizeDiffImports #[`test.TestA] #[`test.TestB] sp sp

open private docStringExt in Lean.findDocString?
#check docStringExt
#eval summarizeDiffImports #[`test.TestA] #[`test2.Test] sp sp
1 change: 1 addition & 0 deletions test2/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/.lake
1 change: 1 addition & 0 deletions test2/Test/Basic.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
def hello := "world"
27 changes: 27 additions & 0 deletions test2/Test/Test.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
def a : Nat := 1

def b : Nat := 1

-- value changed
def c : Nat := 2

def sada : Int := 123


class blah where
(a b : Nat)

/-- not so magic number-/
def hasdoc : Int := 123


class blasdf where
(a b : Nat)

instance floo : blasdf := ⟨1, 2

theorem bloop2 : 39 := by decide

theorem defToLemma : 1 = 1 := rfl

-- #eval Leaff.printHashes ``bloop2
8 changes: 8 additions & 0 deletions test2/hashset.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import Leaff.HashSet

open Lean
#eval (mkHashSet.insertMany [3,4,5,6,7,8,9,0,1,4,6,213,2432,435,435,234,12,2]).numBuckets
#eval (mkHashSet.insertMany [3,21343245,213131,4,5,6,7,8,9,0,1,4,6,213,2432,435,435,234,12,2]).numBuckets
#eval (mkHashSet.insertMany [1]).numBuckets
#eval (mkHashSet.insertMany [3,4,5,6,7,8,9,0,1,4,6,213,2432,435,435,234,12,2,12312,12321] |>.sdiff (mkHashSet.insertMany [1,2,3])).toList
#eval (mkHashSet.insertMany [3,4] |>.sdiff (mkHashSet.insertMany [1,2,3])).toList
5 changes: 5 additions & 0 deletions test2/lake-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{"version": 7,
"packagesDir": ".lake/packages",
"packages": [],
"name": "test2",
"lakeDir": ".lake"}
9 changes: 9 additions & 0 deletions test2/lakefile.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import Lake
open Lake DSL

package «test» where
-- add package configuration options here

lean_lib «Test» where
globs := #[.submodules `Test]
-- add library configuration options here
1 change: 1 addition & 0 deletions test2/lean-toolchain
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
leanprover/lean4:v4.5.0-rc1
12 changes: 12 additions & 0 deletions test2/main.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import Leaff.Diff
import Lean

open Lean

def sp : SearchPath :=
["."/".lake" /"build"/"lib","."/".lake" /"packages"/"std"/"build"/"lib","/home/alexanderbest/.elan/toolchains/leanprover--lean4---v4.4.0-rc1/lib/lean"]

#eval summarizeDiffImports #[`Std.Classes.RatCast] #[`Std.Data.Rat] sp sp
-- #eval summarizeDiffImports #[`Mathlib] #[`Mathlib] sp₁ sp₂

#eval summarizeDiffImports #[`test.TestA] #[`test.TestB] sp sp

0 comments on commit 16ec657

Please sign in to comment.