-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #46 from paulcadman/session-2024-11-18
Session 2024-11-18
- Loading branch information
Showing
10 changed files
with
73 additions
and
11 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,15 @@ | ||
{"version": "1.1.0", | ||
"packagesDir": ".lake/packages", | ||
"packages": [], | ||
"name": "«lean-raylib»", | ||
"packages": | ||
[{"url": "https://github.com/leanprover-community/batteries.git", | ||
"type": "git", | ||
"subDir": null, | ||
"scope": "", | ||
"rev": "01f4969b6e861db6a99261ea5eadd5a9bb63011b", | ||
"name": "batteries", | ||
"manifestFile": "lake-manifest.json", | ||
"inputRev": "01f4969b6e861db6a99261ea5eadd5a9bb63011b", | ||
"inherited": false, | ||
"configFile": "lakefile.toml"}], | ||
"name": "raylean", | ||
"lakeDir": ".lake"} |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
leanprover/lean4:v4.13.0 | ||
leanprover/lean4:v4.14.0-rc1 |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import Raylean | ||
import Batteries | ||
|
||
open Raylean.Types | ||
|
||
structure Location where | ||
x : Rat | ||
y : Rat | ||
|
||
def Image (α : Type) : Type := Location → α | ||
|
||
def lift0 (a : α) : Image α := Function.const _ a | ||
|
||
def lift1 (f : α → β) : (Image α → Image β) := fun g => f ∘ g | ||
|
||
def lift2 (f : α → β → γ) : (Image α → Image β → Image γ) := | ||
fun ia ib => fun l => f (ia l) (ib l) | ||
|
||
def monochrome (a : α) := lift0 a | ||
|
||
def blend (a1 a2 : Color) : Color := | ||
if a1.a == 0 then a2 else a1 | ||
|
||
def over [BEq α] [Inhabited α] (a1 a2 : α) : α := | ||
if a1 == default then a2 else a1 | ||
|
||
def overi [BEq α] [Inhabited α] (i1 i2 : Image α) : Image α := lift2 over i1 i2 | ||
|
||
def blendi (i1 i2 : Image Color) : Image Color := lift2 blend i1 i2 | ||
|
||
def condi (c : Image Bool) (ia1 ia2 : Image α) : Image α := | ||
fun l => if c l then ia1 l else ia2 l | ||
|
||
def emptyImage : Image Color := monochrome Color.transparent | ||
|
||
def crop (c : Image Bool) (im : Image Color) : Image Color := condi c im emptyImage | ||
|
||
def transform (f : Location → Location) (i : Image Color) : Image Color := i ∘ f | ||
|
||
instance [i : Inhabited α] : Inhabited (Image α) where | ||
default := monochrome i.default | ||
|
||
instance [BEq α] [Inhabited α] [Append α] : Append (Image α) where | ||
append : Image α → Image α → Image α := overi | ||
|
||
instance : Append (Image Color) where | ||
append : Image Color → Image Color → Image Color := blendi |
This file contains 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