Skip to content

Commit 271f978

Browse files
committed
Add evaluation and constraint solving for expressions in Question2
1 parent c3b98a2 commit 271f978

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

ProgramAnalysis/Example/Exam2425.lean

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,36 @@ def expr : Expr := [Fun|
8686
#guard_msgs in
8787
#eval IO.println expr
8888

89+
/-- info: (some 2) -/
90+
#guard_msgs in
91+
#eval IO.println (expr.eval .empty)
92+
93+
def constraints := expr.constraints.run expr.allFns
94+
/--
95+
info: [C(5) ⊆ C(8), C(7) ⊆ C(8), C(8) ⊆ r(f), C(11) ⊆ C(12), r(f) ⊆ C(9), r(x) ⊆ C(4), r(y) ⊆ C(6), fn x => x⁴ ⊆ C(5), fn y => y⁶ ⊆ C(7), fn x => x⁴ ⊆ C(9) => C(4) ⊆ C(11), fn x => x⁴ ⊆ C(9) => C(10) ⊆ r(x), fn y => y⁶ ⊆ C(9) => C(6) ⊆ C(11), fn y => y⁶ ⊆ C(9) => C(10) ⊆ r(y)]
96+
-/
97+
#guard_msgs in
98+
#eval IO.println constraints
99+
100+
def solution := Constraint.solve constraints.toList
101+
102+
/--
103+
info: C(4) ↦ []
104+
C(5) ↦ [fn x => x⁴]
105+
C(6) ↦ []
106+
C(7) ↦ [fn y => y⁶]
107+
C(8) ↦ [fn x => x⁴, fn y => y⁶]
108+
C(9) ↦ [fn x => x⁴, fn y => y⁶]
109+
C(10) ↦ []
110+
C(11) ↦ []
111+
C(12) ↦ []
112+
r(f) ↦ [fn x => x⁴, fn y => y⁶]
113+
r(x) ↦ []
114+
r(y) ↦ []
115+
-/
116+
#guard_msgs in
117+
#eval solution.toList.forM (fun (node, value) => IO.println s!"{node}{value.toList.map (fun t: FnTerm => t)}")
118+
89119
end Question2
90120

91121
end ProgramAnalysis.Example

0 commit comments

Comments
 (0)