-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move some code out of Conal/Language.lean into appropriate files
- Loading branch information
1 parent
785ac79
commit d1b4432
Showing
5 changed files
with
67 additions
and
62 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
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,39 @@ | ||
-- A translation to Lean from Agda | ||
-- https://github.com/conal/paper-2021-language-derivatives/blob/main/Decidability.lagda | ||
|
||
|
||
-- data Dec (A: Set l):Set l where | ||
-- yes: A → Dec A | ||
-- no :¬A → Dec A | ||
inductive Dec (α: Type u): Type u where | ||
| yes: α -> Dec α | ||
| no: (α -> PEmpty.{u}) -> Dec α | ||
|
||
-- ⊥? : Dec ⊥ | ||
-- ⊥? =no(𝜆()) | ||
def empty? : Dec PEmpty := | ||
Dec.no (by intro; contradiction) | ||
|
||
def unit? : Dec PUnit := | ||
Dec.yes PUnit.unit | ||
|
||
def sum? (a: Dec α) (b: Dec β): Dec (α ⊕ β) := | ||
match (a, b) with | ||
| (Dec.no a, Dec.no b) => | ||
Dec.no (fun ab => | ||
match ab with | ||
| Sum.inl sa => a sa | ||
| Sum.inr sb => b sb | ||
) | ||
| (Dec.yes a, Dec.no _) => | ||
Dec.yes (Sum.inl a) | ||
| (_, Dec.yes b) => | ||
Dec.yes (Sum.inr b) | ||
|
||
def prod? (a: Dec α) (b: Dec β): Dec (α × β) := | ||
match (a, b) with | ||
| (Dec.yes a, Dec.yes b) => Dec.yes (Prod.mk a b) | ||
| (Dec.no a, Dec.yes _) => Dec.no (fun ⟨a', _⟩ => a a') | ||
| (_, Dec.no b) => Dec.no (fun ⟨_, b'⟩ => b b') | ||
|
||
def list?: Dec α -> Dec (List α) := fun _ => Dec.yes [] |
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,19 @@ | ||
-- A translation to Lean from Agda | ||
-- https://github.com/conal/paper-2021-language-derivatives/blob/main/Symbolic.lagda | ||
|
||
import Katydid.Conal.Decidability | ||
import Katydid.Conal.Language | ||
|
||
variable {P Q : dLang α} | ||
variable {s : Type u} | ||
|
||
inductive Lang : (List α -> Type u) -> Type (u + 1) where | ||
| emptySet : Lang dLang.emptyset | ||
| universal : Lang (fun _ => PUnit) | ||
| emptyStr : Lang dLang.emptystr | ||
| char {a: Type u}: (a: α) -> Lang (dLang.char a) | ||
| or : Lang P -> Lang Q -> Lang (dLang.or P Q) | ||
| and : Lang P -> Lang Q -> Lang (dLang.and P Q) | ||
| scalar {s: Type u}: (Dec s) -> Lang P -> Lang (dLang.scalar s P) | ||
| concat : Lang P -> Lang Q -> Lang (dLang.concat P Q) | ||
| star : Lang P -> Lang (dLang.star P) |