Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions LeroyCompilerVerificationCourse/Compil.lean
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ def machine_goes_wrong (C: List instr) (s_init: store) : Prop :=
def compile_program (p: com) : List instr:=
compile_com p ++ .Ihalt :: []

/-- info: [instr.Ivar "x", instr.Iconst 1, instr.Iadd, instr.Isetvar "x", instr.Ihalt] -/
#guard_msgs in
#eval (compile_program (.ASSIGN "x" (.PLUS (.VAR "x") (.CONST 1))))

def smart_Ibranch (d: Int) : List instr:=
Expand Down
2 changes: 2 additions & 0 deletions LeroyCompilerVerificationCourse/Constprop.lean
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ set_option grind.warning false
| .PLUS a1 a2 => mk_PLUS (simplif_aexp a1) (simplif_aexp a2)
| .MINUS a1 a2 => mk_MINUS (simplif_aexp a1) (simplif_aexp a2)

/-- info: aexp.MINUS (aexp.VAR "x") (aexp.VAR "y") -/
#guard_msgs in
#eval simplif_aexp (.MINUS (.PLUS (.VAR "x") (.CONST 1)) (.PLUS (.VAR "y") (.CONST 1)))

@[grind] theorem mk_PLUS_CONST_sound:
Expand Down
2 changes: 0 additions & 2 deletions LeroyCompilerVerificationCourse/Fixpoints.lean
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,6 @@ instance : WellFoundedRelation α where
decreasing_by
grind [beq_false']

#check iterate

@[grind] theorem iterate_correct (x : α) (PRE: le x (F x)) (SMALL: forall z, le (F z) z -> le x z) (heq : y = iterate _ F x PRE SMALL ) : eq y (F y) ∧ ∀ z, le (F z) z → le y z := by
fun_induction iterate
case case1 x' PRE SMALL isTrue =>
Expand Down
4 changes: 2 additions & 2 deletions LeroyCompilerVerificationCourse/Imp.lean
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ def store : Type := ident → Int
| .PLUS a1 a2 => aeval s a1 + aeval s a2
| .MINUS a1 a2 => aeval s a1 - aeval s a2

/-- info: 3 -/
#guard_msgs in
#eval aeval (λ _ => 2) (.PLUS (.VAR "x") (.MINUS (.VAR "x") (.CONST 1)))

theorem aeval_xplus1 : ∀ s x, aeval s (.PLUS (.VAR x) (.CONST 1)) > aeval s (.VAR x) := by
Expand Down Expand Up @@ -76,8 +78,6 @@ inductive com: Type where

notation:10 l:10 " ;; " r:11 => com.SEQ l r

#check .SKIP ;; .SKIP

def Euclidean_division :=
.ASSIGN "r" (.VAR "a") ;;
.ASSIGN "q" (.CONST 0) ;;
Expand Down