Skip to content

Commit 0452522

Browse files
committed
Merge branch 'ethosEoc2' of https://github.com/ajreynol/AletheLF-tc into ethosEoc2
2 parents 9665152 + 859f380 commit 0452522

2 files changed

Lines changed: 30 additions & 2 deletions

File tree

plugins/desugar/desugar_checker.h

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,36 @@ namespace ethos {
1919
class State;
2020

2121
/**
22+
* Helper for generating the desugared executable proof checker.
23+
*
24+
* `DesugarChecker` is used by the main desugar plugin when VC generation is
25+
* disabled. It inspects each proof-rule declaration, emits an embedded rule
26+
* constant for it, and generates checker invocation cases that translate
27+
* checker commands into calls to the corresponding desugared proof-rule
28+
* program. The accumulated fragments are finally spliced into
29+
* `eo_desugar_checker.eo` by output().
2230
*/
2331
class DesugarChecker : public StdPlugin
2432
{
2533
public:
34+
/** Construct the checker generator and initialize common constants. */
2635
DesugarChecker(State& s);
36+
/** Destroy the checker generator. */
2737
~DesugarChecker();
38+
/** Generate embedded rule and invocation cases for proof rule v. */
2839
void finalizeRule(const Expr& v);
2940

41+
/** Write the generated checker EO fragment to out. */
3042
void output(std::ostream& out);
3143

3244
private:
45+
/** Common true literal used to recognize assumption rules. */
3346
Expr d_true;
34-
// the rules
47+
/** Generated embedded rule declarations. */
3548
std::stringstream d_rules;
49+
/** Generated checker invocations for ordinary proof-rule steps. */
3650
std::stringstream d_ruleInvokes;
51+
/** Generated checker invocations for assumption-pop proof-rule steps. */
3752
std::stringstream d_ruleInvokesPop;
3853
};
3954

plugins/linear_patterns/linear_patterns.h

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,24 @@ class State;
2222
class TypeChecker;
2323

2424
/**
25-
* Provides utilities for linearizing patterns
25+
* Utility for rewriting non-linear EO program patterns into linear patterns.
26+
*
27+
* Some target encodings, including Lean pattern matching, require each pattern
28+
* variable to occur at most once. `LinearPattern` rewrites repeated variables
29+
* by replacing later occurrences with fresh parameters and collecting equality
30+
* guards that enforce the original sharing. When a guarded case is followed
31+
* by later cases, linearization may split the original program into helper
32+
* programs so the old fall-through behavior is preserved.
33+
*
34+
* The utility is exposed as static methods because callers typically need a
35+
* one-shot transformation of an already-built program definition.
2636
*/
2737
class LinearPattern : public StdPlugin
2838
{
2939
public:
40+
/** Construct the linear-pattern utility plugin. */
3041
LinearPattern(State& s);
42+
/** Destroy the linear-pattern utility plugin. */
3143
~LinearPattern();
3244
/**
3345
* Linearize patterns in prog whose definition is progDef.
@@ -44,6 +56,7 @@ class LinearPattern : public StdPlugin
4456
* If condition is null, then no linearization was necessary.
4557
*/
4658
static std::pair<Expr, Expr> linearizePattern(State& s, const Expr& pat);
59+
/** Recursively replace repeated parameters and collect equality guards. */
4760
static Expr linearizeRec(State& s,
4861
const Expr& pat,
4962
std::map<Expr, size_t>& params,

0 commit comments

Comments
 (0)