Created
November 14, 2018 07:34
-
-
Save vaskaloidis/ccc4a3ce6b5bd1e7489ad295d171e694 to your computer and use it in GitHub Desktop.
proof-j.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# proofj.rb - tests the proof: | |
# If m is any even integer, then (−1)𝑚+3 = −1. | |
# Config | |
verbose = true | |
super_verbose = false | |
# Iteration Boundaries | |
start_number = -10 | |
end_number = 10 | |
# The Proof | |
proof_equation = ->(param) { "If m is any even integer, then (−1)#{param}+3 = −1" } | |
the_proof = proof_equation.("m") | |
p_equation = ->(param) { (param%2)==0 } | |
p_valid = ->(param) { p_equation.(param) } | |
q_equation = ->(q) { ((-1)*q)+3 } | |
q_valid = ->(q) {q_equation.(q)==-1} | |
# The Proof Test | |
puts the_proof | |
puts "Iterating from m=#{start_number} to m=#{end_number}" | |
(start_number..end_number).each do |number| | |
result = q_equation.(number) | |
if p_valid.(number) | |
puts "m=#{number} is even" if super_verbose | |
if q_valid.(number) | |
# puts "(−1)#{number}+3 = −1 TRUE" | |
puts "" | |
puts "m=#{number} true -> true is TRUE" | |
puts "#{proof_equation.(number)}is valid" | |
puts "" | |
else | |
puts "m=#{number} true -> false is FALSE" | |
end | |
else | |
if q_valid.(number) | |
puts "m=#{number} false -> true is TRUE" if super_verbose | |
puts "(−1)#{number}+3 = #{result}" if super_verbose | |
else | |
puts "m=#{number} false -> false is TRUE" if super_verbose | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment