Skip to content

Commit 33737f0

Browse files
committed
Juvix.Core.Main.Language
1 parent 710b4fe commit 33737f0

File tree

11 files changed

+73
-2
lines changed

11 files changed

+73
-2
lines changed

Juvix.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
-- This module serves as the root of the `Juvix` library.
22
-- Import modules here that should be built as part of the library.
3-
import Juvix.Basic
3+
import Juvix.Core.Main

Juvix/Basic.lean

Lines changed: 0 additions & 1 deletion
This file was deleted.

Juvix/Core/Main.lean

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
import Juvix.Core.Main.Language
3+
import Juvix.Core.Main.Semantics

Juvix/Core/Main/Language.lean

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
import Juvix.Core.Main.Language.Base
3+
import Juvix.Core.Main.Language.Value

Juvix/Core/Main/Language/Base.lean

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
2+
namespace Juvix.Core.Main
3+
4+
abbrev Name : Type := String
5+
6+
inductive Constant : Type where
7+
| int : Int → Constant
8+
| string : String → Constant
9+
deriving Inhabited, DecidableEq
10+
11+
inductive BuiltinOp : Type where
12+
| add_int : BuiltinOp
13+
| sub_int : BuiltinOp
14+
| mul_int : BuiltinOp
15+
| div_int : BuiltinOp
16+
deriving Inhabited, DecidableEq
17+
18+
mutual
19+
inductive Expr : Type where
20+
| var : Nat → Expr
21+
| ident : Name → Expr
22+
| const : Constant → Expr
23+
| app : Expr → Expr → Expr
24+
| builtin_app : (oper : BuiltinOp) → (args : List Expr) → Expr
25+
| constr_app : (constr : Name) → (args : List Expr) → Expr
26+
| lambda : (body : Expr) → Expr
27+
| let : (value : Expr) → (body : Expr) → Expr
28+
| case : (value : Expr) → (branches : List CaseBranch) → Expr
29+
| unit : Expr
30+
deriving Inhabited
31+
32+
structure CaseBranch where
33+
constr : Name
34+
body : Expr
35+
end
36+
37+
structure Program where
38+
defs : List Expr
39+
40+
end Juvix.Core.Main

Juvix/Core/Main/Language/Value.lean

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
2+
import Juvix.Core.Main.Language.Base
3+
4+
namespace Juvix.Core.Main
5+
6+
inductive Value : Type where
7+
| const : Constant → Value
8+
| constr_app : (constr : Name) → (args : List Value) → Value
9+
| closure : (ctx : List Value) → (value : Expr) → Value
10+
| unit : Value
11+
deriving Inhabited
12+
13+
abbrev Context : Type := List Value
14+
15+
end Juvix.Core.Main

Juvix/Core/Main/Semantics.lean

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
import Juvix.Core.Main.Language
3+
4+
namespace Juvix.Core.Main
5+
6+
def f : Expr -> Expr := λ e =>
7+
match e with
8+
| Expr.lambda (body := e) => e
9+
| _ => Expr.lambda (body := e)
10+
11+
end Juvix.Core.Main

Juvix/Core/Stored/Language.lean

Whitespace-only changes.

Juvix/Core/Stored/Semantics.lean

Whitespace-only changes.

Juvix/Core/Stripped/Language.lean

Whitespace-only changes.

Juvix/Core/Stripped/Semantics.lean

Whitespace-only changes.

0 commit comments

Comments
 (0)