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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ Changes to the frontend:
Changes to hax-lib:
- New behavior for `hax_lib::include`: it now forces inclusion when in contradiction with `-i` flag.

Changes to the Lean backend:
- Improve support for functionalized loops (#1695)

Miscellaneous:
- A lean tutorial has been added to the hax website (#1626)
- Diagnostics reporting were improved (#1692)
Expand Down
2 changes: 1 addition & 1 deletion engine/lib/phases/phase_rewrite_control_flow.ml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ module Make (F : Features.T) =
let arms =
[
MS.arm
(mk_cf_pat `Break (U.make_var_pat id typ span))
(mk_cf_pat `Break (U.make_var_pat id return_type span))
return_expr;
MS.arm (mk_cf_pat `Continue pat)
(U.make_lets stmts_after final |> self#visit_expr in_loop);
Expand Down
1 change: 0 additions & 1 deletion examples/lean_barrett/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ default:
cargo hax into lean
(cd proofs/lean/extraction && \
elan default stable && \
lake update && \
lake build)

clean:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
leanprover/lean4:v4.22.0
1 change: 0 additions & 1 deletion examples/lean_chacha20/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ default:
cargo hax into lean
(cd proofs/lean/extraction && \
elan default stable && \
lake update && \
lake build)

clean:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -614,56 +614,22 @@ def Lean_chacha20.chacha20 (m : (RustSlice u8))
theorem Lean_chacha20.Hacspec_helper.add_state_spec (state : (Vector u32 16)) (other : (Vector u32 16)) :
⦃ ⌜ True ⌝ ⦄
(Lean_chacha20.Hacspec_helper.add_state state other)
⦃ ⇓ _ => True ⦄ := by
mvcgen [Lean_chacha20.Hacspec_helper.add_state]
<;> try apply SPred.pure_intro
<;> simp [Vector.size] at *
<;> cases System.Platform.numBits_eq with
| inl h
| inr h =>
expose_names
rw [h]
omega
⦃ ⇓ _ => True ⦄ := by sorry

@[spec]
theorem Lean_chacha20.Hacspec_helper.to_le_u32s_16_spec bytes :
bytes.size = 64 →
⦃ ⌜ True ⌝ ⦄
(Lean_chacha20.Hacspec_helper.to_le_u32s_16 bytes)
⦃ ⇓ _ => True ⦄ := by
intro
open SpecNat in
mvcgen [Lean_chacha20.Hacspec_helper.to_le_u32s_16]
<;> (try apply SPred.pure_intro)
all_goals simp [USize.size, Vector.size] at *
any_goals subst_vars
all_goals try simp [USize.le_iff_toNat_le]
all_goals try (cases System.Platform.numBits_eq with
| inl h
| inr h =>
expose_names
rw [h]
omega ; done )
⦃ ⇓ _ => True ⦄ := by sorry


@[spec]
theorem Lean_chacha20.Hacspec_helper.to_le_u32s_3_spec bytes :
bytes.size = 12 →
⦃ ⌜ True ⌝ ⦄
(Lean_chacha20.Hacspec_helper.to_le_u32s_3 bytes)
⦃ ⇓ _ => True ⦄ := by
intros
open SpecNat in
mvcgen [Lean_chacha20.Hacspec_helper.to_le_u32s_3]
all_goals simp [USize.size, RustArray, Vector.size] at *
any_goals subst_vars
all_goals try simp [USize.le_iff_toNat_le]
all_goals try (cases System.Platform.numBits_eq with
| inl h
| inr h =>
expose_names
rw [h]
omega ; done )
⦃ ⇓ _ => True ⦄ := by sorry



Expand All @@ -672,81 +638,27 @@ theorem Lean_chacha20.Hacspec_helper.to_le_u32s_8_spec (bytes : (Array u8)) :
bytes.size = 32 →
⦃ ⌜ True ⌝ ⦄
( Lean_chacha20.Hacspec_helper.to_le_u32s_8 bytes )
⦃ ⇓ _ => True ⦄ := by
intros
open SpecNat in
mvcgen [Lean_chacha20.Hacspec_helper.to_le_u32s_8]
all_goals simp [USize.size, Vector.size] at *
any_goals subst_vars
all_goals try simp [USize.le_iff_toNat_le]
all_goals try (cases System.Platform.numBits_eq with
| inl h
| inr h =>
expose_names
rw [h]
omega ; done )
⦃ ⇓ _ => True ⦄ := by sorry

@[spec]
theorem Lean_chacha20.Hacspec_helper.u32s_to_le_bytes_spec (state : (Vector u32 16)) :
⦃ ⌜ True ⌝ ⦄
(Lean_chacha20.Hacspec_helper.u32s_to_le_bytes state)
⦃ ⇓ _ => True ⦄ := by
intros
open SpecNat in
mvcgen [Lean_chacha20.Hacspec_helper.u32s_to_le_bytes, Core.Num.Impl_8.to_le_bytes]
all_goals simp [USize.size, Vector.size] at *
any_goals subst_vars
all_goals try simp [USize.toNat_ofNat'] at *
all_goals try (cases System.Platform.numBits_eq with
| inl h
| inr h =>
expose_names
rw [h] ;
try rw [h] at h_2
try rw [h] at h_3
try rw [h] at h_5
omega ; done )
⦃ ⇓ _ => True ⦄ := by sorry

@[spec]
theorem Lean_chacha20.Hacspec_helper.xor_state_spec (state other: (Vector u32 16)) :
⦃ ⌜ True ⌝ ⦄
(Lean_chacha20.Hacspec_helper.xor_state state other)
⦃ ⇓ _ => True ⦄ := by
intros
open SpecNat in
mvcgen [Lean_chacha20.Hacspec_helper.xor_state,
Core.Num.Impl_8.to_le_bytes]
all_goals simp [Vector.size] at *
any_goals subst_vars
all_goals try simp at *
all_goals try (cases System.Platform.numBits_eq with
| inl h
| inr h =>
expose_names
rw [h] ;
omega ; done )
⦃ ⇓ _ => True ⦄ := by sorry


@[spec]
theorem Lean_chacha20.Hacspec_helper.update_array_spec (a: (Vector u8 64)) (v: Array u8) :
v.size ≤ 64 →
⦃ ⌜ True ⌝ ⦄
(Lean_chacha20.Hacspec_helper.update_array a v)
⦃ ⇓ _ => True ⦄ := by
intros
open SpecNat in
mvcgen_step 24 [Lean_chacha20.Hacspec_helper.update_array]
all_goals simp [Vector.size, USize.le_iff_toNat_le] at *
any_goals subst_vars
all_goals try simp [USize.toNat_ofNat'] at *
all_goals try (cases System.Platform.numBits_eq with
| inl h
| inr h =>
expose_names
try rw [h] ;
try rw [h] at h_2
try rw [h] at h_4
omega ; done )
⦃ ⇓ _ => True ⦄ := by sorry

@[spec]
theorem Lean_chacha20.chacha20_line_spec
Expand Down Expand Up @@ -784,8 +696,7 @@ theorem Lean_chacha20.chacha20_double_round_spec (state : (Vector u32 16)) :
theorem Lean_chacha20.chacha20_rounds_spec state :
⦃ ⌜ True ⌝ ⦄
(Lean_chacha20.chacha20_rounds state)
⦃ ⇓ _ => True ⦄ := by
mvcgen [Lean_chacha20.chacha20_rounds]
⦃ ⇓ _ => True ⦄ := by sorry


@[spec]
Expand Down Expand Up @@ -850,25 +761,7 @@ theorem Lean_chacha20.chacha20_update_spec (st0 : (Vector u32 16)) (m : (Array u
⦃ m.size ≤ USize.size ⦄
(Lean_chacha20.chacha20_update st0 m)
⦃ ⇓ _ => True ⦄
:= by
open SpecNat in
mvcgen [Lean_chacha20.chacha20_update,
Alloc.Slice.Impl.to_vec,
Core.Result.Impl.unwrap.spec,
Alloc.Vec.Impl.new,
Alloc.Vec.Impl_1.len,
] <;> subst_vars
all_goals simp [Array.size_extract, USize.eq_iff_toBitVec_eq, BitVec.toNat_eq, USize.size, USize.le_iff_toNat_le ] at *
all_goals try cases System.Platform.numBits_eq with
| inl h
| inr h =>
expose_names
try rw [h]
try rw [h] at h_1
try rw [h] at h_2
try rw [h] at h_3
try rw [h] at h_4
omega ; done
:= by sorry

theorem Lean_chacha20.chacha20_spec
(m : (Array u8)) (key : (Vector u8 32)) (iv : (Vector u8 12)) (ctr : u32) :
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
leanprover/lean4:v4.22.0-rc4
Loading
Loading