Use unification-based 'eq' for numbers and symbols
Signed-off-by: Danila Fedorin <danila.fedorin@gmail.com>
This commit is contained in:
parent
37dd9ad6d4
commit
3be67ca4c8
|
@ -285,6 +285,9 @@ the exact rules that were used in computing a particular value. The variables
|
||||||
`x`, `y`, and `z` are pre-defined for your convenience.
|
`x`, `y`, and `z` are pre-defined for your convenience.
|
||||||
|
|
||||||
{{< bergamot_widget id="expr-widget" query="" prompt="eval(extend(extend(extend(empty, x, 17), y, 42), z, 0), TERM, ?v)" modes="Expression:Expression" >}}
|
{{< bergamot_widget id="expr-widget" query="" prompt="eval(extend(extend(extend(empty, x, 17), y, 42), z, 0), TERM, ?v)" modes="Expression:Expression" >}}
|
||||||
|
hidden section "" {
|
||||||
|
Eq @ eq(?x, ?x) <-;
|
||||||
|
}
|
||||||
section "" {
|
section "" {
|
||||||
EvalNum @ eval(?rho, lit(?n), ?n) <- int(?n);
|
EvalNum @ eval(?rho, lit(?n), ?n) <- int(?n);
|
||||||
EvalVar @ eval(?rho, var(?x), ?v) <- inenv(?x, ?v, ?rho);
|
EvalVar @ eval(?rho, var(?x), ?v) <- inenv(?x, ?v, ?rho);
|
||||||
|
@ -295,7 +298,7 @@ section "" {
|
||||||
}
|
}
|
||||||
hidden section "" {
|
hidden section "" {
|
||||||
EnvTake @ inenv(?x, ?v, extend(?rho, ?x, ?v)) <-;
|
EnvTake @ inenv(?x, ?v, extend(?rho, ?x, ?v)) <-;
|
||||||
EnvSkip @ inenv(?x, ?v_1, extend(?rho, ?y, ?v_2)) <- inenv(?x, ?v_1, ?rho), not(symeq(?x, ?y));
|
EnvSkip @ inenv(?x, ?v_1, extend(?rho, ?y, ?v_2)) <- inenv(?x, ?v_1, ?rho), not(eq(?x, ?y));
|
||||||
}
|
}
|
||||||
{{< /bergamot_widget >}}
|
{{< /bergamot_widget >}}
|
||||||
|
|
||||||
|
@ -349,6 +352,9 @@ a Bergamot instance, this time with simple statements. Try out `noop` or some
|
||||||
sort of variable assignment, like `x = x + 1`.
|
sort of variable assignment, like `x = x + 1`.
|
||||||
|
|
||||||
{{< bergamot_widget id="basic-stmt-widget" query="" prompt="stepbasic(extend(extend(extend(empty, x, 17), y, 42), z, 0), TERM, ?env)" modes="Basic Statement:Basic Statement" >}}
|
{{< bergamot_widget id="basic-stmt-widget" query="" prompt="stepbasic(extend(extend(extend(empty, x, 17), y, 42), z, 0), TERM, ?env)" modes="Basic Statement:Basic Statement" >}}
|
||||||
|
hidden section "" {
|
||||||
|
Eq @ eq(?x, ?x) <-;
|
||||||
|
}
|
||||||
hidden section "" {
|
hidden section "" {
|
||||||
EvalNum @ eval(?rho, lit(?n), ?n) <- int(?n);
|
EvalNum @ eval(?rho, lit(?n), ?n) <- int(?n);
|
||||||
EvalVar @ eval(?rho, var(?x), ?v) <- inenv(?x, ?v, ?rho);
|
EvalVar @ eval(?rho, var(?x), ?v) <- inenv(?x, ?v, ?rho);
|
||||||
|
@ -363,7 +369,7 @@ section "" {
|
||||||
}
|
}
|
||||||
hidden section "" {
|
hidden section "" {
|
||||||
EnvTake @ inenv(?x, ?v, extend(?rho, ?x, ?v)) <-;
|
EnvTake @ inenv(?x, ?v, extend(?rho, ?x, ?v)) <-;
|
||||||
EnvSkip @ inenv(?x, ?v_1, extend(?rho, ?y, ?v_2)) <- inenv(?x, ?v_1, ?rho), not(symeq(?x, ?y));
|
EnvSkip @ inenv(?x, ?v_1, extend(?rho, ?y, ?v_2)) <- inenv(?x, ?v_1, ?rho), not(eq(?x, ?y));
|
||||||
}
|
}
|
||||||
{{< /bergamot_widget >}}
|
{{< /bergamot_widget >}}
|
||||||
|
|
||||||
|
@ -420,6 +426,9 @@ The rule for evaluating a conditional with a "false" branch is very similar.
|
||||||
{{< /latex >}}
|
{{< /latex >}}
|
||||||
|
|
||||||
{{< bergamot_widget id="stmt-widget" query="" prompt="step(extend(extend(extend(empty, x, 17), y, 42), z, 0), TERM, ?env)" modes="Statement:Statement" >}}
|
{{< bergamot_widget id="stmt-widget" query="" prompt="step(extend(extend(extend(empty, x, 17), y, 42), z, 0), TERM, ?env)" modes="Statement:Statement" >}}
|
||||||
|
hidden section "" {
|
||||||
|
Eq @ eq(?x, ?x) <-;
|
||||||
|
}
|
||||||
hidden section "" {
|
hidden section "" {
|
||||||
EvalNum @ eval(?rho, lit(?n), ?n) <- int(?n);
|
EvalNum @ eval(?rho, lit(?n), ?n) <- int(?n);
|
||||||
EvalVar @ eval(?rho, var(?x), ?v) <- inenv(?x, ?v, ?rho);
|
EvalVar @ eval(?rho, var(?x), ?v) <- inenv(?x, ?v, ?rho);
|
||||||
|
@ -440,14 +449,14 @@ hidden section "" {
|
||||||
StepLiftBasic @ step(?rho_1, ?s, ?rho_2) <- stepbasic(?rho_1, ?s, ?rho_2);
|
StepLiftBasic @ step(?rho_1, ?s, ?rho_2) <- stepbasic(?rho_1, ?s, ?rho_2);
|
||||||
}
|
}
|
||||||
section "" {
|
section "" {
|
||||||
StepIfTrue @ step(?rho_1, if(?e, ?s_1, ?s_2), ?rho_2) <- eval(?rho_1, ?e, ?v), not(numeq(?v, 0)), step(?rho_1, ?s_1, ?rho_2);
|
StepIfTrue @ step(?rho_1, if(?e, ?s_1, ?s_2), ?rho_2) <- eval(?rho_1, ?e, ?v), not(eq(?v, 0)), step(?rho_1, ?s_1, ?rho_2);
|
||||||
StepIfFalse @ step(?rho_1, if(?e, ?s_1, ?s_2), ?rho_2) <- eval(?rho_1, ?e, ?v), numeq(?v, 0), step(?rho_1, ?s_2, ?rho_2);
|
StepIfFalse @ step(?rho_1, if(?e, ?s_1, ?s_2), ?rho_2) <- eval(?rho_1, ?e, ?v), eq(?v, 0), step(?rho_1, ?s_2, ?rho_2);
|
||||||
StepWhileTrue @ step(?rho_1, while(?e, ?s), ?rho_3) <- eval(?rho_1, ?e, ?v), not(numeq(?v, 0)), step(?rho_1, ?s, ?rho_2), step(?rho_2, while(?e, ?s), ?rho_3);
|
StepWhileTrue @ step(?rho_1, while(?e, ?s), ?rho_3) <- eval(?rho_1, ?e, ?v), not(eq(?v, 0)), step(?rho_1, ?s, ?rho_2), step(?rho_2, while(?e, ?s), ?rho_3);
|
||||||
StepWhileFalse @ step(?rho_1, while(?e, ?s), ?rho_1) <- eval(?rho_1, ?e, ?v), numeq(?v, 0);
|
StepWhileFalse @ step(?rho_1, while(?e, ?s), ?rho_1) <- eval(?rho_1, ?e, ?v), eq(?v, 0);
|
||||||
StepSeq @ step(?rho_1, seq(?s_1, ?s_2), ?rho_3) <- step(?rho_1, ?s_1, ?rho_2), step(?rho_2, ?s_2, ?rho_3);
|
StepSeq @ step(?rho_1, seq(?s_1, ?s_2), ?rho_3) <- step(?rho_1, ?s_1, ?rho_2), step(?rho_2, ?s_2, ?rho_3);
|
||||||
}
|
}
|
||||||
hidden section "" {
|
hidden section "" {
|
||||||
EnvTake @ inenv(?x, ?v, extend(?rho, ?x, ?v)) <-;
|
EnvTake @ inenv(?x, ?v, extend(?rho, ?x, ?v)) <-;
|
||||||
EnvSkip @ inenv(?x, ?v_1, extend(?rho, ?y, ?v_2)) <- inenv(?x, ?v_1, ?rho), not(symeq(?x, ?y));
|
EnvSkip @ inenv(?x, ?v_1, extend(?rho, ?y, ?v_2)) <- inenv(?x, ?v_1, ?rho), not(eq(?x, ?y));
|
||||||
}
|
}
|
||||||
{{< /bergamot_widget >}}
|
{{< /bergamot_widget >}}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user