Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function forall($x="@",$set=[],$statement) {
- $str = "true";
- for ($i = 0; $i < count($set); $i++) {
- $str .= " & (".str_replace($x,$set[$i],$statement).")";
- }
- return "($str)";
- }
- function exists($x="@",$set=[],$statement) {
- $str = "false";
- for ($i = 0; $i < count($set); $i++) {
- $str .= " || (".str_replace($x,$set[$i],$statement).")";
- }
- return "($str)";
- }
- function implies($statement1,$statement2) {
- $str = "(($statement1) || !($statement2))";
- return $str;
- }
- function verify($statement) {
- eval("\$st = ($statement);");
- return $st;
- }
- //Example
- print verify(forall("x",[1,2,4,8,16],implies("(x+1)%2==0","x==1"))); //Checks that ∀ x ∈ {1,2,4,8,16} (x+1 ≡ 0 (mod 2) => x=1)
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement