Skip to content

Merge the prop equality extension #287

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

Merged
merged 91 commits into from
Jul 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
91 commits
Select commit Hold shift + click to select a range
41daec1
Merge pull request #206 from Beluga-lang/main
HuStmpHrrr Sep 15, 2024
a7fe369
update syntax for propositional equality (#205)
HuStmpHrrr Sep 15, 2024
5fecefe
add rules for prop equality (#207)
HuStmpHrrr Sep 15, 2024
e303379
fix context subtyping (#208)
HuStmpHrrr Sep 15, 2024
80c5477
Merge branch 'main' into pr-merge-main
Ailrun Sep 17, 2024
de0694f
Merge pull request #214 from Beluga-lang/pr-merge-main
Ailrun Sep 17, 2024
0303e99
Merge pull request #216 from Beluga-lang/main
Ailrun Sep 18, 2024
12261d3
Merge remote-tracking branch 'Beluga-lang/main' into pr-fix-prop-eq-g…
Ailrun Sep 19, 2024
9199213
Fix precendences to avoid weird substitution
Ailrun Sep 19, 2024
b590d32
Merge pull request #221 from Beluga-lang/pr-fix-prop-eq-grammar
Ailrun Sep 19, 2024
1829f6b
Feature/fix presup (#223)
HuStmpHrrr Sep 30, 2024
8b37077
Merge remote-tracking branch 'Beluga-lang/main' into pr-update-prop-e…
Ailrun Sep 30, 2024
522b9c6
Merge pull request #231 from Beluga-lang/pr-update-prop-eq-presup
Ailrun Sep 30, 2024
604391b
Merge branch 'main' into ext/prop-eq
Ailrun Oct 1, 2024
cb61d68
Merge pull request #235 from Beluga-lang/main
Ailrun Oct 1, 2024
bd5d609
Merge remote-tracking branch 'Beluga-lang/main' into pr-port-consistency
Ailrun Oct 2, 2024
23772fc
Merge pull request #237 from Beluga-lang/pr-port-consistency
Ailrun Oct 2, 2024
8a8ceb2
Merge pull request #240 from Beluga-lang/main
Ailrun Oct 4, 2024
6757806
Optimize presup
Ailrun Oct 2, 2024
44c8633
Merge pull request #241 from Beluga-lang/pr-optimize-presup
Ailrun Oct 4, 2024
2e9760e
back merge (#244)
HuStmpHrrr Oct 5, 2024
20415bb
Optimize a bit more
Ailrun Oct 5, 2024
ae037ab
Merge pull request #245 from Beluga-lang/pr-optimize-presup
Ailrun Oct 5, 2024
a41fce1
Merge remote-tracking branch 'Beluga-lang/main' into pr-port-main
Ailrun Oct 8, 2024
f689b92
Merge pull request #249 from Beluga-lang/pr-port-main
Ailrun Oct 8, 2024
0f98b91
Merge pull request #255 from Beluga-lang/main
HuStmpHrrr Oct 18, 2024
4072e80
Add semantics for prop eq (#254)
Ailrun Oct 20, 2024
871ae8c
Eq completeness cases and some optimization (#256)
Ailrun Oct 26, 2024
97c560d
Working on soundness proof (#259)
HuStmpHrrr Nov 16, 2024
295ba57
Merge branch 'main' into feature/merge-from-main
HuStmpHrrr Nov 23, 2024
4a412da
change mcltt to mctt
HuStmpHrrr Nov 23, 2024
1fd96bb
leftover
HuStmpHrrr Nov 23, 2024
3e33620
Merge pull request #266 from Beluga-lang/feature/merge-from-main
HuStmpHrrr Nov 23, 2024
d626e59
Fix realizability and Lemmas (#267)
HuStmpHrrr Dec 4, 2024
03d5f3b
add a template for soundness proof (#270)
HuStmpHrrr Dec 9, 2024
0507289
finished semantic well-formedness of equality type (#271)
HuStmpHrrr Dec 19, 2024
f0dbf07
fix build on MacOS (#278)
jiangsy May 13, 2025
57742eb
Merge pull request #279 from Beluga-lang/main
Ailrun May 13, 2025
549a1d8
existential destruction keeps the original name
jiangsy May 15, 2025
cbafff0
look at rel_exp_eqrec_cong
jiangsy May 19, 2025
806e968
try to make some progress on rel_exp_eqrec_sub
jiangsy May 21, 2025
03bbc4b
finish rel_exp_eqrec_beta
jiangsy May 21, 2025
f193b59
minor changes
jiangsy May 22, 2025
462e55f
try to extract more common parts in rel_exp_eqrec_per_ctx_env_gen, bu…
jiangsy May 22, 2025
88c41f6
really a bit insane for rel_exp_eqrec_sub
jiangsy May 22, 2025
8fbaecb
the first case of rel_exp_eqrec_sub looks (almost) good
jiangsy May 22, 2025
e9c6fd4
Merge branch 'ext/prop-eq' into ext/prop-eq-dev
jiangsy May 22, 2025
e7dedcd
more on rel_exp_eqrec_sub
jiangsy May 23, 2025
d04abd0
look at the second case in rel_exp_eqrec_sub
jiangsy May 23, 2025
7e90e32
fix the notation def for eqrec
jiangsy May 23, 2025
d6a9169
abstract over eval_eqrec_sub_neut
jiangsy May 23, 2025
98e43e2
rel_exp_eqrec_sub should be good modulo eval_eqrec_sub_neut and some …
jiangsy May 24, 2025
d3bae96
finished rel_exp_eqrec_sub modulo eval_eqrec_sub_neut
jiangsy May 24, 2025
bc9c0a0
eval_eqrec_sub_neut should be good
jiangsy May 25, 2025
566f2ae
fix the def of eval_eqrec_sub_neut
jiangsy May 26, 2025
7af6d75
an ugly but working eval_eqrec_sub_neut
jiangsy May 26, 2025
28545cb
improve robustness of the script
jiangsy May 26, 2025
b72f4e8
look at rel_exp_eqrec_cong
jiangsy May 29, 2025
0f18d80
the first case of rel_exp_eqrec_cong looks good
jiangsy May 29, 2025
3ab7580
completeness is done
jiangsy May 29, 2025
b44e31c
some cleaning
jiangsy May 29, 2025
2491406
rename lazy_destruct to deex_destruct_rel and add comments
jiangsy May 29, 2025
d34f802
minor
jiangsy May 29, 2025
ab10e9e
Merge pull request #281 from Beluga-lang/pr-prop-eq-completeness
jiangsy Jun 4, 2025
04a1c85
Soundness for the extension of judgmental equality (#284)
jiangsy Jun 18, 2025
31d4854
Merge branch 'main' into ext/prop-eq
jiangsy Jun 18, 2025
6faad5e
Finish eq impl
Ailrun Jun 19, 2025
80b8ac1
Fix indentation
Ailrun Jun 19, 2025
c175918
Merge branch 'ext/prop-eq' into pr-finish-eq
Ailrun Jun 19, 2025
90d1a1e
Merge pull request #285 from Beluga-lang/pr-finish-eq
jiangsy Jun 19, 2025
836ed70
Add two examples of prop eq (#286)
Ailrun Jun 19, 2025
f242b95
Optimize type checker proofs a bit
Ailrun Jun 19, 2025
d22e249
Bring dune test back
Ailrun Jun 19, 2025
1084c5b
Optimize type checker proofs a lot
Ailrun Jun 20, 2025
553bc6a
Optimize prop eq soundness a bit
Ailrun Jun 20, 2025
e5bf3f2
use better names
jiangsy Jun 21, 2025
0b50f09
remove unnecessary handle_per_univ_elem_irrel
jiangsy Jun 21, 2025
be1cdce
more unnecessary tactics
jiangsy Jun 21, 2025
3ef0bf0
Merge branch 'main' into port-pr-288
Ailrun Jun 26, 2025
1b440a9
Merge pull request #289 from Beluga-lang/port-pr-288
Ailrun Jun 26, 2025
dac3461
Replace conv rules with conv' helpers
Ailrun Jun 26, 2025
6ad0a86
Improve tactics a bit
Ailrun Jun 26, 2025
2b77d11
Merge branch 'main' into ext/prop-eq
jiangsy Jun 30, 2025
274a659
Merge branch 'main' into ext/prop-eq
jiangsy Jun 30, 2025
4a7458b
fix rel_exp_eqrec_cong
jiangsy Jul 1, 2025
0751c2e
Remove all UIP usages
Ailrun Jul 1, 2025
b7daa1a
Remove unused tactic
Ailrun Jul 1, 2025
422057a
Merge branch 'main' into ext/prop-eq
Ailrun Jul 1, 2025
e277824
Merge branch 'main' into ext/prop-eq
jiangsy Jul 1, 2025
026381a
mark todo
jiangsy Jul 1, 2025
4b79c50
Merge branch 'main' into ext/prop-eq
jiangsy Jul 5, 2025
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.vscode

# Dune outputs
_build
*.opam
Expand Down
19 changes: 17 additions & 2 deletions driver/Lexer.mll
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,12 @@
| DOT _ -> "."
| LET _ -> "let"
| IN _ -> "in"
| EQ _ -> ":="
| DEF _ -> ":="
| EQ _ -> "="
| LANGLE _ -> "<"
| RANGLE _ -> ">"
| REFL _ -> "refl"
| AS _ -> "as"

let get_range_of_token : token -> (position * position) =
function
Expand All @@ -69,7 +74,12 @@
| DOT r
| LET r
| IN r
| DEF r
| EQ r
| LANGLE r
| RANGLE r
| REFL r
| AS r
| VAR (r, _) -> r

let format_token (f: Format.formatter) (t: token): unit =
Expand Down Expand Up @@ -109,7 +119,12 @@ rule read =
| "." { DOT (get_range lexbuf) }
| "let" {LET (get_range lexbuf) }
| "in" {IN (get_range lexbuf) }
| ":=" {EQ (get_range lexbuf) }
| ":=" {DEF (get_range lexbuf) }
| "=" {EQ (get_range lexbuf) }
| "<" {LANGLE (get_range lexbuf) }
| ">" {RANGLE (get_range lexbuf) }
| "refl" {REFL (get_range lexbuf) }
| "as" {AS (get_range lexbuf) }
| string { VAR (get_range lexbuf, Lexing.lexeme lexbuf) }
| _ as c { failwith (Format.asprintf "@[<v 2>Lexer error:@ @[<v 2>Unexpected character %C@ at %a@]@]@." c format_position lexbuf.lex_start_p) }
and comment =
Expand Down
100 changes: 76 additions & 24 deletions driver/PrettyPrinter.ml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ let rec get_pi_params_of_obj : Cst.obj -> (string * Cst.obj) list * Cst.obj =
let rec format_obj_prec (p : int) (f : Format.formatter) : Cst.obj -> unit =
let open Format in
function
| Cst.Coq_var x -> pp_print_string f x
| Cst.Coq_typ i -> fprintf f "Type@%d" i
| Cst.Coq_nat -> fprintf f "Nat"
| Cst.Coq_zero -> fprintf f "0"
Expand All @@ -61,17 +62,10 @@ let rec format_obj_prec (p : int) (f : Format.formatter) : Cst.obj -> unit =
format_obj escr mx format_obj em format_obj ez sx sr format_obj es
in
pp_print_paren_if (p >= 1) impl f ()
| Cst.Coq_app (ef, ea) ->
let impl f () =
fprintf f "%a@ %a" (format_obj_prec 1) ef (format_obj_prec 2) ea
in
pp_open_hvbox f 2;
pp_print_paren_if (p >= 2) impl f ();
pp_close_box f ()
| Cst.Coq_fn (px, ep, ebody) ->
let params, ebody' = get_fn_params_of_obj ebody in
| Cst.Coq_pi (px, ep, eret) ->
let params, eret' = get_pi_params_of_obj eret in
let impl f () =
pp_print_string f "fun ";
pp_print_string f "forall ";
pp_open_tbox f ();
pp_set_tab f ();
pp_print_list ~pp_sep:pp_print_tab format_obj_param f ((px, ep) :: params);
Expand All @@ -81,15 +75,15 @@ let rec format_obj_prec (p : int) (f : Format.formatter) : Cst.obj -> unit =
then pp_print_space f ()
else pp_force_newline f ()
end;
fprintf f "-> @[<hov 2>%a@]" format_obj ebody'
fprintf f "-> @[<hov 2>%a@]" format_obj eret'
in
pp_open_hvbox f 2;
pp_print_paren_if (p >= 1) impl f ();
pp_close_box f ()
| Cst.Coq_pi (px, ep, eret) ->
let params, eret' = get_pi_params_of_obj eret in
| Cst.Coq_fn (px, ep, ebody) ->
let params, ebody' = get_fn_params_of_obj ebody in
let impl f () =
pp_print_string f "forall ";
pp_print_string f "fun ";
pp_open_tbox f ();
pp_set_tab f ();
pp_print_list ~pp_sep:pp_print_tab format_obj_param f ((px, ep) :: params);
Expand All @@ -99,12 +93,49 @@ let rec format_obj_prec (p : int) (f : Format.formatter) : Cst.obj -> unit =
then pp_print_space f ()
else pp_force_newline f ()
end;
fprintf f "-> @[<hov 2>%a@]" format_obj eret'
fprintf f "-> @[<hov 2>%a@]" format_obj ebody'
in
pp_open_hvbox f 2;
pp_print_paren_if (p >= 1) impl f ();
pp_close_box f ()
| Cst.Coq_var x -> pp_print_string f x
| Cst.Coq_app (ef, ea) ->
let impl f () =
fprintf f "%a@ %a" (format_obj_prec 1) ef (format_obj_prec 2) ea
in
pp_open_hvbox f 2;
pp_print_paren_if (p >= 2) impl f ();
pp_close_box f ()
| Cst.Coq_prop_eq (e1, et, e2) ->
let impl f () =
fprintf f "%a@ =<%a>@ %a" (format_obj_prec 1) e1 (format_obj_prec 0) et (format_obj_prec 1) e2
in
pp_open_hvbox f 2;
pp_print_paren_if (p >= 1) impl f ();
pp_close_box f ()
| Cst.Coq_refl (et, ex) ->
let impl f () =
fprintf f "refl@ %a@ %a" (format_obj_prec 2) et (format_obj_prec 2) ex
in
pp_open_hvbox f 2;
pp_print_paren_if (p >= 1) impl f ();
pp_close_box f ()
| Cst.Coq_eqrec (escr, mx, my, mz, em, rx, er, e1, ea, e2) ->
let impl f () =
fprintf f
"@[<hv 0>@[<hov 2>rec %a@ as %a =<%a> %a@ return %s %s %s . %a@]@ @[<hov 2>| refl %s =>@ \
%a@]@ end@]"
format_obj escr
format_obj e1
format_obj ea
format_obj e2
mx
my
mz
format_obj em
rx
format_obj er
in
pp_print_paren_if (p >= 1) impl f ()

and format_obj_param f (px, ep) = Format.fprintf f "(%s : %a)" px format_obj ep
and format_obj f = format_obj_prec 0 f
Expand All @@ -128,6 +159,9 @@ let exp_to_obj =
fun () -> suffix := 0 )
in
let rec impl (ctx : string list) : exp -> Cst.obj = function
| Coq_a_var x -> Cst.Coq_var (List.nth ctx x)
| Coq_a_typ i -> Cst.Coq_typ i
| Coq_a_nat -> Cst.Coq_nat
| Coq_a_zero -> Cst.Coq_zero
| Coq_a_succ e -> Cst.Coq_succ (impl ctx e)
| Coq_a_natrec (em, ez, es, escr) ->
Expand All @@ -139,9 +173,11 @@ let exp_to_obj =
let ez' = impl ctx ez in
let es' = impl (sr :: sx :: ctx) es in
Cst.Coq_natrec (escr', mx, em', ez', sx, sr, es')
| Coq_a_nat -> Cst.Coq_nat
| Coq_a_typ i -> Cst.Coq_typ i
| Coq_a_var x -> Cst.Coq_var (List.nth ctx x)
| Coq_a_pi (ep, eret) ->
let px = match ep with Coq_a_typ _ -> new_tyvar () | _ -> new_var () in
let ep' = impl ctx ep in
let eret' = impl (px :: ctx) eret in
Cst.Coq_pi (px, ep', eret')
| Coq_a_fn (ep, ebody) ->
let px = match ep with Coq_a_typ _ -> new_tyvar () | _ -> new_var () in
let ep' = impl ctx ep in
Expand All @@ -151,11 +187,27 @@ let exp_to_obj =
let ef' = impl ctx ef in
let ea' = impl ctx ea in
Cst.Coq_app (ef', ea')
| Coq_a_pi (ep, eret) ->
let px = match ep with Coq_a_typ _ -> new_tyvar () | _ -> new_var () in
let ep' = impl ctx ep in
let eret' = impl (px :: ctx) eret in
Cst.Coq_pi (px, ep', eret')
| Coq_a_eq (et, e1, e2) ->
let et' = impl ctx et in
let e1' = impl ctx e1 in
let e2' = impl ctx e2 in
Cst.Coq_prop_eq (e1', et', e2')
| Coq_a_refl (et, ex) ->
let et' = impl ctx et in
let ex' = impl ctx ex in
Cst.Coq_refl (et', ex')
| Coq_a_eqrec (ea, em, er, e1, e2, escr) ->
let ea' = impl ctx ea in
let mx = match ea with Coq_a_typ _ -> new_tyvar () | _ -> new_var () in
let my = match ea with Coq_a_typ _ -> new_tyvar () | _ -> new_var () in
let mz = new_tyvar () in
let em' = impl (mz :: my :: mx :: ctx) em in
let rx = match em with Coq_a_typ _ -> new_tyvar () | _ -> new_var () in
let er' = impl (rx :: ctx) er in
let e1' = impl ctx e1 in
let e2' = impl ctx e2 in
let escr' = impl ctx escr in
Cst.Coq_eqrec (escr', mx, my, mz, em', rx, er', e1', ea', e2')
| Coq_a_sub _ -> failwith "Invalid internal language construct"
in
fun exp ->
Expand Down
Loading