Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typeclass lang #76

Open
wants to merge 172 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
172 commits
Select commit Hold shift + click to select a range
9dbda8c
typeclass parsing: copy parsing from pure and change pureAST
Gordon-Sau Oct 7, 2023
b9a03e7
typeclass typing: copy pure_tcexp and pure_typing
Gordon-Sau Oct 7, 2023
88a2a9e
Merge remote-tracking branch 'origin/master' into typeclassLang
Gordon-Sau Oct 7, 2023
1225587
typeclass kind_check: add an inductive set for kind_checking
Gordon-Sau Oct 8, 2023
8bd5a3a
typeclass: fixing holmake errors
Gordon-Sau Oct 17, 2023
5301eac
typeclass: update type system, add kind check and pure_tcexp
Gordon-Sau Nov 15, 2023
e9be6bf
typeclass: update AST to support class and instance declarations
Gordon-Sau Nov 15, 2023
00d42de
typeclass: complete most of ast_to_cexp
Gordon-Sau Nov 25, 2023
199ad32
typeclass: add helper functions and lemmas in tcexp
Gordon-Sau Nov 27, 2023
792c135
typeclass: update ast_to_cexp
Gordon-Sau Nov 27, 2023
68f8463
tcexp: remove unnecessary keys in instinfo
Gordon-Sau Nov 28, 2023
f672e3f
ast_to_cexp: transform all usage of finite map to mlmap
Gordon-Sau Nov 28, 2023
3e750b8
Move letrecs_distinct_def and Lets_def up
myreen Oct 4, 2023
b1b1552
Make letrecs_distinct_def into an automatic simp
myreen Oct 4, 2023
600e940
Move some definitions upwards
myreen Oct 4, 2023
7e97a54
Delete some unnecessary dependencies in `pure_tcexpTheory`
hrutvik Oct 4, 2023
a784aad
Update translation for moves
myreen Oct 4, 2023
b56f03b
Tweak pure_pres
myreen Oct 4, 2023
55fceea
Tidy up some thunkLang files
myreen Oct 4, 2023
b1dee19
Fix App_Lam rule in bidir
myreen Oct 5, 2023
4b2d955
Fix a broken proof (in an unused file)
myreen Oct 7, 2023
d8e147e
Pass in numbers on command line
hrutvik Oct 9, 2023
cb19eaf
Fix a breakage
hrutvik Oct 9, 2023
f706862
Remove some test code
hrutvik Oct 10, 2023
604c23c
Delete unused things
myreen Oct 9, 2023
6be18ed
Remove Rec and rename to inline_rel
myreen Oct 9, 2023
60ffb5e
Remove rhs type
myreen Oct 10, 2023
0795695
Replace Binds with Lets
myreen Oct 10, 2023
6a549da
Define pre and tidy up proofs
myreen Oct 10, 2023
0707363
Remove boundvars from vars_of
myreen Oct 10, 2023
d4fb191
Switch to using pure_inline_relTheory
myreen Oct 10, 2023
ba31a73
Delete crhs type and update proofs
myreen Oct 10, 2023
f410a0b
Tidy up definition of inline_rel
myreen Oct 10, 2023
39c8be8
Rearrange content of file
myreen Oct 10, 2023
88f0575
Simplify pre
myreen Oct 10, 2023
18b3c4f
Clean up the inliner implementation
KacperFKorban Oct 10, 2023
50f66ff
Remove named TODOs
KacperFKorban Oct 10, 2023
f0d8e49
Define lets_ok as in paper
myreen Oct 11, 2023
c3a3100
Switch to using remove_call_arg name (as in paper)
myreen Oct 11, 2023
d431bc6
Alternative definitions of specialisation
hrutvik Oct 12, 2023
15d044b
Add inlining to benchmarking config
hrutvik Oct 12, 2023
181938c
Update `examples` README with inlining
hrutvik Oct 12, 2023
aad8425
Delete no_shadowing (replace with barendregt)
myreen Oct 13, 2023
0b357c3
Update for rebind
myreen Oct 11, 2023
6e9ca0b
Remove some duplicates
myreen Oct 11, 2023
cf1bac4
Updates for rebind
myreen Oct 11, 2023
e85a889
Fixes for rebind
myreen Oct 13, 2023
8350da7
Fix rebinds
myreen Oct 17, 2023
8b6e8e6
Fix rebinds
myreen Oct 17, 2023
6fe323a
Add relations dir to top-level Holmakefile
myreen Oct 17, 2023
76d8822
Fix rebinds
myreen Oct 17, 2023
1b6cdb0
Update CI: longer timeout + build new `relations` directory
hrutvik Oct 18, 2023
de718bd
Update benchmarking patches
hrutvik Oct 19, 2023
246d8e7
Add a script for updating files to adjusted syntax of Inductive
myreen Nov 8, 2023
8bdb3a4
Fix for adjusted Inductive syntax in HOL
myreen Nov 8, 2023
88e5899
Fix for adjusted Inductive syntax
myreen Nov 9, 2023
24757ce
Get a file to build
myreen Nov 9, 2023
1ff186c
Fix for new `case_elim` in HOL (HOL-Theorem-Prover/HOL@64ee5d9)
hrutvik Dec 7, 2023
88588bb
Fixes for `OPTREL` changes in HOL (probably HOL-Theorem-Prover/HOL@f0…
hrutvik Dec 7, 2023
b3c7d68
typeclass: ast_to_cexp: reject duplicate function definition and crea…
Gordon-Sau Dec 12, 2023
1110f32
remove /\ in kind_wf definition
Gordon-Sau Dec 12, 2023
57c1337
typeclass: add wellformedness check (TODO)
Gordon-Sau Dec 26, 2023
6a88061
typeclassLang: update the prefix to "typeclass_" and update well-form…
Gordon-Sau Feb 9, 2024
fb6a859
typeclassLang: move the implementations of maps for type classes and …
Gordon-Sau Feb 9, 2024
4c908f6
typeclassLang: implement a generic cycle detection algorithm
Gordon-Sau Feb 9, 2024
640359c
typeclassLang: implement cycle detection for typeclass superclass rel…
Gordon-Sau Feb 9, 2024
4a8dc58
typeclass: change the proof for cycle_detection to use TC_depends_on_…
Gordon-Sau Feb 10, 2024
53671c8
typeclassLang: attempt to update unification
Gordon-Sau Feb 9, 2024
e3020bf
typeclass: update datatype for type
Gordon-Sau Feb 16, 2024
1620167
half way through unification
Gordon-Sau Feb 17, 2024
98bc413
unification done
Gordon-Sau Feb 20, 2024
26bc7e2
typeclass: prove termination of by_super
Gordon-Sau Mar 5, 2024
b67b99b
typeclass: update definition of by_super
Gordon-Sau Mar 19, 2024
ff88baa
typeclass: complete by_super_aux termination proof
Gordon-Sau Mar 19, 2024
150e9ad
typeclass_env_map: prove by_super implies super_reachable
Gordon-Sau Mar 19, 2024
1b4bb16
typeclass_env_map: make by_super_IMP_reachable stronger
Gordon-Sau Mar 21, 2024
e24f755
typeclass_env_map: prove that if something is reachable, then it is v…
Gordon-Sau Mar 21, 2024
bb2d2fd
type_env_map: prove that by_super_aux is equivalent to super_reachable
Gordon-Sau Mar 21, 2024
73686ef
typeclas_env_map: prove that if the cl_map is well_formed, then by_su…
Gordon-Sau Mar 21, 2024
c492569
update instance syntax and inst_map
Gordon-Sau Mar 21, 2024
6c0e7fd
typeclass_env_map: add init_inst_map and inst_map_cmp (the comparison…
Gordon-Sau Apr 1, 2024
bf6eef8
typeclass: fix ast_to_cexp
Gordon-Sau Apr 1, 2024
4a920ce
typeclass_env_map: add by_inst
Gordon-Sau Apr 1, 2024
20c3dae
typeclass_env_map: add some entail theorems
Gordon-Sau Apr 3, 2024
f190511
typeclass_types: add tcons_to_type to typeclass_types
Gordon-Sau Apr 4, 2024
808c588
typeclass: refactroring, update spec and typing rules
Gordon-Sau Apr 5, 2024
10a7dd8
typeclass_typing: update typing and class constraint elaboration rules
Gordon-Sau Apr 13, 2024
9473173
typeclass_typing: add typing rules for Prim
Gordon-Sau Apr 13, 2024
800f7a2
typeclass_typing: add typing rules for NestedCases
Gordon-Sau Apr 13, 2024
5d504e1
typeclass_typing: prove kind is preserved under substitution and typi…
Gordon-Sau Apr 13, 2024
f3a1220
typeclass_typing: implement translation of predicate (termination pro…
Gordon-Sau Apr 15, 2024
5f2d7e2
typeclass pure_tcexp: updatepure_tcexp with Nestedcase
Gordon-Sau Apr 17, 2024
7e9d23c
typeclass typing: renamce typeclass_tcexp to texp and add exhausive c…
Gordon-Sau Apr 17, 2024
91c2c19
typeclass pure_tcexp: add NestedCase to pure_tcexp and update lemmas …
Gordon-Sau Apr 17, 2024
c0fb2f7
typeclass tcexp: add the check that case pattern does not contain the…
Gordon-Sau Apr 18, 2024
8897617
typeclass typing: update typing rules for tcexp
Gordon-Sau Apr 18, 2024
251021c
typeclass typing: update translate pred types related stuffs
Gordon-Sau Apr 19, 2024
2a99f72
update pure_tcexp_typing
Gordon-Sau May 10, 2024
9c5bd61
add type_elaborate_prog
Gordon-Sau May 10, 2024
878f16e
implement prog_construct_dict
Gordon-Sau May 11, 2024
ffe7eec
fix class_env_to_env
Gordon-Sau May 12, 2024
3279f7a
type_check foldMap
Gordon-Sau May 13, 2024
7eaf764
type_check foldMap and mappend for list
Gordon-Sau May 13, 2024
153433c
type chest example
Gordon-Sau May 14, 2024
f2415e8
prove type_elaborate example with default methods
Gordon-Sau May 15, 2024
5c75063
typecheck example with instances with constraints
Gordon-Sau May 16, 2024
5df4527
fix super class translationg in instance_construct_dict
Gordon-Sau May 17, 2024
9e3adc8
use SmartLam and prove test_instance_env_construct_dict
Gordon-Sau May 18, 2024
f9c7615
move thms to the right places
Gordon-Sau May 19, 2024
2837f1b
fixing typingProps
Gordon-Sau May 22, 2024
a626da6
fixing typing rules for typeclass lang and proving props for the typi…
Gordon-Sau May 26, 2024
021ec94
add some theorems in typeclass_kindCheck and typeclass_texp
Gordon-Sau May 26, 2024
7582f36
add itype_kind_ok to inference_common
Gordon-Sau May 26, 2024
5fd8a16
move theorems from typeclass_env_map_impl to typeclass_typesProps
Gordon-Sau May 26, 2024
4c398db
fix typeclass typing rules example
Gordon-Sau May 26, 2024
662c969
fixing typing rules
Gordon-Sau May 27, 2024
91048ed
fix pure_tcexp_typing Case rule and prove type_ok
Gordon-Sau May 29, 2024
48e9ecc
prove type_tcexp_subst_db
Gordon-Sau Jun 9, 2024
57de8ee
proving shift_db
Gordon-Sau Jun 9, 2024
781cd16
proved type_tcxp_shift_db
Gordon-Sau Jun 9, 2024
57e6d06
prove freevars_specialises
Gordon-Sau Jun 10, 2024
f67a54e
update Seq rule for insert_seq
Gordon-Sau Jun 11, 2024
156e185
Proves that insert_seq preserves typing and updated proofs that break…
Gordon-Sau Jun 12, 2024
f07fcca
update typesoundness proofs with some cheats
Gordon-Sau Jun 13, 2024
fe6a9d0
Fix a theory name
IlmariReissumies Jun 17, 2024
a129727
Fix another theory name
IlmariReissumies Jun 17, 2024
9762758
Fix some more theory names
IlmariReissumies Jun 17, 2024
825eb84
Prove some "easy" cases from type_soundness_up_to
IlmariReissumies Jun 18, 2024
c32b0df
Use >~ instead of comments to signpost
IlmariReissumies Jun 18, 2024
d7f961f
Prove Apps case
IlmariReissumies Jun 18, 2024
217516e
Prove Letrec case
IlmariReissumies Jun 18, 2024
a7cba93
start working on dictionary construction proof
Gordon-Sau Jun 16, 2024
050fd95
adding distinctness conditions
Gordon-Sau Jun 21, 2024
c90d6ad
prove the var and pred case
Gordon-Sau Jun 22, 2024
91d777d
working on Let rule and found that we need to shift lie when we are g…
Gordon-Sau Jun 22, 2024
9a4124a
tshift the lie in the typing rules
Gordon-Sau Jun 23, 2024
62e71d9
typeclass: texp_construct_dict_type_tcexp: prove Let and Lam case
Gordon-Sau Jun 23, 2024
9fd797d
Cons
Gordon-Sau Jun 24, 2024
e0912f2
separate exists and type_tcexp proof
Gordon-Sau Jun 24, 2024
41641fb
more cases
Gordon-Sau Jun 25, 2024
b66f66d
change PrimSeq rule
Gordon-Sau Jun 27, 2024
e936710
change the defintion of destruactalbe_type and tcexp_exhaustive_cepat…
Gordon-Sau Jun 29, 2024
f941839
Merge branch 'typeclassLang' of github.com:CakeML/pure into typeclass…
Gordon-Sau Jun 29, 2024
5aed581
complete the induction theorem for dictionary translation
Gordon-Sau Jun 30, 2024
6c5dfb4
prove well-typedness of class_env_construct_dict
Gordon-Sau Jul 8, 2024
79e3fed
Merge branch 'master' into typeclassLang
hrutvik Aug 20, 2024
86f5f1a
Add type class work to regression + top-level Holmakefile
hrutvik Aug 27, 2024
a14f29c
Merge branch 'typeclassLang' of github.com:CakeML/pure into typeclass…
Gordon-Sau Sep 6, 2024
2cbd29b
typeclassLang: refactoring: updates the fintate maps to remove some s…
Gordon-Sau Sep 15, 2024
ee383ac
typeclassLang: update typing Proof
Gordon-Sau Sep 17, 2024
c0e9c5e
typeclassLang: update typing Proof
Gordon-Sau Sep 18, 2024
cd168ee
typeclassLang: update the definition of type_elaborate_prog and prog_…
Gordon-Sau Sep 18, 2024
d10134b
typeclass: prove the superclass accessors in the translated lang is w…
Gordon-Sau Sep 22, 2024
b47bb86
typeclass: prove that the method accessors are well-typed and fix the…
Gordon-Sau Sep 23, 2024
be11591
typeclass: prove impls well-typed and default implementations are wel…
Gordon-Sau Sep 28, 2024
ec17734
update main theorem
Gordon-Sau Oct 6, 2024
e43ed9b
typeclass: complete typing translation proof
Gordon-Sau Oct 8, 2024
d748f02
typeclass: remove trailing whitespace
Gordon-Sau Oct 8, 2024
9692a2d
typeclass: fix test_typeclass_typing
Gordon-Sau Oct 8, 2024
33f341f
typeclass: fix typeclass_env_map_impl
Gordon-Sau Oct 9, 2024
614c35c
typeclass: remove cycle_detection as it is now in HOL
Gordon-Sau Oct 10, 2024
beaad40
typeclass: fix ast_to_cexp and fix texp_wf
Gordon-Sau Oct 11, 2024
43fcd63
typeclass: small cleanup
Gordon-Sau Oct 11, 2024
7ec1b34
typeclass: update destruct_type_cons
Gordon-Sau Oct 12, 2024
0bf0a37
typeclass: update definition of exhaustive_cepat
Gordon-Sau Oct 13, 2024
daaf2a6
typeclass: fix exhaustive_cepat
Gordon-Sau Oct 13, 2024
5f8e72d
typeclass: fix type_soundness_next
Gordon-Sau Oct 13, 2024
a7e79fb
typeclass: fix type_soundness_up_to Case
Gordon-Sau Oct 14, 2024
186f8ca
typeclass: fix the file structure. Revert changes in typing/ and move…
Gordon-Sau Oct 16, 2024
8a5541a
typeclass: add a readme
Gordon-Sau Oct 16, 2024
af1b574
typeclass: add description for test_typeclass_typing
Gordon-Sau Oct 16, 2024
bcd4189
typeclass: fix the workflow to build things in typeclass/
Gordon-Sau Oct 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/pure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ jobs:
run: cd pure/compiler/backend/languages/properties && Holmake
- name: Build typing
run: cd pure/typing && Holmake
- name: Build typeclass/typing
run: cd pure/typeclass/typing && Holmake
- name: Build typeclass/compiler/parsing
run: cd pure/typeclass/compiler/parsing && Holmake
- name: Build compiler/backend/passes
run: cd pure/compiler/backend/passes && Holmake
- name: Build compiler/backend/passes/proofs
Expand Down
2 changes: 2 additions & 0 deletions Holmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ INCLUDES = misc\
compiler/backend/languages/properties\
compiler/backend/languages/relations\
typing\
typeclass/compiler/parsing\
typeclass/typing\
compiler/backend/passes\
compiler/backend/passes/proofs\
compiler/parsing\
Expand Down
10 changes: 10 additions & 0 deletions typeclass/Holmakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
ifndef CAKEMLDIR
CAKEMLDIR = $(HOME)/cakeml/master
endif

INCLUDES = $(CAKEMLDIR)/basis/pure \
$(PUREDIR)/misc \
$(HOLDIR)/examples/algorithms \
$(PUREDIR)/typeclass/typing \
$(PUREDIR)/typeclass/compiler/parsing \

21 changes: 21 additions & 0 deletions typeclass/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# TypeclassLang

This is a language that support type classes. The file structure is similar to pure.
- compiler/parsing: contains the AST for typeclassLang and defines how the AST is translated to TypeclassLang. The lexer and parser is not done yet.
- typing: It contains all the typing related stuffs
- `typeclass_types`: We update the datatype for types to allow types like `m a`.
- `typeclass_kindCheck`: This defines the kinding rules.
- `typeclass_typing`: This translates TypeclassLang to pureLang. It defines the type elaborating relation and the dictionary construction relation (We split the relation in the original paper into two relations). The ie parameter in the relations is generated from the `class_map` and `inst_list`. It also contains how types and environment is translated when typeclassLang is translated to pureLang.
- `test_typeclass_typing`: This is an example that types a program in TypeclassLang and translates it to pureLang.
- `pure_tcexp_typing`: This defines the typing rules for tcexp. We need to change the typing rules because we need to allow constructors like `MonadDict (forall a. m a -> (a -> m a) -> m a)` to make the type translation proof work.
- `typeclass_typingProof`: This proves the if the expression in typeclassLang is well-typed, and we can construct the dictionaries, then the translated expression in pureLang is well-typed.
- `pure_tcexp_typingProof`: This proves the type soundness of the typing relation defined in `pure_tcexp_typing`. The `NestedCase` is still WIP.
- `typeclass_env_map_impl`: This defines the concreate data structures for classes and instances. It defines some well-formedness conditions. It also defines `by_super`, `by_inst` and `entail` (an implementation of `has_dict`), which should be useful for inferencing.

TODO:
- type soundness proof (`NestedCase` case)
- parsing: lexer, parser and well-formedness check
- concrete implementation of dictionary construction
- type inferencing
- kind inferencing

1 change: 1 addition & 0 deletions typeclass/compiler/parsing/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
parsing-selftest.log
16 changes: 16 additions & 0 deletions typeclass/compiler/parsing/Holmakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
ifndef CAKEMLDIR
CAKEMLDIR = $(HOME)/cakeml/master
endif

INCLUDES = $(HOLDIR)/examples/formal-languages/context-free \
$(CAKEMLDIR)/semantics \
$(CAKEMLDIR)/basis/pure \
$(PUREDIR)/typeclass/typing \
$(PUREDIR)/misc/

HOLHEAP = $(CAKEMLDIR)/misc/cakeml-heap

all: $(DEFAULT_TARGETS)

.PHONY: all

Loading