MoonBit program generation and semantic modeling for MoonSmith
| 生成器选择 | 标识与范围 |
|---|---|
| Generator.ScalarV1 | template-rules-v1,原有标量模板规则,保留固定案例的原始生成条件 |
| Generator.CompositeV2(默认) | template-rules-v2,增加元组构造、局部绑定与投影,以及条件选择枚举值后的穷尽匹配 |
| 生成预算 | 默认值 | 允许范围 | 含义 |
|---|---|---|---|
| max_nodes | 128 | 1..2048 | 完整程序节点数,包括函数、枚举定义、构造子和参数;当前标量空洞预留一个节点 |
| max_depth | 6 | 0..16 | 表达式嵌套深度,叶子为零 |
| max_attempts | 256 | 1..8192 | 模板和补全合计的规则构造次数,包括函数、枚举、构造子头与终结节点 |
pub(all) suberror StructureError {
UnfilledHole(Ty)
InvalidBinder(Int)
DuplicateBinding(Int)
UnknownBinding(Int)
TypeMismatch(Ty, Ty)
UnknownFunction(Int)
ArgumentCount(Int, Int, Int)
CyclicCall(Int)
InvalidTupleArity(Int)
ExpectedTuple(Ty)
InvalidProjection(Int, Int)
UnknownEnum(Int)
EmptyEnum(Int)
CyclicEnum(Int)
UnknownVariant(Int, Int)
VariantArguments(Int, Int, Int, Int)
MatchArms(Int, Int, Int)
PatternArguments(Int, Int, Int, Int)
UnsupportedResultType(Ty)
} derive(Eq, Debug)fn CompleteProgram::equivalent_group(self : CompleteProgram) -> EquivalentGroup raise StructureErrorfn CompleteProgram::equivalent_variants(self : CompleteProgram) -> Array[CompleteProgram] raise StructureErrorpub struct EquivalentGroup {
// private fields
}pub(all) enum Expr {
Hole(Ty)
IntLiteral(Int)
BoolLiteral(Bool)
Ref(Int)
Let(Binder, Expr, Expr)
Add(Expr, Expr)
Subtract(Expr, Expr)
Less(Expr, Expr)
Not(Expr)
If(Expr, Expr, Expr)
Call(Int, Array[Expr])
Tuple(Array[Expr])
Project(Expr, Int)
Variant(Int, Int, Array[Expr])
Match(Int, Expr, Array[MatchArm])
} derive(Eq, Debug)pub(all) struct GeneratedProgram {
program : CompleteProgram
construction_attempts : Int
generator : Generator
}fn synthesize(seed : Int, limits? : GenerationLimits, generator? : Generator) -> GeneratedProgram raise