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

Derivation trees #1302

Draft
wants to merge 142 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
142 commits
Select commit Hold shift + click to select a range
d28642f
init
GuoDCZ May 4, 2024
b851154
abbr trial
GuoDCZ May 6, 2024
a724ec7
refactor error msg with concrete type
GuoDCZ May 15, 2024
6976690
task(1/7): type ported
GuoDCZ May 17, 2024
6c8a7b6
task(2/7): prop pattern supported
GuoDCZ May 17, 2024
b1ab19c
task(2/7): entail pattern supported
GuoDCZ May 17, 2024
82e6358
task(2/7): entail repr refine
GuoDCZ May 17, 2024
37fc71e
task(2/7): refine precedence and judgement print
GuoDCZ May 17, 2024
4e14567
port everything have done with ml
GuoDCZ May 19, 2024
3f066b7
task(3/7): port rule to builtin functions
GuoDCZ May 19, 2024
dee4bfa
task(5/7): cascade derivation
GuoDCZ May 22, 2024
fae9144
task(6/9): new pattern der introduced
GuoDCZ May 22, 2024
d75a1c8
task(7/9): marked conclusion
GuoDCZ May 27, 2024
fbbee43
task(8/9): turn derive pattern to close struct
GuoDCZ May 27, 2024
dd59d32
task(8/9): frontend trial
GuoDCZ May 28, 2024
2f958a6
exercise ui change trial
GuoDCZ May 29, 2024
4b5f3ab
feat: derivation frame imported to exercise mode
GuoDCZ May 31, 2024
47a460b
rebase tree util
GuoDCZ May 31, 2024
5858fff
exercise mode derivation basic verify
GuoDCZ May 31, 2024
77831bc
(unstable): before flatten
GuoDCZ Jun 1, 2024
e0cd132
rebase derivation in exercise.re to pure list
GuoDCZ Jun 1, 2024
cf47269
polish util flattree/tree
GuoDCZ Jun 1, 2024
23c5655
flattree version, to be rebase
GuoDCZ Jun 2, 2024
0ab899b
manual rule select is ok
GuoDCZ Jun 2, 2024
0b65040
Derivaiton UI update
Jun 6, 2024
eff37c7
ExerciseMode Partition partial
Jun 17, 2024
e00b223
refactor exercise (now normal/proof mode works are happy)
Jun 17, 2024
ca0c9f5
Stopper
Jun 17, 2024
0fe744b
rebase Proof exercise
Jun 18, 2024
b3fe261
lack 22
Jun 18, 2024
1adf207
frontend update dropdown
Jun 19, 2024
dde7c1c
feat:ez rule switch
Jun 21, 2024
e0e1c5b
add manual add/del botton
Jul 1, 2024
c5950d8
Merge branch 'dev' into derivation
Jul 2, 2024
8b688af
refine Exercise logic
Jul 2, 2024
9ac6302
modify exercise serialize
Jul 2, 2024
1606054
return builtin
Jul 4, 2024
2313d37
merge to dev
Aug 12, 2024
79d154a
modulize exercise
Aug 12, 2024
a493a4b
modulize Proof exercise
Aug 12, 2024
0253157
update action handler & exercise clearify module
Aug 13, 2024
ca31bce
revert changes
Aug 13, 2024
1d77e86
refactor derivation base
Aug 15, 2024
05d9863
refactor derivation error
Aug 15, 2024
8982e4c
grade view
Aug 17, 2024
bb15d17
derivation abbr scheme
Aug 17, 2024
cceb179
abbr advance ctrl
Aug 18, 2024
e8afd0b
fix&update UI
Aug 19, 2024
eafa7e1
Abbr facilitate
Aug 20, 2024
0b41ddb
update core logic
Aug 23, 2024
083dc17
merge to dev
Aug 23, 2024
3e1d06b
AL basic
Aug 24, 2024
5000244
add builtin derivation ctr
Aug 24, 2024
7115bfb
before removing prop term
Aug 29, 2024
efff02b
remove Prop exp, leaving Typ. Rebase derivation
Aug 29, 2024
0e5004a
temp cmt/ switch to new device
Aug 31, 2024
44599fc
temp: switch device
Sep 1, 2024
f059c18
AL complete
Sep 1, 2024
c33e40a
ALF logic
Sep 2, 2024
8e26c59
ALFp logic
Sep 2, 2024
0257f00
bidirectional type system
Sep 2, 2024
8cba4a3
ALFA logic
Sep 2, 2024
45e2a8d
simplify derivation failure format
Sep 2, 2024
8027e40
improve unbox GADT
Sep 3, 2024
d4f3204
ALFA refine collection/ rule verf.
Sep 4, 2024
4883822
alfa form initial
Sep 4, 2024
221368b
use ninja-keys for rules palette
Sep 5, 2024
4c3343c
introduce verfication ghost; fix UI failure
Sep 9, 2024
b3490df
arch frontend progress
Sep 9, 2024
492b549
of drv sort input
Sep 11, 2024
0fcad1e
New Sort proted. fix remolding issue partially.
Sep 11, 2024
e6d97f0
for editor view backup
Sep 13, 2024
5b4ee35
switch explainthis mode
Sep 13, 2024
1b56ad2
good init for sidebar
Sep 15, 2024
20b9986
drv frontend upgrade
Sep 15, 2024
8c2142c
poor solution to remold issue
Sep 16, 2024
9951da3
temp fix remolding issue: mk jdmt term op
Sep 16, 2024
e6fcd4a
leave up storing comment
Sep 16, 2024
5878da5
fast trial serialize
Sep 16, 2024
14cd36a
fix reload failure issue
Sep 16, 2024
711d5e1
build explainthis
Sep 16, 2024
452aeb1
refine styling issue drv tree
Sep 17, 2024
4c964f5
refine for demo
Sep 17, 2024
241d59e
fix patch exercise issue
Sep 17, 2024
8c6f7d9
severe bugs fix
Sep 17, 2024
70abfdc
prop&exp var binding
Sep 20, 2024
a9e1c83
Merge branch 'dev' into derivation
Sep 20, 2024
b3c68df
improve ninja-keys search keywords
Sep 20, 2024
4242234
change hasty to typ, check all rules except S/A
Sep 20, 2024
ba3914a
fix tylr parsing
Sep 30, 2024
d75978d
intro new sort ctxt
Oct 3, 2024
2be1b1f
merge sort
Oct 4, 2024
85d8a89
update jdmt writing term
Oct 4, 2024
1b3957b
tv
Oct 6, 2024
c77652e
fix typ abbr error
Oct 7, 2024
0c57035
merge to dev
Oct 7, 2024
1574e73
fix refresh issue, add more example
Oct 7, 2024
692c784
add demo derivation
Oct 8, 2024
ccf42ad
rebase rule spec
Oct 15, 2024
67b3853
fix rebase minor
Oct 15, 2024
1b83caa
fix test
Oct 15, 2024
8e741b1
gradual ALFA
Oct 25, 2024
a3931ec
version select
Oct 25, 2024
1c94c9d
fix alfa_rul critical issue
Oct 25, 2024
d026fa7
fix cache error
Oct 30, 2024
4a1df72
fix matched_arrow symbol inconssitent
Oct 30, 2024
bd019e1
fix on-load no-parse on treeroot
Oct 30, 2024
ae15735
temp fix on weird version select error
Oct 30, 2024
9e9ea30
merge to dev
Oct 31, 2024
bece313
fix selected deduction style
Nov 7, 2024
92da61d
accommondate free abbr var:
Nov 22, 2024
d81eb80
half merge
Dec 23, 2024
5110b0f
merge to dev
Jan 10, 2025
a51f79c
fix sidebar backend; recons ex; recons cache
Jan 13, 2025
eb2ceec
fix elab/statics/explainview/highlights for derivations
Jan 22, 2025
8d19b39
merge to dev
Jan 22, 2025
f9523a2
fix a few bugs
Jan 26, 2025
094d7e1
rewrite maketerm drv logic
Jan 26, 2025
d0dedf4
code clean up
Jan 26, 2025
c1e2481
merge to dev
Jan 26, 2025
67d0983
drv complete doc/example; ready for review
Jan 27, 2025
01f3a7f
merge - dev
Feb 14, 2025
0e645ec
remove drvsymbols (buggy version)
Feb 20, 2025
f3ec13a
fix mold err; fix drv transistion error
Feb 20, 2025
a75b610
merge ut dev
Feb 20, 2025
1362b62
rebase rule spec
Feb 21, 2025
2d715ba
merge to dev; fix drv deco color
Mar 1, 2025
fec5df9
fix typhole form/maketerm; fix multihole exptoseg
Mar 2, 2025
f33ffe2
fix precedence err
Mar 2, 2025
7b365db
fix transist function parse err
Mar 2, 2025
2409c2d
try fix hole issue
Mar 7, 2025
8a95813
fix re-eval
Mar 7, 2025
4efe240
refine hole case report; drvgrading exception
Mar 7, 2025
b74681e
close eval result when setting dynamic is off
Mar 7, 2025
7dc51a6
write test pp
Mar 7, 2025
ae8f838
Merge branch 'dev' of github.com:hazelgrove/hazel into derivation
Mar 7, 2025
8191019
fix drv doc (in a way I dont like)
Mar 7, 2025
d7635bf
fix color highlit same id err
Mar 8, 2025
91661ba
fix subst/substty sort inconsistency
Mar 8, 2025
d678a96
fix ignore case cant show
Mar 8, 2025
37d75da
refactor test style
Mar 8, 2025
0c64d6d
feat ninjakeys only show opts of curr ver
Mar 9, 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
13 changes: 12 additions & 1 deletion src/haz3lcore/assistant/AssistantForms.re
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,18 @@ module Typ = {
("let" ++ leading_expander, unk),
("test" ++ leading_expander, Prod([]) |> Typ.fresh),
("type" ++ leading_expander, unk),
("of_jdmt" ++ leading_expander, unk),
("of_ctx" ++ leading_expander, unk),
("of_prop" ++ leading_expander, unk),
("of_alfa_exp" ++ leading_expander, unk),
("of_alfa_typ" ++ leading_expander, unk),
("of_alfa_pat" ++ leading_expander, unk),
("of_alfa_tpat" ++ leading_expander, unk),
("consistent" ++ leading_expander, unk),
("matched_arrow" ++ leading_expander, unk),
("matched_prod" ++ leading_expander, unk),
("matched_sum" ++ leading_expander, unk),
("eval" ++ leading_expander, unk),
];

let of_infix_delim: list((Token.t, Typ.term)) = [
Expand All @@ -42,7 +54,6 @@ module Typ = {
("@", List(unk)),
(";", Unknown(Internal)),
("&&", Bool),
("\\/", Bool),
("||", Bool),
("$==", Bool),
("==.", Bool),
Expand Down
295 changes: 295 additions & 0 deletions src/haz3lcore/derivation/DrvDoc.re
Original file line number Diff line number Diff line change
@@ -0,0 +1,295 @@
open DrvTermBase;

module SymbolMap =
SymbolMap.M({
type exp = exp_t;
type pat = pat_t;
type typ = typ_t;
type tpat = tpat_t;
let exp: string => exp = s => Var(s) |> Drv.Exp.fresh;
let pat: string => pat = s => Var(s) |> Drv.Pat.fresh;
let typ: string => typ = s => Var(s) |> Drv.Typ.fresh;
let tpat: string => tpat = s => Var(s) |> Drv.TPat.fresh;
});
open SymbolMap;

let settings =
ExpToSegment.Settings.{
inline: true,
fold_case_clauses: false,
fold_fn_bodies: false,
hide_fixpoints: false,
fold_cast_types: false,
show_filters: false,
};

let f_jdmt: exp_t => Segment.t =
ExpToSegment.drv_exp_to_pretty(~settings, ~sort=Jdmt);
let f_ctx: exp_t => Segment.t =
ExpToSegment.drv_exp_to_pretty(~settings, ~sort=Ctx);
let f_prop: exp_t => Segment.t =
ExpToSegment.drv_exp_to_pretty(~settings, ~sort=Prop);
let f_exp: exp_t => Segment.t =
ExpToSegment.drv_exp_to_pretty(~settings, ~sort=Exp);
let f_pat: pat_t => Segment.t = ExpToSegment.drv_pat_to_pretty(~settings);
let f_typ: typ_t => Segment.t = ExpToSegment.drv_typ_to_pretty(~settings);
let f_tpat: tpat_t => Segment.t = ExpToSegment.drv_tpat_to_pretty(~settings);

let exp_form: exp_t => (Segment.t, string) =
exp =>
switch (Drv.Exp.term_of(exp)) {
| Hole(_) => (exp |> f_exp, "")
| Var(_) => (exp |> f_exp, "The variable represents the expression.")
| Quote(_) => (
Var("$x") |> Drv.Exp.fresh |> f_exp,
"The abbreviation represents the definition of $x.",
)
| Parens(_) => (
Parens(e) |> Drv.Exp.fresh |> f_exp,
"The parenthesis is used to explicitly group expressions. This does not carry other semantic meaning.",
)
| Val(_) => (
Val(e) |> Drv.Exp.fresh |> f_jdmt,
"The value judgement defines the values in ALFA, i.e. v is a value",
)
| Eval(_) => (
Eval(e, v) |> Drv.Exp.fresh |> f_jdmt,
"The evaluation judgement defines the evaluation behavior of ALFA expressions, i.e. it relates an expression e to its value v.",
)
| Entail(_) => (
Entail(gamma, a) |> Drv.Exp.fresh |> f_jdmt,
"The judgement defines that the context gamma entails the proposition a.",
)
| Consistent(_) => (
Consistent(t1, t2) |> Drv.Exp.fresh |> f_jdmt,
"A Type consistency judgement is a weakened form of equivalence: t1 and t2 are consistent if they differ only up to the appearance of an unknown type.",
)
| MatchedArrow(_) => (
MatchedArrow(t, Arrow(t1, t2) |> Drv.Typ.fresh)
|> Drv.Exp.fresh
|> f_jdmt,
"The matched arrow judgement defines that the type t matches the arrow type Arrow(t1, t2). When t is already an arrow type, it matches to itself. When t is the unknown type, then it gets matched to ? -> f.",
)
| MatchedProd(_) => (
MatchedProd(t, Prod(t1, t2) |> Drv.Typ.fresh)
|> Drv.Exp.fresh
|> f_jdmt,
"The matched product judgement defines that the type t matches the product type Prod(t1, t2). When t is already a product type, it matches to itself. When t is the unknown type, then it gets matched to ? * ?.",
)
| MatchedSum(_) => (
MatchedSum(t, Sum(t1, t2) |> Drv.Typ.fresh)
|> Drv.Exp.fresh
|> f_jdmt,
"The matched sum judgement defines that the type t matches the sum type Sum(t1, t2). When t is already a sum type, it matches to itself. When t is the unknown type, then it gets matched to ? + ?.",
)
| Ctx([]) => (Ctx([]) |> Drv.Exp.fresh |> f_ctx, "The empty context.")
| Ctx(_) => (
Ctx([a, b, Var("...") |> Drv.Exp.fresh]) |> Drv.Exp.fresh |> f_ctx,
"The context is a list of propositions A, B, ... The order does not matter.",
)
| Cons(_, _) => (
Cons(a, Ctx([a, Var("...") |> Drv.Exp.fresh]) |> Drv.Exp.fresh)
|> Drv.Exp.fresh
|> f_ctx,
"The context cons operation adds the proposition A to the context. The order does not matter.",
)
| Concat(_, _) => (
Concat(Ctx([a, Var("...") |> Drv.Exp.fresh]) |> Drv.Exp.fresh, b)
|> Drv.Exp.fresh
|> f_ctx,
"The context concatenation operation appends the proposition B to the context. The order does not matter.",
)
| Type(_) => (
Type(t) |> Drv.Exp.fresh |> f_prop,
"The type validity proposition defines that the type variable t does actually stand for a valid type.",
)
| HasType(_) => (
HasType(e, t) |> Drv.Exp.fresh |> f_prop,
"The type proposition defines that the expression e has type t",
)
| Syn(_) => (
Syn(e, t) |> Drv.Exp.fresh |> f_prop,
"The type synthesis proposition defines that the expression e synthesizes type t",
)
| Ana(_) => (
Ana(e, t) |> Drv.Exp.fresh |> f_prop,
"The type analysis proposition defines that the expression e analyzes against type t",
)
| And(_) => (
And(a, b) |> Drv.Exp.fresh |> f_prop,
"The conjunction proposition is true if both a and b are true assuming the given hypothesis.",
)
| Or(_) => (
Or(a, b) |> Drv.Exp.fresh |> f_prop,
"The disjunction proposition is true if either a or b is true assuming the given hypothesis.",
)
| Impl(_) => (
Impl(a, b) |> Drv.Exp.fresh |> f_prop,
"The implication proposition is true if a implies b assuming the given hypothesis.",
)
| Truth => (
Truth |> Drv.Exp.fresh |> f_prop,
"The truth proposition is always true.",
)
| Falsity => (
Falsity |> Drv.Exp.fresh |> f_prop,
"The falsity proposition is always false.",
)
| NumLit(_) => (n |> f_exp, "The numeric literal represents the number.")
| Neg(_) => (
Neg(e) |> Drv.Exp.fresh |> f_exp,
"The negation of the expression e.",
)
| BinOp(op, _, _) => (
BinOp(op, e1, e2) |> Drv.Exp.fresh |> f_exp,
"The binary operation "
++ Grammar.Drv.show_op_bin(op)
++ " of the expressions e1 and e2.",
)
| True => (True |> Drv.Exp.fresh |> f_exp, "The boolean literal true.")
| False => (False |> Drv.Exp.fresh |> f_exp, "The boolean literal false.")
| If(_, _, _) => (
If(e, e1, e2) |> Drv.Exp.fresh |> f_exp,
"The conditional expression if e is true then e1 else e2.",
)
| Let(_, _, _) => (
Let(x, e_body, e) |> Drv.Exp.fresh |> f_exp,
"The let expression defines a binding of the variable x to the expression e_body in the expression e.",
)
| Fix(_, _) => (
Fix(x, e) |> Drv.Exp.fresh |> f_exp,
"The fixpoint expression defines a recursive binding of the variable x to the expression e.",
)
| Fun(_, _) => (
Fun(x, e) |> Drv.Exp.fresh |> f_exp,
"The function expression defines a lambda abstraction of the variable x in the expression e.",
)
| Ap(_, _) => (
Ap(e1, e2) |> Drv.Exp.fresh |> f_exp,
"The application of the expression e1 to the expression e2.",
)
| Tuple(_)
| Pair(_, _) => (
Pair(e1, e2) |> Drv.Exp.fresh |> f_exp,
"The pair expression.",
)
| Triv => (Triv |> Drv.Exp.fresh |> f_exp, "The unit literal expression.")
| PrjL(_) => (
PrjL(e) |> Drv.Exp.fresh |> f_exp,
"The projection of the left component of the pair expression e.",
)
| PrjR(_) => (
PrjR(e) |> Drv.Exp.fresh |> f_exp,
"The projection of the right component of the pair expression e.",
)
| InjL(_) => (
InjL(e) |> Drv.Exp.fresh |> f_exp,
"The injection of the left component of the sum expression e.",
)
| InjR(_) => (
InjR(e) |> Drv.Exp.fresh |> f_exp,
"The injection of the right component of the sum expression e.",
)
| Case(_) => (
Case(e, x, e1, y, e2) |> Drv.Exp.fresh |> f_exp,
"The case expression of the expression e with the patterns x and y and the expressions e1 and e2.",
)
| Roll(_) => (
Roll(e) |> Drv.Exp.fresh |> f_exp,
"The roll expression of the expression e.",
)
| Unroll(_) => (
Unroll(e) |> Drv.Exp.fresh |> f_exp,
"The unroll expression of the expression e.",
)
| ExpHole => (ExpHole |> Drv.Exp.fresh |> f_exp, "The expression hole.")
};

let typ_form: typ_t => (Segment.t, string) =
typ =>
switch (Drv.Typ.term_of(typ)) {
| Hole(_) => (typ |> f_typ, "")
| Var(_) => (typ |> f_typ, "The type variable represents the type.")
| Quote(_) => (
Var("$x") |> Drv.Typ.fresh |> f_typ,
"The abbreviation represents the definition of type $x.",
)
| Num => (
Num |> Drv.Typ.fresh |> f_typ,
"The numlit type defines the type of numlit",
)
| Bool => (
Bool |> Drv.Typ.fresh |> f_typ,
"The bool type defines the type of boolean",
)
| Arrow(_) => (
Arrow(t1, t2) |> Drv.Typ.fresh |> f_typ,
"This arrow type defines the type of function that takes an argument of type t1 and returns a value of type t2.",
)
| Prod(_) => (
Prod(t1, t2) |> Drv.Typ.fresh |> f_typ,
"The product type defines the type of pair of t1 and t2.",
)
| Unit => (
Unit |> Drv.Typ.fresh |> f_typ,
"The unit type defines the type of unit literal",
)
| Sum(_) => (
Sum(t1, t2) |> Drv.Typ.fresh |> f_typ,
"The sum type defines the type of either t1 or t2.",
)
| Rec(_) => (
Rec(tpat, t) |> Drv.Typ.fresh |> f_typ,
"This recursive type defines the type of t that is recursively defined by a.",
)
| TypHole => (TypHole |> Drv.Typ.fresh |> f_typ, "The type hole")
| Parens(_) => (
Var("(t)") |> Drv.Typ.fresh |> f_typ,
"The parenthesis type is used to explicitly group types. This does not carry other semantic meaning.",
)
};

let pat_form: pat_t => (Segment.t, string) =
pat =>
switch (Drv.Pat.term_of(pat)) {
| Hole(_) => (pat |> f_pat, "")
| Quote(_) => (
Var("$x") |> Drv.Pat.fresh |> f_pat,
"The abbreviation represents the definition of pattern $x.",
)
| Var(_) => (pat |> f_pat, "The pattern variable represents the pattern.")
| Cast(_) => (
Cast(x, t) |> Drv.Pat.fresh |> f_pat,
"Only expression that matches the pattern x and have the type t match this type annotation pattern.",
)
| InjL(_) => (
InjL(x) |> Drv.Pat.fresh |> f_pat,
"The left injection pattern matches any expression that is injected to L(x).",
)
| InjR(_) => (
InjR(x) |> Drv.Pat.fresh |> f_pat,
"The right injection pattern matches any expression that is injected to R(x).",
)
| Pair(_) => (
Pair(x, y) |> Drv.Pat.fresh |> f_pat,
"The pair pattern matches any expression that matches both patterns x and y.",
)
| Parens(_) => (
Var("(x)") |> Drv.Pat.fresh |> f_pat,
"The parenthesis pattern is used to explicitly group patterns. This does not carry other semantic meaning.",
)
};

let tpat_form: tpat_t => (Segment.t, string) =
tpat =>
switch (Drv.TPat.term_of(tpat)) {
| Hole(_) => (tpat |> f_tpat, "")
| Quote(_) => (
Var("$x") |> Drv.TPat.fresh |> f_tpat,
"The abbreviation represents the definition of type pattern $x.",
)
| Var(_) => (
tpat |> f_tpat,
"The type pattern variable represents the type pattern.",
)
};
Loading