benchmark_name
stringclasses
3 values
index
stringlengths
1
3
method_filepath
stringlengths
21
58
method_without_assertion_filename
stringlengths
17
78
method_name
stringlengths
6
66
method_content
stringlengths
183
6.2k
method_without_assertion_content
stringlengths
133
6.16k
libraries
30
./src/JSON/ZeroCopy/Serializer.dfy
MembersImpl_fix_30.dfy
MembersImpl
method MembersImpl(obj: jobject, writer: Writer) returns (wr: Writer) decreases obj, 1 ensures wr == MembersSpec(obj, obj.data, writer) { wr := writer; var members := obj.data; assert wr == MembersSpec(obj, members[..0], writer); for i := 0 to |members| // FIXME uint32 invariant wr == MembersSpec(obj, members[..i], writer) { assert members[..i+1][..i] == members[..i]; wr := Member(obj, members[i], wr); } assert members[..|members|] == members; assert wr == MembersSpec(obj, members, writer); }
method MembersImpl(obj: jobject, writer: Writer) returns (wr: Writer) decreases obj, 1 ensures wr == MembersSpec(obj, obj.data, writer) { wr := writer; var members := obj.data; for i := 0 to |members| // FIXME uint32 invariant wr == MembersSpec(obj, members[..i], writer) { assert members[..i+1][..i] == members[..i]; wr := Member(obj, members[i], wr); } assert members[..|members|] == members; assert wr == MembersSpec(obj, members, writer); }
libraries
31
./src/JSON/ZeroCopy/Serializer.dfy
MembersImpl_fix_31.dfy
MembersImpl
method MembersImpl(obj: jobject, writer: Writer) returns (wr: Writer) decreases obj, 1 ensures wr == MembersSpec(obj, obj.data, writer) { wr := writer; var members := obj.data; assert wr == MembersSpec(obj, members[..0], writer); for i := 0 to |members| // FIXME uint32 invariant wr == MembersSpec(obj, members[..i], writer) { assert members[..i+1][..i] == members[..i]; wr := Member(obj, members[i], wr); } assert members[..|members|] == members; assert wr == MembersSpec(obj, members, writer); }
method MembersImpl(obj: jobject, writer: Writer) returns (wr: Writer) decreases obj, 1 ensures wr == MembersSpec(obj, obj.data, writer) { wr := writer; var members := obj.data; assert wr == MembersSpec(obj, members[..0], writer); for i := 0 to |members| // FIXME uint32 invariant wr == MembersSpec(obj, members[..i], writer) { wr := Member(obj, members[i], wr); } assert members[..|members|] == members; assert wr == MembersSpec(obj, members, writer); }
libraries
32
./src/JSON/ZeroCopy/Serializer.dfy
MembersImpl_fix_32.dfy
MembersImpl
method MembersImpl(obj: jobject, writer: Writer) returns (wr: Writer) decreases obj, 1 ensures wr == MembersSpec(obj, obj.data, writer) { wr := writer; var members := obj.data; assert wr == MembersSpec(obj, members[..0], writer); for i := 0 to |members| // FIXME uint32 invariant wr == MembersSpec(obj, members[..i], writer) { assert members[..i+1][..i] == members[..i]; wr := Member(obj, members[i], wr); } assert members[..|members|] == members; assert wr == MembersSpec(obj, members, writer); }
method MembersImpl(obj: jobject, writer: Writer) returns (wr: Writer) decreases obj, 1 ensures wr == MembersSpec(obj, obj.data, writer) { wr := writer; var members := obj.data; assert wr == MembersSpec(obj, members[..0], writer); for i := 0 to |members| // FIXME uint32 invariant wr == MembersSpec(obj, members[..i], writer) { assert members[..i+1][..i] == members[..i]; wr := Member(obj, members[i], wr); } assert wr == MembersSpec(obj, members, writer); }
libraries
39
./src/Collections/Sets/Sets.dfy
LemmaIsSingleton_fix_39.dfy
LemmaIsSingleton
lemma LemmaIsSingleton<T>(s: set<T>) ensures |s| == 1 <==> IsSingleton(s) { if |s| == 1 { forall x, y | x in s && y in s ensures x == y { LemmaSingletonEquality(s, x, y); } } if IsSingleton(s) { var x :| x in s; assert s == {x}; assert |s| == 1; } }
lemma LemmaIsSingleton<T>(s: set<T>) ensures |s| == 1 <==> IsSingleton(s) { if |s| == 1 { forall x, y | x in s && y in s ensures x == y { LemmaSingletonEquality(s, x, y); } } if IsSingleton(s) { var x :| x in s; assert |s| == 1; } }
libraries
42
./src/Collections/Sets/Sets.dfy
LemmaUnionSize_fix_42.dfy
LemmaUnionSize
lemma LemmaUnionSize<X>(xs: set<X>, ys: set<X>) ensures |xs + ys| >= |xs| ensures |xs + ys| >= |ys| { if ys == {} { } else { var y :| y in ys; if y in xs { var xr := xs - {y}; var yr := ys - {y}; assert xr + yr == xs + ys - {y}; LemmaUnionSize(xr, yr); } else { var yr := ys - {y}; assert xs + yr == xs + ys - {y}; LemmaUnionSize(xs, yr); } } }
lemma LemmaUnionSize<X>(xs: set<X>, ys: set<X>) ensures |xs + ys| >= |xs| ensures |xs + ys| >= |ys| { if ys == {} { } else { var y :| y in ys; if y in xs { var xr := xs - {y}; var yr := ys - {y}; LemmaUnionSize(xr, yr); } else { var yr := ys - {y}; assert xs + yr == xs + ys - {y}; LemmaUnionSize(xs, yr); } } }
libraries
43
./src/Collections/Sets/Sets.dfy
LemmaUnionSize_fix_43.dfy
LemmaUnionSize
lemma LemmaUnionSize<X>(xs: set<X>, ys: set<X>) ensures |xs + ys| >= |xs| ensures |xs + ys| >= |ys| { if ys == {} { } else { var y :| y in ys; if y in xs { var xr := xs - {y}; var yr := ys - {y}; assert xr + yr == xs + ys - {y}; LemmaUnionSize(xr, yr); } else { var yr := ys - {y}; assert xs + yr == xs + ys - {y}; LemmaUnionSize(xs, yr); } } }
lemma LemmaUnionSize<X>(xs: set<X>, ys: set<X>) ensures |xs + ys| >= |xs| ensures |xs + ys| >= |ys| { if ys == {} { } else { var y :| y in ys; if y in xs { var xr := xs - {y}; var yr := ys - {y}; assert xr + yr == xs + ys - {y}; LemmaUnionSize(xr, yr); } else { var yr := ys - {y}; LemmaUnionSize(xs, yr); } } }
libraries
45
./src/Collections/Sequences/LittleEndianNat.dfy
LemmaSeqNeq_fix_45.dfy
LemmaSeqNeq
lemma LemmaSeqNeq(xs: seq<uint>, ys: seq<uint>) requires |xs| == |ys| requires xs != ys ensures ToNatRight(xs) != ToNatRight(ys) { ghost var i: nat, n: nat := 0, |xs|; while i < n invariant 0 <= i < n invariant xs[..i] == ys[..i] { if xs[i] != ys[i] { break; } i := i + 1; } assert ToNatLeft(xs[..i]) == ToNatLeft(ys[..i]); reveal ToNatLeft(); assert xs[..i+1][..i] == xs[..i]; assert ys[..i+1][..i] == ys[..i]; LemmaPowPositiveAuto(); LemmaMulStrictInequalityAuto(); assert ToNatLeft(xs[..i+1]) != ToNatLeft(ys[..i+1]); LemmaToNatLeftEqToNatRightAuto(); LemmaSeqPrefixNeq(xs, ys, i+1); }
lemma LemmaSeqNeq(xs: seq<uint>, ys: seq<uint>) requires |xs| == |ys| requires xs != ys ensures ToNatRight(xs) != ToNatRight(ys) { ghost var i: nat, n: nat := 0, |xs|; while i < n invariant 0 <= i < n invariant xs[..i] == ys[..i] { if xs[i] != ys[i] { break; } i := i + 1; } assert ToNatLeft(xs[..i]) == ToNatLeft(ys[..i]); reveal ToNatLeft(); assert ys[..i+1][..i] == ys[..i]; LemmaPowPositiveAuto(); LemmaMulStrictInequalityAuto(); assert ToNatLeft(xs[..i+1]) != ToNatLeft(ys[..i+1]); LemmaToNatLeftEqToNatRightAuto(); LemmaSeqPrefixNeq(xs, ys, i+1); }
libraries
46
./src/Collections/Sequences/LittleEndianNat.dfy
LemmaSeqNeq_fix_46.dfy
LemmaSeqNeq
lemma LemmaSeqNeq(xs: seq<uint>, ys: seq<uint>) requires |xs| == |ys| requires xs != ys ensures ToNatRight(xs) != ToNatRight(ys) { ghost var i: nat, n: nat := 0, |xs|; while i < n invariant 0 <= i < n invariant xs[..i] == ys[..i] { if xs[i] != ys[i] { break; } i := i + 1; } assert ToNatLeft(xs[..i]) == ToNatLeft(ys[..i]); reveal ToNatLeft(); assert xs[..i+1][..i] == xs[..i]; assert ys[..i+1][..i] == ys[..i]; LemmaPowPositiveAuto(); LemmaMulStrictInequalityAuto(); assert ToNatLeft(xs[..i+1]) != ToNatLeft(ys[..i+1]); LemmaToNatLeftEqToNatRightAuto(); LemmaSeqPrefixNeq(xs, ys, i+1); }
lemma LemmaSeqNeq(xs: seq<uint>, ys: seq<uint>) requires |xs| == |ys| requires xs != ys ensures ToNatRight(xs) != ToNatRight(ys) { ghost var i: nat, n: nat := 0, |xs|; while i < n invariant 0 <= i < n invariant xs[..i] == ys[..i] { if xs[i] != ys[i] { break; } i := i + 1; } assert ToNatLeft(xs[..i]) == ToNatLeft(ys[..i]); reveal ToNatLeft(); assert xs[..i+1][..i] == xs[..i]; LemmaPowPositiveAuto(); LemmaMulStrictInequalityAuto(); assert ToNatLeft(xs[..i+1]) != ToNatLeft(ys[..i+1]); LemmaToNatLeftEqToNatRightAuto(); LemmaSeqPrefixNeq(xs, ys, i+1); }
libraries
49
./src/Collections/Sequences/LittleEndianNat.dfy
LemmaSeqPrefixNeq_fix_49.dfy
LemmaSeqPrefixNeq
lemma LemmaSeqPrefixNeq(xs: seq<uint>, ys: seq<uint>, i: nat) requires 0 <= i <= |xs| == |ys| requires ToNatRight(xs[..i]) != ToNatRight(ys[..i]) ensures ToNatRight(xs) != ToNatRight(ys) decreases |xs| - i { if i == |xs| { assert xs[..i] == xs; assert ys[..i] == ys; } else { if xs[i] == ys[i] { reveal ToNatLeft(); assert DropLast(xs[..i+1]) == xs[..i]; assert DropLast(ys[..i+1]) == ys[..i]; LemmaToNatLeftEqToNatRightAuto(); assert ToNatRight(xs[..i+1]) == ToNatLeft(xs[..i+1]); } else if xs[i] < ys[i] { LemmaSeqMswInequality(xs[..i+1], ys[..i+1]); } else { LemmaSeqMswInequality(ys[..i+1], xs[..i+1]); } reveal ToNatRight(); LemmaSeqPrefixNeq(xs, ys, i + 1); } }
lemma LemmaSeqPrefixNeq(xs: seq<uint>, ys: seq<uint>, i: nat) requires 0 <= i <= |xs| == |ys| requires ToNatRight(xs[..i]) != ToNatRight(ys[..i]) ensures ToNatRight(xs) != ToNatRight(ys) decreases |xs| - i { if i == |xs| { assert ys[..i] == ys; } else { if xs[i] == ys[i] { reveal ToNatLeft(); assert DropLast(xs[..i+1]) == xs[..i]; assert DropLast(ys[..i+1]) == ys[..i]; LemmaToNatLeftEqToNatRightAuto(); assert ToNatRight(xs[..i+1]) == ToNatLeft(xs[..i+1]); } else if xs[i] < ys[i] { LemmaSeqMswInequality(xs[..i+1], ys[..i+1]); } else { LemmaSeqMswInequality(ys[..i+1], xs[..i+1]); } reveal ToNatRight(); LemmaSeqPrefixNeq(xs, ys, i + 1); } }
libraries
50
./src/Collections/Sequences/LittleEndianNat.dfy
LemmaSeqPrefixNeq_fix_50.dfy
LemmaSeqPrefixNeq
lemma LemmaSeqPrefixNeq(xs: seq<uint>, ys: seq<uint>, i: nat) requires 0 <= i <= |xs| == |ys| requires ToNatRight(xs[..i]) != ToNatRight(ys[..i]) ensures ToNatRight(xs) != ToNatRight(ys) decreases |xs| - i { if i == |xs| { assert xs[..i] == xs; assert ys[..i] == ys; } else { if xs[i] == ys[i] { reveal ToNatLeft(); assert DropLast(xs[..i+1]) == xs[..i]; assert DropLast(ys[..i+1]) == ys[..i]; LemmaToNatLeftEqToNatRightAuto(); assert ToNatRight(xs[..i+1]) == ToNatLeft(xs[..i+1]); } else if xs[i] < ys[i] { LemmaSeqMswInequality(xs[..i+1], ys[..i+1]); } else { LemmaSeqMswInequality(ys[..i+1], xs[..i+1]); } reveal ToNatRight(); LemmaSeqPrefixNeq(xs, ys, i + 1); } }
lemma LemmaSeqPrefixNeq(xs: seq<uint>, ys: seq<uint>, i: nat) requires 0 <= i <= |xs| == |ys| requires ToNatRight(xs[..i]) != ToNatRight(ys[..i]) ensures ToNatRight(xs) != ToNatRight(ys) decreases |xs| - i { if i == |xs| { assert xs[..i] == xs; } else { if xs[i] == ys[i] { reveal ToNatLeft(); assert DropLast(xs[..i+1]) == xs[..i]; assert DropLast(ys[..i+1]) == ys[..i]; LemmaToNatLeftEqToNatRightAuto(); assert ToNatRight(xs[..i+1]) == ToNatLeft(xs[..i+1]); } else if xs[i] < ys[i] { LemmaSeqMswInequality(xs[..i+1], ys[..i+1]); } else { LemmaSeqMswInequality(ys[..i+1], xs[..i+1]); } reveal ToNatRight(); LemmaSeqPrefixNeq(xs, ys, i + 1); } }
libraries
51
./src/Collections/Sequences/LittleEndianNat.dfy
LemmaSeqPrefixNeq_fix_51.dfy
LemmaSeqPrefixNeq
lemma LemmaSeqPrefixNeq(xs: seq<uint>, ys: seq<uint>, i: nat) requires 0 <= i <= |xs| == |ys| requires ToNatRight(xs[..i]) != ToNatRight(ys[..i]) ensures ToNatRight(xs) != ToNatRight(ys) decreases |xs| - i { if i == |xs| { assert xs[..i] == xs; assert ys[..i] == ys; } else { if xs[i] == ys[i] { reveal ToNatLeft(); assert DropLast(xs[..i+1]) == xs[..i]; assert DropLast(ys[..i+1]) == ys[..i]; LemmaToNatLeftEqToNatRightAuto(); assert ToNatRight(xs[..i+1]) == ToNatLeft(xs[..i+1]); } else if xs[i] < ys[i] { LemmaSeqMswInequality(xs[..i+1], ys[..i+1]); } else { LemmaSeqMswInequality(ys[..i+1], xs[..i+1]); } reveal ToNatRight(); LemmaSeqPrefixNeq(xs, ys, i + 1); } }
lemma LemmaSeqPrefixNeq(xs: seq<uint>, ys: seq<uint>, i: nat) requires 0 <= i <= |xs| == |ys| requires ToNatRight(xs[..i]) != ToNatRight(ys[..i]) ensures ToNatRight(xs) != ToNatRight(ys) decreases |xs| - i { if i == |xs| { assert xs[..i] == xs; assert ys[..i] == ys; } else { if xs[i] == ys[i] { reveal ToNatLeft(); assert DropLast(ys[..i+1]) == ys[..i]; LemmaToNatLeftEqToNatRightAuto(); assert ToNatRight(xs[..i+1]) == ToNatLeft(xs[..i+1]); } else if xs[i] < ys[i] { LemmaSeqMswInequality(xs[..i+1], ys[..i+1]); } else { LemmaSeqMswInequality(ys[..i+1], xs[..i+1]); } reveal ToNatRight(); LemmaSeqPrefixNeq(xs, ys, i + 1); } }
libraries
52
./src/Collections/Sequences/LittleEndianNat.dfy
LemmaSeqPrefixNeq_fix_52.dfy
LemmaSeqPrefixNeq
lemma LemmaSeqPrefixNeq(xs: seq<uint>, ys: seq<uint>, i: nat) requires 0 <= i <= |xs| == |ys| requires ToNatRight(xs[..i]) != ToNatRight(ys[..i]) ensures ToNatRight(xs) != ToNatRight(ys) decreases |xs| - i { if i == |xs| { assert xs[..i] == xs; assert ys[..i] == ys; } else { if xs[i] == ys[i] { reveal ToNatLeft(); assert DropLast(xs[..i+1]) == xs[..i]; assert DropLast(ys[..i+1]) == ys[..i]; LemmaToNatLeftEqToNatRightAuto(); assert ToNatRight(xs[..i+1]) == ToNatLeft(xs[..i+1]); } else if xs[i] < ys[i] { LemmaSeqMswInequality(xs[..i+1], ys[..i+1]); } else { LemmaSeqMswInequality(ys[..i+1], xs[..i+1]); } reveal ToNatRight(); LemmaSeqPrefixNeq(xs, ys, i + 1); } }
lemma LemmaSeqPrefixNeq(xs: seq<uint>, ys: seq<uint>, i: nat) requires 0 <= i <= |xs| == |ys| requires ToNatRight(xs[..i]) != ToNatRight(ys[..i]) ensures ToNatRight(xs) != ToNatRight(ys) decreases |xs| - i { if i == |xs| { assert xs[..i] == xs; assert ys[..i] == ys; } else { if xs[i] == ys[i] { reveal ToNatLeft(); assert DropLast(xs[..i+1]) == xs[..i]; LemmaToNatLeftEqToNatRightAuto(); assert ToNatRight(xs[..i+1]) == ToNatLeft(xs[..i+1]); } else if xs[i] < ys[i] { LemmaSeqMswInequality(xs[..i+1], ys[..i+1]); } else { LemmaSeqMswInequality(ys[..i+1], xs[..i+1]); } reveal ToNatRight(); LemmaSeqPrefixNeq(xs, ys, i + 1); } }
libraries
54
./src/Collections/Sequences/Seq.dfy
LemmaCardinalityOfEmptySetIs0_fix_54.dfy
LemmaCardinalityOfEmptySetIs0
lemma LemmaCardinalityOfEmptySetIs0<T>(xs: seq<T>) ensures |ToSet(xs)| == 0 <==> |xs| == 0 { reveal ToSet(); if |xs| != 0 { assert xs[0] in ToSet(xs); } }
lemma LemmaCardinalityOfEmptySetIs0<T>(xs: seq<T>) ensures |ToSet(xs)| == 0 <==> |xs| == 0 { reveal ToSet(); if |xs| != 0 { } }
libraries
56
./src/Collections/Sequences/Seq.dfy
LemmaFlattenReverseConcat_fix_56.dfy
LemmaFlattenReverseConcat
lemma LemmaFlattenReverseConcat<T>(xs: seq<seq<T>>, ys: seq<seq<T>>) ensures FlattenReverse(xs + ys) == FlattenReverse(xs) + FlattenReverse(ys) { if |ys| == 0 { assert FlattenReverse(ys) == []; assert xs + ys == xs; } else { calc == { FlattenReverse(xs + ys); { assert Last(xs + ys) == Last(ys); assert DropLast(xs + ys) == xs + DropLast(ys); } FlattenReverse(xs + DropLast(ys)) + Last(ys); FlattenReverse(xs) + FlattenReverse(DropLast(ys)) + Last(ys); FlattenReverse(xs) + FlattenReverse(ys); } } }
lemma LemmaFlattenReverseConcat<T>(xs: seq<seq<T>>, ys: seq<seq<T>>) ensures FlattenReverse(xs + ys) == FlattenReverse(xs) + FlattenReverse(ys) { if |ys| == 0 { assert FlattenReverse(ys) == []; } else { calc == { FlattenReverse(xs + ys); { assert Last(xs + ys) == Last(ys); assert DropLast(xs + ys) == xs + DropLast(ys); } FlattenReverse(xs + DropLast(ys)) + Last(ys); FlattenReverse(xs) + FlattenReverse(DropLast(ys)) + Last(ys); FlattenReverse(xs) + FlattenReverse(ys); } } }
libraries
57
./src/Collections/Sequences/Seq.dfy
LemmaInvFoldRight_fix_57.dfy
LemmaInvFoldRight
lemma LemmaInvFoldRight<A,B>(inv: (seq<A>, B) -> bool, stp: (A, B, B) -> bool, f: (A, B) -> B, b: B, xs: seq<A>) requires InvFoldRight(inv, stp) requires forall a, b :: stp(a, b, f(a, b)) requires inv([], b) ensures inv(xs, FoldRight(f, xs, b)) { reveal FoldRight(); if xs == [] { } else { assert [xs[0]] + xs[1..] == xs; } }
lemma LemmaInvFoldRight<A,B>(inv: (seq<A>, B) -> bool, stp: (A, B, B) -> bool, f: (A, B) -> B, b: B, xs: seq<A>) requires InvFoldRight(inv, stp) requires forall a, b :: stp(a, b, f(a, b)) requires inv([], b) ensures inv(xs, FoldRight(f, xs, b)) { reveal FoldRight(); if xs == [] { } else { } }
libraries
58
./src/Collections/Sequences/Seq.dfy
LemmaInvFoldLeft_fix_58.dfy
LemmaInvFoldLeft
lemma LemmaInvFoldLeft<A,B>(inv: (B, seq<A>) -> bool, stp: (B, A, B) -> bool, f: (B, A) -> B, b: B, xs: seq<A>) requires InvFoldLeft(inv, stp) requires forall b, a :: stp(b, a, f(b, a)) requires inv(b, xs) ensures inv(FoldLeft(f, b, xs), []) { reveal FoldLeft(); if xs == [] { } else { assert [xs[0]] + xs[1..] == xs; LemmaInvFoldLeft(inv, stp, f, f(b, xs[0]), xs[1..]); } }
lemma LemmaInvFoldLeft<A,B>(inv: (B, seq<A>) -> bool, stp: (B, A, B) -> bool, f: (B, A) -> B, b: B, xs: seq<A>) requires InvFoldLeft(inv, stp) requires forall b, a :: stp(b, a, f(b, a)) requires inv(b, xs) ensures inv(FoldLeft(f, b, xs), []) { reveal FoldLeft(); if xs == [] { } else { LemmaInvFoldLeft(inv, stp, f, f(b, xs[0]), xs[1..]); } }
libraries
59
./src/Collections/Sequences/Seq.dfy
LemmaSubseqMin_fix_59.dfy
LemmaSubseqMin
lemma LemmaSubseqMin(xs: seq<int>, from: nat, to: nat) requires from < to <= |xs| ensures Min(xs[from..to]) >= Min(xs) { var subseq := xs[from..to]; if Min(subseq) < Min(xs) { var k :| 0 <= k < |subseq| && subseq[k] == Min(subseq); assert xs[seq(|subseq|, i requires 0 <= i < |subseq| => i + from)[k]] in xs; } }
lemma LemmaSubseqMin(xs: seq<int>, from: nat, to: nat) requires from < to <= |xs| ensures Min(xs[from..to]) >= Min(xs) { var subseq := xs[from..to]; if Min(subseq) < Min(xs) { var k :| 0 <= k < |subseq| && subseq[k] == Min(subseq); } }
libraries
60
./src/Collections/Sequences/Seq.dfy
LemmaFlattenConcat_fix_60.dfy
LemmaFlattenConcat
lemma LemmaFlattenConcat<T>(xs: seq<seq<T>>, ys: seq<seq<T>>) ensures Flatten(xs + ys) == Flatten(xs) + Flatten(ys) { if |xs| == 0 { assert xs + ys == ys; } else { calc == { Flatten(xs + ys); { assert (xs + ys)[0] == xs[0]; assert (xs + ys)[1..] == xs[1..] + ys; } xs[0] + Flatten(xs[1..] + ys); xs[0] + Flatten(xs[1..]) + Flatten(ys); Flatten(xs) + Flatten(ys); } } }
lemma LemmaFlattenConcat<T>(xs: seq<seq<T>>, ys: seq<seq<T>>) ensures Flatten(xs + ys) == Flatten(xs) + Flatten(ys) { if |xs| == 0 { } else { calc == { Flatten(xs + ys); { assert (xs + ys)[0] == xs[0]; assert (xs + ys)[1..] == xs[1..] + ys; } xs[0] + Flatten(xs[1..] + ys); xs[0] + Flatten(xs[1..]) + Flatten(ys); Flatten(xs) + Flatten(ys); } } }
libraries
61
./src/Collections/Sequences/Seq.dfy
LemmaSubseqMax_fix_61.dfy
LemmaSubseqMax
lemma LemmaSubseqMax(xs: seq<int>, from: nat, to: nat) requires from < to <= |xs| ensures Max(xs[from..to]) <= Max(xs) { var subseq := xs[from..to]; if Max(subseq) > Max(xs) { var k :| 0 <= k < |subseq| && subseq[k] == Max(subseq); assert xs[seq(|subseq|, i requires 0 <= i < |subseq| => i + from)[k]] in xs; assert false; } }
lemma LemmaSubseqMax(xs: seq<int>, from: nat, to: nat) requires from < to <= |xs| ensures Max(xs[from..to]) <= Max(xs) { var subseq := xs[from..to]; if Max(subseq) > Max(xs) { var k :| 0 <= k < |subseq| && subseq[k] == Max(subseq); assert false; } }
libraries
63
./src/Collections/Sequences/Seq.dfy
LemmaFlattenLengthLeMul_fix_63.dfy
LemmaFlattenLengthLeMul
lemma LemmaFlattenLengthLeMul<T>(xs: seq<seq<T>>, j: int) requires forall i | 0 <= i < |xs| :: |xs[i]| <= j ensures |FlattenReverse(xs)| <= |xs| * j { if |xs| == 0 { } else { LemmaFlattenLengthLeMul(xs[..|xs|-1], j); assert |FlattenReverse(xs[..|xs|-1])| <= (|xs|-1) * j; } }
lemma LemmaFlattenLengthLeMul<T>(xs: seq<seq<T>>, j: int) requires forall i | 0 <= i < |xs| :: |xs[i]| <= j ensures |FlattenReverse(xs)| <= |xs| * j { if |xs| == 0 { } else { LemmaFlattenLengthLeMul(xs[..|xs|-1], j); } }
libraries
64
./src/Collections/Sequences/Seq.dfy
LemmaCardinalityOfSet_fix_64.dfy
LemmaCardinalityOfSet
lemma LemmaCardinalityOfSet<T>(xs: seq<T>) ensures |ToSet(xs)| <= |xs| { reveal ToSet(); if |xs| == 0 { } else { assert ToSet(xs) == ToSet(DropLast(xs)) + {Last(xs)}; LemmaCardinalityOfSet(DropLast(xs)); } }
lemma LemmaCardinalityOfSet<T>(xs: seq<T>) ensures |ToSet(xs)| <= |xs| { reveal ToSet(); if |xs| == 0 { } else { LemmaCardinalityOfSet(DropLast(xs)); } }
libraries
65
./src/Collections/Sequences/Seq.dfy
LemmaCardinalityOfSetNoDuplicates_fix_65.dfy
LemmaCardinalityOfSetNoDuplicates
lemma LemmaCardinalityOfSetNoDuplicates<T>(xs: seq<T>) requires HasNoDuplicates(xs) ensures |ToSet(xs)| == |xs| { reveal HasNoDuplicates(); reveal ToSet(); if |xs| == 0 { } else { LemmaCardinalityOfSetNoDuplicates(DropLast(xs)); assert ToSet(xs) == ToSet(DropLast(xs)) + {Last(xs)}; } }
lemma LemmaCardinalityOfSetNoDuplicates<T>(xs: seq<T>) requires HasNoDuplicates(xs) ensures |ToSet(xs)| == |xs| { reveal HasNoDuplicates(); reveal ToSet(); if |xs| == 0 { } else { LemmaCardinalityOfSetNoDuplicates(DropLast(xs)); } }
libraries
67
./src/Collections/Sequences/Seq.dfy
LemmaNoDuplicatesCardinalityOfSet_fix_67.dfy
LemmaNoDuplicatesCardinalityOfSet
lemma LemmaNoDuplicatesCardinalityOfSet<T>(xs: seq<T>) requires |ToSet(xs)| == |xs| ensures HasNoDuplicates(xs) { reveal HasNoDuplicates(); reveal ToSet(); if |xs| == 0 { } else { assert xs == [First(xs)] + DropFirst(xs); assert ToSet(xs) == {First(xs)} + ToSet(DropFirst(xs)); if First(xs) in DropFirst(xs) { // If there is a duplicate, then we show that |ToSet(s)| == |s| cannot hold. assert ToSet(xs) == ToSet(DropFirst(xs)); LemmaCardinalityOfSet(DropFirst(xs)); assert |ToSet(xs)| <= |DropFirst(xs)|; } else { assert |ToSet(xs)| == 1 + |ToSet(DropFirst(xs))|; LemmaNoDuplicatesCardinalityOfSet(DropFirst(xs)); } } }
lemma LemmaNoDuplicatesCardinalityOfSet<T>(xs: seq<T>) requires |ToSet(xs)| == |xs| ensures HasNoDuplicates(xs) { reveal HasNoDuplicates(); reveal ToSet(); if |xs| == 0 { } else { assert xs == [First(xs)] + DropFirst(xs); if First(xs) in DropFirst(xs) { // If there is a duplicate, then we show that |ToSet(s)| == |s| cannot hold. assert ToSet(xs) == ToSet(DropFirst(xs)); LemmaCardinalityOfSet(DropFirst(xs)); assert |ToSet(xs)| <= |DropFirst(xs)|; } else { assert |ToSet(xs)| == 1 + |ToSet(DropFirst(xs))|; LemmaNoDuplicatesCardinalityOfSet(DropFirst(xs)); } } }
libraries
71
./src/Collections/Sequences/Seq.dfy
LemmaMultisetHasNoDuplicates_fix_71.dfy
LemmaMultisetHasNoDuplicates
lemma LemmaMultisetHasNoDuplicates<T>(xs: seq<T>) requires HasNoDuplicates(xs) ensures forall x | x in multiset(xs) :: multiset(xs)[x] == 1 { if |xs| == 0 { } else { assert xs == DropLast(xs) + [Last(xs)]; assert Last(xs) !in DropLast(xs) by { reveal HasNoDuplicates(); } assert HasNoDuplicates(DropLast(xs)) by { reveal HasNoDuplicates(); } LemmaMultisetHasNoDuplicates(DropLast(xs)); } }
lemma LemmaMultisetHasNoDuplicates<T>(xs: seq<T>) requires HasNoDuplicates(xs) ensures forall x | x in multiset(xs) :: multiset(xs)[x] == 1 { if |xs| == 0 { } else { assert Last(xs) !in DropLast(xs) by { reveal HasNoDuplicates(); } assert HasNoDuplicates(DropLast(xs)) by { reveal HasNoDuplicates(); } LemmaMultisetHasNoDuplicates(DropLast(xs)); } }
libraries
73
./src/Collections/Sequences/Seq.dfy
LemmaMinOfConcat_fix_73.dfy
LemmaMinOfConcat
lemma LemmaMinOfConcat(xs: seq<int>, ys: seq<int>) requires 0 < |xs| && 0 < |ys| ensures Min(xs+ys) <= Min(xs) ensures Min(xs+ys) <= Min(ys) ensures forall i :: i in xs + ys ==> Min(xs + ys) <= i { reveal Min(); if |xs| == 1 { } else { assert xs[1..] + ys == (xs + ys)[1..]; LemmaMinOfConcat(xs[1..], ys); } }
lemma LemmaMinOfConcat(xs: seq<int>, ys: seq<int>) requires 0 < |xs| && 0 < |ys| ensures Min(xs+ys) <= Min(xs) ensures Min(xs+ys) <= Min(ys) ensures forall i :: i in xs + ys ==> Min(xs + ys) <= i { reveal Min(); if |xs| == 1 { } else { LemmaMinOfConcat(xs[1..], ys); } }
libraries
74
./src/Collections/Sequences/Seq.dfy
LemmaMaxOfConcat_fix_74.dfy
LemmaMaxOfConcat
lemma LemmaMaxOfConcat(xs: seq<int>, ys: seq<int>) requires 0 < |xs| && 0 < |ys| ensures Max(xs+ys) >= Max(xs) ensures Max(xs+ys) >= Max(ys) ensures forall i {:trigger i in [Max(xs + ys)]} :: i in xs + ys ==> Max(xs + ys) >= i { reveal Max(); if |xs| == 1 { } else { assert xs[1..] + ys == (xs + ys)[1..]; LemmaMaxOfConcat(xs[1..], ys); } }
lemma LemmaMaxOfConcat(xs: seq<int>, ys: seq<int>) requires 0 < |xs| && 0 < |ys| ensures Max(xs+ys) >= Max(xs) ensures Max(xs+ys) >= Max(ys) ensures forall i {:trigger i in [Max(xs + ys)]} :: i in xs + ys ==> Max(xs + ys) >= i { reveal Max(); if |xs| == 1 { } else { LemmaMaxOfConcat(xs[1..], ys); } }
libraries
76
./src/Collections/Sequences/Seq.dfy
SortedUnique_fix_76.dfy
SortedUnique
lemma SortedUnique<T>(xs: seq<T>, ys: seq<T>, R: (T, T) -> bool) requires SortedBy(xs, R) requires SortedBy(ys, R) requires TotalOrdering(R) requires multiset(xs) == multiset(ys) ensures xs == ys { assert |xs| == |multiset(xs)| == |multiset(ys)| == |ys|; if xs == [] || ys == [] { } else { assert xs == [xs[0]] + xs[1..]; assert ys == [ys[0]] + ys[1..]; assert multiset(xs[1..]) == multiset(xs) - multiset{xs[0]}; assert multiset(ys[1..]) == multiset(ys) - multiset{ys[0]}; assert multiset(xs[1..]) == multiset(ys[1..]); SortedUnique(xs[1..], ys[1..], R); } }
lemma SortedUnique<T>(xs: seq<T>, ys: seq<T>, R: (T, T) -> bool) requires SortedBy(xs, R) requires SortedBy(ys, R) requires TotalOrdering(R) requires multiset(xs) == multiset(ys) ensures xs == ys { assert |xs| == |multiset(xs)| == |multiset(ys)| == |ys|; if xs == [] || ys == [] { } else { assert ys == [ys[0]] + ys[1..]; assert multiset(xs[1..]) == multiset(xs) - multiset{xs[0]}; assert multiset(ys[1..]) == multiset(ys) - multiset{ys[0]}; assert multiset(xs[1..]) == multiset(ys[1..]); SortedUnique(xs[1..], ys[1..], R); } }
libraries
77
./src/Collections/Sequences/Seq.dfy
SortedUnique_fix_77.dfy
SortedUnique
lemma SortedUnique<T>(xs: seq<T>, ys: seq<T>, R: (T, T) -> bool) requires SortedBy(xs, R) requires SortedBy(ys, R) requires TotalOrdering(R) requires multiset(xs) == multiset(ys) ensures xs == ys { assert |xs| == |multiset(xs)| == |multiset(ys)| == |ys|; if xs == [] || ys == [] { } else { assert xs == [xs[0]] + xs[1..]; assert ys == [ys[0]] + ys[1..]; assert multiset(xs[1..]) == multiset(xs) - multiset{xs[0]}; assert multiset(ys[1..]) == multiset(ys) - multiset{ys[0]}; assert multiset(xs[1..]) == multiset(ys[1..]); SortedUnique(xs[1..], ys[1..], R); } }
lemma SortedUnique<T>(xs: seq<T>, ys: seq<T>, R: (T, T) -> bool) requires SortedBy(xs, R) requires SortedBy(ys, R) requires TotalOrdering(R) requires multiset(xs) == multiset(ys) ensures xs == ys { assert |xs| == |multiset(xs)| == |multiset(ys)| == |ys|; if xs == [] || ys == [] { } else { assert xs == [xs[0]] + xs[1..]; assert multiset(xs[1..]) == multiset(xs) - multiset{xs[0]}; assert multiset(ys[1..]) == multiset(ys) - multiset{ys[0]}; assert multiset(xs[1..]) == multiset(ys[1..]); SortedUnique(xs[1..], ys[1..], R); } }
libraries
99
./src/NonlinearArithmetic/Power2.dfy
LemmaPow2MaskDiv2_fix_99.dfy
LemmaPow2MaskDiv2
lemma LemmaPow2MaskDiv2(e: nat) requires 0 < e ensures (Pow2(e) - 1) / 2 == Pow2(e - 1) - 1 { LemmaPow2Auto(); LemmaPowAuto(); var f := e => 0 < e ==> (Pow2(e) - 1) / 2 == Pow2(e - 1) - 1; assert forall i {:trigger IsLe(0, i)} :: IsLe(0, i) && f(i) ==> f(i + 1); assert forall i {:trigger IsLe(i, 0)} :: IsLe(i, 0) && f(i) ==> f(i - 1); LemmaMulInductionAuto(e, f); }
lemma LemmaPow2MaskDiv2(e: nat) requires 0 < e ensures (Pow2(e) - 1) / 2 == Pow2(e - 1) - 1 { LemmaPow2Auto(); LemmaPowAuto(); var f := e => 0 < e ==> (Pow2(e) - 1) / 2 == Pow2(e - 1) - 1; assert forall i {:trigger IsLe(i, 0)} :: IsLe(i, 0) && f(i) ==> f(i - 1); LemmaMulInductionAuto(e, f); }
libraries
151
./src/NonlinearArithmetic/Internals/GeneralInternals.dfy
LemmaInductionHelper_fix_151.dfy
LemmaInductionHelper
lemma LemmaInductionHelper(n: int, f: int -> bool, x: int) requires n > 0 requires forall i :: 0 <= i < n ==> f(i) requires forall i {:trigger f(i), f(i + n)} :: i >= 0 && f(i) ==> f(i + n) requires forall i {:trigger f(i), f(i - n)} :: i < n && f(i) ==> f(i - n) ensures f(x) decreases if x >= n then x else -x { if (x >= n) { LemmaInductionHelper(n, f, x - n); assert f((x - n) + n); } else if (x < 0) { LemmaInductionHelper(n, f, x + n); assert f((x + n) - n); } }
lemma LemmaInductionHelper(n: int, f: int -> bool, x: int) requires n > 0 requires forall i :: 0 <= i < n ==> f(i) requires forall i {:trigger f(i), f(i + n)} :: i >= 0 && f(i) ==> f(i + n) requires forall i {:trigger f(i), f(i - n)} :: i < n && f(i) ==> f(i - n) ensures f(x) decreases if x >= n then x else -x { if (x >= n) { LemmaInductionHelper(n, f, x - n); } else if (x < 0) { LemmaInductionHelper(n, f, x + n); assert f((x + n) - n); } }
libraries
152
./src/NonlinearArithmetic/Internals/GeneralInternals.dfy
LemmaInductionHelper_fix_152.dfy
LemmaInductionHelper
lemma LemmaInductionHelper(n: int, f: int -> bool, x: int) requires n > 0 requires forall i :: 0 <= i < n ==> f(i) requires forall i {:trigger f(i), f(i + n)} :: i >= 0 && f(i) ==> f(i + n) requires forall i {:trigger f(i), f(i - n)} :: i < n && f(i) ==> f(i - n) ensures f(x) decreases if x >= n then x else -x { if (x >= n) { LemmaInductionHelper(n, f, x - n); assert f((x - n) + n); } else if (x < 0) { LemmaInductionHelper(n, f, x + n); assert f((x + n) - n); } }
lemma LemmaInductionHelper(n: int, f: int -> bool, x: int) requires n > 0 requires forall i :: 0 <= i < n ==> f(i) requires forall i {:trigger f(i), f(i + n)} :: i >= 0 && f(i) ==> f(i + n) requires forall i {:trigger f(i), f(i - n)} :: i < n && f(i) ==> f(i - n) ensures f(x) decreases if x >= n then x else -x { if (x >= n) { LemmaInductionHelper(n, f, x - n); assert f((x - n) + n); } else if (x < 0) { LemmaInductionHelper(n, f, x + n); } }
libraries
153
./src/NonlinearArithmetic/Internals/DivInternals.dfy
LemmaDivInductionAutoForall_fix_153.dfy
LemmaDivInductionAutoForall
lemma LemmaDivInductionAutoForall(n:int, f:int->bool) requires n > 0 requires DivAuto(n) ==> && (forall i {:trigger IsLe(0, i)} :: IsLe(0, i) && i < n ==> f(i)) && (forall i {:trigger IsLe(0, i)} :: IsLe(0, i) && f(i) ==> f(i + n)) && (forall i {:trigger IsLe(i + 1, n)} :: IsLe(i + 1, n) && f(i) ==> f(i - n)) ensures DivAuto(n) ensures forall i {:trigger f(i)} :: f(i) { LemmaDivAuto(n); assert forall i :: IsLe(0, i) && i < n ==> f(i); assert forall i {:trigger f(i), f(i + n)} :: IsLe(0, i) && f(i) ==> f(i + n); assert forall i {:trigger f(i), f(i - n)} :: IsLe(i + 1, n) && f(i) ==> f(i - n); LemmaModInductionForall(n, f); }
lemma LemmaDivInductionAutoForall(n:int, f:int->bool) requires n > 0 requires DivAuto(n) ==> && (forall i {:trigger IsLe(0, i)} :: IsLe(0, i) && i < n ==> f(i)) && (forall i {:trigger IsLe(0, i)} :: IsLe(0, i) && f(i) ==> f(i + n)) && (forall i {:trigger IsLe(i + 1, n)} :: IsLe(i + 1, n) && f(i) ==> f(i - n)) ensures DivAuto(n) ensures forall i {:trigger f(i)} :: f(i) { LemmaDivAuto(n); assert forall i {:trigger f(i), f(i + n)} :: IsLe(0, i) && f(i) ==> f(i + n); assert forall i {:trigger f(i), f(i - n)} :: IsLe(i + 1, n) && f(i) ==> f(i - n); LemmaModInductionForall(n, f); }
libraries
154
./src/NonlinearArithmetic/Internals/DivInternals.dfy
LemmaDivInductionAutoForall_fix_154.dfy
LemmaDivInductionAutoForall
lemma LemmaDivInductionAutoForall(n:int, f:int->bool) requires n > 0 requires DivAuto(n) ==> && (forall i {:trigger IsLe(0, i)} :: IsLe(0, i) && i < n ==> f(i)) && (forall i {:trigger IsLe(0, i)} :: IsLe(0, i) && f(i) ==> f(i + n)) && (forall i {:trigger IsLe(i + 1, n)} :: IsLe(i + 1, n) && f(i) ==> f(i - n)) ensures DivAuto(n) ensures forall i {:trigger f(i)} :: f(i) { LemmaDivAuto(n); assert forall i :: IsLe(0, i) && i < n ==> f(i); assert forall i {:trigger f(i), f(i + n)} :: IsLe(0, i) && f(i) ==> f(i + n); assert forall i {:trigger f(i), f(i - n)} :: IsLe(i + 1, n) && f(i) ==> f(i - n); LemmaModInductionForall(n, f); }
lemma LemmaDivInductionAutoForall(n:int, f:int->bool) requires n > 0 requires DivAuto(n) ==> && (forall i {:trigger IsLe(0, i)} :: IsLe(0, i) && i < n ==> f(i)) && (forall i {:trigger IsLe(0, i)} :: IsLe(0, i) && f(i) ==> f(i + n)) && (forall i {:trigger IsLe(i + 1, n)} :: IsLe(i + 1, n) && f(i) ==> f(i - n)) ensures DivAuto(n) ensures forall i {:trigger f(i)} :: f(i) { LemmaDivAuto(n); assert forall i :: IsLe(0, i) && i < n ==> f(i); assert forall i {:trigger f(i), f(i - n)} :: IsLe(i + 1, n) && f(i) ==> f(i - n); LemmaModInductionForall(n, f); }
libraries
155
./src/NonlinearArithmetic/Internals/DivInternals.dfy
LemmaDivInductionAutoForall_fix_155.dfy
LemmaDivInductionAutoForall
lemma LemmaDivInductionAutoForall(n:int, f:int->bool) requires n > 0 requires DivAuto(n) ==> && (forall i {:trigger IsLe(0, i)} :: IsLe(0, i) && i < n ==> f(i)) && (forall i {:trigger IsLe(0, i)} :: IsLe(0, i) && f(i) ==> f(i + n)) && (forall i {:trigger IsLe(i + 1, n)} :: IsLe(i + 1, n) && f(i) ==> f(i - n)) ensures DivAuto(n) ensures forall i {:trigger f(i)} :: f(i) { LemmaDivAuto(n); assert forall i :: IsLe(0, i) && i < n ==> f(i); assert forall i {:trigger f(i), f(i + n)} :: IsLe(0, i) && f(i) ==> f(i + n); assert forall i {:trigger f(i), f(i - n)} :: IsLe(i + 1, n) && f(i) ==> f(i - n); LemmaModInductionForall(n, f); }
lemma LemmaDivInductionAutoForall(n:int, f:int->bool) requires n > 0 requires DivAuto(n) ==> && (forall i {:trigger IsLe(0, i)} :: IsLe(0, i) && i < n ==> f(i)) && (forall i {:trigger IsLe(0, i)} :: IsLe(0, i) && f(i) ==> f(i + n)) && (forall i {:trigger IsLe(i + 1, n)} :: IsLe(i + 1, n) && f(i) ==> f(i - n)) ensures DivAuto(n) ensures forall i {:trigger f(i)} :: f(i) { LemmaDivAuto(n); assert forall i :: IsLe(0, i) && i < n ==> f(i); assert forall i {:trigger f(i), f(i + n)} :: IsLe(0, i) && f(i) ==> f(i + n); LemmaModInductionForall(n, f); }
libraries
156
./src/NonlinearArithmetic/Internals/DivInternals.dfy
LemmaDivInductionAuto_fix_156.dfy
LemmaDivInductionAuto
lemma LemmaDivInductionAuto(n: int, x: int, f: int->bool) requires n > 0 requires DivAuto(n) ==> && (forall i {:trigger IsLe(0, i)} :: IsLe(0, i) && i < n ==> f(i)) && (forall i {:trigger IsLe(0, i)} :: IsLe(0, i) && f(i) ==> f(i + n)) && (forall i {:trigger IsLe(i + 1, n)} :: IsLe(i + 1, n) && f(i) ==> f(i - n)) ensures DivAuto(n) ensures f(x) { LemmaDivAuto(n); assert forall i :: IsLe(0, i) && i < n ==> f(i); assert forall i {:trigger f(i), f(i + n)} :: IsLe(0, i) && f(i) ==> f(i + n); assert forall i {:trigger f(i), f(i - n)} :: IsLe(i + 1, n) && f(i) ==> f(i - n); LemmaModInductionForall(n, f); assert f(x); }
lemma LemmaDivInductionAuto(n: int, x: int, f: int->bool) requires n > 0 requires DivAuto(n) ==> && (forall i {:trigger IsLe(0, i)} :: IsLe(0, i) && i < n ==> f(i)) && (forall i {:trigger IsLe(0, i)} :: IsLe(0, i) && f(i) ==> f(i + n)) && (forall i {:trigger IsLe(i + 1, n)} :: IsLe(i + 1, n) && f(i) ==> f(i - n)) ensures DivAuto(n) ensures f(x) { LemmaDivAuto(n); assert forall i {:trigger f(i), f(i + n)} :: IsLe(0, i) && f(i) ==> f(i + n); assert forall i {:trigger f(i), f(i - n)} :: IsLe(i + 1, n) && f(i) ==> f(i - n); LemmaModInductionForall(n, f); assert f(x); }
libraries
157
./src/NonlinearArithmetic/Internals/DivInternals.dfy
LemmaDivInductionAuto_fix_157.dfy
LemmaDivInductionAuto
lemma LemmaDivInductionAuto(n: int, x: int, f: int->bool) requires n > 0 requires DivAuto(n) ==> && (forall i {:trigger IsLe(0, i)} :: IsLe(0, i) && i < n ==> f(i)) && (forall i {:trigger IsLe(0, i)} :: IsLe(0, i) && f(i) ==> f(i + n)) && (forall i {:trigger IsLe(i + 1, n)} :: IsLe(i + 1, n) && f(i) ==> f(i - n)) ensures DivAuto(n) ensures f(x) { LemmaDivAuto(n); assert forall i :: IsLe(0, i) && i < n ==> f(i); assert forall i {:trigger f(i), f(i + n)} :: IsLe(0, i) && f(i) ==> f(i + n); assert forall i {:trigger f(i), f(i - n)} :: IsLe(i + 1, n) && f(i) ==> f(i - n); LemmaModInductionForall(n, f); assert f(x); }
lemma LemmaDivInductionAuto(n: int, x: int, f: int->bool) requires n > 0 requires DivAuto(n) ==> && (forall i {:trigger IsLe(0, i)} :: IsLe(0, i) && i < n ==> f(i)) && (forall i {:trigger IsLe(0, i)} :: IsLe(0, i) && f(i) ==> f(i + n)) && (forall i {:trigger IsLe(i + 1, n)} :: IsLe(i + 1, n) && f(i) ==> f(i - n)) ensures DivAuto(n) ensures f(x) { LemmaDivAuto(n); assert forall i :: IsLe(0, i) && i < n ==> f(i); assert forall i {:trigger f(i), f(i - n)} :: IsLe(i + 1, n) && f(i) ==> f(i - n); LemmaModInductionForall(n, f); assert f(x); }
libraries
158
./src/NonlinearArithmetic/Internals/DivInternals.dfy
LemmaDivInductionAuto_fix_158.dfy
LemmaDivInductionAuto
lemma LemmaDivInductionAuto(n: int, x: int, f: int->bool) requires n > 0 requires DivAuto(n) ==> && (forall i {:trigger IsLe(0, i)} :: IsLe(0, i) && i < n ==> f(i)) && (forall i {:trigger IsLe(0, i)} :: IsLe(0, i) && f(i) ==> f(i + n)) && (forall i {:trigger IsLe(i + 1, n)} :: IsLe(i + 1, n) && f(i) ==> f(i - n)) ensures DivAuto(n) ensures f(x) { LemmaDivAuto(n); assert forall i :: IsLe(0, i) && i < n ==> f(i); assert forall i {:trigger f(i), f(i + n)} :: IsLe(0, i) && f(i) ==> f(i + n); assert forall i {:trigger f(i), f(i - n)} :: IsLe(i + 1, n) && f(i) ==> f(i - n); LemmaModInductionForall(n, f); assert f(x); }
lemma LemmaDivInductionAuto(n: int, x: int, f: int->bool) requires n > 0 requires DivAuto(n) ==> && (forall i {:trigger IsLe(0, i)} :: IsLe(0, i) && i < n ==> f(i)) && (forall i {:trigger IsLe(0, i)} :: IsLe(0, i) && f(i) ==> f(i + n)) && (forall i {:trigger IsLe(i + 1, n)} :: IsLe(i + 1, n) && f(i) ==> f(i - n)) ensures DivAuto(n) ensures f(x) { LemmaDivAuto(n); assert forall i :: IsLe(0, i) && i < n ==> f(i); assert forall i {:trigger f(i), f(i + n)} :: IsLe(0, i) && f(i) ==> f(i + n); LemmaModInductionForall(n, f); assert f(x); }
libraries
170
./src/NonlinearArithmetic/Internals/DivInternals.dfy
LemmaDivAuto_fix_170.dfy
LemmaDivAuto
lemma LemmaDivAuto(n: int) requires n > 0 ensures DivAuto(n) { LemmaModAuto(n); LemmaDivBasics(n); assert (0 + n) / n == 1; assert (0 - n) / n == -1; forall x:int, y:int {:trigger (x + y) / n} ensures var z := (x % n) + (y % n); (|| (0 <= z < n && (x + y) / n == x / n + y / n) || (n <= z < 2 * n && (x + y) / n == x / n + y / n + 1)) { var f := (xx:int, yy:int) => (var z := (xx % n) + (yy % n); ( (0 <= z < n && (xx + yy) / n == xx / n + yy / n) || (n <= z < 2 * n && (xx + yy) / n == xx / n + yy / n + 1))); forall i, j ensures j >= 0 && f(i, j) ==> f(i, j + n) ensures i < n && f(i, j) ==> f(i - n, j) ensures j < n && f(i, j) ==> f(i, j - n) ensures i >= 0 && f(i, j) ==> f(i + n, j) { assert ((i + n) + j) / n == ((i + j) + n) / n; assert (i + (j + n)) / n == ((i + j) + n) / n; assert ((i - n) + j) / n == ((i + j) - n) / n; assert (i + (j - n)) / n == ((i + j) - n) / n; } forall i, j ensures 0 <= i < n && 0 <= j < n ==> f(i, j) { assert ((i + n) + j) / n == ((i + j) + n) / n; assert (i + (j + n)) / n == ((i + j) + n) / n; assert ((i - n) + j) / n == ((i + j) - n) / n; assert (i + (j - n)) / n == ((i + j) - n) / n; } LemmaModInductionForall2(n, f); assert f(x, y); } forall x:int, y:int {:trigger (x - y) / n} ensures var z := (x % n) - (y % n); (|| (0 <= z < n && (x - y) / n == x / n - y / n) || (-n <= z < 0 && (x - y) / n == x / n - y / n - 1)) { var f := (xx:int, yy:int) => (var z := (xx % n) - (yy % n); ( (0 <= z < n && (xx - yy) / n == xx / n - yy / n) || (-n <= z < 0 && (xx - yy) / n == xx / n - yy / n - 1))); forall i, j ensures j >= 0 && f(i, j) ==> f(i, j + n) ensures i < n && f(i, j) ==> f(i - n, j) ensures j < n && f(i, j) ==> f(i, j - n) ensures i >= 0 && f(i, j) ==> f(i + n, j) { assert ((i + n) - j) / n == ((i - j) + n) / n; assert (i - (j - n)) / n == ((i - j) + n) / n; assert ((i - n) - j) / n == ((i - j) - n) / n; assert (i - (j + n)) / n == ((i - j) - n) / n; } forall i, j ensures 0 <= i < n && 0 <= j < n ==> f(i, j) { assert ((i + n) - j) / n == ((i - j) + n) / n; assert (i - (j - n)) / n == ((i - j) + n) / n; assert ((i - n) - j) / n == ((i - j) - n) / n; assert (i - (j + n)) / n == ((i - j) - n) / n; } LemmaModInductionForall2(n, f); assert f(x, y); } }
lemma LemmaDivAuto(n: int) requires n > 0 ensures DivAuto(n) { LemmaModAuto(n); LemmaDivBasics(n); assert (0 + n) / n == 1; assert (0 - n) / n == -1; forall x:int, y:int {:trigger (x + y) / n} ensures var z := (x % n) + (y % n); (|| (0 <= z < n && (x + y) / n == x / n + y / n) || (n <= z < 2 * n && (x + y) / n == x / n + y / n + 1)) { var f := (xx:int, yy:int) => (var z := (xx % n) + (yy % n); ( (0 <= z < n && (xx + yy) / n == xx / n + yy / n) || (n <= z < 2 * n && (xx + yy) / n == xx / n + yy / n + 1))); forall i, j ensures j >= 0 && f(i, j) ==> f(i, j + n) ensures i < n && f(i, j) ==> f(i - n, j) ensures j < n && f(i, j) ==> f(i, j - n) ensures i >= 0 && f(i, j) ==> f(i + n, j) { assert ((i + n) + j) / n == ((i + j) + n) / n; assert (i + (j + n)) / n == ((i + j) + n) / n; assert ((i - n) + j) / n == ((i + j) - n) / n; assert (i + (j - n)) / n == ((i + j) - n) / n; } forall i, j ensures 0 <= i < n && 0 <= j < n ==> f(i, j) { assert ((i + n) + j) / n == ((i + j) + n) / n; assert (i + (j + n)) / n == ((i + j) + n) / n; assert ((i - n) + j) / n == ((i + j) - n) / n; assert (i + (j - n)) / n == ((i + j) - n) / n; } LemmaModInductionForall2(n, f); } forall x:int, y:int {:trigger (x - y) / n} ensures var z := (x % n) - (y % n); (|| (0 <= z < n && (x - y) / n == x / n - y / n) || (-n <= z < 0 && (x - y) / n == x / n - y / n - 1)) { var f := (xx:int, yy:int) => (var z := (xx % n) - (yy % n); ( (0 <= z < n && (xx - yy) / n == xx / n - yy / n) || (-n <= z < 0 && (xx - yy) / n == xx / n - yy / n - 1))); forall i, j ensures j >= 0 && f(i, j) ==> f(i, j + n) ensures i < n && f(i, j) ==> f(i - n, j) ensures j < n && f(i, j) ==> f(i, j - n) ensures i >= 0 && f(i, j) ==> f(i + n, j) { assert ((i + n) - j) / n == ((i - j) + n) / n; assert (i - (j - n)) / n == ((i - j) + n) / n; assert ((i - n) - j) / n == ((i - j) - n) / n; assert (i - (j + n)) / n == ((i - j) - n) / n; } forall i, j ensures 0 <= i < n && 0 <= j < n ==> f(i, j) { assert ((i + n) - j) / n == ((i - j) + n) / n; assert (i - (j - n)) / n == ((i - j) + n) / n; assert ((i - n) - j) / n == ((i - j) - n) / n; assert (i - (j + n)) / n == ((i - j) - n) / n; } LemmaModInductionForall2(n, f); assert f(x, y); } }
libraries
180
./src/NonlinearArithmetic/Internals/MulInternals.dfy
LemmaMulInductionAutoForall_fix_180.dfy
LemmaMulInductionAutoForall
lemma LemmaMulInductionAutoForall(f: int -> bool) requires MulAuto() ==> f(0) && (forall i {:trigger IsLe(0, i)} :: IsLe(0, i) && f(i) ==> f(i + 1)) && (forall i {:trigger IsLe(i, 0)} :: IsLe(i, 0) && f(i) ==> f(i - 1)) ensures MulAuto() ensures forall i {:trigger f(i)} :: f(i) { LemmaMulCommutes(); LemmaMulDistributes(); assert forall i {:trigger f(i)} :: IsLe(0, i) && f(i) ==> f(i + 1); assert forall i {:trigger f(i)} :: IsLe(i, 0) && f(i) ==> f(i - 1); LemmaMulInduction(f); }
lemma LemmaMulInductionAutoForall(f: int -> bool) requires MulAuto() ==> f(0) && (forall i {:trigger IsLe(0, i)} :: IsLe(0, i) && f(i) ==> f(i + 1)) && (forall i {:trigger IsLe(i, 0)} :: IsLe(i, 0) && f(i) ==> f(i - 1)) ensures MulAuto() ensures forall i {:trigger f(i)} :: f(i) { LemmaMulCommutes(); LemmaMulDistributes(); assert forall i {:trigger f(i)} :: IsLe(i, 0) && f(i) ==> f(i - 1); LemmaMulInduction(f); }
libraries
181
./src/NonlinearArithmetic/Internals/MulInternals.dfy
LemmaMulInductionAutoForall_fix_181.dfy
LemmaMulInductionAutoForall
lemma LemmaMulInductionAutoForall(f: int -> bool) requires MulAuto() ==> f(0) && (forall i {:trigger IsLe(0, i)} :: IsLe(0, i) && f(i) ==> f(i + 1)) && (forall i {:trigger IsLe(i, 0)} :: IsLe(i, 0) && f(i) ==> f(i - 1)) ensures MulAuto() ensures forall i {:trigger f(i)} :: f(i) { LemmaMulCommutes(); LemmaMulDistributes(); assert forall i {:trigger f(i)} :: IsLe(0, i) && f(i) ==> f(i + 1); assert forall i {:trigger f(i)} :: IsLe(i, 0) && f(i) ==> f(i - 1); LemmaMulInduction(f); }
lemma LemmaMulInductionAutoForall(f: int -> bool) requires MulAuto() ==> f(0) && (forall i {:trigger IsLe(0, i)} :: IsLe(0, i) && f(i) ==> f(i + 1)) && (forall i {:trigger IsLe(i, 0)} :: IsLe(i, 0) && f(i) ==> f(i - 1)) ensures MulAuto() ensures forall i {:trigger f(i)} :: f(i) { LemmaMulCommutes(); LemmaMulDistributes(); assert forall i {:trigger f(i)} :: IsLe(0, i) && f(i) ==> f(i + 1); LemmaMulInduction(f); }
libraries
182
./src/NonlinearArithmetic/Internals/MulInternals.dfy
LemmaMulInductionAuto_fix_182.dfy
LemmaMulInductionAuto
lemma LemmaMulInductionAuto(x: int, f: int -> bool) requires MulAuto() ==> f(0) && (forall i {:trigger IsLe(0, i)} :: IsLe(0, i) && f(i) ==> f(i + 1)) && (forall i {:trigger IsLe(i, 0)} :: IsLe(i, 0) && f(i) ==> f(i - 1)) ensures MulAuto() ensures f(x) { LemmaMulCommutes(); LemmaMulDistributes(); assert forall i {:trigger f(i)} :: IsLe(0, i) && f(i) ==> f(i + 1); assert forall i {:trigger f(i)} :: IsLe(i, 0) && f(i) ==> f(i - 1); LemmaMulInduction(f); assert f(x); }
lemma LemmaMulInductionAuto(x: int, f: int -> bool) requires MulAuto() ==> f(0) && (forall i {:trigger IsLe(0, i)} :: IsLe(0, i) && f(i) ==> f(i + 1)) && (forall i {:trigger IsLe(i, 0)} :: IsLe(i, 0) && f(i) ==> f(i - 1)) ensures MulAuto() ensures f(x) { LemmaMulCommutes(); LemmaMulDistributes(); assert forall i {:trigger f(i)} :: IsLe(i, 0) && f(i) ==> f(i - 1); LemmaMulInduction(f); assert f(x); }
libraries
183
./src/NonlinearArithmetic/Internals/MulInternals.dfy
LemmaMulInductionAuto_fix_183.dfy
LemmaMulInductionAuto
lemma LemmaMulInductionAuto(x: int, f: int -> bool) requires MulAuto() ==> f(0) && (forall i {:trigger IsLe(0, i)} :: IsLe(0, i) && f(i) ==> f(i + 1)) && (forall i {:trigger IsLe(i, 0)} :: IsLe(i, 0) && f(i) ==> f(i - 1)) ensures MulAuto() ensures f(x) { LemmaMulCommutes(); LemmaMulDistributes(); assert forall i {:trigger f(i)} :: IsLe(0, i) && f(i) ==> f(i + 1); assert forall i {:trigger f(i)} :: IsLe(i, 0) && f(i) ==> f(i - 1); LemmaMulInduction(f); assert f(x); }
lemma LemmaMulInductionAuto(x: int, f: int -> bool) requires MulAuto() ==> f(0) && (forall i {:trigger IsLe(0, i)} :: IsLe(0, i) && f(i) ==> f(i + 1)) && (forall i {:trigger IsLe(i, 0)} :: IsLe(i, 0) && f(i) ==> f(i - 1)) ensures MulAuto() ensures f(x) { LemmaMulCommutes(); LemmaMulDistributes(); assert forall i {:trigger f(i)} :: IsLe(0, i) && f(i) ==> f(i + 1); LemmaMulInduction(f); assert f(x); }
libraries
185
./src/NonlinearArithmetic/Internals/MulInternals.dfy
LemmaMulDistributes_fix_185.dfy
LemmaMulDistributes
lemma LemmaMulDistributes() ensures forall x:int, y:int, z:int {:trigger (x + y) * z} :: (x + y) * z == x * z + y * z ensures forall x:int, y:int, z:int {:trigger (x - y) * z} :: (x - y) * z == x * z - y * z { LemmaMulSuccessor(); forall x:int, y:int, z:int ensures (x + y) * z == x * z + y * z ensures (x - y) * z == x * z - y * z { var f1 := i => (x + i) * z == x * z + i * z; var f2 := i => (x - i) * z == x * z - i * z; assert forall i {:trigger (x + (i + 1)) * z} :: (x + (i + 1)) * z == ((x + i) + 1) * z == (x + i) * z + z; assert forall i {:trigger (x + (i - 1)) * z} :: (x + (i - 1)) * z == ((x + i) - 1) * z == (x + i) * z - z; assert forall i {:trigger (x - (i + 1)) * z} :: (x - (i + 1)) * z == ((x - i) - 1) * z == (x - i) * z - z; assert forall i {:trigger (x - (i - 1)) * z} :: (x - (i - 1)) * z == ((x - i) + 1) * z == (x - i) * z + z; LemmaMulInduction(f1); LemmaMulInduction(f2); assert f1(y); assert f2(y); } }
lemma LemmaMulDistributes() ensures forall x:int, y:int, z:int {:trigger (x + y) * z} :: (x + y) * z == x * z + y * z ensures forall x:int, y:int, z:int {:trigger (x - y) * z} :: (x - y) * z == x * z - y * z { LemmaMulSuccessor(); forall x:int, y:int, z:int ensures (x + y) * z == x * z + y * z ensures (x - y) * z == x * z - y * z { var f1 := i => (x + i) * z == x * z + i * z; var f2 := i => (x - i) * z == x * z - i * z; assert forall i {:trigger (x + (i - 1)) * z} :: (x + (i - 1)) * z == ((x + i) - 1) * z == (x + i) * z - z; assert forall i {:trigger (x - (i + 1)) * z} :: (x - (i + 1)) * z == ((x - i) - 1) * z == (x - i) * z - z; assert forall i {:trigger (x - (i - 1)) * z} :: (x - (i - 1)) * z == ((x - i) + 1) * z == (x - i) * z + z; LemmaMulInduction(f1); LemmaMulInduction(f2); assert f1(y); assert f2(y); } }
libraries
186
./src/NonlinearArithmetic/Internals/MulInternals.dfy
LemmaMulDistributes_fix_186.dfy
LemmaMulDistributes
lemma LemmaMulDistributes() ensures forall x:int, y:int, z:int {:trigger (x + y) * z} :: (x + y) * z == x * z + y * z ensures forall x:int, y:int, z:int {:trigger (x - y) * z} :: (x - y) * z == x * z - y * z { LemmaMulSuccessor(); forall x:int, y:int, z:int ensures (x + y) * z == x * z + y * z ensures (x - y) * z == x * z - y * z { var f1 := i => (x + i) * z == x * z + i * z; var f2 := i => (x - i) * z == x * z - i * z; assert forall i {:trigger (x + (i + 1)) * z} :: (x + (i + 1)) * z == ((x + i) + 1) * z == (x + i) * z + z; assert forall i {:trigger (x + (i - 1)) * z} :: (x + (i - 1)) * z == ((x + i) - 1) * z == (x + i) * z - z; assert forall i {:trigger (x - (i + 1)) * z} :: (x - (i + 1)) * z == ((x - i) - 1) * z == (x - i) * z - z; assert forall i {:trigger (x - (i - 1)) * z} :: (x - (i - 1)) * z == ((x - i) + 1) * z == (x - i) * z + z; LemmaMulInduction(f1); LemmaMulInduction(f2); assert f1(y); assert f2(y); } }
lemma LemmaMulDistributes() ensures forall x:int, y:int, z:int {:trigger (x + y) * z} :: (x + y) * z == x * z + y * z ensures forall x:int, y:int, z:int {:trigger (x - y) * z} :: (x - y) * z == x * z - y * z { LemmaMulSuccessor(); forall x:int, y:int, z:int ensures (x + y) * z == x * z + y * z ensures (x - y) * z == x * z - y * z { var f1 := i => (x + i) * z == x * z + i * z; var f2 := i => (x - i) * z == x * z - i * z; assert forall i {:trigger (x + (i + 1)) * z} :: (x + (i + 1)) * z == ((x + i) + 1) * z == (x + i) * z + z; assert forall i {:trigger (x - (i + 1)) * z} :: (x - (i + 1)) * z == ((x - i) - 1) * z == (x - i) * z - z; assert forall i {:trigger (x - (i - 1)) * z} :: (x - (i - 1)) * z == ((x - i) + 1) * z == (x - i) * z + z; LemmaMulInduction(f1); LemmaMulInduction(f2); assert f1(y); assert f2(y); } }
libraries
187
./src/NonlinearArithmetic/Internals/MulInternals.dfy
LemmaMulDistributes_fix_187.dfy
LemmaMulDistributes
lemma LemmaMulDistributes() ensures forall x:int, y:int, z:int {:trigger (x + y) * z} :: (x + y) * z == x * z + y * z ensures forall x:int, y:int, z:int {:trigger (x - y) * z} :: (x - y) * z == x * z - y * z { LemmaMulSuccessor(); forall x:int, y:int, z:int ensures (x + y) * z == x * z + y * z ensures (x - y) * z == x * z - y * z { var f1 := i => (x + i) * z == x * z + i * z; var f2 := i => (x - i) * z == x * z - i * z; assert forall i {:trigger (x + (i + 1)) * z} :: (x + (i + 1)) * z == ((x + i) + 1) * z == (x + i) * z + z; assert forall i {:trigger (x + (i - 1)) * z} :: (x + (i - 1)) * z == ((x + i) - 1) * z == (x + i) * z - z; assert forall i {:trigger (x - (i + 1)) * z} :: (x - (i + 1)) * z == ((x - i) - 1) * z == (x - i) * z - z; assert forall i {:trigger (x - (i - 1)) * z} :: (x - (i - 1)) * z == ((x - i) + 1) * z == (x - i) * z + z; LemmaMulInduction(f1); LemmaMulInduction(f2); assert f1(y); assert f2(y); } }
lemma LemmaMulDistributes() ensures forall x:int, y:int, z:int {:trigger (x + y) * z} :: (x + y) * z == x * z + y * z ensures forall x:int, y:int, z:int {:trigger (x - y) * z} :: (x - y) * z == x * z - y * z { LemmaMulSuccessor(); forall x:int, y:int, z:int ensures (x + y) * z == x * z + y * z ensures (x - y) * z == x * z - y * z { var f1 := i => (x + i) * z == x * z + i * z; var f2 := i => (x - i) * z == x * z - i * z; assert forall i {:trigger (x + (i + 1)) * z} :: (x + (i + 1)) * z == ((x + i) + 1) * z == (x + i) * z + z; assert forall i {:trigger (x + (i - 1)) * z} :: (x + (i - 1)) * z == ((x + i) - 1) * z == (x + i) * z - z; assert forall i {:trigger (x - (i - 1)) * z} :: (x - (i - 1)) * z == ((x - i) + 1) * z == (x - i) * z + z; LemmaMulInduction(f1); LemmaMulInduction(f2); assert f1(y); assert f2(y); } }
libraries
188
./src/NonlinearArithmetic/Internals/MulInternals.dfy
LemmaMulDistributes_fix_188.dfy
LemmaMulDistributes
lemma LemmaMulDistributes() ensures forall x:int, y:int, z:int {:trigger (x + y) * z} :: (x + y) * z == x * z + y * z ensures forall x:int, y:int, z:int {:trigger (x - y) * z} :: (x - y) * z == x * z - y * z { LemmaMulSuccessor(); forall x:int, y:int, z:int ensures (x + y) * z == x * z + y * z ensures (x - y) * z == x * z - y * z { var f1 := i => (x + i) * z == x * z + i * z; var f2 := i => (x - i) * z == x * z - i * z; assert forall i {:trigger (x + (i + 1)) * z} :: (x + (i + 1)) * z == ((x + i) + 1) * z == (x + i) * z + z; assert forall i {:trigger (x + (i - 1)) * z} :: (x + (i - 1)) * z == ((x + i) - 1) * z == (x + i) * z - z; assert forall i {:trigger (x - (i + 1)) * z} :: (x - (i + 1)) * z == ((x - i) - 1) * z == (x - i) * z - z; assert forall i {:trigger (x - (i - 1)) * z} :: (x - (i - 1)) * z == ((x - i) + 1) * z == (x - i) * z + z; LemmaMulInduction(f1); LemmaMulInduction(f2); assert f1(y); assert f2(y); } }
lemma LemmaMulDistributes() ensures forall x:int, y:int, z:int {:trigger (x + y) * z} :: (x + y) * z == x * z + y * z ensures forall x:int, y:int, z:int {:trigger (x - y) * z} :: (x - y) * z == x * z - y * z { LemmaMulSuccessor(); forall x:int, y:int, z:int ensures (x + y) * z == x * z + y * z ensures (x - y) * z == x * z - y * z { var f1 := i => (x + i) * z == x * z + i * z; var f2 := i => (x - i) * z == x * z - i * z; assert forall i {:trigger (x + (i + 1)) * z} :: (x + (i + 1)) * z == ((x + i) + 1) * z == (x + i) * z + z; assert forall i {:trigger (x + (i - 1)) * z} :: (x + (i - 1)) * z == ((x + i) - 1) * z == (x + i) * z - z; assert forall i {:trigger (x - (i + 1)) * z} :: (x - (i + 1)) * z == ((x - i) - 1) * z == (x - i) * z - z; LemmaMulInduction(f1); LemmaMulInduction(f2); assert f1(y); assert f2(y); } }
libraries
189
./src/NonlinearArithmetic/Internals/MulInternals.dfy
LemmaMulDistributes_fix_189.dfy
LemmaMulDistributes
lemma LemmaMulDistributes() ensures forall x:int, y:int, z:int {:trigger (x + y) * z} :: (x + y) * z == x * z + y * z ensures forall x:int, y:int, z:int {:trigger (x - y) * z} :: (x - y) * z == x * z - y * z { LemmaMulSuccessor(); forall x:int, y:int, z:int ensures (x + y) * z == x * z + y * z ensures (x - y) * z == x * z - y * z { var f1 := i => (x + i) * z == x * z + i * z; var f2 := i => (x - i) * z == x * z - i * z; assert forall i {:trigger (x + (i + 1)) * z} :: (x + (i + 1)) * z == ((x + i) + 1) * z == (x + i) * z + z; assert forall i {:trigger (x + (i - 1)) * z} :: (x + (i - 1)) * z == ((x + i) - 1) * z == (x + i) * z - z; assert forall i {:trigger (x - (i + 1)) * z} :: (x - (i + 1)) * z == ((x - i) - 1) * z == (x - i) * z - z; assert forall i {:trigger (x - (i - 1)) * z} :: (x - (i - 1)) * z == ((x - i) + 1) * z == (x - i) * z + z; LemmaMulInduction(f1); LemmaMulInduction(f2); assert f1(y); assert f2(y); } }
lemma LemmaMulDistributes() ensures forall x:int, y:int, z:int {:trigger (x + y) * z} :: (x + y) * z == x * z + y * z ensures forall x:int, y:int, z:int {:trigger (x - y) * z} :: (x - y) * z == x * z - y * z { LemmaMulSuccessor(); forall x:int, y:int, z:int ensures (x + y) * z == x * z + y * z ensures (x - y) * z == x * z - y * z { var f1 := i => (x + i) * z == x * z + i * z; var f2 := i => (x - i) * z == x * z - i * z; assert forall i {:trigger (x + (i + 1)) * z} :: (x + (i + 1)) * z == ((x + i) + 1) * z == (x + i) * z + z; assert forall i {:trigger (x + (i - 1)) * z} :: (x + (i - 1)) * z == ((x + i) - 1) * z == (x + i) * z - z; assert forall i {:trigger (x - (i + 1)) * z} :: (x - (i + 1)) * z == ((x - i) - 1) * z == (x - i) * z - z; assert forall i {:trigger (x - (i - 1)) * z} :: (x - (i - 1)) * z == ((x - i) + 1) * z == (x - i) * z + z; LemmaMulInduction(f1); LemmaMulInduction(f2); assert f2(y); } }
libraries
190
./src/NonlinearArithmetic/Internals/MulInternals.dfy
LemmaMulDistributes_fix_190.dfy
LemmaMulDistributes
lemma LemmaMulDistributes() ensures forall x:int, y:int, z:int {:trigger (x + y) * z} :: (x + y) * z == x * z + y * z ensures forall x:int, y:int, z:int {:trigger (x - y) * z} :: (x - y) * z == x * z - y * z { LemmaMulSuccessor(); forall x:int, y:int, z:int ensures (x + y) * z == x * z + y * z ensures (x - y) * z == x * z - y * z { var f1 := i => (x + i) * z == x * z + i * z; var f2 := i => (x - i) * z == x * z - i * z; assert forall i {:trigger (x + (i + 1)) * z} :: (x + (i + 1)) * z == ((x + i) + 1) * z == (x + i) * z + z; assert forall i {:trigger (x + (i - 1)) * z} :: (x + (i - 1)) * z == ((x + i) - 1) * z == (x + i) * z - z; assert forall i {:trigger (x - (i + 1)) * z} :: (x - (i + 1)) * z == ((x - i) - 1) * z == (x - i) * z - z; assert forall i {:trigger (x - (i - 1)) * z} :: (x - (i - 1)) * z == ((x - i) + 1) * z == (x - i) * z + z; LemmaMulInduction(f1); LemmaMulInduction(f2); assert f1(y); assert f2(y); } }
lemma LemmaMulDistributes() ensures forall x:int, y:int, z:int {:trigger (x + y) * z} :: (x + y) * z == x * z + y * z ensures forall x:int, y:int, z:int {:trigger (x - y) * z} :: (x - y) * z == x * z - y * z { LemmaMulSuccessor(); forall x:int, y:int, z:int ensures (x + y) * z == x * z + y * z ensures (x - y) * z == x * z - y * z { var f1 := i => (x + i) * z == x * z + i * z; var f2 := i => (x - i) * z == x * z - i * z; assert forall i {:trigger (x + (i + 1)) * z} :: (x + (i + 1)) * z == ((x + i) + 1) * z == (x + i) * z + z; assert forall i {:trigger (x + (i - 1)) * z} :: (x + (i - 1)) * z == ((x + i) - 1) * z == (x + i) * z - z; assert forall i {:trigger (x - (i + 1)) * z} :: (x - (i + 1)) * z == ((x - i) - 1) * z == (x - i) * z - z; assert forall i {:trigger (x - (i - 1)) * z} :: (x - (i - 1)) * z == ((x - i) + 1) * z == (x - i) * z + z; LemmaMulInduction(f1); LemmaMulInduction(f2); assert f1(y); } }
libraries
197
./src/NonlinearArithmetic/Internals/ModInternals.dfy
LemmaModInductionAuto_fix_197.dfy
LemmaModInductionAuto
lemma LemmaModInductionAuto(n: int, x: int, f: int -> bool) requires n > 0 requires ModAuto(n) ==> && (forall i {:trigger IsLe(0, i)} :: IsLe(0, i) && i < n ==> f(i)) && (forall i {:trigger IsLe(0, i)} :: IsLe(0, i) && f(i) ==> f(i + n)) && (forall i {:trigger IsLe(i + 1, n)} :: IsLe(i + 1, n) && f(i) ==> f(i - n)) ensures ModAuto(n) ensures f(x) { LemmaModAuto(n); assert forall i :: IsLe(0, i) && i < n ==> f(i); assert forall i {:trigger f(i), f(i + n)} :: IsLe(0, i) && f(i) ==> f(i + n); assert forall i {:trigger f(i), f(i - n)} :: IsLe(i + 1, n) && f(i) ==> f(i - n); LemmaModInductionForall(n, f); assert f(x); }
lemma LemmaModInductionAuto(n: int, x: int, f: int -> bool) requires n > 0 requires ModAuto(n) ==> && (forall i {:trigger IsLe(0, i)} :: IsLe(0, i) && i < n ==> f(i)) && (forall i {:trigger IsLe(0, i)} :: IsLe(0, i) && f(i) ==> f(i + n)) && (forall i {:trigger IsLe(i + 1, n)} :: IsLe(i + 1, n) && f(i) ==> f(i - n)) ensures ModAuto(n) ensures f(x) { LemmaModAuto(n); assert forall i :: IsLe(0, i) && i < n ==> f(i); assert forall i {:trigger f(i), f(i + n)} :: IsLe(0, i) && f(i) ==> f(i + n); LemmaModInductionForall(n, f); assert f(x); }
libraries
199
./src/NonlinearArithmetic/Internals/ModInternals.dfy
LemmaModInductionForall2_fix_199.dfy
LemmaModInductionForall2
lemma LemmaModInductionForall2(n: int, f:(int, int)->bool) requires n > 0 requires forall i, j :: 0 <= i < n && 0 <= j < n ==> f(i, j) requires forall i, j {:trigger f(i, j), f(i + n, j)} :: i >= 0 && f(i, j) ==> f(i + n, j) requires forall i, j {:trigger f(i, j), f(i, j + n)} :: j >= 0 && f(i, j) ==> f(i, j + n) requires forall i, j {:trigger f(i, j), f(i - n, j)} :: i < n && f(i, j) ==> f(i - n, j) requires forall i, j {:trigger f(i, j), f(i, j - n)} :: j < n && f(i, j) ==> f(i, j - n) ensures forall i, j :: f(i, j) { forall x, y ensures f(x, y) { forall i | 0 <= i < n ensures f(i, y) { var fj := j => f(i, j); LemmaModInductionForall(n, fj); assert fj(y); } var fi := i => f(i, y); LemmaModInductionForall(n, fi); assert fi(x); } }
lemma LemmaModInductionForall2(n: int, f:(int, int)->bool) requires n > 0 requires forall i, j :: 0 <= i < n && 0 <= j < n ==> f(i, j) requires forall i, j {:trigger f(i, j), f(i + n, j)} :: i >= 0 && f(i, j) ==> f(i + n, j) requires forall i, j {:trigger f(i, j), f(i, j + n)} :: j >= 0 && f(i, j) ==> f(i, j + n) requires forall i, j {:trigger f(i, j), f(i - n, j)} :: i < n && f(i, j) ==> f(i - n, j) requires forall i, j {:trigger f(i, j), f(i, j - n)} :: j < n && f(i, j) ==> f(i, j - n) ensures forall i, j :: f(i, j) { forall x, y ensures f(x, y) { forall i | 0 <= i < n ensures f(i, y) { var fj := j => f(i, j); LemmaModInductionForall(n, fj); } var fi := i => f(i, y); LemmaModInductionForall(n, fi); assert fi(x); } }
libraries
200
./src/NonlinearArithmetic/Internals/ModInternals.dfy
LemmaModInductionForall2_fix_200.dfy
LemmaModInductionForall2
lemma LemmaModInductionForall2(n: int, f:(int, int)->bool) requires n > 0 requires forall i, j :: 0 <= i < n && 0 <= j < n ==> f(i, j) requires forall i, j {:trigger f(i, j), f(i + n, j)} :: i >= 0 && f(i, j) ==> f(i + n, j) requires forall i, j {:trigger f(i, j), f(i, j + n)} :: j >= 0 && f(i, j) ==> f(i, j + n) requires forall i, j {:trigger f(i, j), f(i - n, j)} :: i < n && f(i, j) ==> f(i - n, j) requires forall i, j {:trigger f(i, j), f(i, j - n)} :: j < n && f(i, j) ==> f(i, j - n) ensures forall i, j :: f(i, j) { forall x, y ensures f(x, y) { forall i | 0 <= i < n ensures f(i, y) { var fj := j => f(i, j); LemmaModInductionForall(n, fj); assert fj(y); } var fi := i => f(i, y); LemmaModInductionForall(n, fi); assert fi(x); } }
lemma LemmaModInductionForall2(n: int, f:(int, int)->bool) requires n > 0 requires forall i, j :: 0 <= i < n && 0 <= j < n ==> f(i, j) requires forall i, j {:trigger f(i, j), f(i + n, j)} :: i >= 0 && f(i, j) ==> f(i + n, j) requires forall i, j {:trigger f(i, j), f(i, j + n)} :: j >= 0 && f(i, j) ==> f(i, j + n) requires forall i, j {:trigger f(i, j), f(i - n, j)} :: i < n && f(i, j) ==> f(i - n, j) requires forall i, j {:trigger f(i, j), f(i, j - n)} :: j < n && f(i, j) ==> f(i, j - n) ensures forall i, j :: f(i, j) { forall x, y ensures f(x, y) { forall i | 0 <= i < n ensures f(i, y) { var fj := j => f(i, j); LemmaModInductionForall(n, fj); assert fj(y); } var fi := i => f(i, y); LemmaModInductionForall(n, fi); } }
libraries
201
./src/NonlinearArithmetic/Internals/ModInternals.dfy
LemmaModInductionAutoForall_fix_201.dfy
LemmaModInductionAutoForall
lemma LemmaModInductionAutoForall(n: int, f: int -> bool) requires n > 0 requires ModAuto(n) ==> && (forall i {:trigger IsLe(0, i)} :: IsLe(0, i) && i < n ==> f(i)) && (forall i {:trigger IsLe(0, i)} :: IsLe(0, i) && f(i) ==> f(i + n)) && (forall i {:trigger IsLe(i + 1, n)} :: IsLe(i + 1, n) && f(i) ==> f(i - n)) ensures ModAuto(n) ensures forall i {:trigger f(i)} :: f(i) { LemmaModAuto(n); assert forall i :: IsLe(0, i) && i < n ==> f(i); assert forall i {:trigger f(i), f(i + n)} :: IsLe(0, i) && f(i) ==> f(i + n); assert forall i {:trigger f(i), f(i - n)} :: IsLe(i + 1, n) && f(i) ==> f(i - n); LemmaModInductionForall(n, f); }
lemma LemmaModInductionAutoForall(n: int, f: int -> bool) requires n > 0 requires ModAuto(n) ==> && (forall i {:trigger IsLe(0, i)} :: IsLe(0, i) && i < n ==> f(i)) && (forall i {:trigger IsLe(0, i)} :: IsLe(0, i) && f(i) ==> f(i + n)) && (forall i {:trigger IsLe(i + 1, n)} :: IsLe(i + 1, n) && f(i) ==> f(i - n)) ensures ModAuto(n) ensures forall i {:trigger f(i)} :: f(i) { LemmaModAuto(n); assert forall i {:trigger f(i), f(i + n)} :: IsLe(0, i) && f(i) ==> f(i + n); assert forall i {:trigger f(i), f(i - n)} :: IsLe(i + 1, n) && f(i) ==> f(i - n); LemmaModInductionForall(n, f); }
libraries
202
./src/NonlinearArithmetic/Internals/ModInternals.dfy
LemmaModInductionAutoForall_fix_202.dfy
LemmaModInductionAutoForall
lemma LemmaModInductionAutoForall(n: int, f: int -> bool) requires n > 0 requires ModAuto(n) ==> && (forall i {:trigger IsLe(0, i)} :: IsLe(0, i) && i < n ==> f(i)) && (forall i {:trigger IsLe(0, i)} :: IsLe(0, i) && f(i) ==> f(i + n)) && (forall i {:trigger IsLe(i + 1, n)} :: IsLe(i + 1, n) && f(i) ==> f(i - n)) ensures ModAuto(n) ensures forall i {:trigger f(i)} :: f(i) { LemmaModAuto(n); assert forall i :: IsLe(0, i) && i < n ==> f(i); assert forall i {:trigger f(i), f(i + n)} :: IsLe(0, i) && f(i) ==> f(i + n); assert forall i {:trigger f(i), f(i - n)} :: IsLe(i + 1, n) && f(i) ==> f(i - n); LemmaModInductionForall(n, f); }
lemma LemmaModInductionAutoForall(n: int, f: int -> bool) requires n > 0 requires ModAuto(n) ==> && (forall i {:trigger IsLe(0, i)} :: IsLe(0, i) && i < n ==> f(i)) && (forall i {:trigger IsLe(0, i)} :: IsLe(0, i) && f(i) ==> f(i + n)) && (forall i {:trigger IsLe(i + 1, n)} :: IsLe(i + 1, n) && f(i) ==> f(i - n)) ensures ModAuto(n) ensures forall i {:trigger f(i)} :: f(i) { LemmaModAuto(n); assert forall i :: IsLe(0, i) && i < n ==> f(i); assert forall i {:trigger f(i), f(i - n)} :: IsLe(i + 1, n) && f(i) ==> f(i - n); LemmaModInductionForall(n, f); }
libraries
203
./src/NonlinearArithmetic/Internals/ModInternals.dfy
LemmaModInductionAutoForall_fix_203.dfy
LemmaModInductionAutoForall
lemma LemmaModInductionAutoForall(n: int, f: int -> bool) requires n > 0 requires ModAuto(n) ==> && (forall i {:trigger IsLe(0, i)} :: IsLe(0, i) && i < n ==> f(i)) && (forall i {:trigger IsLe(0, i)} :: IsLe(0, i) && f(i) ==> f(i + n)) && (forall i {:trigger IsLe(i + 1, n)} :: IsLe(i + 1, n) && f(i) ==> f(i - n)) ensures ModAuto(n) ensures forall i {:trigger f(i)} :: f(i) { LemmaModAuto(n); assert forall i :: IsLe(0, i) && i < n ==> f(i); assert forall i {:trigger f(i), f(i + n)} :: IsLe(0, i) && f(i) ==> f(i + n); assert forall i {:trigger f(i), f(i - n)} :: IsLe(i + 1, n) && f(i) ==> f(i - n); LemmaModInductionForall(n, f); }
lemma LemmaModInductionAutoForall(n: int, f: int -> bool) requires n > 0 requires ModAuto(n) ==> && (forall i {:trigger IsLe(0, i)} :: IsLe(0, i) && i < n ==> f(i)) && (forall i {:trigger IsLe(0, i)} :: IsLe(0, i) && f(i) ==> f(i + n)) && (forall i {:trigger IsLe(i + 1, n)} :: IsLe(i + 1, n) && f(i) ==> f(i - n)) ensures ModAuto(n) ensures forall i {:trigger f(i)} :: f(i) { LemmaModAuto(n); assert forall i :: IsLe(0, i) && i < n ==> f(i); assert forall i {:trigger f(i), f(i + n)} :: IsLe(0, i) && f(i) ==> f(i + n); LemmaModInductionForall(n, f); }
libraries
204
./src/Unicode/UnicodeEncodingForm.dfy
LemmaSplitPrefixMinimalWellFormedCodeUnitSubsequenceInvertsPrepend_fix_204.dfy
LemmaSplitPrefixMinimalWellFormedCodeUnitSubsequenceInvertsPrepend
lemma LemmaSplitPrefixMinimalWellFormedCodeUnitSubsequenceInvertsPrepend(m: MinimalWellFormedCodeUnitSeq, s: CodeUnitSeq) ensures SplitPrefixMinimalWellFormedCodeUnitSubsequence(m + s) == Some(m) { var ms := m + s; assert IsMinimalWellFormedCodeUnitSubsequence(ms[..|m|]); var prefix := SplitPrefixMinimalWellFormedCodeUnitSubsequence(ms).Extract(); calc ==> { IsMinimalWellFormedCodeUnitSubsequence(m); |prefix| <= |m|; prefix == ms[..|prefix|] == m[..|prefix|] == m; } }
lemma LemmaSplitPrefixMinimalWellFormedCodeUnitSubsequenceInvertsPrepend(m: MinimalWellFormedCodeUnitSeq, s: CodeUnitSeq) ensures SplitPrefixMinimalWellFormedCodeUnitSubsequence(m + s) == Some(m) { var ms := m + s; var prefix := SplitPrefixMinimalWellFormedCodeUnitSubsequence(ms).Extract(); calc ==> { IsMinimalWellFormedCodeUnitSubsequence(m); |prefix| <= |m|; prefix == ms[..|prefix|] == m[..|prefix|] == m; } }
libraries
211
./src/dafny/BinaryOperations.dfy
MonoidInverseIsUnique_fix_211.dfy
MonoidInverseIsUnique
lemma MonoidInverseIsUnique<T(!new)>(m: Monoid<T>, inverse1: T -> T, inverse2: T -> T) requires IsInverse(m.bop, inverse1, m.unit) requires IsInverse(m.bop, inverse2, m.unit) ensures forall x :: inverse1(x) == inverse2(x) { assert IsMonoid(m.bop, m.unit); forall x ensures inverse1(x) == inverse2(x) { calc { inverse1(x); == { assert IsRightUnital(m.bop, m.unit); } m.bop(inverse1(x), m.unit); == { assert IsRightInverse(m.bop, inverse2, m.unit); assert m.unit == m.bop(x, inverse2(x)); } m.bop(inverse1(x), m.bop(x, inverse2(x))); == { assert IsAssociative(m.bop); } m.bop(m.bop(inverse1(x), x), inverse2(x)); == { assert IsLeftInverse(m.bop, inverse1, m.unit); } m.bop(m.unit, inverse2(x)); == { assert IsLeftUnital(m.bop, m.unit); } inverse2(x); } } }
lemma MonoidInverseIsUnique<T(!new)>(m: Monoid<T>, inverse1: T -> T, inverse2: T -> T) requires IsInverse(m.bop, inverse1, m.unit) requires IsInverse(m.bop, inverse2, m.unit) ensures forall x :: inverse1(x) == inverse2(x) { forall x ensures inverse1(x) == inverse2(x) { calc { inverse1(x); == { assert IsRightUnital(m.bop, m.unit); } m.bop(inverse1(x), m.unit); == { assert IsRightInverse(m.bop, inverse2, m.unit); assert m.unit == m.bop(x, inverse2(x)); } m.bop(inverse1(x), m.bop(x, inverse2(x))); == { assert IsAssociative(m.bop); } m.bop(m.bop(inverse1(x), x), inverse2(x)); == { assert IsLeftInverse(m.bop, inverse1, m.unit); } m.bop(m.unit, inverse2(x)); == { assert IsLeftUnital(m.bop, m.unit); } inverse2(x); } } }
libraries
378
./src/dafny/NonlinearArithmetic/Internals/ModInternals.dfy
LemmaModInductionAuto_fix_378.dfy
LemmaModInductionAuto
lemma LemmaModInductionAuto(n: int, x: int, f: int -> bool) requires n > 0 requires ModAuto(n) ==> && (forall i {:trigger IsLe(0, i)} :: IsLe(0, i) && i < n ==> f(i)) && (forall i {:trigger IsLe(0, i)} :: IsLe(0, i) && f(i) ==> f(i + n)) && (forall i {:trigger IsLe(i + 1, n)} :: IsLe(i + 1, n) && f(i) ==> f(i - n)) ensures ModAuto(n) ensures f(x) { LemmaModAuto(n); assert forall i :: IsLe(0, i) && i < n ==> f(i); assert forall i {:trigger f(i), f(i + n)} :: IsLe(0, i) && f(i) ==> f(i + n); assert forall i {:trigger f(i), f(i - n)} :: IsLe(i + 1, n) && f(i) ==> f(i - n); LemmaModInductionForall(n, f); assert f(x); }
lemma LemmaModInductionAuto(n: int, x: int, f: int -> bool) requires n > 0 requires ModAuto(n) ==> && (forall i {:trigger IsLe(0, i)} :: IsLe(0, i) && i < n ==> f(i)) && (forall i {:trigger IsLe(0, i)} :: IsLe(0, i) && f(i) ==> f(i + n)) && (forall i {:trigger IsLe(i + 1, n)} :: IsLe(i + 1, n) && f(i) ==> f(i - n)) ensures ModAuto(n) ensures f(x) { LemmaModAuto(n); assert forall i {:trigger f(i), f(i + n)} :: IsLe(0, i) && f(i) ==> f(i + n); assert forall i {:trigger f(i), f(i - n)} :: IsLe(i + 1, n) && f(i) ==> f(i - n); LemmaModInductionForall(n, f); assert f(x); }
libraries
379
./src/dafny/NonlinearArithmetic/Internals/ModInternals.dfy
LemmaModInductionAuto_fix_379.dfy
LemmaModInductionAuto
lemma LemmaModInductionAuto(n: int, x: int, f: int -> bool) requires n > 0 requires ModAuto(n) ==> && (forall i {:trigger IsLe(0, i)} :: IsLe(0, i) && i < n ==> f(i)) && (forall i {:trigger IsLe(0, i)} :: IsLe(0, i) && f(i) ==> f(i + n)) && (forall i {:trigger IsLe(i + 1, n)} :: IsLe(i + 1, n) && f(i) ==> f(i - n)) ensures ModAuto(n) ensures f(x) { LemmaModAuto(n); assert forall i :: IsLe(0, i) && i < n ==> f(i); assert forall i {:trigger f(i), f(i + n)} :: IsLe(0, i) && f(i) ==> f(i + n); assert forall i {:trigger f(i), f(i - n)} :: IsLe(i + 1, n) && f(i) ==> f(i - n); LemmaModInductionForall(n, f); assert f(x); }
lemma LemmaModInductionAuto(n: int, x: int, f: int -> bool) requires n > 0 requires ModAuto(n) ==> && (forall i {:trigger IsLe(0, i)} :: IsLe(0, i) && i < n ==> f(i)) && (forall i {:trigger IsLe(0, i)} :: IsLe(0, i) && f(i) ==> f(i + n)) && (forall i {:trigger IsLe(i + 1, n)} :: IsLe(i + 1, n) && f(i) ==> f(i - n)) ensures ModAuto(n) ensures f(x) { LemmaModAuto(n); assert forall i :: IsLe(0, i) && i < n ==> f(i); assert forall i {:trigger f(i), f(i - n)} :: IsLe(i + 1, n) && f(i) ==> f(i - n); LemmaModInductionForall(n, f); assert f(x); }
cedar
891
./cedar-dafny/def/ext/ipaddr.dfy
CountDCComp_fix_891.dfy
CountDCComp
lemma CountDCComp(l: seq<SegV6>, r: seq<SegV6>) ensures countDC(l+r) == countDC(l)+countDC(r) { if |l| == 0 { assert l + r == r; } else { assert l + r == [l[0]] + (l[1..] + r); } }
lemma CountDCComp(l: seq<SegV6>, r: seq<SegV6>) ensures countDC(l+r) == countDC(l)+countDC(r) { if |l| == 0 { } else { assert l + r == [l[0]] + (l[1..] + r); } }
cedar
443
./cedar-dafny/validation/thm/soundness.dfy
SoundEqAuxDiffUids_fix_443.dfy
SoundEqAuxDiffUids
lemma SoundEqAuxDiffUids(u1: EntityUID, u2: EntityUID, t: Type, effs: Effects) requires Typesafe(BinaryApp(BinaryOp.Eq,PrimitiveLit(Primitive.EntityUID(u1)),PrimitiveLit(Primitive.EntityUID(u2))),effs,t) requires u1 != u2 ensures IsSafe(r,s,BinaryApp(BinaryOp.Eq,PrimitiveLit(Primitive.EntityUID(u1)),PrimitiveLit(Primitive.EntityUID(u2))),t) { var e1: Expr := PrimitiveLit(Primitive.EntityUID(u1)); var e2: Expr := PrimitiveLit(Primitive.EntityUID(u2)); var t' :| getType(BinaryApp(BinaryOp.Eq,e1,e2),effs) == t' && subty(t',t,ValidationMode.Permissive); assert TC.inferEq(e1,e2,effs) == types.Ok(t'); // Somehow, these unused variables help nudge Dafny to complete the proof. var t1 := getType(e1,effs); var t2 := getType(e2,effs); assert t' == Type.Bool(False); assert IsSafe(r,s,BinaryApp(BinaryOp.Eq,e1,e2),t') by { EqEntityDiffSafe(r,s,u1,u2); } assert IsSafe(r,s,BinaryApp(BinaryOp.Eq,e1,e2),t) by { SubtyCompat(t',t); SemSubtyTransport(r,s,BinaryApp(BinaryOp.Eq,e1,e2),t',t); } }
lemma SoundEqAuxDiffUids(u1: EntityUID, u2: EntityUID, t: Type, effs: Effects) requires Typesafe(BinaryApp(BinaryOp.Eq,PrimitiveLit(Primitive.EntityUID(u1)),PrimitiveLit(Primitive.EntityUID(u2))),effs,t) requires u1 != u2 ensures IsSafe(r,s,BinaryApp(BinaryOp.Eq,PrimitiveLit(Primitive.EntityUID(u1)),PrimitiveLit(Primitive.EntityUID(u2))),t) { var e1: Expr := PrimitiveLit(Primitive.EntityUID(u1)); var e2: Expr := PrimitiveLit(Primitive.EntityUID(u2)); var t' :| getType(BinaryApp(BinaryOp.Eq,e1,e2),effs) == t' && subty(t',t,ValidationMode.Permissive); // Somehow, these unused variables help nudge Dafny to complete the proof. var t1 := getType(e1,effs); var t2 := getType(e2,effs); assert t' == Type.Bool(False); assert IsSafe(r,s,BinaryApp(BinaryOp.Eq,e1,e2),t') by { EqEntityDiffSafe(r,s,u1,u2); } assert IsSafe(r,s,BinaryApp(BinaryOp.Eq,e1,e2),t) by { SubtyCompat(t',t); SemSubtyTransport(r,s,BinaryApp(BinaryOp.Eq,e1,e2),t',t); } }
cedar
104
./cedar-dafny/validation/thm/model.dfy
OrRShortSafe_fix_104.dfy
OrRShortSafe
lemma OrRShortSafe(r: Request, s: EntityStore, e: Expr, e': Expr) requires IsSafe(r,s,e,Type.Bool(AnyBool)) requires IsTrue(r,s,e') ensures IsTrue(r,s,Or(e,e')) { reveal IsSafe(); if Evaluate(e,r,s).Ok? && Evaluate(e',r,s).Ok? { assert Evaluate(e',r,s) == base.Ok(Value.Primitive(Primitive.Bool(true))); assert Evaluator(r,s).interpretShortcircuit(Or(e,e'),e,e',true) == base.Ok(Value.Primitive(Primitive.Bool(true))); assert Evaluate(Or(e,e'),r,s) == base.Ok(Value.Primitive(Primitive.Bool(true))); } else { if Evaluate(e,r,s).Err? { assert Evaluator(r,s).interpretShortcircuit(Or(e,e'),e,e',true) == Evaluate(e,r,s); assert Evaluate(Or(e,e'),r,s) == Evaluate(e,r,s); } else { assert Evaluate(e',r,s).Err?; var b :| Evaluate(e,r,s) == base.Ok(Value.Primitive(Primitive.Bool(b))); if b { assert Evaluator(r,s).interpretShortcircuit(Or(e,e'),e,e',true) == base.Ok(Value.Primitive(Primitive.Bool(true))); assert Evaluate(Or(e,e'),r,s) == base.Ok(Value.Primitive(Primitive.Bool(true))); } else { assert Evaluator(r,s).interpretShortcircuit(Or(e,e'),e,e',true) == Evaluate(e',r,s); assert Evaluate(Or(e,e'),r,s) == Evaluate(e',r,s); } } } }
lemma OrRShortSafe(r: Request, s: EntityStore, e: Expr, e': Expr) requires IsSafe(r,s,e,Type.Bool(AnyBool)) requires IsTrue(r,s,e') ensures IsTrue(r,s,Or(e,e')) { reveal IsSafe(); if Evaluate(e,r,s).Ok? && Evaluate(e',r,s).Ok? { assert Evaluate(e',r,s) == base.Ok(Value.Primitive(Primitive.Bool(true))); assert Evaluator(r,s).interpretShortcircuit(Or(e,e'),e,e',true) == base.Ok(Value.Primitive(Primitive.Bool(true))); assert Evaluate(Or(e,e'),r,s) == base.Ok(Value.Primitive(Primitive.Bool(true))); } else { if Evaluate(e,r,s).Err? { assert Evaluate(Or(e,e'),r,s) == Evaluate(e,r,s); } else { assert Evaluate(e',r,s).Err?; var b :| Evaluate(e,r,s) == base.Ok(Value.Primitive(Primitive.Bool(b))); if b { assert Evaluator(r,s).interpretShortcircuit(Or(e,e'),e,e',true) == base.Ok(Value.Primitive(Primitive.Bool(true))); assert Evaluate(Or(e,e'),r,s) == base.Ok(Value.Primitive(Primitive.Bool(true))); } else { assert Evaluator(r,s).interpretShortcircuit(Or(e,e'),e,e',true) == Evaluate(e',r,s); assert Evaluate(Or(e,e'),r,s) == Evaluate(e',r,s); } } } }
cedar
854
./cedar-dafny/validation/thm/strict_soundness.dfy
StrictGetLubRecordType_fix_854.dfy
StrictGetLubRecordType
lemma StrictGetLubRecordType(lub: EntityLUB) requires ets.getLubRecordType(lub, ValidationMode.Strict).Ok? ensures ets.getLubRecordType(lub, ValidationMode.Permissive) == ets.getLubRecordType(lub, ValidationMode.Strict) { if lub.AnyEntity? || exists et <- lub.tys :: isAction(et) { assert ets.getLubRecordType(lub, ValidationMode.Permissive).Ok?; } else { assert forall et <- lub.tys :: et in ets.types; def.util.EntityTypeLeqIsTotalOrder(); var lubSeq := def.util.SetToSortedSeq(lub.tys,def.util.EntityTypeLeq); var s := seq (|lubSeq|, i requires 0 <= i < |lubSeq| => ets.types[lubSeq[i]]); assert s != []; assert lubRecordTypeSeq(s, ValidationMode.Strict) == lubRecordTypeSeq(s, ValidationMode.Permissive) by { assert ets.getLubRecordType(lub, ValidationMode.Strict).Ok?; StrictLubRecordTypeSeq(s); } } }
lemma StrictGetLubRecordType(lub: EntityLUB) requires ets.getLubRecordType(lub, ValidationMode.Strict).Ok? ensures ets.getLubRecordType(lub, ValidationMode.Permissive) == ets.getLubRecordType(lub, ValidationMode.Strict) { if lub.AnyEntity? || exists et <- lub.tys :: isAction(et) { } else { assert forall et <- lub.tys :: et in ets.types; def.util.EntityTypeLeqIsTotalOrder(); var lubSeq := def.util.SetToSortedSeq(lub.tys,def.util.EntityTypeLeq); var s := seq (|lubSeq|, i requires 0 <= i < |lubSeq| => ets.types[lubSeq[i]]); assert s != []; assert lubRecordTypeSeq(s, ValidationMode.Strict) == lubRecordTypeSeq(s, ValidationMode.Permissive) by { assert ets.getLubRecordType(lub, ValidationMode.Strict).Ok?; StrictLubRecordTypeSeq(s); } } }
cedar
94
./cedar-dafny/validation/thm/model.dfy
OrRRetSafe_fix_94.dfy
OrRRetSafe
lemma OrRRetSafe(r: Request, s: EntityStore, e: Expr, e': Expr, t: Type) requires IsFalse(r,s,e) requires IsSafe(r,s,e',t) requires SemanticSubty(t,Type.Bool(AnyBool)) ensures IsSafe(r,s,Or(e,e'),t) { reveal IsSafe(); if Evaluate(e,r,s).Ok? && Evaluate(e',r,s).Ok? { assert Evaluate(e,r,s) == base.Ok(Value.Primitive(Primitive.Bool(false))); var v :| Evaluate(e',r,s) == base.Ok(v) && InstanceOfType(v,t); assert InstanceOfType(v,Type.Bool(AnyBool)) by { SemSubtyTransportVal(t,Type.Bool(AnyBool),v); } var b :| v == Value.Primitive(Primitive.Bool(b)); assert Evaluator(r,s).interpretShortcircuit(Or(e,e'),e,e',true) == base.Ok(Value.Primitive(Primitive.Bool(b))); assert Evaluate(Or(e,e'),r,s) == base.Ok(Value.Primitive(Primitive.Bool(b))); assert IsSafe(r,s,e',Type.Bool(AnyBool)) by { SemSubtyTransport(r,s,e',t,Type.Bool(AnyBool)); } } else { if Evaluate(e,r,s).Err? { assert Evaluator(r,s).interpretShortcircuit(Or(e,e'),e,e',true) == Evaluate(e,r,s); assert Evaluate(Or(e,e'),r,s) == Evaluate(e,r,s); } else { assert Evaluate(e',r,s).Err?; var b :| Evaluate(e,r,s) == base.Ok(Value.Primitive(Primitive.Bool(b))); if b { assert Evaluator(r,s).interpretShortcircuit(Or(e,e'),e,e',true) == base.Ok(Value.Primitive(Primitive.Bool(true))); assert Evaluate(Or(e,e'),r,s) == base.Ok(Value.Primitive(Primitive.Bool(true))); } else { assert Evaluator(r,s).interpretShortcircuit(Or(e,e'),e,e',true) == Evaluate(e',r,s); assert Evaluate(Or(e,e'),r,s) == Evaluate(e',r,s); } } } }
lemma OrRRetSafe(r: Request, s: EntityStore, e: Expr, e': Expr, t: Type) requires IsFalse(r,s,e) requires IsSafe(r,s,e',t) requires SemanticSubty(t,Type.Bool(AnyBool)) ensures IsSafe(r,s,Or(e,e'),t) { reveal IsSafe(); if Evaluate(e,r,s).Ok? && Evaluate(e',r,s).Ok? { assert Evaluate(e,r,s) == base.Ok(Value.Primitive(Primitive.Bool(false))); var v :| Evaluate(e',r,s) == base.Ok(v) && InstanceOfType(v,t); assert InstanceOfType(v,Type.Bool(AnyBool)) by { SemSubtyTransportVal(t,Type.Bool(AnyBool),v); } var b :| v == Value.Primitive(Primitive.Bool(b)); assert Evaluator(r,s).interpretShortcircuit(Or(e,e'),e,e',true) == base.Ok(Value.Primitive(Primitive.Bool(b))); assert Evaluate(Or(e,e'),r,s) == base.Ok(Value.Primitive(Primitive.Bool(b))); assert IsSafe(r,s,e',Type.Bool(AnyBool)) by { SemSubtyTransport(r,s,e',t,Type.Bool(AnyBool)); } } else { if Evaluate(e,r,s).Err? { assert Evaluate(Or(e,e'),r,s) == Evaluate(e,r,s); } else { assert Evaluate(e',r,s).Err?; var b :| Evaluate(e,r,s) == base.Ok(Value.Primitive(Primitive.Bool(b))); if b { assert Evaluator(r,s).interpretShortcircuit(Or(e,e'),e,e',true) == base.Ok(Value.Primitive(Primitive.Bool(true))); assert Evaluate(Or(e,e'),r,s) == base.Ok(Value.Primitive(Primitive.Bool(true))); } else { assert Evaluator(r,s).interpretShortcircuit(Or(e,e'),e,e',true) == Evaluate(e',r,s); assert Evaluate(Or(e,e'),r,s) == Evaluate(e',r,s); } } } }
cedar
109
./cedar-dafny/validation/thm/model.dfy
OrRShortSafe_fix_109.dfy
OrRShortSafe
lemma OrRShortSafe(r: Request, s: EntityStore, e: Expr, e': Expr) requires IsSafe(r,s,e,Type.Bool(AnyBool)) requires IsTrue(r,s,e') ensures IsTrue(r,s,Or(e,e')) { reveal IsSafe(); if Evaluate(e,r,s).Ok? && Evaluate(e',r,s).Ok? { assert Evaluate(e',r,s) == base.Ok(Value.Primitive(Primitive.Bool(true))); assert Evaluator(r,s).interpretShortcircuit(Or(e,e'),e,e',true) == base.Ok(Value.Primitive(Primitive.Bool(true))); assert Evaluate(Or(e,e'),r,s) == base.Ok(Value.Primitive(Primitive.Bool(true))); } else { if Evaluate(e,r,s).Err? { assert Evaluator(r,s).interpretShortcircuit(Or(e,e'),e,e',true) == Evaluate(e,r,s); assert Evaluate(Or(e,e'),r,s) == Evaluate(e,r,s); } else { assert Evaluate(e',r,s).Err?; var b :| Evaluate(e,r,s) == base.Ok(Value.Primitive(Primitive.Bool(b))); if b { assert Evaluator(r,s).interpretShortcircuit(Or(e,e'),e,e',true) == base.Ok(Value.Primitive(Primitive.Bool(true))); assert Evaluate(Or(e,e'),r,s) == base.Ok(Value.Primitive(Primitive.Bool(true))); } else { assert Evaluator(r,s).interpretShortcircuit(Or(e,e'),e,e',true) == Evaluate(e',r,s); assert Evaluate(Or(e,e'),r,s) == Evaluate(e',r,s); } } } }
lemma OrRShortSafe(r: Request, s: EntityStore, e: Expr, e': Expr) requires IsSafe(r,s,e,Type.Bool(AnyBool)) requires IsTrue(r,s,e') ensures IsTrue(r,s,Or(e,e')) { reveal IsSafe(); if Evaluate(e,r,s).Ok? && Evaluate(e',r,s).Ok? { assert Evaluate(e',r,s) == base.Ok(Value.Primitive(Primitive.Bool(true))); assert Evaluator(r,s).interpretShortcircuit(Or(e,e'),e,e',true) == base.Ok(Value.Primitive(Primitive.Bool(true))); assert Evaluate(Or(e,e'),r,s) == base.Ok(Value.Primitive(Primitive.Bool(true))); } else { if Evaluate(e,r,s).Err? { assert Evaluator(r,s).interpretShortcircuit(Or(e,e'),e,e',true) == Evaluate(e,r,s); assert Evaluate(Or(e,e'),r,s) == Evaluate(e,r,s); } else { assert Evaluate(e',r,s).Err?; var b :| Evaluate(e,r,s) == base.Ok(Value.Primitive(Primitive.Bool(b))); if b { assert Evaluator(r,s).interpretShortcircuit(Or(e,e'),e,e',true) == base.Ok(Value.Primitive(Primitive.Bool(true))); assert Evaluate(Or(e,e'),r,s) == base.Ok(Value.Primitive(Primitive.Bool(true))); } else { assert Evaluate(Or(e,e'),r,s) == Evaluate(e',r,s); } } } }
cedar
82
./cedar-dafny/validation/thm/model.dfy
AndRShortSafe_fix_82.dfy
AndRShortSafe
lemma AndRShortSafe(r: Request, s: EntityStore, e: Expr, e': Expr) requires IsSafe(r,s,e,Type.Bool(AnyBool)) requires IsFalse(r,s,e') ensures IsFalse(r,s,And(e,e')) { reveal IsSafe(); if Evaluate(e,r,s).Ok? && Evaluate(e',r,s).Ok? { assert Evaluate(e',r,s) == base.Ok(Value.Primitive(Primitive.Bool(false))); assert Evaluator(r,s).interpretShortcircuit(And(e,e'),e,e',false) == base.Ok(Value.Primitive(Primitive.Bool(false))); assert Evaluate(And(e,e'),r,s) == base.Ok(Value.Primitive(Primitive.Bool(false))); } else { if Evaluate(e,r,s).Err? { assert Evaluator(r,s).interpretShortcircuit(And(e,e'),e,e',false) == Evaluate(e,r,s); assert Evaluate(And(e,e'),r,s) == Evaluate(e,r,s); } else { assert Evaluate(e',r,s).Err?; var b :| Evaluate(e,r,s) == base.Ok(Value.Primitive(Primitive.Bool(b))); if b { assert Evaluator(r,s).interpretShortcircuit(And(e,e'),e,e',false) == Evaluate(e',r,s); assert Evaluate(And(e,e'),r,s) == Evaluate(e',r,s); } else { assert Evaluator(r,s).interpretShortcircuit(And(e,e'),e,e',false) == base.Ok(Value.Primitive(Primitive.Bool(false))); assert Evaluate(And(e,e'),r,s) == base.Ok(Value.Primitive(Primitive.Bool(false))); } } } }
lemma AndRShortSafe(r: Request, s: EntityStore, e: Expr, e': Expr) requires IsSafe(r,s,e,Type.Bool(AnyBool)) requires IsFalse(r,s,e') ensures IsFalse(r,s,And(e,e')) { reveal IsSafe(); if Evaluate(e,r,s).Ok? && Evaluate(e',r,s).Ok? { assert Evaluate(e',r,s) == base.Ok(Value.Primitive(Primitive.Bool(false))); assert Evaluate(And(e,e'),r,s) == base.Ok(Value.Primitive(Primitive.Bool(false))); } else { if Evaluate(e,r,s).Err? { assert Evaluator(r,s).interpretShortcircuit(And(e,e'),e,e',false) == Evaluate(e,r,s); assert Evaluate(And(e,e'),r,s) == Evaluate(e,r,s); } else { assert Evaluate(e',r,s).Err?; var b :| Evaluate(e,r,s) == base.Ok(Value.Primitive(Primitive.Bool(b))); if b { assert Evaluator(r,s).interpretShortcircuit(And(e,e'),e,e',false) == Evaluate(e',r,s); assert Evaluate(And(e,e'),r,s) == Evaluate(e',r,s); } else { assert Evaluator(r,s).interpretShortcircuit(And(e,e'),e,e',false) == base.Ok(Value.Primitive(Primitive.Bool(false))); assert Evaluate(And(e,e'),r,s) == base.Ok(Value.Primitive(Primitive.Bool(false))); } } } }
cedar
788
./cedar-dafny/validation/thm/soundness.dfy
SoundArith_fix_788.dfy
SoundArith
lemma SoundArith(op: BinaryOp, e1: Expr, e2: Expr, t: Type, effs: Effects) decreases BinaryApp(op,e1,e2) , 0 requires op == Add || op == Sub requires WellFormedRequestAndStore() requires EffectsInvariant(effs) requires Typesafe(BinaryApp(op,e1,e2),effs,t) ensures IsSafe(r,s,BinaryApp(op,e1,e2),t) ensures getEffects(BinaryApp(op,e1,e2),effs) == Effects.empty() { var t' :| getType(BinaryApp(op,e1,e2),effs) == t' && subty(t',t,ValidationMode.Permissive); assert TC.inferArith2(op,e1,e2,effs) == types.Ok(Type.Int); assert TC.ensureIntType(e1,effs).Ok?; assert Typesafe(e1,effs,Type.Int); assert TC.ensureIntType(e2,effs).Ok?; assert Typesafe(e2,effs,Type.Int); assert IsSafe(r,s,e1,Type.Int) by { Sound(e1,Type.Int,effs); } assert IsSafe(r,s,e2,Type.Int) by { Sound(e2,Type.Int,effs); } assert IsSafe(r,s,BinaryApp(op,e1,e2),t') by { ArithSafe(r,s,op,e1,e2); } assert IsSafe(r,s,BinaryApp(op,e1,e2),t) by { SubtyCompat(t',t); SemSubtyTransport(r,s,BinaryApp(op,e1,e2),t',t); } }
lemma SoundArith(op: BinaryOp, e1: Expr, e2: Expr, t: Type, effs: Effects) decreases BinaryApp(op,e1,e2) , 0 requires op == Add || op == Sub requires WellFormedRequestAndStore() requires EffectsInvariant(effs) requires Typesafe(BinaryApp(op,e1,e2),effs,t) ensures IsSafe(r,s,BinaryApp(op,e1,e2),t) ensures getEffects(BinaryApp(op,e1,e2),effs) == Effects.empty() { var t' :| getType(BinaryApp(op,e1,e2),effs) == t' && subty(t',t,ValidationMode.Permissive); assert TC.ensureIntType(e1,effs).Ok?; assert Typesafe(e1,effs,Type.Int); assert TC.ensureIntType(e2,effs).Ok?; assert Typesafe(e2,effs,Type.Int); assert IsSafe(r,s,e1,Type.Int) by { Sound(e1,Type.Int,effs); } assert IsSafe(r,s,e2,Type.Int) by { Sound(e2,Type.Int,effs); } assert IsSafe(r,s,BinaryApp(op,e1,e2),t') by { ArithSafe(r,s,op,e1,e2); } assert IsSafe(r,s,BinaryApp(op,e1,e2),t) by { SubtyCompat(t',t); SemSubtyTransport(r,s,BinaryApp(op,e1,e2),t',t); } }
cedar
816
./cedar-dafny/validation/thm/soundness.dfy
SoundInSetMemberFalse_fix_816.dfy
SoundInSetMemberFalse
lemma SoundInSetMemberFalse(e1: Expr, ei2s: seq<Expr>, i: nat, effs: Effects) decreases BinaryApp(BinaryOp.In,e1,Expr.Set(ei2s)) , 0 , Expr.Set(ei2s) , 0 requires WellFormedRequestAndStore() requires EffectsInvariant(effs) requires WellTyped(BinaryApp(BinaryOp.In,e1,Expr.Set(ei2s)),effs) requires getType(BinaryApp(BinaryOp.In,e1,Expr.Set(ei2s)),effs) == Type.Bool(False) requires !reqty.isUnspecifiedVar(e1) requires 0 <= i < |ei2s| ensures IsFalse(r,s,BinaryApp(BinaryOp.In,e1,ei2s[i])) { // Reestablishing things we had at the call site in `SoundIn`. var e2 := Expr.Set(ei2s); assert TC.inferIn(BinaryApp(BinaryOp.In,e1,e2),e1,e2,effs) == types.Ok(Type.Bool(False)); assert TC.ensureEntityType(e1,effs).Ok?; var t1 := getType(e1,effs); var euids2 :- assert TC.tryGetEUIDs(e2); var ets2 := set u <- euids2 :: u.ty; // New proof. var u2 :- assert TC.tryGetEUID(ei2s[i]); assert u2 in euids2; match e1 { case Var(v1) => var et1 :- assert TC.getPrincipalOrResource(v1); assert t1 == Type.Entity(EntityLUB({et1})); assert IsSafe(r,s,Var(v1),t1) by { Sound(e1,t1,effs); } assert !ets.possibleDescendantOf(et1,u2.ty); reveal WellFormedRequestAndStore(); InSingleFalseEntityTypeAndLiteral(r,s,e1,et1,u2); case PrimitiveLit(EntityUID(u1)) => if isAction(u1.ty) { assert !acts.descendantOfSet(u1,euids2); assert !acts.descendantOf(u1,u2); } else { assert !ets.possibleDescendantOfSet(u1.ty,ets2); assert !ets.possibleDescendantOf(u1.ty,u2.ty); } reveal WellFormedRequestAndStore(); InSingleFalseLiterals(r,s,u1,u2); } }
lemma SoundInSetMemberFalse(e1: Expr, ei2s: seq<Expr>, i: nat, effs: Effects) decreases BinaryApp(BinaryOp.In,e1,Expr.Set(ei2s)) , 0 , Expr.Set(ei2s) , 0 requires WellFormedRequestAndStore() requires EffectsInvariant(effs) requires WellTyped(BinaryApp(BinaryOp.In,e1,Expr.Set(ei2s)),effs) requires getType(BinaryApp(BinaryOp.In,e1,Expr.Set(ei2s)),effs) == Type.Bool(False) requires !reqty.isUnspecifiedVar(e1) requires 0 <= i < |ei2s| ensures IsFalse(r,s,BinaryApp(BinaryOp.In,e1,ei2s[i])) { // Reestablishing things we had at the call site in `SoundIn`. var e2 := Expr.Set(ei2s); assert TC.inferIn(BinaryApp(BinaryOp.In,e1,e2),e1,e2,effs) == types.Ok(Type.Bool(False)); assert TC.ensureEntityType(e1,effs).Ok?; var t1 := getType(e1,effs); var euids2 :- assert TC.tryGetEUIDs(e2); var ets2 := set u <- euids2 :: u.ty; // New proof. var u2 :- assert TC.tryGetEUID(ei2s[i]); assert u2 in euids2; match e1 { case Var(v1) => var et1 :- assert TC.getPrincipalOrResource(v1); assert t1 == Type.Entity(EntityLUB({et1})); assert IsSafe(r,s,Var(v1),t1) by { Sound(e1,t1,effs); } reveal WellFormedRequestAndStore(); InSingleFalseEntityTypeAndLiteral(r,s,e1,et1,u2); case PrimitiveLit(EntityUID(u1)) => if isAction(u1.ty) { assert !acts.descendantOfSet(u1,euids2); assert !acts.descendantOf(u1,u2); } else { assert !ets.possibleDescendantOfSet(u1.ty,ets2); assert !ets.possibleDescendantOf(u1.ty,u2.ty); } reveal WellFormedRequestAndStore(); InSingleFalseLiterals(r,s,u1,u2); } }
cedar
797
./cedar-dafny/validation/thm/soundness.dfy
SoundIneq_fix_797.dfy
SoundIneq
lemma SoundIneq(op: BinaryOp, e1: Expr, e2: Expr, t: Type, effs: Effects) decreases BinaryApp(op,e1,e2) , 0 requires op == Less || op == BinaryOp.LessEq requires WellFormedRequestAndStore() requires EffectsInvariant(effs) requires Typesafe(BinaryApp(op,e1,e2),effs,t) ensures IsSafe(r,s,BinaryApp(op,e1,e2),t) ensures getEffects(BinaryApp(op,e1,e2),effs) == Effects.empty() { var t' :| getType(BinaryApp(op,e1,e2),effs) == t' && subty(t',t,ValidationMode.Permissive); assert TC.inferIneq(op,e1,e2,effs) == types.Ok(Type.Bool(AnyBool)); assert TC.ensureIntType(e1,effs).Ok?; assert Typesafe(e1,effs,Type.Int); assert TC.ensureIntType(e2,effs).Ok?; assert Typesafe(e2,effs,Type.Int); assert IsSafe(r,s,e1,Type.Int) by { Sound(e1,Type.Int,effs); } assert IsSafe(r,s,e2,Type.Int) by { Sound(e2,Type.Int,effs); } assert IsSafe(r,s,BinaryApp(op,e1,e2),t') by { IneqSafe(r,s,op,e1,e2); } assert IsSafe(r,s,BinaryApp(op,e1,e2),t) by { SubtyCompat(t',t); SemSubtyTransport(r,s,BinaryApp(op,e1,e2),t',t); } }
lemma SoundIneq(op: BinaryOp, e1: Expr, e2: Expr, t: Type, effs: Effects) decreases BinaryApp(op,e1,e2) , 0 requires op == Less || op == BinaryOp.LessEq requires WellFormedRequestAndStore() requires EffectsInvariant(effs) requires Typesafe(BinaryApp(op,e1,e2),effs,t) ensures IsSafe(r,s,BinaryApp(op,e1,e2),t) ensures getEffects(BinaryApp(op,e1,e2),effs) == Effects.empty() { var t' :| getType(BinaryApp(op,e1,e2),effs) == t' && subty(t',t,ValidationMode.Permissive); assert TC.inferIneq(op,e1,e2,effs) == types.Ok(Type.Bool(AnyBool)); assert Typesafe(e1,effs,Type.Int); assert TC.ensureIntType(e2,effs).Ok?; assert Typesafe(e2,effs,Type.Int); assert IsSafe(r,s,e1,Type.Int) by { Sound(e1,Type.Int,effs); } assert IsSafe(r,s,e2,Type.Int) by { Sound(e2,Type.Int,effs); } assert IsSafe(r,s,BinaryApp(op,e1,e2),t') by { IneqSafe(r,s,op,e1,e2); } assert IsSafe(r,s,BinaryApp(op,e1,e2),t) by { SubtyCompat(t',t); SemSubtyTransport(r,s,BinaryApp(op,e1,e2),t',t); } }
cedar
857
./cedar-dafny/validation/thm/strict_soundness.dfy
StrictGetLubRecordType_fix_857.dfy
StrictGetLubRecordType
lemma StrictGetLubRecordType(lub: EntityLUB) requires ets.getLubRecordType(lub, ValidationMode.Strict).Ok? ensures ets.getLubRecordType(lub, ValidationMode.Permissive) == ets.getLubRecordType(lub, ValidationMode.Strict) { if lub.AnyEntity? || exists et <- lub.tys :: isAction(et) { assert ets.getLubRecordType(lub, ValidationMode.Permissive).Ok?; } else { assert forall et <- lub.tys :: et in ets.types; def.util.EntityTypeLeqIsTotalOrder(); var lubSeq := def.util.SetToSortedSeq(lub.tys,def.util.EntityTypeLeq); var s := seq (|lubSeq|, i requires 0 <= i < |lubSeq| => ets.types[lubSeq[i]]); assert s != []; assert lubRecordTypeSeq(s, ValidationMode.Strict) == lubRecordTypeSeq(s, ValidationMode.Permissive) by { assert ets.getLubRecordType(lub, ValidationMode.Strict).Ok?; StrictLubRecordTypeSeq(s); } } }
lemma StrictGetLubRecordType(lub: EntityLUB) requires ets.getLubRecordType(lub, ValidationMode.Strict).Ok? ensures ets.getLubRecordType(lub, ValidationMode.Permissive) == ets.getLubRecordType(lub, ValidationMode.Strict) { if lub.AnyEntity? || exists et <- lub.tys :: isAction(et) { assert ets.getLubRecordType(lub, ValidationMode.Permissive).Ok?; } else { assert forall et <- lub.tys :: et in ets.types; def.util.EntityTypeLeqIsTotalOrder(); var lubSeq := def.util.SetToSortedSeq(lub.tys,def.util.EntityTypeLeq); var s := seq (|lubSeq|, i requires 0 <= i < |lubSeq| => ets.types[lubSeq[i]]); assert s != []; assert lubRecordTypeSeq(s, ValidationMode.Strict) == lubRecordTypeSeq(s, ValidationMode.Permissive) by { StrictLubRecordTypeSeq(s); } } }
cedar
2
./cedar-dafny/validation/subtyping.dfy
StrictSubtyIsStrict_fix_2.dfy
StrictSubtyIsStrict
lemma StrictSubtyIsStrict(t1: Type, t2: Type) requires subty(t1, t2, ValidationMode.Strict) ensures subty(t1, t2, ValidationMode.Permissive) { match (t1,t2) { case (Record(rt1),Record(rt2)) => { if(rt2.attrs.Keys <= rt1.attrs.Keys) { if ! (forall k | k in rt2.attrs.Keys :: subtyAttrType(rt1.attrs[k], rt2.attrs[k], ValidationMode.Permissive)) { assert exists k | k in rt2.attrs.Keys :: !subtyAttrType(rt1.attrs[k], rt2.attrs[k], ValidationMode.Permissive); assert exists k | k in rt2.attrs.Keys :: !subtyAttrType(rt1.attrs[k], rt2.attrs[k], ValidationMode.Strict); } } } case _ => } }
lemma StrictSubtyIsStrict(t1: Type, t2: Type) requires subty(t1, t2, ValidationMode.Strict) ensures subty(t1, t2, ValidationMode.Permissive) { match (t1,t2) { case (Record(rt1),Record(rt2)) => { if(rt2.attrs.Keys <= rt1.attrs.Keys) { if ! (forall k | k in rt2.attrs.Keys :: subtyAttrType(rt1.attrs[k], rt2.attrs[k], ValidationMode.Permissive)) { assert exists k | k in rt2.attrs.Keys :: !subtyAttrType(rt1.attrs[k], rt2.attrs[k], ValidationMode.Permissive); } } } case _ => } }
cedar
856
./cedar-dafny/validation/thm/strict_soundness.dfy
StrictGetLubRecordType_fix_856.dfy
StrictGetLubRecordType
lemma StrictGetLubRecordType(lub: EntityLUB) requires ets.getLubRecordType(lub, ValidationMode.Strict).Ok? ensures ets.getLubRecordType(lub, ValidationMode.Permissive) == ets.getLubRecordType(lub, ValidationMode.Strict) { if lub.AnyEntity? || exists et <- lub.tys :: isAction(et) { assert ets.getLubRecordType(lub, ValidationMode.Permissive).Ok?; } else { assert forall et <- lub.tys :: et in ets.types; def.util.EntityTypeLeqIsTotalOrder(); var lubSeq := def.util.SetToSortedSeq(lub.tys,def.util.EntityTypeLeq); var s := seq (|lubSeq|, i requires 0 <= i < |lubSeq| => ets.types[lubSeq[i]]); assert s != []; assert lubRecordTypeSeq(s, ValidationMode.Strict) == lubRecordTypeSeq(s, ValidationMode.Permissive) by { assert ets.getLubRecordType(lub, ValidationMode.Strict).Ok?; StrictLubRecordTypeSeq(s); } } }
lemma StrictGetLubRecordType(lub: EntityLUB) requires ets.getLubRecordType(lub, ValidationMode.Strict).Ok? ensures ets.getLubRecordType(lub, ValidationMode.Permissive) == ets.getLubRecordType(lub, ValidationMode.Strict) { if lub.AnyEntity? || exists et <- lub.tys :: isAction(et) { assert ets.getLubRecordType(lub, ValidationMode.Permissive).Ok?; } else { assert forall et <- lub.tys :: et in ets.types; def.util.EntityTypeLeqIsTotalOrder(); var lubSeq := def.util.SetToSortedSeq(lub.tys,def.util.EntityTypeLeq); var s := seq (|lubSeq|, i requires 0 <= i < |lubSeq| => ets.types[lubSeq[i]]); assert lubRecordTypeSeq(s, ValidationMode.Strict) == lubRecordTypeSeq(s, ValidationMode.Permissive) by { assert ets.getLubRecordType(lub, ValidationMode.Strict).Ok?; StrictLubRecordTypeSeq(s); } } }
cedar
895
./cedar-dafny/def/ext/ipaddr.dfy
CountDC1SepMeansNoDc_fix_895.dfy
CountDC1SepMeansNoDc
lemma CountDC1SepMeansNoDc(segs: seq<SegV6>) requires countDC(segs) <= 1 ensures findDCIdx(segs).Some? ==> countDC(segs[0..findDCIdx(segs).value]) == 0 && countDC(segs[findDCIdx(segs).value+1..]) == 0 { var idx := findDCIdx(segs); if idx.None? { } else { assert segs == segs[0..idx.value+1] + segs[idx.value+1..]; CountDCComp(segs[0..idx.value+1], segs[idx.value+1..]); assert countDC(segs[0..idx.value+1]) + countDC(segs[idx.value+1..]) == countDC(segs); assert segs[0..idx.value+1] == segs[0..idx.value] + [segs[idx.value]]; CountDCComp(segs[0..idx.value], [segs[idx.value]]); assert countDC(segs[0..idx.value]) + countDC([segs[idx.value]]) == countDC(segs[0..idx.value+1]); } }
lemma CountDC1SepMeansNoDc(segs: seq<SegV6>) requires countDC(segs) <= 1 ensures findDCIdx(segs).Some? ==> countDC(segs[0..findDCIdx(segs).value]) == 0 && countDC(segs[findDCIdx(segs).value+1..]) == 0 { var idx := findDCIdx(segs); if idx.None? { } else { assert segs == segs[0..idx.value+1] + segs[idx.value+1..]; CountDCComp(segs[0..idx.value+1], segs[idx.value+1..]); assert countDC(segs[0..idx.value+1]) + countDC(segs[idx.value+1..]) == countDC(segs); CountDCComp(segs[0..idx.value], [segs[idx.value]]); assert countDC(segs[0..idx.value]) + countDC([segs[idx.value]]) == countDC(segs[0..idx.value+1]); } }
cedar
772
./cedar-dafny/validation/thm/soundness.dfy
SoundOr_fix_772.dfy
SoundOr
lemma SoundOr(e1: Expr, e2: Expr, t: Type, effs: Effects) decreases Or(e1,e2) , 0 requires WellFormedRequestAndStore() requires EffectsInvariant(effs) requires Typesafe(Or(e1,e2),effs,t) ensures IsSafe(r,s,Or(e1,e2),t) ensures GuardedEffectsInvariant(Or(e1,e2),getEffects(Or(e1,e2),effs)) { var t' :| getType(Or(e1,e2),effs) == t' && subty(t',t,ValidationMode.Permissive); assert TC.inferOr(e1,e2,effs).Ok?; var (bt1, effs1) := TC.inferBoolType(e1,effs).value; assert Typesafe(e1,effs,Type.Bool(bt1)); assert IsSafe(r,s,e1,Type.Bool(bt1)) && GuardedEffectsInvariant(e1,effs1) by { Sound(e1,Type.Bool(bt1),effs); } assert GuardedEffectsInvariant(Or(e1,e2),Effects.empty()) by { EmptyEffectsInvariant(); } match bt1 { case True => assert IsTrue(r,s,e1); assert IsSafe(r,s,Or(e1,e2),t') by { OrLShortSafe(r,s,e1,e2); } assert IsSafe(r,s,Or(e1,e2),t) by { SubtyCompat(t',t); SemSubtyTransport(r,s,Or(e1,e2),t',t); } case False => assert IsFalse(r,s,e1); var (bt2, effs2) := TC.inferBoolType(e2,effs).value; assert Typesafe(e2,effs,Type.Bool(bt2)); assert IsSafe(r,s,e2,Type.Bool(bt2)) && GuardedEffectsInvariant(e2,effs2) by { Sound(e2,Type.Bool(bt2),effs); } assert SemanticSubty(Type.Bool(bt2),Type.Bool(AnyBool)) by { assert subty(Type.Bool(bt2),Type.Bool(AnyBool),ValidationMode.Permissive); SubtyCompat(Type.Bool(bt2),Type.Bool(AnyBool)); } assert IsSafe(r,s,Or(e1,e2),Type.Bool(bt2)) by { OrRRetSafe(r,s,e1,e2,Type.Bool(bt2)); } assert IsSafe(r,s,Or(e1,e2),t) by { SubtyCompat(t',t); SemSubtyTransport(r,s,Or(e1,e2),t',t); } assert GuardedEffectsInvariant(Or(e1,e2),effs2) by { if IsTrueStrong(r,s,Or(e1,e2)) { OrTrueStrong(r,s,e1,e2); FalseImpliesNotTrueStrong(r,s,e1); assert IsTrueStrong(r,s,e2); assert EffectsInvariant(effs2); } } case _ => var (bt2, effs2) := TC.inferBoolType(e2,effs).value; assert Typesafe(e2,effs,Type.Bool(bt2)); assert IsSafe(r,s,e2,Type.Bool(bt2)) && GuardedEffectsInvariant(e2,effs2) by { Sound(e2,Type.Bool(bt2),effs); } match bt2 { case True => assert IsTrue(r,s,e2); assert IsSafe(r,s,e1,Type.Bool(AnyBool)) by { SubtyCompat(Type.Bool(bt1),Type.Bool(AnyBool)); SemSubtyTransport(r,s,e1,Type.Bool(bt1),Type.Bool(AnyBool)); } assert IsTrue(r,s,Or(e1,e2)) by { OrRShortSafe(r,s,e1,e2); } assert IsSafe(r,s,Or(e1,e2),t) by { SubtyCompat(Type.Bool(True),t); SemSubtyTransport(r,s,Or(e1,e2),Type.Bool(True),t); } case False => assert IsFalse(r,s,e2); assert IsSafe(r,s,Or(e1,e2),t) by { OrLRetSafe(r,s,e1,e2,Type.Bool(bt1)); SubtyCompat(Type.Bool(bt1),t); SemSubtyTransport(r,s,Or(e1,e2),Type.Bool(bt1),t); } assert GuardedEffectsInvariant(Or(e1,e2),effs1) by { if IsTrueStrong(r,s,Or(e1,e2)) { OrTrueStrong(r,s,e1,e2); FalseImpliesNotTrueStrong(r,s,e2); assert IsTrueStrong(r,s,e1); assert EffectsInvariant(effs1); } } case _ => assert IsSafe(r,s,e1,Type.Bool(AnyBool)) by { SubtyCompat(Type.Bool(bt1),Type.Bool(AnyBool)); SemSubtyTransport(r,s,e1,Type.Bool(bt1),Type.Bool(AnyBool)); } assert IsSafe(r,s,e2,Type.Bool(AnyBool)) by { SubtyCompat(Type.Bool(bt2),Type.Bool(AnyBool)); SemSubtyTransport(r,s,e2,Type.Bool(bt2),Type.Bool(AnyBool)); } assert IsSafe(r,s,Or(e1,e2),Type.Bool(AnyBool)) by { OrSafe(r,s,e1,e2); } assert IsSafe(r,s,Or(e1,e2),t) by { SubtyCompat(t',t); SemSubtyTransport(r,s,Or(e1,e2),t',t); } assert GuardedEffectsInvariant(Or(e1,e2),effs1.intersect(effs2)) by { if IsTrueStrong(r,s,Or(e1,e2)) { OrTrueStrong(r,s,e1,e2); if IsTrueStrong(r,s,e1) { assert EffectsInvariant(effs1); EffectsInvariantIntersectL(effs1,effs2); } else { assert IsTrueStrong(r,s,e2); assert EffectsInvariant(effs2); EffectsInvariantIntersectR(effs1,effs2); } } } } } }
lemma SoundOr(e1: Expr, e2: Expr, t: Type, effs: Effects) decreases Or(e1,e2) , 0 requires WellFormedRequestAndStore() requires EffectsInvariant(effs) requires Typesafe(Or(e1,e2),effs,t) ensures IsSafe(r,s,Or(e1,e2),t) ensures GuardedEffectsInvariant(Or(e1,e2),getEffects(Or(e1,e2),effs)) { var t' :| getType(Or(e1,e2),effs) == t' && subty(t',t,ValidationMode.Permissive); var (bt1, effs1) := TC.inferBoolType(e1,effs).value; assert Typesafe(e1,effs,Type.Bool(bt1)); assert IsSafe(r,s,e1,Type.Bool(bt1)) && GuardedEffectsInvariant(e1,effs1) by { Sound(e1,Type.Bool(bt1),effs); } assert GuardedEffectsInvariant(Or(e1,e2),Effects.empty()) by { EmptyEffectsInvariant(); } match bt1 { case True => assert IsTrue(r,s,e1); assert IsSafe(r,s,Or(e1,e2),t') by { OrLShortSafe(r,s,e1,e2); } assert IsSafe(r,s,Or(e1,e2),t) by { SubtyCompat(t',t); SemSubtyTransport(r,s,Or(e1,e2),t',t); } case False => assert IsFalse(r,s,e1); var (bt2, effs2) := TC.inferBoolType(e2,effs).value; assert Typesafe(e2,effs,Type.Bool(bt2)); assert IsSafe(r,s,e2,Type.Bool(bt2)) && GuardedEffectsInvariant(e2,effs2) by { Sound(e2,Type.Bool(bt2),effs); } assert SemanticSubty(Type.Bool(bt2),Type.Bool(AnyBool)) by { assert subty(Type.Bool(bt2),Type.Bool(AnyBool),ValidationMode.Permissive); SubtyCompat(Type.Bool(bt2),Type.Bool(AnyBool)); } assert IsSafe(r,s,Or(e1,e2),Type.Bool(bt2)) by { OrRRetSafe(r,s,e1,e2,Type.Bool(bt2)); } assert IsSafe(r,s,Or(e1,e2),t) by { SubtyCompat(t',t); SemSubtyTransport(r,s,Or(e1,e2),t',t); } assert GuardedEffectsInvariant(Or(e1,e2),effs2) by { if IsTrueStrong(r,s,Or(e1,e2)) { OrTrueStrong(r,s,e1,e2); FalseImpliesNotTrueStrong(r,s,e1); assert IsTrueStrong(r,s,e2); assert EffectsInvariant(effs2); } } case _ => var (bt2, effs2) := TC.inferBoolType(e2,effs).value; assert Typesafe(e2,effs,Type.Bool(bt2)); assert IsSafe(r,s,e2,Type.Bool(bt2)) && GuardedEffectsInvariant(e2,effs2) by { Sound(e2,Type.Bool(bt2),effs); } match bt2 { case True => assert IsTrue(r,s,e2); assert IsSafe(r,s,e1,Type.Bool(AnyBool)) by { SubtyCompat(Type.Bool(bt1),Type.Bool(AnyBool)); SemSubtyTransport(r,s,e1,Type.Bool(bt1),Type.Bool(AnyBool)); } assert IsTrue(r,s,Or(e1,e2)) by { OrRShortSafe(r,s,e1,e2); } assert IsSafe(r,s,Or(e1,e2),t) by { SubtyCompat(Type.Bool(True),t); SemSubtyTransport(r,s,Or(e1,e2),Type.Bool(True),t); } case False => assert IsFalse(r,s,e2); assert IsSafe(r,s,Or(e1,e2),t) by { OrLRetSafe(r,s,e1,e2,Type.Bool(bt1)); SubtyCompat(Type.Bool(bt1),t); SemSubtyTransport(r,s,Or(e1,e2),Type.Bool(bt1),t); } assert GuardedEffectsInvariant(Or(e1,e2),effs1) by { if IsTrueStrong(r,s,Or(e1,e2)) { OrTrueStrong(r,s,e1,e2); FalseImpliesNotTrueStrong(r,s,e2); assert IsTrueStrong(r,s,e1); assert EffectsInvariant(effs1); } } case _ => assert IsSafe(r,s,e1,Type.Bool(AnyBool)) by { SubtyCompat(Type.Bool(bt1),Type.Bool(AnyBool)); SemSubtyTransport(r,s,e1,Type.Bool(bt1),Type.Bool(AnyBool)); } assert IsSafe(r,s,e2,Type.Bool(AnyBool)) by { SubtyCompat(Type.Bool(bt2),Type.Bool(AnyBool)); SemSubtyTransport(r,s,e2,Type.Bool(bt2),Type.Bool(AnyBool)); } assert IsSafe(r,s,Or(e1,e2),Type.Bool(AnyBool)) by { OrSafe(r,s,e1,e2); } assert IsSafe(r,s,Or(e1,e2),t) by { SubtyCompat(t',t); SemSubtyTransport(r,s,Or(e1,e2),t',t); } assert GuardedEffectsInvariant(Or(e1,e2),effs1.intersect(effs2)) by { if IsTrueStrong(r,s,Or(e1,e2)) { OrTrueStrong(r,s,e1,e2); if IsTrueStrong(r,s,e1) { assert EffectsInvariant(effs1); EffectsInvariantIntersectL(effs1,effs2); } else { assert IsTrueStrong(r,s,e2); assert EffectsInvariant(effs2); EffectsInvariantIntersectR(effs1,effs2); } } } } } }
cedar
46
./cedar-dafny/validation/thm/model.dfy
OrTrueStrong_fix_46.dfy
OrTrueStrong
lemma OrTrueStrong(r: Request, s: EntityStore, e1: Expr, e2: Expr) requires IsTrueStrong(r,s,Or(e1,e2)) ensures IsTrueStrong(r,s,e1) || IsTrueStrong(r,s,e2) { reveal IsSafeStrong(); reveal IsSafe(); assert Evaluator(r,s).interpretShortcircuit(Or(e1,e2),e1,e2,true) == base.Ok(Value.Bool(true)); }
lemma OrTrueStrong(r: Request, s: EntityStore, e1: Expr, e2: Expr) requires IsTrueStrong(r,s,Or(e1,e2)) ensures IsTrueStrong(r,s,e1) || IsTrueStrong(r,s,e2) { reveal IsSafeStrong(); reveal IsSafe(); }
cedar
67
./cedar-dafny/validation/thm/model.dfy
SubtyCompatMatchPointwise_fix_67.dfy
SubtyCompatMatchPointwise
lemma SubtyCompatMatchPointwise(t: Type, t': Type, v: Value) requires subty(t,t',ValidationMode.Permissive) requires InstanceOfType(v,t) ensures InstanceOfType(v,t') decreases t { match (t,t',v) { case (Never,_,_) => case (String,String,_) => case (Int,Int,_) => case (Bool(b1),Bool(b2),_) => case (Set(t1),Set(t2),Set(s)) => assert forall v' | v' in s :: InstanceOfType(v',t2) by { forall v': Value | v' in s ensures InstanceOfType(v',t2) { assert InstanceOfType(v',t1); SubtyCompatMatchPointwise(t1,t2,v'); } } case (Record(rt1),Record(rt2),Record(rv)) => assert forall k | k in rt2.attrs && k in rv :: InstanceOfType(rv[k],rt2.attrs[k].ty) by { forall k: Attr | k in rt2.attrs && k in rv ensures InstanceOfType(rv[k],rt2.attrs[k].ty) { assert InstanceOfType(rv[k],rt1.attrs[k].ty); assert subtyAttrType(rt1.attrs[k],rt2.attrs[k],ValidationMode.Permissive); SubtyCompatMatchPointwise(rt1.attrs[k].ty,rt2.attrs[k].ty,rv[k]); } } assert forall k | k in rt2.attrs && rt2.attrs[k].isRequired :: k in rv by { forall k | k in rt2.attrs && rt2.attrs[k].isRequired ensures k in rv { assert subtyAttrType(rt1.attrs[k],rt2.attrs[k],ValidationMode.Permissive); } } case (Entity(e1),Entity(e2),_) => case (Extension(e1),Extension(e2),_) => } }
lemma SubtyCompatMatchPointwise(t: Type, t': Type, v: Value) requires subty(t,t',ValidationMode.Permissive) requires InstanceOfType(v,t) ensures InstanceOfType(v,t') decreases t { match (t,t',v) { case (Never,_,_) => case (String,String,_) => case (Int,Int,_) => case (Bool(b1),Bool(b2),_) => case (Set(t1),Set(t2),Set(s)) => assert forall v' | v' in s :: InstanceOfType(v',t2) by { forall v': Value | v' in s ensures InstanceOfType(v',t2) { assert InstanceOfType(v',t1); SubtyCompatMatchPointwise(t1,t2,v'); } } case (Record(rt1),Record(rt2),Record(rv)) => assert forall k | k in rt2.attrs && k in rv :: InstanceOfType(rv[k],rt2.attrs[k].ty) by { forall k: Attr | k in rt2.attrs && k in rv ensures InstanceOfType(rv[k],rt2.attrs[k].ty) { assert InstanceOfType(rv[k],rt1.attrs[k].ty); SubtyCompatMatchPointwise(rt1.attrs[k].ty,rt2.attrs[k].ty,rv[k]); } } assert forall k | k in rt2.attrs && rt2.attrs[k].isRequired :: k in rv by { forall k | k in rt2.attrs && rt2.attrs[k].isRequired ensures k in rv { assert subtyAttrType(rt1.attrs[k],rt2.attrs[k],ValidationMode.Permissive); } } case (Entity(e1),Entity(e2),_) => case (Extension(e1),Extension(e2),_) => } }
cedar
888
./cedar-dafny/def/ext/decimal.dfy
ParseDigitsAndDot_fix_888.dfy
ParseDigitsAndDot
lemma ParseDigitsAndDot(s1: string, s2: string) requires |s1| > 0 requires forall i | 0 <= i < |s1| :: '0' <= s1[i] <= '9' ensures ParseDecStr(s1+"."+s2).Some? && ParseDecStr(s1+"."+s2).value.0 == s1 && ParseDecStr(s1+"."+s2).value.1 == "."+s2 { if |s1| == 1 { assert (s1+"."+s2)[1..] == "."+s2; assert ParseDecStr("."+s2).None?; } else { ParseDecAll(s1); ParseDigitsAndDot(s1[1..],s2); assert s1+"."+s2 == [s1[0]]+(s1[1..]+"."+s2); } }
lemma ParseDigitsAndDot(s1: string, s2: string) requires |s1| > 0 requires forall i | 0 <= i < |s1| :: '0' <= s1[i] <= '9' ensures ParseDecStr(s1+"."+s2).Some? && ParseDecStr(s1+"."+s2).value.0 == s1 && ParseDecStr(s1+"."+s2).value.1 == "."+s2 { if |s1| == 1 { assert (s1+"."+s2)[1..] == "."+s2; } else { ParseDecAll(s1); ParseDigitsAndDot(s1[1..],s2); assert s1+"."+s2 == [s1[0]]+(s1[1..]+"."+s2); } }
cedar
58
./cedar-dafny/validation/thm/model.dfy
AndSafe_fix_58.dfy
AndSafe
lemma AndSafe(r: Request, s: EntityStore, e: Expr, e': Expr) requires IsSafe(r,s,e,Type.Bool(AnyBool)) requires IsSafe(r,s,e',Type.Bool(AnyBool)) ensures IsSafe(r,s,And(e,e'),Type.Bool(AnyBool)) { reveal IsSafe(); if Evaluate(e,r,s).Ok? && Evaluate(e',r,s).Ok? { assert Evaluator(r,s).interpretShortcircuit(And(e,e'),e,e',false).Ok?; assert Evaluate(And(e,e'),r,s).Ok?; } else { if Evaluate(e,r,s).Err? { assert Evaluator(r,s).interpretShortcircuit(And(e,e'),e,e',false) == Evaluate(e,r,s); assert Evaluate(And(e,e'),r,s) == Evaluate(e,r,s); } else { assert Evaluate(e',r,s).Err?; var b :| Evaluate(e,r,s) == base.Ok(Value.Primitive(Primitive.Bool(b))); if b { assert Evaluator(r,s).interpretShortcircuit(And(e,e'),e,e',false) == Evaluate(e',r,s); assert Evaluate(And(e,e'),r,s) == Evaluate(e',r,s); } else { assert Evaluator(r,s).interpretShortcircuit(And(e,e'),e,e',false) == base.Ok(Value.Primitive(Primitive.Bool(false))); assert Evaluate(And(e,e'),r,s) == base.Ok(Value.Primitive(Primitive.Bool(false))); } } } }
lemma AndSafe(r: Request, s: EntityStore, e: Expr, e': Expr) requires IsSafe(r,s,e,Type.Bool(AnyBool)) requires IsSafe(r,s,e',Type.Bool(AnyBool)) ensures IsSafe(r,s,And(e,e'),Type.Bool(AnyBool)) { reveal IsSafe(); if Evaluate(e,r,s).Ok? && Evaluate(e',r,s).Ok? { assert Evaluator(r,s).interpretShortcircuit(And(e,e'),e,e',false).Ok?; assert Evaluate(And(e,e'),r,s).Ok?; } else { if Evaluate(e,r,s).Err? { assert Evaluate(And(e,e'),r,s) == Evaluate(e,r,s); } else { assert Evaluate(e',r,s).Err?; var b :| Evaluate(e,r,s) == base.Ok(Value.Primitive(Primitive.Bool(b))); if b { assert Evaluator(r,s).interpretShortcircuit(And(e,e'),e,e',false) == Evaluate(e',r,s); assert Evaluate(And(e,e'),r,s) == Evaluate(e',r,s); } else { assert Evaluator(r,s).interpretShortcircuit(And(e,e'),e,e',false) == base.Ok(Value.Primitive(Primitive.Bool(false))); assert Evaluate(And(e,e'),r,s) == base.Ok(Value.Primitive(Primitive.Bool(false))); } } } }
cedar
77
./cedar-dafny/validation/thm/model.dfy
AndLRetSafe_fix_77.dfy
AndLRetSafe
lemma AndLRetSafe(r: Request, s: EntityStore, e: Expr, e': Expr, t: Type) requires IsSafe(r,s,e,t) requires IsTrue(r,s,e') requires SemanticSubty(t,Type.Bool(AnyBool)) ensures IsSafe(r,s,And(e,e'),t) { reveal IsSafe(); if Evaluate(e,r,s).Ok? && Evaluate(e',r,s).Ok? { assert Evaluate(e',r,s) == base.Ok(Value.Primitive(Primitive.Bool(true))); var v :| Evaluate(e,r,s) == base.Ok(v) && InstanceOfType(v,t); assert InstanceOfType(v,Type.Bool(AnyBool)) by { SemSubtyTransportVal(t,Type.Bool(AnyBool),v); } var b :| v == Value.Primitive(Primitive.Bool(b)); assert Evaluator(r,s).interpretShortcircuit(And(e,e'),e,e',false) == base.Ok(Value.Primitive(Primitive.Bool(b))); assert Evaluate(And(e,e'),r,s) == base.Ok(Value.Primitive(Primitive.Bool(b))); } else { if Evaluate(e,r,s).Err? { assert Evaluator(r,s).interpretShortcircuit(And(e,e'),e,e',false) == Evaluate(e,r,s); assert Evaluate(And(e,e'),r,s) == Evaluate(e,r,s); } else { assert Evaluate(e',r,s).Err?; var b :| Evaluate(e,r,s) == base.Ok(Value.Primitive(Primitive.Bool(b))); if b { assert Evaluator(r,s).interpretShortcircuit(And(e,e'),e,e',false) == Evaluate(e',r,s); assert Evaluate(And(e,e'),r,s) == Evaluate(e',r,s); } else { assert Evaluator(r,s).interpretShortcircuit(And(e,e'),e,e',false) == base.Ok(Value.Primitive(Primitive.Bool(false))); assert Evaluate(And(e,e'),r,s) == base.Ok(Value.Primitive(Primitive.Bool(false))); } } } }
lemma AndLRetSafe(r: Request, s: EntityStore, e: Expr, e': Expr, t: Type) requires IsSafe(r,s,e,t) requires IsTrue(r,s,e') requires SemanticSubty(t,Type.Bool(AnyBool)) ensures IsSafe(r,s,And(e,e'),t) { reveal IsSafe(); if Evaluate(e,r,s).Ok? && Evaluate(e',r,s).Ok? { assert Evaluate(e',r,s) == base.Ok(Value.Primitive(Primitive.Bool(true))); var v :| Evaluate(e,r,s) == base.Ok(v) && InstanceOfType(v,t); assert InstanceOfType(v,Type.Bool(AnyBool)) by { SemSubtyTransportVal(t,Type.Bool(AnyBool),v); } var b :| v == Value.Primitive(Primitive.Bool(b)); assert Evaluator(r,s).interpretShortcircuit(And(e,e'),e,e',false) == base.Ok(Value.Primitive(Primitive.Bool(b))); assert Evaluate(And(e,e'),r,s) == base.Ok(Value.Primitive(Primitive.Bool(b))); } else { if Evaluate(e,r,s).Err? { assert Evaluator(r,s).interpretShortcircuit(And(e,e'),e,e',false) == Evaluate(e,r,s); assert Evaluate(And(e,e'),r,s) == Evaluate(e,r,s); } else { assert Evaluate(e',r,s).Err?; var b :| Evaluate(e,r,s) == base.Ok(Value.Primitive(Primitive.Bool(b))); if b { assert Evaluator(r,s).interpretShortcircuit(And(e,e'),e,e',false) == Evaluate(e',r,s); assert Evaluate(And(e,e'),r,s) == Evaluate(e',r,s); } else { assert Evaluate(And(e,e'),r,s) == base.Ok(Value.Primitive(Primitive.Bool(false))); } } } }
cedar
756
./cedar-dafny/validation/thm/soundness.dfy
SoundIf_fix_756.dfy
SoundIf
lemma SoundIf(e: Expr, e1: Expr, e2: Expr, t: Type, effs: Effects) decreases If(e,e1,e2) , 0 requires WellFormedRequestAndStore() requires EffectsInvariant(effs) requires Typesafe(If(e,e1,e2),effs,t) ensures IsSafe(r,s,If(e,e1,e2),t) ensures GuardedEffectsInvariant(If(e,e1,e2),getEffects(If(e,e1,e2),effs)) { var t' :| getType(If(e,e1,e2),effs) == t' && subty(t',t,ValidationMode.Permissive); assert TC.inferIf(e,e1,e2,effs).Ok?; var (bt, effs1) := TC.inferBoolType(e,effs).value; assert IsSafe(r,s,e,Type.Bool(bt)) && GuardedEffectsInvariant(e,effs1) by { assert getType(e,effs) == Type.Bool(bt); assert subty(Type.Bool(bt),Type.Bool(bt),ValidationMode.Permissive); assert Typesafe(e,effs,Type.Bool(bt)); Sound(e,Type.Bool(bt),effs); } match bt { case True => assert IsTrue(r,s,e); var (t1,effs2) := TC.infer(e1,effs.union(effs1)).value; assert Typesafe(e1,effs.union(effs1),t1) by { SubtyRefl(t1); } if IsTrueStrong(r,s,e) { assert EffectsInvariant(effs1); assert IsSafe(r,s,e1,t1) && GuardedEffectsInvariant(e1,effs2) by { EffectsInvariantUnion(effs,effs1); Sound(e1,t1,effs.union(effs1)); } assert IsSafe(r,s,If(e,e1,e2),t') by { IteTrueSafe(r,s,e,e1,e2,t'); } assert IsSafe(r,s,If(e,e1,e2),t) by { SubtyCompat(t',t); SemSubtyTransport(r,s,If(e,e1,e2),t',t); } assert GuardedEffectsInvariant(If(e,e1,e2),effs1.union(effs2)) by { if IsTrueStrong(r,s,If(e,e1,e2)) { IteTrueStrongTrue(r,s,e,e1,e2); assert EffectsInvariant(effs2); EffectsInvariantUnion(effs1,effs2); } } } else { assert IsSafe(r,s,If(e,e1,e2),t) by { IteError(r,s,e,e1,e2,Type.Bool(True),t); } assert GuardedEffectsInvariant(If(e,e1,e2),effs1.union(effs2)) by { IteError(r,s,e,e1,e2,Type.Bool(True),Type.Bool(True)); assert !IsTrueStrong(r,s,If(e,e1,e2)); } } case False => assert IsFalse(r,s,e); var (t2,effs2) := TC.infer(e2,effs).value; assert Typesafe(e2,effs,t2) by { SubtyRefl(t2); } assert IsSafe(r,s,e2,t2) && GuardedEffectsInvariant(e2,effs2) by { Sound(e2,t2,effs); } assert IsSafe(r,s,If(e,e1,e2),t') by { IteFalseSafe(r,s,e,e1,e2,t'); } assert IsSafe(r,s,If(e,e1,e2),t) by { SubtyCompat(t',t); SemSubtyTransport(r,s,If(e,e1,e2),t',t); } assert GuardedEffectsInvariant(If(e,e1,e2),effs2) by { if IsTrueStrong(r,s,If(e,e1,e2)) { IteTrueStrongFalse(r,s,e,e1,e2); assert EffectsInvariant(effs2); } } case AnyBool => var (t1,effs2) := TC.infer(e1,effs.union(effs1)).value; var (t2,effs3) := TC.infer(e2,effs).value; assert Typesafe(e1,effs.union(effs1),t1) by { SubtyRefl(t1); } assert Typesafe(e2,effs,t2) by { SubtyRefl(t2); } assert t' == lubOpt(t1,t2,ValidationMode.Permissive).value; assert subty(t1,t',ValidationMode.Permissive) && subty(t2,t',ValidationMode.Permissive) by { LubIsUB(t1,t2,t',ValidationMode.Permissive); } if IsSafeStrong(r,s,e,Type.Bool(bt)) { if IsTrue(r,s,e) { // `e` evaluates to true IsTrueImpliesIsTrueStrong(r,s,e,Type.Bool(bt)); assert IsTrueStrong(r,s,e); assert EffectsInvariant(effs1); assert IsSafe(r,s,e1,t1) && GuardedEffectsInvariant(e1,effs2) by { EffectsInvariantUnion(effs,effs1); Sound(e1,t1,effs.union(effs1)); } assert IsSafe(r,s,If(e,e1,e2),t1) by { IteTrueSafe(r,s,e,e1,e2,t1); } assert IsSafe(r,s,If(e,e1,e2),t) by { SubtyCompat(t1,t'); SubtyCompat(t',t); SemSubtyTransport(r,s,If(e,e1,e2),t1,t); } assert GuardedEffectsInvariant(If(e,e1,e2),effs1.union(effs2)) by { if IsTrueStrong(r,s,If(e,e1,e2)) { IteTrueStrongTrue(r,s,e,e1,e2); EffectsInvariantUnion(effs1,effs2); } } assert GuardedEffectsInvariant(If(e,e1,e2),effs1.union(effs2).intersect(effs3)) by { if IsTrueStrong(r,s,If(e,e1,e2)) { EffectsInvariantIntersectL(effs1.union(effs2),effs3); } } } else { // `e` evaluates to false NotTrueImpliesFalse(r,s,e,bt); assert IsFalse(r,s,e); assert IsSafe(r,s,e2,t2) && GuardedEffectsInvariant(e2,effs3) by { Sound(e2,t2,effs); } assert IsSafe(r,s,If(e,e1,e2),t2) by { IteFalseSafe(r,s,e,e1,e2,t2); } assert IsSafe(r,s,If(e,e1,e2),t) by { SubtyCompat(t2,t'); SubtyCompat(t',t); SemSubtyTransport(r,s,If(e,e1,e2),t2,t); } assert GuardedEffectsInvariant(If(e,e1,e2),effs3) by { if IsTrueStrong(r,s,If(e,e1,e2)) { IteTrueStrongFalse(r,s,e,e1,e2); } } assert GuardedEffectsInvariant(If(e,e1,e2),effs1.union(effs2).intersect(effs3)) by { if IsTrueStrong(r,s,If(e,e1,e2)) { EffectsInvariantIntersectR(effs1.union(effs2),effs3); } } } } else { // `e` produces an error assert IsSafe(r,s,If(e,e1,e2),t) by { IteError(r,s,e,e1,e2,Type.Bool(bt),t); } assert GuardedEffectsInvariant(If(e,e1,e2),effs1.union(effs2).intersect(effs3)) by { IteError(r,s,e,e1,e2,Type.Bool(bt),Type.Bool(True)); assert !IsTrueStrong(r,s,If(e,e1,e2)); } } } }
lemma SoundIf(e: Expr, e1: Expr, e2: Expr, t: Type, effs: Effects) decreases If(e,e1,e2) , 0 requires WellFormedRequestAndStore() requires EffectsInvariant(effs) requires Typesafe(If(e,e1,e2),effs,t) ensures IsSafe(r,s,If(e,e1,e2),t) ensures GuardedEffectsInvariant(If(e,e1,e2),getEffects(If(e,e1,e2),effs)) { var t' :| getType(If(e,e1,e2),effs) == t' && subty(t',t,ValidationMode.Permissive); var (bt, effs1) := TC.inferBoolType(e,effs).value; assert IsSafe(r,s,e,Type.Bool(bt)) && GuardedEffectsInvariant(e,effs1) by { assert getType(e,effs) == Type.Bool(bt); assert subty(Type.Bool(bt),Type.Bool(bt),ValidationMode.Permissive); assert Typesafe(e,effs,Type.Bool(bt)); Sound(e,Type.Bool(bt),effs); } match bt { case True => assert IsTrue(r,s,e); var (t1,effs2) := TC.infer(e1,effs.union(effs1)).value; assert Typesafe(e1,effs.union(effs1),t1) by { SubtyRefl(t1); } if IsTrueStrong(r,s,e) { assert EffectsInvariant(effs1); assert IsSafe(r,s,e1,t1) && GuardedEffectsInvariant(e1,effs2) by { EffectsInvariantUnion(effs,effs1); Sound(e1,t1,effs.union(effs1)); } assert IsSafe(r,s,If(e,e1,e2),t') by { IteTrueSafe(r,s,e,e1,e2,t'); } assert IsSafe(r,s,If(e,e1,e2),t) by { SubtyCompat(t',t); SemSubtyTransport(r,s,If(e,e1,e2),t',t); } assert GuardedEffectsInvariant(If(e,e1,e2),effs1.union(effs2)) by { if IsTrueStrong(r,s,If(e,e1,e2)) { IteTrueStrongTrue(r,s,e,e1,e2); assert EffectsInvariant(effs2); EffectsInvariantUnion(effs1,effs2); } } } else { assert IsSafe(r,s,If(e,e1,e2),t) by { IteError(r,s,e,e1,e2,Type.Bool(True),t); } assert GuardedEffectsInvariant(If(e,e1,e2),effs1.union(effs2)) by { IteError(r,s,e,e1,e2,Type.Bool(True),Type.Bool(True)); assert !IsTrueStrong(r,s,If(e,e1,e2)); } } case False => assert IsFalse(r,s,e); var (t2,effs2) := TC.infer(e2,effs).value; assert Typesafe(e2,effs,t2) by { SubtyRefl(t2); } assert IsSafe(r,s,e2,t2) && GuardedEffectsInvariant(e2,effs2) by { Sound(e2,t2,effs); } assert IsSafe(r,s,If(e,e1,e2),t') by { IteFalseSafe(r,s,e,e1,e2,t'); } assert IsSafe(r,s,If(e,e1,e2),t) by { SubtyCompat(t',t); SemSubtyTransport(r,s,If(e,e1,e2),t',t); } assert GuardedEffectsInvariant(If(e,e1,e2),effs2) by { if IsTrueStrong(r,s,If(e,e1,e2)) { IteTrueStrongFalse(r,s,e,e1,e2); assert EffectsInvariant(effs2); } } case AnyBool => var (t1,effs2) := TC.infer(e1,effs.union(effs1)).value; var (t2,effs3) := TC.infer(e2,effs).value; assert Typesafe(e1,effs.union(effs1),t1) by { SubtyRefl(t1); } assert Typesafe(e2,effs,t2) by { SubtyRefl(t2); } assert t' == lubOpt(t1,t2,ValidationMode.Permissive).value; assert subty(t1,t',ValidationMode.Permissive) && subty(t2,t',ValidationMode.Permissive) by { LubIsUB(t1,t2,t',ValidationMode.Permissive); } if IsSafeStrong(r,s,e,Type.Bool(bt)) { if IsTrue(r,s,e) { // `e` evaluates to true IsTrueImpliesIsTrueStrong(r,s,e,Type.Bool(bt)); assert IsTrueStrong(r,s,e); assert EffectsInvariant(effs1); assert IsSafe(r,s,e1,t1) && GuardedEffectsInvariant(e1,effs2) by { EffectsInvariantUnion(effs,effs1); Sound(e1,t1,effs.union(effs1)); } assert IsSafe(r,s,If(e,e1,e2),t1) by { IteTrueSafe(r,s,e,e1,e2,t1); } assert IsSafe(r,s,If(e,e1,e2),t) by { SubtyCompat(t1,t'); SubtyCompat(t',t); SemSubtyTransport(r,s,If(e,e1,e2),t1,t); } assert GuardedEffectsInvariant(If(e,e1,e2),effs1.union(effs2)) by { if IsTrueStrong(r,s,If(e,e1,e2)) { IteTrueStrongTrue(r,s,e,e1,e2); EffectsInvariantUnion(effs1,effs2); } } assert GuardedEffectsInvariant(If(e,e1,e2),effs1.union(effs2).intersect(effs3)) by { if IsTrueStrong(r,s,If(e,e1,e2)) { EffectsInvariantIntersectL(effs1.union(effs2),effs3); } } } else { // `e` evaluates to false NotTrueImpliesFalse(r,s,e,bt); assert IsFalse(r,s,e); assert IsSafe(r,s,e2,t2) && GuardedEffectsInvariant(e2,effs3) by { Sound(e2,t2,effs); } assert IsSafe(r,s,If(e,e1,e2),t2) by { IteFalseSafe(r,s,e,e1,e2,t2); } assert IsSafe(r,s,If(e,e1,e2),t) by { SubtyCompat(t2,t'); SubtyCompat(t',t); SemSubtyTransport(r,s,If(e,e1,e2),t2,t); } assert GuardedEffectsInvariant(If(e,e1,e2),effs3) by { if IsTrueStrong(r,s,If(e,e1,e2)) { IteTrueStrongFalse(r,s,e,e1,e2); } } assert GuardedEffectsInvariant(If(e,e1,e2),effs1.union(effs2).intersect(effs3)) by { if IsTrueStrong(r,s,If(e,e1,e2)) { EffectsInvariantIntersectR(effs1.union(effs2),effs3); } } } } else { // `e` produces an error assert IsSafe(r,s,If(e,e1,e2),t) by { IteError(r,s,e,e1,e2,Type.Bool(bt),t); } assert GuardedEffectsInvariant(If(e,e1,e2),effs1.union(effs2).intersect(effs3)) by { IteError(r,s,e,e1,e2,Type.Bool(bt),Type.Bool(True)); assert !IsTrueStrong(r,s,If(e,e1,e2)); } } } }
cedar
799
./cedar-dafny/validation/thm/soundness.dfy
SoundIneq_fix_799.dfy
SoundIneq
lemma SoundIneq(op: BinaryOp, e1: Expr, e2: Expr, t: Type, effs: Effects) decreases BinaryApp(op,e1,e2) , 0 requires op == Less || op == BinaryOp.LessEq requires WellFormedRequestAndStore() requires EffectsInvariant(effs) requires Typesafe(BinaryApp(op,e1,e2),effs,t) ensures IsSafe(r,s,BinaryApp(op,e1,e2),t) ensures getEffects(BinaryApp(op,e1,e2),effs) == Effects.empty() { var t' :| getType(BinaryApp(op,e1,e2),effs) == t' && subty(t',t,ValidationMode.Permissive); assert TC.inferIneq(op,e1,e2,effs) == types.Ok(Type.Bool(AnyBool)); assert TC.ensureIntType(e1,effs).Ok?; assert Typesafe(e1,effs,Type.Int); assert TC.ensureIntType(e2,effs).Ok?; assert Typesafe(e2,effs,Type.Int); assert IsSafe(r,s,e1,Type.Int) by { Sound(e1,Type.Int,effs); } assert IsSafe(r,s,e2,Type.Int) by { Sound(e2,Type.Int,effs); } assert IsSafe(r,s,BinaryApp(op,e1,e2),t') by { IneqSafe(r,s,op,e1,e2); } assert IsSafe(r,s,BinaryApp(op,e1,e2),t) by { SubtyCompat(t',t); SemSubtyTransport(r,s,BinaryApp(op,e1,e2),t',t); } }
lemma SoundIneq(op: BinaryOp, e1: Expr, e2: Expr, t: Type, effs: Effects) decreases BinaryApp(op,e1,e2) , 0 requires op == Less || op == BinaryOp.LessEq requires WellFormedRequestAndStore() requires EffectsInvariant(effs) requires Typesafe(BinaryApp(op,e1,e2),effs,t) ensures IsSafe(r,s,BinaryApp(op,e1,e2),t) ensures getEffects(BinaryApp(op,e1,e2),effs) == Effects.empty() { var t' :| getType(BinaryApp(op,e1,e2),effs) == t' && subty(t',t,ValidationMode.Permissive); assert TC.inferIneq(op,e1,e2,effs) == types.Ok(Type.Bool(AnyBool)); assert TC.ensureIntType(e1,effs).Ok?; assert Typesafe(e1,effs,Type.Int); assert Typesafe(e2,effs,Type.Int); assert IsSafe(r,s,e1,Type.Int) by { Sound(e1,Type.Int,effs); } assert IsSafe(r,s,e2,Type.Int) by { Sound(e2,Type.Int,effs); } assert IsSafe(r,s,BinaryApp(op,e1,e2),t') by { IneqSafe(r,s,op,e1,e2); } assert IsSafe(r,s,BinaryApp(op,e1,e2),t) by { SubtyCompat(t',t); SemSubtyTransport(r,s,BinaryApp(op,e1,e2),t',t); } }
cedar
49
./cedar-dafny/validation/thm/model.dfy
OrSafe_fix_49.dfy
OrSafe
lemma OrSafe(r: Request, s: EntityStore, e: Expr, e': Expr) requires IsSafe(r,s,e,Type.Bool(AnyBool)) requires IsSafe(r,s,e',Type.Bool(AnyBool)) ensures IsSafe(r,s,Or(e,e'),Type.Bool(AnyBool)) { reveal IsSafe(); if Evaluate(e,r,s).Ok? && Evaluate(e',r,s).Ok? { assert Evaluator(r,s).interpretShortcircuit(Or(e,e'),e,e',true).Ok?; assert Evaluate(Or(e,e'),r,s).Ok?; } else { if Evaluate(e,r,s).Err? { assert Evaluator(r,s).interpretShortcircuit(Or(e,e'),e,e',true) == Evaluate(e,r,s); assert Evaluate(Or(e,e'),r,s) == Evaluate(e,r,s); } else { assert Evaluate(e',r,s).Err?; var b :| Evaluate(e,r,s) == base.Ok(Value.Primitive(Primitive.Bool(b))); if b { assert Evaluator(r,s).interpretShortcircuit(Or(e,e'),e,e',true) == base.Ok(Value.Primitive(Primitive.Bool(true))); assert Evaluate(Or(e,e'),r,s) == base.Ok(Value.Primitive(Primitive.Bool(true))); } else { assert Evaluator(r,s).interpretShortcircuit(Or(e,e'),e,e',true) == Evaluate(e',r,s); assert Evaluate(Or(e,e'),r,s) == Evaluate(e',r,s); } } } }
lemma OrSafe(r: Request, s: EntityStore, e: Expr, e': Expr) requires IsSafe(r,s,e,Type.Bool(AnyBool)) requires IsSafe(r,s,e',Type.Bool(AnyBool)) ensures IsSafe(r,s,Or(e,e'),Type.Bool(AnyBool)) { reveal IsSafe(); if Evaluate(e,r,s).Ok? && Evaluate(e',r,s).Ok? { assert Evaluator(r,s).interpretShortcircuit(Or(e,e'),e,e',true).Ok?; assert Evaluate(Or(e,e'),r,s).Ok?; } else { if Evaluate(e,r,s).Err? { assert Evaluate(Or(e,e'),r,s) == Evaluate(e,r,s); } else { assert Evaluate(e',r,s).Err?; var b :| Evaluate(e,r,s) == base.Ok(Value.Primitive(Primitive.Bool(b))); if b { assert Evaluator(r,s).interpretShortcircuit(Or(e,e'),e,e',true) == base.Ok(Value.Primitive(Primitive.Bool(true))); assert Evaluate(Or(e,e'),r,s) == base.Ok(Value.Primitive(Primitive.Bool(true))); } else { assert Evaluator(r,s).interpretShortcircuit(Or(e,e'),e,e',true) == Evaluate(e',r,s); assert Evaluate(Or(e,e'),r,s) == Evaluate(e',r,s); } } } }
cedar
92
./cedar-dafny/validation/thm/model.dfy
OrRRetSafe_fix_92.dfy
OrRRetSafe
lemma OrRRetSafe(r: Request, s: EntityStore, e: Expr, e': Expr, t: Type) requires IsFalse(r,s,e) requires IsSafe(r,s,e',t) requires SemanticSubty(t,Type.Bool(AnyBool)) ensures IsSafe(r,s,Or(e,e'),t) { reveal IsSafe(); if Evaluate(e,r,s).Ok? && Evaluate(e',r,s).Ok? { assert Evaluate(e,r,s) == base.Ok(Value.Primitive(Primitive.Bool(false))); var v :| Evaluate(e',r,s) == base.Ok(v) && InstanceOfType(v,t); assert InstanceOfType(v,Type.Bool(AnyBool)) by { SemSubtyTransportVal(t,Type.Bool(AnyBool),v); } var b :| v == Value.Primitive(Primitive.Bool(b)); assert Evaluator(r,s).interpretShortcircuit(Or(e,e'),e,e',true) == base.Ok(Value.Primitive(Primitive.Bool(b))); assert Evaluate(Or(e,e'),r,s) == base.Ok(Value.Primitive(Primitive.Bool(b))); assert IsSafe(r,s,e',Type.Bool(AnyBool)) by { SemSubtyTransport(r,s,e',t,Type.Bool(AnyBool)); } } else { if Evaluate(e,r,s).Err? { assert Evaluator(r,s).interpretShortcircuit(Or(e,e'),e,e',true) == Evaluate(e,r,s); assert Evaluate(Or(e,e'),r,s) == Evaluate(e,r,s); } else { assert Evaluate(e',r,s).Err?; var b :| Evaluate(e,r,s) == base.Ok(Value.Primitive(Primitive.Bool(b))); if b { assert Evaluator(r,s).interpretShortcircuit(Or(e,e'),e,e',true) == base.Ok(Value.Primitive(Primitive.Bool(true))); assert Evaluate(Or(e,e'),r,s) == base.Ok(Value.Primitive(Primitive.Bool(true))); } else { assert Evaluator(r,s).interpretShortcircuit(Or(e,e'),e,e',true) == Evaluate(e',r,s); assert Evaluate(Or(e,e'),r,s) == Evaluate(e',r,s); } } } }
lemma OrRRetSafe(r: Request, s: EntityStore, e: Expr, e': Expr, t: Type) requires IsFalse(r,s,e) requires IsSafe(r,s,e',t) requires SemanticSubty(t,Type.Bool(AnyBool)) ensures IsSafe(r,s,Or(e,e'),t) { reveal IsSafe(); if Evaluate(e,r,s).Ok? && Evaluate(e',r,s).Ok? { assert Evaluate(e,r,s) == base.Ok(Value.Primitive(Primitive.Bool(false))); var v :| Evaluate(e',r,s) == base.Ok(v) && InstanceOfType(v,t); assert InstanceOfType(v,Type.Bool(AnyBool)) by { SemSubtyTransportVal(t,Type.Bool(AnyBool),v); } var b :| v == Value.Primitive(Primitive.Bool(b)); assert Evaluate(Or(e,e'),r,s) == base.Ok(Value.Primitive(Primitive.Bool(b))); assert IsSafe(r,s,e',Type.Bool(AnyBool)) by { SemSubtyTransport(r,s,e',t,Type.Bool(AnyBool)); } } else { if Evaluate(e,r,s).Err? { assert Evaluator(r,s).interpretShortcircuit(Or(e,e'),e,e',true) == Evaluate(e,r,s); assert Evaluate(Or(e,e'),r,s) == Evaluate(e,r,s); } else { assert Evaluate(e',r,s).Err?; var b :| Evaluate(e,r,s) == base.Ok(Value.Primitive(Primitive.Bool(b))); if b { assert Evaluator(r,s).interpretShortcircuit(Or(e,e'),e,e',true) == base.Ok(Value.Primitive(Primitive.Bool(true))); assert Evaluate(Or(e,e'),r,s) == base.Ok(Value.Primitive(Primitive.Bool(true))); } else { assert Evaluator(r,s).interpretShortcircuit(Or(e,e'),e,e',true) == Evaluate(e',r,s); assert Evaluate(Or(e,e'),r,s) == Evaluate(e',r,s); } } } }
cedar
791
./cedar-dafny/validation/thm/soundness.dfy
SoundArith_fix_791.dfy
SoundArith
lemma SoundArith(op: BinaryOp, e1: Expr, e2: Expr, t: Type, effs: Effects) decreases BinaryApp(op,e1,e2) , 0 requires op == Add || op == Sub requires WellFormedRequestAndStore() requires EffectsInvariant(effs) requires Typesafe(BinaryApp(op,e1,e2),effs,t) ensures IsSafe(r,s,BinaryApp(op,e1,e2),t) ensures getEffects(BinaryApp(op,e1,e2),effs) == Effects.empty() { var t' :| getType(BinaryApp(op,e1,e2),effs) == t' && subty(t',t,ValidationMode.Permissive); assert TC.inferArith2(op,e1,e2,effs) == types.Ok(Type.Int); assert TC.ensureIntType(e1,effs).Ok?; assert Typesafe(e1,effs,Type.Int); assert TC.ensureIntType(e2,effs).Ok?; assert Typesafe(e2,effs,Type.Int); assert IsSafe(r,s,e1,Type.Int) by { Sound(e1,Type.Int,effs); } assert IsSafe(r,s,e2,Type.Int) by { Sound(e2,Type.Int,effs); } assert IsSafe(r,s,BinaryApp(op,e1,e2),t') by { ArithSafe(r,s,op,e1,e2); } assert IsSafe(r,s,BinaryApp(op,e1,e2),t) by { SubtyCompat(t',t); SemSubtyTransport(r,s,BinaryApp(op,e1,e2),t',t); } }
lemma SoundArith(op: BinaryOp, e1: Expr, e2: Expr, t: Type, effs: Effects) decreases BinaryApp(op,e1,e2) , 0 requires op == Add || op == Sub requires WellFormedRequestAndStore() requires EffectsInvariant(effs) requires Typesafe(BinaryApp(op,e1,e2),effs,t) ensures IsSafe(r,s,BinaryApp(op,e1,e2),t) ensures getEffects(BinaryApp(op,e1,e2),effs) == Effects.empty() { var t' :| getType(BinaryApp(op,e1,e2),effs) == t' && subty(t',t,ValidationMode.Permissive); assert TC.inferArith2(op,e1,e2,effs) == types.Ok(Type.Int); assert TC.ensureIntType(e1,effs).Ok?; assert Typesafe(e1,effs,Type.Int); assert Typesafe(e2,effs,Type.Int); assert IsSafe(r,s,e1,Type.Int) by { Sound(e1,Type.Int,effs); } assert IsSafe(r,s,e2,Type.Int) by { Sound(e2,Type.Int,effs); } assert IsSafe(r,s,BinaryApp(op,e1,e2),t') by { ArithSafe(r,s,op,e1,e2); } assert IsSafe(r,s,BinaryApp(op,e1,e2),t) by { SubtyCompat(t',t); SemSubtyTransport(r,s,BinaryApp(op,e1,e2),t',t); } }
cedar
873
./cedar-dafny/thm/eval/basic.dfy
RecordSemanticsOkAttrs_fix_873.dfy
RecordSemanticsOkAttrs
lemma RecordSemanticsOkAttrs(es: seq<(Attr, Expr)>, E: Evaluator) requires E.interpretRecord(es).Ok? ensures E.interpretRecord(es).value.Keys == set e | e in es :: e.0 { if es != [] { RecordSemanticsOkAttrs(es[1..], E); var rec' := E.interpretRecord(es[1..]).value; if es[0].0 in rec'.Keys { assert E.interpretRecord(es).value == rec'; assert (set e | e in es :: e.0) == (set e | e in es[1..] :: e.0); } else { assert E.interpretRecord(es).value == rec'[es[0].0 := E.interpret(es[0].1).value]; assert (set e | e in es :: e.0) == (set e | e in es[1..] :: e.0) + {es[0].0}; } } }
lemma RecordSemanticsOkAttrs(es: seq<(Attr, Expr)>, E: Evaluator) requires E.interpretRecord(es).Ok? ensures E.interpretRecord(es).value.Keys == set e | e in es :: e.0 { if es != [] { RecordSemanticsOkAttrs(es[1..], E); var rec' := E.interpretRecord(es[1..]).value; if es[0].0 in rec'.Keys { assert E.interpretRecord(es).value == rec'; assert (set e | e in es :: e.0) == (set e | e in es[1..] :: e.0); } else { assert E.interpretRecord(es).value == rec'[es[0].0 := E.interpret(es[0].1).value]; } } }
cedar
45
./cedar-dafny/validation/thm/model.dfy
AndTrueStrong_fix_45.dfy
AndTrueStrong
lemma AndTrueStrong(r: Request, s: EntityStore, e1: Expr, e2: Expr) requires IsTrue(r,s,e1) requires IsTrueStrong(r,s,And(e1,e2)) ensures IsTrueStrong(r,s,e2) { reveal IsSafeStrong(); reveal IsSafe(); assert Evaluator(r,s).interpretShortcircuit(And(e1,e2),e1,e2,false) == base.Ok(Value.Bool(true)); }
lemma AndTrueStrong(r: Request, s: EntityStore, e1: Expr, e2: Expr) requires IsTrue(r,s,e1) requires IsTrueStrong(r,s,And(e1,e2)) ensures IsTrueStrong(r,s,e2) { reveal IsSafeStrong(); reveal IsSafe(); }
cedar
750
./cedar-dafny/validation/thm/soundness.dfy
SoundLike_fix_750.dfy
SoundLike
lemma SoundLike(e: Expr, p: Pattern, t: Type, effs: Effects) decreases UnaryApp(Like(p),e) , 0 requires WellFormedRequestAndStore() requires EffectsInvariant(effs) requires Typesafe(UnaryApp(Like(p),e),effs,t) ensures IsSafe(r,s,UnaryApp(Like(p),e),t) ensures getEffects(UnaryApp(Like(p),e),effs) == Effects.empty() { var t' :| getType(UnaryApp(Like(p),e),effs) == t' && subty(t',t,ValidationMode.Permissive); assert TC.inferLike(p,e,effs) == types.Ok(Type.Bool(AnyBool)); assert TC.ensureStringType(e,effs).Ok?; assert Typesafe(e,effs,Type.String); assert IsSafe(r,s,e,Type.String) by { Sound(e,Type.String,effs); } assert IsSafe(r,s,UnaryApp(Like(p),e),t') by { LikeSafe(r,s,e,p); } assert IsSafe(r,s,UnaryApp(Like(p),e),t) by { SubtyCompat(t',t); SemSubtyTransport(r,s,UnaryApp(Like(p),e),t',t); } }
lemma SoundLike(e: Expr, p: Pattern, t: Type, effs: Effects) decreases UnaryApp(Like(p),e) , 0 requires WellFormedRequestAndStore() requires EffectsInvariant(effs) requires Typesafe(UnaryApp(Like(p),e),effs,t) ensures IsSafe(r,s,UnaryApp(Like(p),e),t) ensures getEffects(UnaryApp(Like(p),e),effs) == Effects.empty() { var t' :| getType(UnaryApp(Like(p),e),effs) == t' && subty(t',t,ValidationMode.Permissive); assert TC.ensureStringType(e,effs).Ok?; assert Typesafe(e,effs,Type.String); assert IsSafe(r,s,e,Type.String) by { Sound(e,Type.String,effs); } assert IsSafe(r,s,UnaryApp(Like(p),e),t') by { LikeSafe(r,s,e,p); } assert IsSafe(r,s,UnaryApp(Like(p),e),t) by { SubtyCompat(t',t); SemSubtyTransport(r,s,UnaryApp(Like(p),e),t',t); } }
cedar
820
./cedar-dafny/validation/thm/soundness.dfy
SoundInSetMemberFalse_fix_820.dfy
SoundInSetMemberFalse
lemma SoundInSetMemberFalse(e1: Expr, ei2s: seq<Expr>, i: nat, effs: Effects) decreases BinaryApp(BinaryOp.In,e1,Expr.Set(ei2s)) , 0 , Expr.Set(ei2s) , 0 requires WellFormedRequestAndStore() requires EffectsInvariant(effs) requires WellTyped(BinaryApp(BinaryOp.In,e1,Expr.Set(ei2s)),effs) requires getType(BinaryApp(BinaryOp.In,e1,Expr.Set(ei2s)),effs) == Type.Bool(False) requires !reqty.isUnspecifiedVar(e1) requires 0 <= i < |ei2s| ensures IsFalse(r,s,BinaryApp(BinaryOp.In,e1,ei2s[i])) { // Reestablishing things we had at the call site in `SoundIn`. var e2 := Expr.Set(ei2s); assert TC.inferIn(BinaryApp(BinaryOp.In,e1,e2),e1,e2,effs) == types.Ok(Type.Bool(False)); assert TC.ensureEntityType(e1,effs).Ok?; var t1 := getType(e1,effs); var euids2 :- assert TC.tryGetEUIDs(e2); var ets2 := set u <- euids2 :: u.ty; // New proof. var u2 :- assert TC.tryGetEUID(ei2s[i]); assert u2 in euids2; match e1 { case Var(v1) => var et1 :- assert TC.getPrincipalOrResource(v1); assert t1 == Type.Entity(EntityLUB({et1})); assert IsSafe(r,s,Var(v1),t1) by { Sound(e1,t1,effs); } assert !ets.possibleDescendantOf(et1,u2.ty); reveal WellFormedRequestAndStore(); InSingleFalseEntityTypeAndLiteral(r,s,e1,et1,u2); case PrimitiveLit(EntityUID(u1)) => if isAction(u1.ty) { assert !acts.descendantOfSet(u1,euids2); assert !acts.descendantOf(u1,u2); } else { assert !ets.possibleDescendantOfSet(u1.ty,ets2); assert !ets.possibleDescendantOf(u1.ty,u2.ty); } reveal WellFormedRequestAndStore(); InSingleFalseLiterals(r,s,u1,u2); } }
lemma SoundInSetMemberFalse(e1: Expr, ei2s: seq<Expr>, i: nat, effs: Effects) decreases BinaryApp(BinaryOp.In,e1,Expr.Set(ei2s)) , 0 , Expr.Set(ei2s) , 0 requires WellFormedRequestAndStore() requires EffectsInvariant(effs) requires WellTyped(BinaryApp(BinaryOp.In,e1,Expr.Set(ei2s)),effs) requires getType(BinaryApp(BinaryOp.In,e1,Expr.Set(ei2s)),effs) == Type.Bool(False) requires !reqty.isUnspecifiedVar(e1) requires 0 <= i < |ei2s| ensures IsFalse(r,s,BinaryApp(BinaryOp.In,e1,ei2s[i])) { // Reestablishing things we had at the call site in `SoundIn`. var e2 := Expr.Set(ei2s); assert TC.inferIn(BinaryApp(BinaryOp.In,e1,e2),e1,e2,effs) == types.Ok(Type.Bool(False)); assert TC.ensureEntityType(e1,effs).Ok?; var t1 := getType(e1,effs); var euids2 :- assert TC.tryGetEUIDs(e2); var ets2 := set u <- euids2 :: u.ty; // New proof. var u2 :- assert TC.tryGetEUID(ei2s[i]); assert u2 in euids2; match e1 { case Var(v1) => var et1 :- assert TC.getPrincipalOrResource(v1); assert t1 == Type.Entity(EntityLUB({et1})); assert IsSafe(r,s,Var(v1),t1) by { Sound(e1,t1,effs); } assert !ets.possibleDescendantOf(et1,u2.ty); reveal WellFormedRequestAndStore(); InSingleFalseEntityTypeAndLiteral(r,s,e1,et1,u2); case PrimitiveLit(EntityUID(u1)) => if isAction(u1.ty) { assert !acts.descendantOfSet(u1,euids2); assert !acts.descendantOf(u1,u2); } else { assert !ets.possibleDescendantOfSet(u1.ty,ets2); } reveal WellFormedRequestAndStore(); InSingleFalseLiterals(r,s,u1,u2); } }
cedar
862
./cedar-dafny/validation/thm/strict_soundness.dfy
StrictIn_fix_862.dfy
StrictIn
lemma StrictIn(e1: Expr, e2: Expr, effs: Effects) decreases BinaryApp(BinaryOp.In, e1, e2), 0 requires S_TC.infer(BinaryApp(BinaryOp.In, e1, e2), effs).Ok? ensures P_TC.infer(BinaryApp(BinaryOp.In, e1, e2), effs) == S_TC.infer(BinaryApp(BinaryOp.In, e1, e2), effs) { assert S_TC.ensureEntityType(e1,effs).Ok?; assert P_TC.ensureEntityType(e1,effs).Ok? by { StrictTypecheckingIsStrict(e1, effs); } assert S_TC.ensureEntitySetType(e2,effs).Ok?; assert P_TC.ensureEntitySetType(e2,effs).Ok? by { StrictTypecheckingIsStrict(e2, effs); } var (t2, effs') := S_TC.infer(e2,effs).value; assert P_TC.infer(e2, effs) == Ok((t2, effs')) by { StrictTypecheckingIsStrict(e2, effs); } }
lemma StrictIn(e1: Expr, e2: Expr, effs: Effects) decreases BinaryApp(BinaryOp.In, e1, e2), 0 requires S_TC.infer(BinaryApp(BinaryOp.In, e1, e2), effs).Ok? ensures P_TC.infer(BinaryApp(BinaryOp.In, e1, e2), effs) == S_TC.infer(BinaryApp(BinaryOp.In, e1, e2), effs) { assert P_TC.ensureEntityType(e1,effs).Ok? by { StrictTypecheckingIsStrict(e1, effs); } assert S_TC.ensureEntitySetType(e2,effs).Ok?; assert P_TC.ensureEntitySetType(e2,effs).Ok? by { StrictTypecheckingIsStrict(e2, effs); } var (t2, effs') := S_TC.infer(e2,effs).value; assert P_TC.infer(e2, effs) == Ok((t2, effs')) by { StrictTypecheckingIsStrict(e2, effs); } }
cedar
801
./cedar-dafny/validation/thm/soundness.dfy
SoundMulBy_fix_801.dfy
SoundMulBy
lemma SoundMulBy(i: int, e: Expr, t: Type, effs: Effects) decreases UnaryApp(MulBy(i),e) , 0 requires WellFormedRequestAndStore() requires EffectsInvariant(effs) requires Typesafe(UnaryApp(MulBy(i),e),effs,t) ensures IsSafe(r,s,UnaryApp(MulBy(i),e),t) ensures getEffects(UnaryApp(MulBy(i),e),effs) == Effects.empty() { var t' :| getType(UnaryApp(MulBy(i),e),effs) == t' && subty(t',t,ValidationMode.Permissive); assert TC.inferArith1(MulBy(i),e,effs) == types.Ok(Type.Int); assert TC.ensureIntType(e,effs).Ok?; assert Typesafe(e,effs,Type.Int); assert IsSafe(r,s,e,Type.Int) by { Sound(e,Type.Int,effs); } assert IsSafe(r,s,UnaryApp(MulBy(i),e),t') by { MulBySafe(r,s,e,i); } assert IsSafe(r,s,UnaryApp(MulBy(i),e),t) by { SubtyCompat(t',t); SemSubtyTransport(r,s,UnaryApp(MulBy(i),e),t',t); } }
lemma SoundMulBy(i: int, e: Expr, t: Type, effs: Effects) decreases UnaryApp(MulBy(i),e) , 0 requires WellFormedRequestAndStore() requires EffectsInvariant(effs) requires Typesafe(UnaryApp(MulBy(i),e),effs,t) ensures IsSafe(r,s,UnaryApp(MulBy(i),e),t) ensures getEffects(UnaryApp(MulBy(i),e),effs) == Effects.empty() { var t' :| getType(UnaryApp(MulBy(i),e),effs) == t' && subty(t',t,ValidationMode.Permissive); assert TC.ensureIntType(e,effs).Ok?; assert Typesafe(e,effs,Type.Int); assert IsSafe(r,s,e,Type.Int) by { Sound(e,Type.Int,effs); } assert IsSafe(r,s,UnaryApp(MulBy(i),e),t') by { MulBySafe(r,s,e,i); } assert IsSafe(r,s,UnaryApp(MulBy(i),e),t) by { SubtyCompat(t',t); SemSubtyTransport(r,s,UnaryApp(MulBy(i),e),t',t); } }
cedar
883
./cedar-dafny/def/util.dfy
SeqAddInequality_fix_883.dfy
SeqAddInequality
lemma SeqAddInequality<T>(s1: seq<T>, t1: T, s2: seq<T>, t2: T) requires s1 != s2 || t1 != t2 ensures s1 + [t1] != s2 + [t2] { if s1 == s2 { assert t1 != t2; var len := |s1|; assert (s1 + [t1])[len] != (s2 + [t2])[len]; } else if |s1| == |s2| { var i :| 0 <= i < |s1| && s1[i] != s2[i]; assert (s1 + [t1])[i] != (s2 + [t2])[i]; } else { assert |s1 + [t1]| != |s2 + [t2]|; } }
lemma SeqAddInequality<T>(s1: seq<T>, t1: T, s2: seq<T>, t2: T) requires s1 != s2 || t1 != t2 ensures s1 + [t1] != s2 + [t2] { if s1 == s2 { assert t1 != t2; var len := |s1|; assert (s1 + [t1])[len] != (s2 + [t2])[len]; } else if |s1| == |s2| { var i :| 0 <= i < |s1| && s1[i] != s2[i]; } else { assert |s1 + [t1]| != |s2 + [t2]|; } }
cedar
802
./cedar-dafny/validation/thm/soundness.dfy
SoundMulBy_fix_802.dfy
SoundMulBy
lemma SoundMulBy(i: int, e: Expr, t: Type, effs: Effects) decreases UnaryApp(MulBy(i),e) , 0 requires WellFormedRequestAndStore() requires EffectsInvariant(effs) requires Typesafe(UnaryApp(MulBy(i),e),effs,t) ensures IsSafe(r,s,UnaryApp(MulBy(i),e),t) ensures getEffects(UnaryApp(MulBy(i),e),effs) == Effects.empty() { var t' :| getType(UnaryApp(MulBy(i),e),effs) == t' && subty(t',t,ValidationMode.Permissive); assert TC.inferArith1(MulBy(i),e,effs) == types.Ok(Type.Int); assert TC.ensureIntType(e,effs).Ok?; assert Typesafe(e,effs,Type.Int); assert IsSafe(r,s,e,Type.Int) by { Sound(e,Type.Int,effs); } assert IsSafe(r,s,UnaryApp(MulBy(i),e),t') by { MulBySafe(r,s,e,i); } assert IsSafe(r,s,UnaryApp(MulBy(i),e),t) by { SubtyCompat(t',t); SemSubtyTransport(r,s,UnaryApp(MulBy(i),e),t',t); } }
lemma SoundMulBy(i: int, e: Expr, t: Type, effs: Effects) decreases UnaryApp(MulBy(i),e) , 0 requires WellFormedRequestAndStore() requires EffectsInvariant(effs) requires Typesafe(UnaryApp(MulBy(i),e),effs,t) ensures IsSafe(r,s,UnaryApp(MulBy(i),e),t) ensures getEffects(UnaryApp(MulBy(i),e),effs) == Effects.empty() { var t' :| getType(UnaryApp(MulBy(i),e),effs) == t' && subty(t',t,ValidationMode.Permissive); assert TC.inferArith1(MulBy(i),e,effs) == types.Ok(Type.Int); assert Typesafe(e,effs,Type.Int); assert IsSafe(r,s,e,Type.Int) by { Sound(e,Type.Int,effs); } assert IsSafe(r,s,UnaryApp(MulBy(i),e),t') by { MulBySafe(r,s,e,i); } assert IsSafe(r,s,UnaryApp(MulBy(i),e),t) by { SubtyCompat(t',t); SemSubtyTransport(r,s,UnaryApp(MulBy(i),e),t',t); } }
cedar
890
./cedar-dafny/def/ext/ipaddr.dfy
CountDCLast_fix_890.dfy
CountDCLast
lemma CountDCLast(s: seq<numV6>) ensures countDC(wrapNumSegs(s)+[DC]) == 1 { if |s| == 0 { } else { assert wrapNumSegs(s)+[DC] == wrapNumSegs([s[0]]) + (wrapNumSegs(s[1..]) + [DC]); } }
lemma CountDCLast(s: seq<numV6>) ensures countDC(wrapNumSegs(s)+[DC]) == 1 { if |s| == 0 { } else { } }
cedar
99
./cedar-dafny/validation/thm/model.dfy
OrRRetSafe_fix_99.dfy
OrRRetSafe
lemma OrRRetSafe(r: Request, s: EntityStore, e: Expr, e': Expr, t: Type) requires IsFalse(r,s,e) requires IsSafe(r,s,e',t) requires SemanticSubty(t,Type.Bool(AnyBool)) ensures IsSafe(r,s,Or(e,e'),t) { reveal IsSafe(); if Evaluate(e,r,s).Ok? && Evaluate(e',r,s).Ok? { assert Evaluate(e,r,s) == base.Ok(Value.Primitive(Primitive.Bool(false))); var v :| Evaluate(e',r,s) == base.Ok(v) && InstanceOfType(v,t); assert InstanceOfType(v,Type.Bool(AnyBool)) by { SemSubtyTransportVal(t,Type.Bool(AnyBool),v); } var b :| v == Value.Primitive(Primitive.Bool(b)); assert Evaluator(r,s).interpretShortcircuit(Or(e,e'),e,e',true) == base.Ok(Value.Primitive(Primitive.Bool(b))); assert Evaluate(Or(e,e'),r,s) == base.Ok(Value.Primitive(Primitive.Bool(b))); assert IsSafe(r,s,e',Type.Bool(AnyBool)) by { SemSubtyTransport(r,s,e',t,Type.Bool(AnyBool)); } } else { if Evaluate(e,r,s).Err? { assert Evaluator(r,s).interpretShortcircuit(Or(e,e'),e,e',true) == Evaluate(e,r,s); assert Evaluate(Or(e,e'),r,s) == Evaluate(e,r,s); } else { assert Evaluate(e',r,s).Err?; var b :| Evaluate(e,r,s) == base.Ok(Value.Primitive(Primitive.Bool(b))); if b { assert Evaluator(r,s).interpretShortcircuit(Or(e,e'),e,e',true) == base.Ok(Value.Primitive(Primitive.Bool(true))); assert Evaluate(Or(e,e'),r,s) == base.Ok(Value.Primitive(Primitive.Bool(true))); } else { assert Evaluator(r,s).interpretShortcircuit(Or(e,e'),e,e',true) == Evaluate(e',r,s); assert Evaluate(Or(e,e'),r,s) == Evaluate(e',r,s); } } } }
lemma OrRRetSafe(r: Request, s: EntityStore, e: Expr, e': Expr, t: Type) requires IsFalse(r,s,e) requires IsSafe(r,s,e',t) requires SemanticSubty(t,Type.Bool(AnyBool)) ensures IsSafe(r,s,Or(e,e'),t) { reveal IsSafe(); if Evaluate(e,r,s).Ok? && Evaluate(e',r,s).Ok? { assert Evaluate(e,r,s) == base.Ok(Value.Primitive(Primitive.Bool(false))); var v :| Evaluate(e',r,s) == base.Ok(v) && InstanceOfType(v,t); assert InstanceOfType(v,Type.Bool(AnyBool)) by { SemSubtyTransportVal(t,Type.Bool(AnyBool),v); } var b :| v == Value.Primitive(Primitive.Bool(b)); assert Evaluator(r,s).interpretShortcircuit(Or(e,e'),e,e',true) == base.Ok(Value.Primitive(Primitive.Bool(b))); assert Evaluate(Or(e,e'),r,s) == base.Ok(Value.Primitive(Primitive.Bool(b))); assert IsSafe(r,s,e',Type.Bool(AnyBool)) by { SemSubtyTransport(r,s,e',t,Type.Bool(AnyBool)); } } else { if Evaluate(e,r,s).Err? { assert Evaluator(r,s).interpretShortcircuit(Or(e,e'),e,e',true) == Evaluate(e,r,s); assert Evaluate(Or(e,e'),r,s) == Evaluate(e,r,s); } else { assert Evaluate(e',r,s).Err?; var b :| Evaluate(e,r,s) == base.Ok(Value.Primitive(Primitive.Bool(b))); if b { assert Evaluator(r,s).interpretShortcircuit(Or(e,e'),e,e',true) == base.Ok(Value.Primitive(Primitive.Bool(true))); assert Evaluate(Or(e,e'),r,s) == base.Ok(Value.Primitive(Primitive.Bool(true))); } else { assert Evaluate(Or(e,e'),r,s) == Evaluate(e',r,s); } } } }
cedar
852
./cedar-dafny/validation/thm/strict_inf_strict.dfy
StrictGetAttr_fix_852.dfy
StrictGetAttr
lemma StrictGetAttr(e: Expr, l: Attr, effs:Effects) decreases GetAttr(e, l), 0 requires strictEnvironment() requires S_TC.infer(GetAttr(e, l), effs).Ok? ensures S_TC.infer(GetAttr(e, l), effs).value.0.isStrictType() { assert S_TC.inferRecordEntityType(e,effs).Ok?; StrictTypeInf(e, effs); }
lemma StrictGetAttr(e: Expr, l: Attr, effs:Effects) decreases GetAttr(e, l), 0 requires strictEnvironment() requires S_TC.infer(GetAttr(e, l), effs).Ok? ensures S_TC.infer(GetAttr(e, l), effs).value.0.isStrictType() { StrictTypeInf(e, effs); }
cedar
37
./cedar-dafny/validation/thm/model.dfy
EqEntityDiffSafe_fix_37.dfy
EqEntityDiffSafe
lemma EqEntityDiffSafe(r: Request, s: EntityStore, E: EntityUID, E': EntityUID) requires E != E' ensures IsFalse(r,s,Expr.BinaryApp(BinaryOp.Eq,PrimitiveLit(Primitive.EntityUID(E)),PrimitiveLit(Primitive.EntityUID(E')))) { reveal IsSafe(); var e := Expr.BinaryApp(BinaryOp.Eq,PrimitiveLit(Primitive.EntityUID(E)),PrimitiveLit(Primitive.EntityUID(E'))); assert Evaluator(r,s).interpret(e) == base.Ok(Value.Primitive(Primitive.Bool(false))); }
lemma EqEntityDiffSafe(r: Request, s: EntityStore, E: EntityUID, E': EntityUID) requires E != E' ensures IsFalse(r,s,Expr.BinaryApp(BinaryOp.Eq,PrimitiveLit(Primitive.EntityUID(E)),PrimitiveLit(Primitive.EntityUID(E')))) { reveal IsSafe(); var e := Expr.BinaryApp(BinaryOp.Eq,PrimitiveLit(Primitive.EntityUID(E)),PrimitiveLit(Primitive.EntityUID(E'))); }
README.md exists but content is empty.
Downloads last month
0